MLK-19899 spi: lpspi: CLK pin becomes low when CR_RST=1
authorXiaoning Wang <xiaoning.wang@nxp.com>
Mon, 22 Oct 2018 03:01:18 +0000 (11:01 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Remove Reset operation in fsl_lpspi_config(). This RST may cause both CLK and
CS pins go from high to low level under cs-gpio mode.
Add fsl_lpspi_reset() function after one message transfer to clear all
flags in use.

Signed-off-by: Xiaoning Wang <xiaoning.wang@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
drivers/spi/spi-fsl-lpspi.c

index ee285ea..d5eae70 100644 (file)
@@ -287,10 +287,6 @@ static int fsl_lpspi_config(struct fsl_lpspi_data *fsl_lpspi)
        u32 temp;
        int ret;
 
-       temp = CR_RST;
-       writel(temp, fsl_lpspi->base + IMX7ULP_CR);
-       writel(0, fsl_lpspi->base + IMX7ULP_CR);
-
        if (!fsl_lpspi->is_slave) {
                ret = fsl_lpspi_set_bitrate(fsl_lpspi);
                if (ret)
@@ -382,6 +378,21 @@ static int fsl_lpspi_wait_for_completion(struct spi_controller *controller)
        return 0;
 }
 
+static int fsl_lpspi_reset(struct fsl_lpspi_data *fsl_lpspi)
+{
+       u32 temp;
+
+       /* W1C for all flags in SR */
+       temp = 0x3F << 8;
+       writel(temp, fsl_lpspi->base + IMX7ULP_SR);
+
+       /* Clear FIFO and disable module */
+       temp = CR_RRF | CR_RTF;
+       writel(temp, fsl_lpspi->base + IMX7ULP_CR);
+
+       return 0;
+}
+
 static int fsl_lpspi_transfer_one(struct spi_controller *controller,
                                  struct spi_device *spi,
                                  struct spi_transfer *t)
@@ -410,6 +421,8 @@ static int fsl_lpspi_transfer_one(struct spi_controller *controller,
 
        fsl_lpspi_read_rx_fifo(fsl_lpspi);
 
+       fsl_lpspi_reset(fsl_lpspi);
+
        return 0;
 }