spi-nor.txt 2.3 KB

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