aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-09-27 13:58:55 -0400
committerMark Brown <broonie@linaro.org>2013-09-30 07:53:37 -0400
commitdd97e26849c16f484191f056b6e080cc30ebe98b (patch)
tree7b7044783b9c4e758f85e6726a067016f559db72
parent64d930ac116db25db814f76c31bfd4a7ea428f74 (diff)
spi/s3c64xx: Use core cs_gpio field
Rather than using the driver custom platform data to store the chip select GPIO use the cs_gpio field provided by the SPI core, supporting future refectoring. Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/spi/spi-s3c64xx.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 7f960db66763..43caeee8641a 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -558,22 +558,18 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
558static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd, 558static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd,
559 struct spi_device *spi) 559 struct spi_device *spi)
560{ 560{
561 struct s3c64xx_spi_csinfo *cs;
562
563 if (sdd->tgl_spi != NULL) { /* If last device toggled after mssg */ 561 if (sdd->tgl_spi != NULL) { /* If last device toggled after mssg */
564 if (sdd->tgl_spi != spi) { /* if last mssg on diff device */ 562 if (sdd->tgl_spi != spi) { /* if last mssg on diff device */
565 /* Deselect the last toggled device */ 563 /* Deselect the last toggled device */
566 cs = sdd->tgl_spi->controller_data; 564 if (spi->cs_gpio >= 0)
567 if (sdd->cs_gpio) 565 gpio_set_value(spi->cs_gpio,
568 gpio_set_value(cs->line,
569 spi->mode & SPI_CS_HIGH ? 0 : 1); 566 spi->mode & SPI_CS_HIGH ? 0 : 1);
570 } 567 }
571 sdd->tgl_spi = NULL; 568 sdd->tgl_spi = NULL;
572 } 569 }
573 570
574 cs = spi->controller_data; 571 if (spi->cs_gpio >= 0)
575 if (sdd->cs_gpio) 572 gpio_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH ? 1 : 0);
576 gpio_set_value(cs->line, spi->mode & SPI_CS_HIGH ? 1 : 0);
577 573
578 /* Start the signals */ 574 /* Start the signals */
579 writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 575 writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
@@ -701,13 +697,11 @@ static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
701static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd, 697static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd,
702 struct spi_device *spi) 698 struct spi_device *spi)
703{ 699{
704 struct s3c64xx_spi_csinfo *cs = spi->controller_data;
705
706 if (sdd->tgl_spi == spi) 700 if (sdd->tgl_spi == spi)
707 sdd->tgl_spi = NULL; 701 sdd->tgl_spi = NULL;
708 702
709 if (sdd->cs_gpio) 703 if (spi->cs_gpio >= 0)
710 gpio_set_value(cs->line, spi->mode & SPI_CS_HIGH ? 0 : 1); 704 gpio_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
711 705
712 /* Quiese the signals */ 706 /* Quiese the signals */
713 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 707 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
@@ -1070,6 +1064,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
1070 cs->line, err); 1064 cs->line, err);
1071 goto err_gpio_req; 1065 goto err_gpio_req;
1072 } 1066 }
1067
1068 spi->cs_gpio = cs->line;
1073 } 1069 }
1074 1070
1075 spi_set_ctldata(spi, cs); 1071 spi_set_ctldata(spi, cs);
@@ -1139,8 +1135,8 @@ static void s3c64xx_spi_cleanup(struct spi_device *spi)
1139 struct s3c64xx_spi_driver_data *sdd; 1135 struct s3c64xx_spi_driver_data *sdd;
1140 1136
1141 sdd = spi_master_get_devdata(spi->master); 1137 sdd = spi_master_get_devdata(spi->master);
1142 if (cs && sdd->cs_gpio) { 1138 if (spi->cs_gpio) {
1143 gpio_free(cs->line); 1139 gpio_free(spi->cs_gpio);
1144 if (spi->dev.of_node) 1140 if (spi->dev.of_node)
1145 kfree(cs); 1141 kfree(cs);
1146 } 1142 }