diff options
Diffstat (limited to 'include/linux/spi/spi.h')
-rw-r--r-- | include/linux/spi/spi.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 176fce9cc6b1..f9e30a5b3543 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/mod_devicetable.h> | 23 | #include <linux/mod_devicetable.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/kthread.h> | ||
25 | 26 | ||
26 | /* | 27 | /* |
27 | * INTERFACES between SPI master-side drivers and SPI infrastructure. | 28 | * INTERFACES between SPI master-side drivers and SPI infrastructure. |
@@ -235,6 +236,27 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) | |||
235 | * the device whose settings are being modified. | 236 | * the device whose settings are being modified. |
236 | * @transfer: adds a message to the controller's transfer queue. | 237 | * @transfer: adds a message to the controller's transfer queue. |
237 | * @cleanup: frees controller-specific state | 238 | * @cleanup: frees controller-specific state |
239 | * @queued: whether this master is providing an internal message queue | ||
240 | * @kworker: thread struct for message pump | ||
241 | * @kworker_task: pointer to task for message pump kworker thread | ||
242 | * @pump_messages: work struct for scheduling work to the message pump | ||
243 | * @queue_lock: spinlock to syncronise access to message queue | ||
244 | * @queue: message queue | ||
245 | * @cur_msg: the currently in-flight message | ||
246 | * @busy: message pump is busy | ||
247 | * @running: message pump is running | ||
248 | * @rt: whether this queue is set to run as a realtime task | ||
249 | * @prepare_transfer_hardware: a message will soon arrive from the queue | ||
250 | * so the subsystem requests the driver to prepare the transfer hardware | ||
251 | * by issuing this call | ||
252 | * @transfer_one_message: the subsystem calls the driver to transfer a single | ||
253 | * message while queuing transfers that arrive in the meantime. When the | ||
254 | * driver is finished with this message, it must call | ||
255 | * spi_finalize_current_message() so the subsystem can issue the next | ||
256 | * transfer | ||
257 | * @prepare_transfer_hardware: there are currently no more messages on the | ||
258 | * queue so the subsystem notifies the driver that it may relax the | ||
259 | * hardware by issuing this call | ||
238 | * | 260 | * |
239 | * Each SPI master controller can communicate with one or more @spi_device | 261 | * Each SPI master controller can communicate with one or more @spi_device |
240 | * children. These make a small bus, sharing MOSI, MISO and SCK signals | 262 | * children. These make a small bus, sharing MOSI, MISO and SCK signals |
@@ -318,6 +340,28 @@ struct spi_master { | |||
318 | 340 | ||
319 | /* called on release() to free memory provided by spi_master */ | 341 | /* called on release() to free memory provided by spi_master */ |
320 | void (*cleanup)(struct spi_device *spi); | 342 | void (*cleanup)(struct spi_device *spi); |
343 | |||
344 | /* | ||
345 | * These hooks are for drivers that want to use the generic | ||
346 | * master transfer queueing mechanism. If these are used, the | ||
347 | * transfer() function above must NOT be specified by the driver. | ||
348 | * Over time we expect SPI drivers to be phased over to this API. | ||
349 | */ | ||
350 | bool queued; | ||
351 | struct kthread_worker kworker; | ||
352 | struct task_struct *kworker_task; | ||
353 | struct kthread_work pump_messages; | ||
354 | spinlock_t queue_lock; | ||
355 | struct list_head queue; | ||
356 | struct spi_message *cur_msg; | ||
357 | bool busy; | ||
358 | bool running; | ||
359 | bool rt; | ||
360 | |||
361 | int (*prepare_transfer_hardware)(struct spi_master *master); | ||
362 | int (*transfer_one_message)(struct spi_master *master, | ||
363 | struct spi_message *mesg); | ||
364 | int (*unprepare_transfer_hardware)(struct spi_master *master); | ||
321 | }; | 365 | }; |
322 | 366 | ||
323 | static inline void *spi_master_get_devdata(struct spi_master *master) | 367 | static inline void *spi_master_get_devdata(struct spi_master *master) |
@@ -343,6 +387,13 @@ static inline void spi_master_put(struct spi_master *master) | |||
343 | put_device(&master->dev); | 387 | put_device(&master->dev); |
344 | } | 388 | } |
345 | 389 | ||
390 | /* PM calls that need to be issued by the driver */ | ||
391 | extern int spi_master_suspend(struct spi_master *master); | ||
392 | extern int spi_master_resume(struct spi_master *master); | ||
393 | |||
394 | /* Calls the driver make to interact with the message queue */ | ||
395 | extern struct spi_message *spi_get_next_queued_message(struct spi_master *master); | ||
396 | extern void spi_finalize_current_message(struct spi_master *master); | ||
346 | 397 | ||
347 | /* the spi driver core manages memory for the spi_master classdev */ | 398 | /* the spi driver core manages memory for the spi_master classdev */ |
348 | extern struct spi_master * | 399 | extern struct spi_master * |