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.
Unified · Split
| @@ -2995,6 +2995,21 @@ int spi_setup(struct spi_device *spi) · 2994 unmodified lines | ||
| 2995 | 2995 | } |
| 2996 | 2996 | EXPORT_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 | + */ | |
| 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 | + | |
| 2998 | 3013 | static int __spi_validate(struct spi_device *spi, struct spi_message *message) |
| 2999 | 3014 | { |
| 3000 | 3015 | struct spi_controller *ctlr = spi->controller; |
| @@ -330,6 +330,9 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) · 329 unmodified lines | ||
| 330 | 330 | * must fail if an unrecognized or unsupported mode is requested. |
| 331 | 331 | * It's always safe to call this unless transfers are pending on |
| 332 | 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 | 336 | * @transfer: adds a message to the controller's transfer queue. |
| 334 | 337 | * @cleanup: frees controller-specific state |
| 335 | 338 | * @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 | 366 | * @unprepare_transfer_hardware: there are currently no more messages on the |
| 364 | 367 | * queue so the subsystem notifies the driver that it may relax the |
| 365 | 368 | * hardware by issuing this call |
| 369 | + * | |
| 366 | 370 | * @set_cs: set the logic level of the chip select line. May be called |
| 367 | 371 | * from interrupt context. |
| 368 | 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 | 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 | 506 | /* bidirectional bulk transfers |
| 492 | 507 | * |
| 493 | 508 | * + The transfer() method may not sleep; its main role is |