aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-07-10 05:26:29 -0400
committerMark Brown <broonie@linaro.org>2014-07-11 09:39:26 -0400
commitb48b9488e3180b173f37782a348b76ea6bff2c48 (patch)
treeb0a8678fc9c49f0fed451dc47f77276f8c6e8a59
parenta39e65e9cc935b84f35d080e934c3fdd9ff86654 (diff)
spi: cadence: Configure SPI clock in the prepare_message() callback
Currently the cadence SPI driver does the SPI clock configuration (setup CPOL and CPHA) in the prepare_transfer_hardware() callback. The prepare_transfer_hardware() callback is only called though when the controller transitions from a idle state to a non-idle state. Such a transitions happens when the message queue goes from empty to non-empty. If multiple messages from different SPI slaves with different clock settings are in the message queue the clock settings will not be properly updated when switching from one slave device to another. Instead do the updating of the clock configuration in the prepare_message() callback which will be called for each individual message. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/spi/spi-cadence.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index f55702937052..3312eccb18c1 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -382,6 +382,12 @@ static irqreturn_t cdns_spi_irq(int irq, void *dev_id)
382 382
383 return status; 383 return status;
384} 384}
385static int cdns_prepare_message(struct spi_master *master,
386 struct spi_message *msg)
387{
388 cdns_spi_config_clock_mode(msg->spi);
389 return 0;
390}
385 391
386/** 392/**
387 * cdns_transfer_one - Initiates the SPI transfer 393 * cdns_transfer_one - Initiates the SPI transfer
@@ -428,8 +434,6 @@ static int cdns_prepare_transfer_hardware(struct spi_master *master)
428{ 434{
429 struct cdns_spi *xspi = spi_master_get_devdata(master); 435 struct cdns_spi *xspi = spi_master_get_devdata(master);
430 436
431 cdns_spi_config_clock_mode(master->cur_msg->spi);
432
433 cdns_spi_write(xspi, CDNS_SPI_ER_OFFSET, 437 cdns_spi_write(xspi, CDNS_SPI_ER_OFFSET,
434 CDNS_SPI_ER_ENABLE_MASK); 438 CDNS_SPI_ER_ENABLE_MASK);
435 439
@@ -544,6 +548,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
544 xspi->is_decoded_cs = 0; 548 xspi->is_decoded_cs = 0;
545 549
546 master->prepare_transfer_hardware = cdns_prepare_transfer_hardware; 550 master->prepare_transfer_hardware = cdns_prepare_transfer_hardware;
551 master->prepare_message = cdns_prepare_message;
547 master->transfer_one = cdns_transfer_one; 552 master->transfer_one = cdns_transfer_one;
548 master->unprepare_transfer_hardware = cdns_unprepare_transfer_hardware; 553 master->unprepare_transfer_hardware = cdns_unprepare_transfer_hardware;
549 master->set_cs = cdns_spi_chipselect; 554 master->set_cs = cdns_spi_chipselect;