Commit f1ca9992 authored by Sowjanya Komatineni's avatar Sowjanya Komatineni Committed by Mark Brown

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.
Signed-off-by: default avatarSowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 24496da6
...@@ -2995,6 +2995,21 @@ int spi_setup(struct spi_device *spi) ...@@ -2995,6 +2995,21 @@ int spi_setup(struct spi_device *spi)
} }
EXPORT_SYMBOL_GPL(spi_setup); EXPORT_SYMBOL_GPL(spi_setup);
/**
* spi_set_cs_timing - configure CS setup, hold, and inactive delays
* @spi: the device that requires specific CS timing configuration
* @setup: CS setup time in terms of clock count
* @hold: CS hold time in terms of clock count
* @inactive_dly: CS inactive delay between transfers in terms of clock count
*/
void spi_set_cs_timing(struct spi_device *spi, u8 setup, u8 hold,
u8 inactive_dly)
{
if (spi->controller->set_cs_timing)
spi->controller->set_cs_timing(spi, setup, hold, inactive_dly);
}
EXPORT_SYMBOL_GPL(spi_set_cs_timing);
static int __spi_validate(struct spi_device *spi, struct spi_message *message) static int __spi_validate(struct spi_device *spi, struct spi_message *message)
{ {
struct spi_controller *ctlr = spi->controller; struct spi_controller *ctlr = spi->controller;
......
...@@ -330,6 +330,9 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) ...@@ -330,6 +330,9 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
* must fail if an unrecognized or unsupported mode is requested. * must fail if an unrecognized or unsupported mode is requested.
* It's always safe to call this unless transfers are pending on * It's always safe to call this unless transfers are pending on
* the device whose settings are being modified. * the device whose settings are being modified.
* @set_cs_timing: optional hook for SPI devices to request SPI master
* controller for configuring specific CS setup time, hold time and inactive
* delay interms of clock counts
* @transfer: adds a message to the controller's transfer queue. * @transfer: adds a message to the controller's transfer queue.
* @cleanup: frees controller-specific state * @cleanup: frees controller-specific state
* @can_dma: determine whether this controller supports DMA * @can_dma: determine whether this controller supports DMA
...@@ -363,6 +366,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) ...@@ -363,6 +366,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
* @unprepare_transfer_hardware: there are currently no more messages on the * @unprepare_transfer_hardware: there are currently no more messages on the
* queue so the subsystem notifies the driver that it may relax the * queue so the subsystem notifies the driver that it may relax the
* hardware by issuing this call * hardware by issuing this call
*
* @set_cs: set the logic level of the chip select line. May be called * @set_cs: set the logic level of the chip select line. May be called
* from interrupt context. * from interrupt context.
* @prepare_message: set up the controller to transfer a single message, * @prepare_message: set up the controller to transfer a single message,
...@@ -488,6 +492,17 @@ struct spi_controller { ...@@ -488,6 +492,17 @@ struct spi_controller {
*/ */
int (*setup)(struct spi_device *spi); int (*setup)(struct spi_device *spi);
/*
* set_cs_timing() method is for SPI controllers that supports
* configuring CS timing.
*
* This hook allows SPI client drivers to request SPI controllers
* to configure specific CS timing through spi_set_cs_timing() after
* spi_setup().
*/
void (*set_cs_timing)(struct spi_device *spi, u8 setup_clk_cycles,
u8 hold_clk_cycles, u8 inactive_clk_cycles);
/* bidirectional bulk transfers /* bidirectional bulk transfers
* *
* + The transfer() method may not sleep; its main role is * + The transfer() method may not sleep; its main role is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment