diff options
author | Ezequiel Garcia <ezequiel.garcia@imgtec.com> | 2015-04-06 14:29:04 -0700 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-04-07 12:17:54 +0100 |
commit | b6fe39770aa63d14129bc7e061c95cfc3cb1419a (patch) | |
tree | 88c0c91755c5d0ced3259d3728a0d2a985934aff /drivers/spi/spi-img-spfi.c | |
parent | 6e0050ec8e909a5ed7d062552cd4fd223d286687 (diff) | |
download | linux-b6fe39770aa63d14129bc7e061c95cfc3cb1419a.tar.gz linux-b6fe39770aa63d14129bc7e061c95cfc3cb1419a.tar.bz2 linux-b6fe39770aa63d14129bc7e061c95cfc3cb1419a.zip |
spi: img-spfi: Implement a prepare_message() callback
In preparation for switching to using the SPI core's CS GPIO handling,
move setup of the PORT_STATE register, which must be configured before
CS is asserted, to a prepare_message() callback.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-img-spfi.c')
-rw-r--r-- | drivers/spi/spi-img-spfi.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c index fde4b5dd40f2..642259e88429 100644 --- a/drivers/spi/spi-img-spfi.c +++ b/drivers/spi/spi-img-spfi.c @@ -396,6 +396,25 @@ stop_dma: return -EIO; } +static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg) +{ + struct img_spfi *spfi = spi_master_get_devdata(master); + u32 val; + + val = spfi_readl(spfi, SPFI_PORT_STATE); + if (msg->spi->mode & SPI_CPHA) + val |= SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + else + val &= ~SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + if (msg->spi->mode & SPI_CPOL) + val |= SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + else + val &= ~SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + spfi_writel(spfi, val, SPFI_PORT_STATE); + + return 0; +} + static void img_spfi_config(struct spi_master *master, struct spi_device *spi, struct spi_transfer *xfer) { @@ -433,18 +452,6 @@ static void img_spfi_config(struct spi_master *master, struct spi_device *spi, &master->cur_msg->transfers)) val |= SPFI_CONTROL_CONTINUE; spfi_writel(spfi, val, SPFI_CONTROL); - - val = spfi_readl(spfi, SPFI_PORT_STATE); - if (spi->mode & SPI_CPHA) - val |= SPFI_PORT_STATE_CK_PHASE(spi->chip_select); - else - val &= ~SPFI_PORT_STATE_CK_PHASE(spi->chip_select); - if (spi->mode & SPI_CPOL) - val |= SPFI_PORT_STATE_CK_POL(spi->chip_select); - else - val &= ~SPFI_PORT_STATE_CK_POL(spi->chip_select); - spfi_writel(spfi, val, SPFI_PORT_STATE); - spfi_writel(spfi, xfer->len << SPFI_TRANSACTION_TSIZE_SHIFT, SPFI_TRANSACTION); } @@ -591,6 +598,7 @@ static int img_spfi_probe(struct platform_device *pdev) master->set_cs = img_spfi_set_cs; master->transfer_one = img_spfi_transfer_one; + master->prepare_message = img_spfi_prepare; spfi->tx_ch = dma_request_slave_channel(spfi->dev, "tx"); spfi->rx_ch = dma_request_slave_channel(spfi->dev, "rx"); |