spi/s3c64xx: Flush FIFOs prior to cleaning up transfer
Subsystems (3)
Mark Brown
maintainerPATCH 1/6 spi/s3c64xx: Flush FIFOs prior to cleaning up transfer
From: Mark Brown <[email protected]>
Ensure that the FIFOs are fully drained before we deassert /CS or do any delays that have been requested in order to ensure that the behaviour visible on the bus matches that which was requested by the caller.
--- drivers/spi/spi-s3c64xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-s3c64xx.c +2 -2
@@ -960,6 +960,8 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, goto out; } +flush_fifo (sdd); +if (xfer->delay_usecs)udelay (xfer->delay_usecs);
@@ -972,8 +974,6 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, } msg->actual_length += xfer->len; - -flush_fifo (sdd); } out:
Signature · 1 line
1.8.4.rc3
Mark Brown
maintainerPATCH 2/6 spi/s3c64xx: Check that clock enables succeed on runtime resume
From: Mark Brown <[email protected]>
--- drivers/spi/spi-s3c64xx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/spi/spi-s3c64xx.c +10 -2
@@ -1524,9 +1524,17 @@ static int s3c64xx_spi_runtime_resume(struct device *dev) {struct spi_master *master =dev_get_drvdata (dev);struct s3c64xx_spi_driver_data *sdd =spi_master_get_devdata (master); +int ret; -clk_prepare_enable (sdd->src_clk); -clk_prepare_enable (sdd->clk); + ret =clk_prepare_enable (sdd->src_clk); +if (ret !=0 ) +return ret; + + ret =clk_prepare_enable (sdd->clk); +if (ret !=0 ) { +clk_disable_unprepare (sdd->src_clk); +return ret; + }return 0 ; }
Signature · 1 line
1.8.4.rc3
Mark Brown
maintainerPATCH 3/6 spi/s3c64xx: Remove unused gpios field from driver data
In reply to Mark BrownFrom: Mark Brown <[email protected]>
--- drivers/spi/spi-s3c64xx.c | 1 - 1 file changed, 1 deletion(-)
drivers/spi/spi-s3c64xx.c +0 -1
@@ -205,7 +205,6 @@ struct s3c64xx_spi_driver_data {#endif struct s3c64xx_spi_port_config *port_conf;unsigned int port_id; -unsigned long gpios[4 ];bool cs_gpio; };
Signature · 1 line
1.8.4.rc3
Mark Brown
maintainerPATCH 4/6 spi/s3c64xx: Use core cs_gpio field
In reply to Mark BrownFrom: Mark Brown <[email protected]>
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.
--- drivers/spi/spi-s3c64xx.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/spi/spi-s3c64xx.c +10 -14
@@ -558,22 +558,18 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,static inline void enable_cs (struct s3c64xx_spi_driver_data *sdd,struct spi_device *spi) { -struct s3c64xx_spi_csinfo *cs; -if (sdd->tgl_spi !=NULL ) {/* If last device toggled after mssg */ if (sdd->tgl_spi != spi) {/* if last mssg on diff device */ /* Deselect the last toggled device */ - cs = sdd->tgl_spi->controller_data; -if (sdd->cs_gpio) -gpio_set_value (cs->line, +if (spi->cs_gpio >=0 ) +gpio_set_value (spi->cs_gpio, spi->mode &SPI_CS_HIGH ?0 :1 ); } sdd->tgl_spi =NULL ; } - cs = spi->controller_data; -if (sdd->cs_gpio) -gpio_set_value (cs->line, spi->mode &SPI_CS_HIGH ?1 :0 ); +if (spi->cs_gpio >=0 ) +gpio_set_value (spi->cs_gpio, spi->mode &SPI_CS_HIGH ?1 :0 );/* Start the signals */ writel (0 , sdd->regs +S3C64XX_SPI_SLAVE_SEL );
@@ -701,13 +697,11 @@ static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,static inline void disable_cs (struct s3c64xx_spi_driver_data *sdd,struct spi_device *spi) { -struct s3c64xx_spi_csinfo *cs = spi->controller_data; -if (sdd->tgl_spi == spi) sdd->tgl_spi =NULL ; -if (sdd->cs_gpio) -gpio_set_value (cs->line, spi->mode &SPI_CS_HIGH ?0 :1 ); +if (spi->cs_gpio >=0 ) +gpio_set_value (spi->cs_gpio, spi->mode &SPI_CS_HIGH ?0 :1 );/* Quiese the signals */ 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) cs->line, err); goto err_gpio_req; } + + spi->cs_gpio = cs->line; }spi_set_ctldata (spi, cs);
@@ -1139,8 +1135,8 @@ static void s3c64xx_spi_cleanup(struct spi_device *spi)struct s3c64xx_spi_driver_data *sdd; sdd =spi_master_get_devdata (spi->master); -if (cs && sdd->cs_gpio) { -gpio_free (cs->line); +if (spi->cs_gpio) { +gpio_free (spi->cs_gpio);if (spi->dev.of_node)kfree (cs); }
Signature · 1 line
1.8.4.rc3
Mark Brown
maintainerPATCH 5/6 spi/s3c64xx: Factor transfer start out of enable/disable_cs()
In reply to Mark BrownFrom: Mark Brown <[email protected]>
The hardware level /CS handling is tied to the start of the data path so is rolled into the same function as we use to manipulate GPIO /CS. In order to support factoring out the /CS handling into the core separate the two and explicitly start transfers separately to the /CS handling.
--- drivers/spi/spi-s3c64xx.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/spi/spi-s3c64xx.c +11 -8
@@ -570,9 +570,6 @@ static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd,if (spi->cs_gpio >=0 )gpio_set_value (spi->cs_gpio, spi->mode &SPI_CS_HIGH ?1 :0 ); - -/* Start the signals */ -writel (0 , sdd->regs +S3C64XX_SPI_SLAVE_SEL ); } static u32 s3c64xx_spi_wait_for_timeout(struct s3c64xx_spi_driver_data *sdd,
@@ -702,9 +699,6 @@ static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd,if (spi->cs_gpio >=0 )gpio_set_value (spi->cs_gpio, spi->mode &SPI_CS_HIGH ?0 :1 ); - -/* Quiese the signals */ -writel (S3C64XX_SPI_SLAVE_SIG_INACT , sdd->regs +S3C64XX_SPI_SLAVE_SEL ); }static void s3c64xx_spi_config (struct s3c64xx_spi_driver_data *sdd)
@@ -930,6 +924,9 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,/* Slave Select */ enable_cs (sdd, spi); +/* Start the signals */ +writel (0 , sdd->regs +S3C64XX_SPI_SLAVE_SEL ); +spin_unlock_irqrestore (&sdd->lock, flags); status =wait_for_xfer (sdd, xfer, use_dma);
@@ -970,10 +967,14 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, } out: -if (!cs_toggle || status) +if (!cs_toggle || status) { +/* Quiese the signals */ +writel (S3C64XX_SPI_SLAVE_SIG_INACT , + sdd->regs +S3C64XX_SPI_SLAVE_SEL );disable_cs (sdd, spi); -else + }else { sdd->tgl_spi = spi; + }s3c64xx_spi_unmap_mssg (sdd, msg);
@@ -1112,11 +1113,13 @@ static int s3c64xx_spi_setup(struct spi_device *spi) }pm_runtime_put (&sdd->pdev->dev); +writel (S3C64XX_SPI_SLAVE_SIG_INACT , sdd->regs +S3C64XX_SPI_SLAVE_SEL );disable_cs (sdd, spi);return 0 ; setup_exit:/* setup() returns with device de-selected */ +writel (S3C64XX_SPI_SLAVE_SIG_INACT , sdd->regs +S3C64XX_SPI_SLAVE_SEL );disable_cs (sdd, spi);gpio_free (cs->line);
Signature · 1 line
1.8.4.rc3
Mark Brown
maintainerPATCH 6/6 spi/s3c64xx: Enable GPIO /CS prior to starting hardware
In reply to Mark BrownFrom: Mark Brown <[email protected]>
To help with bisection of future refactoring to share more of the code for handling a spi_message pull the enabling of GPIO based /CS prior to all the hardware setup for starting a transfer.
--- drivers/spi/spi-s3c64xx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-s3c64xx.c +3 -3
@@ -906,6 +906,9 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,s3c64xx_spi_config (sdd); } +/* Slave Select */ +enable_cs (sdd, spi); +/* Polling method for xfers not bigger than FIFO capacity */ use_dma =0 ; if (!is_polling(sdd) &&
@@ -921,9 +924,6 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,enable_datapath (sdd, spi, xfer, use_dma); -/* Slave Select */ -enable_cs (sdd, spi); -/* Start the signals */ writel (0 , sdd->regs +S3C64XX_SPI_SLAVE_SEL );
Signature · 1 line
1.8.4.rc3