History

spi: add a method for configuring CS timing

This patch creates set_cs_timing SPI master optional method for SPI masters to implement configuring CS timing if applicable. This patch also creates spi_cs_timing accessory for SPI clients to use for requesting SPI master controllers to configure device requested CS setup time, hold time and inactive delay.

Sowjanya Komatineni committed 7 years ago

Commit f1ca9991 parent 24496da2 files · +30 −0Browse files

Unified · Split

2 files
  1. drivers/spi/spi.c +15 −0
  2. include/linux/spi/spi.h +15 −0
drivers/spi/spi.c+15−0
@@ -2995,6 +2995,21 @@ int spi_setup(struct spi_device *spi) · 2994 unmodified lines
2995}2995}
2996EXPORT_SYMBOL_GPL(spi_setup);2996EXPORT_SYMBOL_GPL(spi_setup);
2997 2997
2998/**
2999 * spi_set_cs_timing - configure CS setup, hold, and inactive delays
3000 * @spi: the device that requires specific CS timing configuration
3001 * @setup: CS setup time in terms of clock count
3002 * @hold: CS hold time in terms of clock count
3003 * @inactive_dly: CS inactive delay between transfers in terms of clock count
3004 */
3005void spi_set_cs_timing(struct spi_device *spi, u8 setup, u8 hold,
3006 u8 inactive_dly)
3007{
3008 if (spi->controller->set_cs_timing)
3009 spi->controller->set_cs_timing(spi, setup, hold, inactive_dly);
3010}
3011EXPORT_SYMBOL_GPL(spi_set_cs_timing);
3012
2998static int __spi_validate(struct spi_device *spi, struct spi_message *message)3013static int __spi_validate(struct spi_device *spi, struct spi_message *message)
2999{3014{
3000 struct spi_controller *ctlr = spi->controller;3015 struct spi_controller *ctlr = spi->controller;
include/linux/spi/spi.h+15−0
@@ -330,6 +330,9 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) · 329 unmodified lines
330 * must fail if an unrecognized or unsupported mode is requested.330 * must fail if an unrecognized or unsupported mode is requested.
331 * It's always safe to call this unless transfers are pending on331 * It's always safe to call this unless transfers are pending on
332 * the device whose settings are being modified.332 * the device whose settings are being modified.
333 * @set_cs_timing: optional hook for SPI devices to request SPI master
334 * controller for configuring specific CS setup time, hold time and inactive
335 * delay interms of clock counts
333 * @transfer: adds a message to the controller's transfer queue.336 * @transfer: adds a message to the controller's transfer queue.
334 * @cleanup: frees controller-specific state337 * @cleanup: frees controller-specific state
335 * @can_dma: determine whether this controller supports DMA338 * @can_dma: determine whether this controller supports DMA
@@ -363,6 +366,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) · 27 unmodified lines
363 * @unprepare_transfer_hardware: there are currently no more messages on the366 * @unprepare_transfer_hardware: there are currently no more messages on the
364 * queue so the subsystem notifies the driver that it may relax the367 * queue so the subsystem notifies the driver that it may relax the
365 * hardware by issuing this call368 * hardware by issuing this call
369 *
366 * @set_cs: set the logic level of the chip select line. May be called370 * @set_cs: set the logic level of the chip select line. May be called
367 * from interrupt context.371 * from interrupt context.
368 * @prepare_message: set up the controller to transfer a single message,372 * @prepare_message: set up the controller to transfer a single message,
@@ -488,6 +492,17 @@ struct spi_controller { · 119 unmodified lines
488 */492 */
489 int (*setup)(struct spi_device *spi);493 int (*setup)(struct spi_device *spi);
490 494
495 /*
496 * set_cs_timing() method is for SPI controllers that supports
497 * configuring CS timing.
498 *
499 * This hook allows SPI client drivers to request SPI controllers
500 * to configure specific CS timing through spi_set_cs_timing() after
501 * spi_setup().
502 */
503 void (*set_cs_timing)(struct spi_device *spi, u8 setup_clk_cycles,
504 u8 hold_clk_cycles, u8 inactive_clk_cycles);
505
491 /* bidirectional bulk transfers506 /* bidirectional bulk transfers
492 *507 *
493 * + The transfer() method may not sleep; its main role is508 * + The transfer() method may not sleep; its main role is

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t