blob: 548d6306ebcaebb2da08ab8eb52e8ccc975ac66d [file] [log] [blame]
Huang Shijie1ef39102014-02-28 15:58:00 +08001 SPI NOR framework
2 ============================================
3
Brian Norris254592d2014-04-08 20:17:04 -07004Part I - Why do we need this framework?
5---------------------------------------
Huang Shijie1ef39102014-02-28 15:58:00 +08006
Brian Norris254592d2014-04-08 20:17:04 -07007SPI bus controllers (drivers/spi/) only deal with streams of bytes; the bus
8controller operates agnostic of the specific device attached. However, some
9controllers (such as Freescale's QuadSPI controller) cannot easily handle
10arbitrary streams of bytes, but rather are designed specifically for SPI NOR.
Huang Shijie1ef39102014-02-28 15:58:00 +080011
Brian Norris254592d2014-04-08 20:17:04 -070012In particular, Freescale's QuadSPI controller must know the NOR commands to
13find the right LUT sequence. Unfortunately, the SPI subsystem has no notion of
14opcodes, addresses, or data payloads; a SPI controller simply knows to send or
15receive bytes (Tx and Rx). Therefore, we must define a new layering scheme under
16which the controller driver is aware of the opcodes, addressing, and other
17details of the SPI NOR protocol.
Huang Shijie1ef39102014-02-28 15:58:00 +080018
19Part II - How does the framework work?
Brian Norris254592d2014-04-08 20:17:04 -070020--------------------------------------
Huang Shijie1ef39102014-02-28 15:58:00 +080021
22This framework just adds a new layer between the MTD and the SPI bus driver.
23With this new layer, the SPI NOR controller driver does not depend on the
24m25p80 code anymore.
25
26 Before this framework, the layer is like:
27
28 MTD
29 ------------------------
30 m25p80
31 ------------------------
32 SPI bus driver
33 ------------------------
34 SPI NOR chip
35
36 After this framework, the layer is like:
37 MTD
38 ------------------------
39 SPI NOR framework
40 ------------------------
41 m25p80
42 ------------------------
43 SPI bus driver
44 ------------------------
45 SPI NOR chip
46
Brian Norris254592d2014-04-08 20:17:04 -070047 With the SPI NOR controller driver (Freescale QuadSPI), it looks like:
Huang Shijie1ef39102014-02-28 15:58:00 +080048 MTD
49 ------------------------
50 SPI NOR framework
51 ------------------------
52 fsl-quadSPI
53 ------------------------
54 SPI NOR chip
55
Brian Norris254592d2014-04-08 20:17:04 -070056Part III - How can drivers use the framework?
57---------------------------------------------
Huang Shijie1ef39102014-02-28 15:58:00 +080058
Brian Norris254592d2014-04-08 20:17:04 -070059The main API is spi_nor_scan(). Before you call the hook, a driver should
60initialize the necessary fields for spi_nor{}. Please see
61drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c
62when you want to write a new driver for a SPI NOR controller.