diff options
author | Andi Shyti <andi.shyti@samsung.com> | 2016-06-27 22:41:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-06-29 17:45:15 -0400 |
commit | aa4964c4eb3ed38666023bcb805403cb7cf2af63 (patch) | |
tree | 2218855fff6330f9788854fa92855078a6d85807 | |
parent | 1a695a905c18548062509178b98bc91e67510864 (diff) |
spi: s3c64xx: group the CS signalling writes in a single function
To enable/disable the CS line, the driver performs a writel in
the S3C64XX_SPI_SLAVE_SEL registers. Group the register's
configuration in a single function.
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-s3c64xx.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 5a76a50063b5..972367d5c7f2 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c | |||
@@ -310,6 +310,28 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma, | |||
310 | dma_async_issue_pending(dma->ch); | 310 | dma_async_issue_pending(dma->ch); |
311 | } | 311 | } |
312 | 312 | ||
313 | static void s3c64xx_spi_set_cs(struct spi_device *spi, bool enable) | ||
314 | { | ||
315 | struct s3c64xx_spi_driver_data *sdd = | ||
316 | spi_master_get_devdata(spi->master); | ||
317 | |||
318 | if (enable) { | ||
319 | if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) { | ||
320 | writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); | ||
321 | } else { | ||
322 | u32 ssel = readl(sdd->regs + S3C64XX_SPI_SLAVE_SEL); | ||
323 | |||
324 | ssel |= (S3C64XX_SPI_SLAVE_AUTO | | ||
325 | S3C64XX_SPI_SLAVE_NSC_CNT_2); | ||
326 | writel(ssel, sdd->regs + S3C64XX_SPI_SLAVE_SEL); | ||
327 | } | ||
328 | } else { | ||
329 | if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) | ||
330 | writel(S3C64XX_SPI_SLAVE_SIG_INACT, | ||
331 | sdd->regs + S3C64XX_SPI_SLAVE_SEL); | ||
332 | } | ||
333 | } | ||
334 | |||
313 | static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) | 335 | static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) |
314 | { | 336 | { |
315 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); | 337 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); |
@@ -706,12 +728,7 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, | |||
706 | enable_datapath(sdd, spi, xfer, use_dma); | 728 | enable_datapath(sdd, spi, xfer, use_dma); |
707 | 729 | ||
708 | /* Start the signals */ | 730 | /* Start the signals */ |
709 | if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) | 731 | s3c64xx_spi_set_cs(spi, true); |
710 | writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); | ||
711 | else | ||
712 | writel(readl(sdd->regs + S3C64XX_SPI_SLAVE_SEL) | ||
713 | | S3C64XX_SPI_SLAVE_AUTO | S3C64XX_SPI_SLAVE_NSC_CNT_2, | ||
714 | sdd->regs + S3C64XX_SPI_SLAVE_SEL); | ||
715 | 732 | ||
716 | spin_unlock_irqrestore(&sdd->lock, flags); | 733 | spin_unlock_irqrestore(&sdd->lock, flags); |
717 | 734 | ||
@@ -861,16 +878,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi) | |||
861 | 878 | ||
862 | pm_runtime_mark_last_busy(&sdd->pdev->dev); | 879 | pm_runtime_mark_last_busy(&sdd->pdev->dev); |
863 | pm_runtime_put_autosuspend(&sdd->pdev->dev); | 880 | pm_runtime_put_autosuspend(&sdd->pdev->dev); |
864 | if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) | 881 | s3c64xx_spi_set_cs(spi, false); |
865 | writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); | 882 | |
866 | return 0; | 883 | return 0; |
867 | 884 | ||
868 | setup_exit: | 885 | setup_exit: |
869 | pm_runtime_mark_last_busy(&sdd->pdev->dev); | 886 | pm_runtime_mark_last_busy(&sdd->pdev->dev); |
870 | pm_runtime_put_autosuspend(&sdd->pdev->dev); | 887 | pm_runtime_put_autosuspend(&sdd->pdev->dev); |
871 | /* setup() returns with device de-selected */ | 888 | /* setup() returns with device de-selected */ |
872 | if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) | 889 | s3c64xx_spi_set_cs(spi, false); |
873 | writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); | ||
874 | 890 | ||
875 | if (gpio_is_valid(spi->cs_gpio)) | 891 | if (gpio_is_valid(spi->cs_gpio)) |
876 | gpio_free(spi->cs_gpio); | 892 | gpio_free(spi->cs_gpio); |