spi-nor.rst 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. =================
  2. SPI NOR framework
  3. =================
  4. Part I - Why do we need this framework?
  5. ---------------------------------------
  6. SPI bus controllers (drivers/spi/) only deal with streams of bytes; the bus
  7. controller operates agnostic of the specific device attached. However, some
  8. controllers (such as Freescale's QuadSPI controller) cannot easily handle
  9. arbitrary streams of bytes, but rather are designed specifically for SPI NOR.
  10. In particular, Freescale's QuadSPI controller must know the NOR commands to
  11. find the right LUT sequence. Unfortunately, the SPI subsystem has no notion of
  12. opcodes, addresses, or data payloads; a SPI controller simply knows to send or
  13. receive bytes (Tx and Rx). Therefore, we must define a new layering scheme under
  14. which the controller driver is aware of the opcodes, addressing, and other
  15. details of the SPI NOR protocol.
  16. Part II - How does the framework work?
  17. --------------------------------------
  18. This framework just adds a new layer between the MTD and the SPI bus driver.
  19. With this new layer, the SPI NOR controller driver does not depend on the
  20. m25p80 code anymore.
  21. Before this framework, the layer is like::
  22. MTD
  23. ------------------------
  24. m25p80
  25. ------------------------
  26. SPI bus driver
  27. ------------------------
  28. SPI NOR chip
  29. After this framework, the layer is like::
  30. MTD
  31. ------------------------
  32. SPI NOR framework
  33. ------------------------
  34. m25p80
  35. ------------------------
  36. SPI bus driver
  37. ------------------------
  38. SPI NOR chip
  39. With the SPI NOR controller driver (Freescale QuadSPI), it looks like::
  40. MTD
  41. ------------------------
  42. SPI NOR framework
  43. ------------------------
  44. fsl-quadSPI
  45. ------------------------
  46. SPI NOR chip
  47. Part III - How can drivers use the framework?
  48. ---------------------------------------------
  49. The main API is spi_nor_scan(). Before you call the hook, a driver should
  50. initialize the necessary fields for spi_nor{}. Please see
  51. drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to spi-fsl-qspi.c
  52. when you want to write a new driver for a SPI NOR controller.
  53. Another API is spi_nor_restore(), this is used to restore the status of SPI
  54. flash chip such as addressing mode. Call it whenever detach the driver from
  55. device or reboot the system.