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
29952995 }
29962996 EXPORT_SYMBOL_GPL(spi_setup);
29972997
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+ */
3005+void 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+}
3011+EXPORT_SYMBOL_GPL(spi_set_cs_timing);
3012+
29983013 static int __spi_validate(struct spi_device *spi, struct spi_message *message)
29993014 {
30003015 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
330330 * must fail if an unrecognized or unsupported mode is requested.
331331 * It's always safe to call this unless transfers are pending on
332332 * 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
333336 * @transfer: adds a message to the controller's transfer queue.
334337 * @cleanup: frees controller-specific state
335338 * @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
363366 * @unprepare_transfer_hardware: there are currently no more messages on the
364367 * queue so the subsystem notifies the driver that it may relax the
365368 * hardware by issuing this call
369+ *
366370 * @set_cs: set the logic level of the chip select line. May be called
367371 * from interrupt context.
368372 * @prepare_message: set up the controller to transfer a single message,
@@ -488,6 +492,17 @@ struct spi_controller { · 119 unmodified lines
488492 */
489493 int (*setup)(struct spi_device *spi);
490494
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+
491506 /* bidirectional bulk transfers
492507 *
493508 * + 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