0001 =================
0002 SPI NOR framework
0003 =================
0004
0005 Part I - Why do we need this framework?
0006 ---------------------------------------
0007
0008 SPI bus controllers (drivers/spi/) only deal with streams of bytes; the bus
0009 controller operates agnostic of the specific device attached. However, some
0010 controllers (such as Freescale's QuadSPI controller) cannot easily handle
0011 arbitrary streams of bytes, but rather are designed specifically for SPI NOR.
0012
0013 In particular, Freescale's QuadSPI controller must know the NOR commands to
0014 find the right LUT sequence. Unfortunately, the SPI subsystem has no notion of
0015 opcodes, addresses, or data payloads; a SPI controller simply knows to send or
0016 receive bytes (Tx and Rx). Therefore, we must define a new layering scheme under
0017 which the controller driver is aware of the opcodes, addressing, and other
0018 details of the SPI NOR protocol.
0019
0020 Part II - How does the framework work?
0021 --------------------------------------
0022
0023 This framework just adds a new layer between the MTD and the SPI bus driver.
0024 With this new layer, the SPI NOR controller driver does not depend on the
0025 m25p80 code anymore.
0026
0027 Before this framework, the layer is like::
0028
0029 MTD
0030 ------------------------
0031 m25p80
0032 ------------------------
0033 SPI bus driver
0034 ------------------------
0035 SPI NOR chip
0036
0037 After this framework, the layer is like::
0038
0039 MTD
0040 ------------------------
0041 SPI NOR framework
0042 ------------------------
0043 m25p80
0044 ------------------------
0045 SPI bus driver
0046 ------------------------
0047 SPI NOR chip
0048
0049 With the SPI NOR controller driver (Freescale QuadSPI), it looks like::
0050
0051 MTD
0052 ------------------------
0053 SPI NOR framework
0054 ------------------------
0055 fsl-quadSPI
0056 ------------------------
0057 SPI NOR chip
0058
0059 Part III - How can drivers use the framework?
0060 ---------------------------------------------
0061
0062 The main API is spi_nor_scan(). Before you call the hook, a driver should
0063 initialize the necessary fields for spi_nor{}. Please see
0064 drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to spi-fsl-qspi.c
0065 when you want to write a new driver for a SPI NOR controller.
0066 Another API is spi_nor_restore(), this is used to restore the status of SPI
0067 flash chip such as addressing mode. Call it whenever detach the driver from
0068 device or reboot the system.