aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/spi/spi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/spi/spi.h')
-rw-r--r--include/linux/spi/spi.h37
1 files changed, 31 insertions, 6 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 176f6e36dbfa..4f0f8c2e58a5 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -114,6 +114,17 @@ static inline void spi_set_ctldata(struct spi_device *spi, void *state)
114 spi->controller_state = state; 114 spi->controller_state = state;
115} 115}
116 116
117/* device driver data */
118
119static inline void spi_set_drvdata(struct spi_device *spi, void *data)
120{
121 dev_set_drvdata(&spi->dev, data);
122}
123
124static inline void *spi_get_drvdata(struct spi_device *spi)
125{
126 return dev_get_drvdata(&spi->dev);
127}
117 128
118struct spi_message; 129struct spi_message;
119 130
@@ -137,13 +148,11 @@ extern int spi_register_driver(struct spi_driver *sdrv);
137 148
138static inline void spi_unregister_driver(struct spi_driver *sdrv) 149static inline void spi_unregister_driver(struct spi_driver *sdrv)
139{ 150{
140 if (!sdrv) 151 if (sdrv)
141 return; 152 driver_unregister(&sdrv->driver);
142 driver_unregister(&sdrv->driver);
143} 153}
144 154
145 155
146
147/** 156/**
148 * struct spi_master - interface to SPI master controller 157 * struct spi_master - interface to SPI master controller
149 * @cdev: class interface to this driver 158 * @cdev: class interface to this driver
@@ -154,7 +163,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
154 * each slave has a chipselect signal, but it's common that not 163 * each slave has a chipselect signal, but it's common that not
155 * every chipselect is connected to a slave. 164 * every chipselect is connected to a slave.
156 * @setup: updates the device mode and clocking records used by a 165 * @setup: updates the device mode and clocking records used by a
157 * device's SPI controller; protocol code may call this. 166 * device's SPI controller; protocol code may call this. This
167 * must fail if an unrecognized or unsupported mode is requested.
158 * @transfer: adds a message to the controller's transfer queue. 168 * @transfer: adds a message to the controller's transfer queue.
159 * @cleanup: frees controller-specific state 169 * @cleanup: frees controller-specific state
160 * 170 *
@@ -211,7 +221,7 @@ struct spi_master {
211 struct spi_message *mesg); 221 struct spi_message *mesg);
212 222
213 /* called on release() to free memory provided by spi_master */ 223 /* called on release() to free memory provided by spi_master */
214 void (*cleanup)(const struct spi_device *spi); 224 void (*cleanup)(struct spi_device *spi);
215}; 225};
216 226
217static inline void *spi_master_get_devdata(struct spi_master *master) 227static inline void *spi_master_get_devdata(struct spi_master *master)
@@ -296,6 +306,16 @@ extern struct spi_master *spi_busnum_to_master(u16 busnum);
296 * shifting out three bytes with word size of sixteen or twenty bits; 306 * shifting out three bytes with word size of sixteen or twenty bits;
297 * the former uses two bytes per word, the latter uses four bytes.) 307 * the former uses two bytes per word, the latter uses four bytes.)
298 * 308 *
309 * In-memory data values are always in native CPU byte order, translated
310 * from the wire byte order (big-endian except with SPI_LSB_FIRST). So
311 * for example when bits_per_word is sixteen, buffers are 2N bytes long
312 * and hold N sixteen bit words in CPU byte order.
313 *
314 * When the word size of the SPI transfer is not a power-of-two multiple
315 * of eight bits, those in-memory words include extra bits. In-memory
316 * words are always seen by protocol drivers as right-justified, so the
317 * undefined (rx) or unused (tx) bits are always the most significant bits.
318 *
299 * All SPI transfers start with the relevant chipselect active. Normally 319 * All SPI transfers start with the relevant chipselect active. Normally
300 * it stays selected until after the last transfer in a message. Drivers 320 * it stays selected until after the last transfer in a message. Drivers
301 * can affect the chipselect signal using cs_change: 321 * can affect the chipselect signal using cs_change:
@@ -453,6 +473,11 @@ static inline void spi_message_free(struct spi_message *m)
453 * changes those settings, and must be called from a context that can sleep. 473 * changes those settings, and must be called from a context that can sleep.
454 * The changes take effect the next time the device is selected and data 474 * The changes take effect the next time the device is selected and data
455 * is transferred to or from it. 475 * is transferred to or from it.
476 *
477 * Note that this call wil fail if the protocol driver specifies an option
478 * that the underlying controller or its driver does not support. For
479 * example, not all hardware supports wire transfers using nine bit words,
480 * LSB-first wire encoding, or active-high chipselects.
456 */ 481 */
457static inline int 482static inline int
458spi_setup(struct spi_device *spi) 483spi_setup(struct spi_device *spi)