162306a36Sopenharmony_ci=================
262306a36Sopenharmony_ciSPI NOR framework
362306a36Sopenharmony_ci=================
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciPart I - Why do we need this framework?
662306a36Sopenharmony_ci---------------------------------------
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciSPI bus controllers (drivers/spi/) only deal with streams of bytes; the bus
962306a36Sopenharmony_cicontroller operates agnostic of the specific device attached. However, some
1062306a36Sopenharmony_cicontrollers (such as Freescale's QuadSPI controller) cannot easily handle
1162306a36Sopenharmony_ciarbitrary streams of bytes, but rather are designed specifically for SPI NOR.
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciIn particular, Freescale's QuadSPI controller must know the NOR commands to
1462306a36Sopenharmony_cifind the right LUT sequence. Unfortunately, the SPI subsystem has no notion of
1562306a36Sopenharmony_ciopcodes, addresses, or data payloads; a SPI controller simply knows to send or
1662306a36Sopenharmony_cireceive bytes (Tx and Rx). Therefore, we must define a new layering scheme under
1762306a36Sopenharmony_ciwhich the controller driver is aware of the opcodes, addressing, and other
1862306a36Sopenharmony_cidetails of the SPI NOR protocol.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciPart II - How does the framework work?
2162306a36Sopenharmony_ci--------------------------------------
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciThis framework just adds a new layer between the MTD and the SPI bus driver.
2462306a36Sopenharmony_ciWith this new layer, the SPI NOR controller driver does not depend on the
2562306a36Sopenharmony_cim25p80 code anymore.
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciBefore this framework, the layer is like::
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci                   MTD
3062306a36Sopenharmony_ci         ------------------------
3162306a36Sopenharmony_ci                  m25p80
3262306a36Sopenharmony_ci         ------------------------
3362306a36Sopenharmony_ci	       SPI bus driver
3462306a36Sopenharmony_ci         ------------------------
3562306a36Sopenharmony_ci	        SPI NOR chip
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciAfter this framework, the layer is like::
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci                   MTD
4062306a36Sopenharmony_ci         ------------------------
4162306a36Sopenharmony_ci              SPI NOR framework
4262306a36Sopenharmony_ci         ------------------------
4362306a36Sopenharmony_ci                  m25p80
4462306a36Sopenharmony_ci         ------------------------
4562306a36Sopenharmony_ci	       SPI bus driver
4662306a36Sopenharmony_ci         ------------------------
4762306a36Sopenharmony_ci	       SPI NOR chip
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciWith the SPI NOR controller driver (Freescale QuadSPI), it looks like::
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci                   MTD
5262306a36Sopenharmony_ci         ------------------------
5362306a36Sopenharmony_ci              SPI NOR framework
5462306a36Sopenharmony_ci         ------------------------
5562306a36Sopenharmony_ci                fsl-quadSPI
5662306a36Sopenharmony_ci         ------------------------
5762306a36Sopenharmony_ci	       SPI NOR chip
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciPart III - How can drivers use the framework?
6062306a36Sopenharmony_ci---------------------------------------------
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciThe main API is spi_nor_scan(). Before you call the hook, a driver should
6362306a36Sopenharmony_ciinitialize the necessary fields for spi_nor{}. Please see
6462306a36Sopenharmony_cidrivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to spi-fsl-qspi.c
6562306a36Sopenharmony_ciwhen you want to write a new driver for a SPI NOR controller.
66