1 The U-Boot Driver Model Project
2 ===============================
5 Viktor Krivak <viktor.krivak@gmail.com>
14 At this moment U-Boot provides standard API that consist of 7 functions:
17 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
18 unsigned int max_hz, unsigned int mode);
19 void spi_free_slave(struct spi_slave *slave);
20 int spi_claim_bus(struct spi_slave *slave);
21 void spi_release_bus(struct spi_slave *slave);
22 int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
23 const void *dout, void *din, unsigned long flags);
24 int spi_cs_is_valid(unsigned int bus, unsigned int cs);
25 void spi_cs_activate(struct spi_slave *slave);
26 void spi_cs_deactivate(struct spi_slave *slave);
27 void spi_set_speed(struct spi_slave *slave, uint hz);
29 Method spi_init() is usually empty. All necessary configuration are sets by
30 spi_setup_slave(). But this configuration is usually stored only in memory.
31 No real hardware sets are made. All hardware settings are provided by method
32 spi_claim_bus(). This method claims the bus and it can't be claimed again
33 until it's release. That's mean all calls of method spi_claim_bus() will
34 fail. But lots of cpu implementation don't meet this behaviour.
35 Method spi_release_bus() does exact opposite. It release bus directly by
36 some hardware sets. spi_free_slave() only free memory allocated by
37 spi_setup_slave(). Method spi_xfer() do actually read and write operation
38 throw specified bus and cs. Other methods are self explanatory.
40 2) Current limitations
41 ----------------------
43 Theoretically at this moment api allows use more then one bus per device at
44 the time. But in real this can be achieved only when all buses have their
45 own base addresses in memory.
54 The current api cannot be used because struct spi_slave have to be in
55 private data. In that case user are prohibited to use different bus on one
56 device at same time. But when base memory address for bus are different.
57 It's possible make more instance of this driver. Otherwise it can't can be
58 done because of hardware limitation.
63 Method spi_init() is moved to probe. Methods spi_setup_slave() and
64 spi_claim_bus() are joined to one method. This method checks if desired bus
65 exists and is available then configure necessary hardware and claims bus.
66 Method spi_release_bus() and spi_free_slave() are also joined to meet this
67 new approach. Other function remain same. Only struct spi_slave was change
71 int (*spi_request_bus)(struct instance *i, unsigned int bus,
72 unsigned int cs, unsigned int max_hz,
74 void (*spi_release_bus)(struct instance *i);
75 int (*spi_xfer) (struct instance *i, unsigned int bitlen,
76 const void *dout, void *din, unsigned long flags);
77 int (*spi_cs_is_valid)(struct instance *i, unsigned int bus,
79 void (*spi_cs_activate)(struct instance *i);
80 void (*spi_cs_deactivate)(struct instance *i);
81 void (*spi_set_speed)(struct instance *i, uint hz);
87 To easy conversion of the whole driver. Original and new api can exist next
88 to each other. New API is designed to be only a wrapper that extracts
89 necessary information from private_data and use old api. When driver can
90 use more than one bus at the time. New API require multiple instance. One
91 for each bus. In this case spi_slave have to be copied in each instance.
93 4) Conversion TIME-LINE
94 -----------------------
96 To prevent build corruption api conversion have to be processed in several
97 independent steps. In first step all old API methods are renamed. After that
98 new API and core function are implemented. Next step is conversion of all
99 board init methods to set platform data. After all these steps it is possible
100 to start conversion of all remaining calls. This procedure guarantees that
101 build procedure and binaries are never broken.
103 III) Analysis of in-tree drivers
104 --------------------------------
108 All methods have designated structure. Simple conversion possible.
112 All methods have designated structure. Simple conversion possible.
116 Support file for andes_spi.c. No conversion is needed.
120 All methods have designated structure. Simple conversion possible.
122 atmel_dataflash_spi.c
123 ---------------------
124 Wrong placement. Will be moved to another location.
128 Supports more than one bus. Need some minor change.
132 Support file for andes_spi.c. No conversion is needed.
136 Supports more than one bus. Need some minor change.
140 Cooperate with some cpu specific methods from other files. Hard conversion.
144 All methods have designated structure. Simple conversion possible.
148 Support file for davinci_spi.h. No conversion is needed.
152 All methods have designated structure. Simple conversion possible.
156 All methods have designated structure. Simple conversion possible.
160 All methods have designated structure. Simple conversion possible.
164 All methods have designated structure. Simple conversion possible.
168 All methods have designated structure. Simple conversion possible.
172 All methods have designated structure. Simple conversion possible.
176 Supports more than one bus. Need some minor change.
180 Supports more than one bus. Need some minor change.
184 Support file for omap3_spi.c. No conversion is needed.
188 All methods have designated structure. Simple conversion possible.
192 Support file for sh_spi.h. No conversion is needed.
196 Use many board specific method linked from other files. Need careful debugging.
200 Some hardware specific problem when releasing bus.