Merge remote-tracking branches 'spi/fix/atmel', 'spi/fix/imx', 'spi/fix/omap2-mcspi...
authorMark Brown <broonie@kernel.org>
Wed, 4 Nov 2015 11:01:58 +0000 (11:01 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 4 Nov 2015 11:01:58 +0000 (11:01 +0000)
drivers/spi/spi-atmel.c
drivers/spi/spi-imx.c
drivers/spi/spi-omap2-mcspi.c
drivers/spi/spi-ti-qspi.c
drivers/spi/spi-xilinx.c

index 63318e2afba1900bc3923d3b4023143699a4842e..3fff59ce065f3057f4a1f34a9165b61cd592ee15 100644 (file)
@@ -773,7 +773,8 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,
 
        *plen = len;
 
-       if (atmel_spi_dma_slave_config(as, &slave_config, 8))
+       if (atmel_spi_dma_slave_config(as, &slave_config,
+                                      xfer->bits_per_word))
                goto err_exit;
 
        /* Send both scatterlists */
index f9deb84e4e551bdd9c42c8ac204c80c18f0f8579..0e5723ab47f0ce023db657c5be0e2274d825c149 100644 (file)
@@ -336,13 +336,20 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx,
 
        if (config->mode & SPI_CPHA)
                cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs);
+       else
+               cfg &= ~MX51_ECSPI_CONFIG_SCLKPHA(config->cs);
 
        if (config->mode & SPI_CPOL) {
                cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs);
                cfg |= MX51_ECSPI_CONFIG_SCLKCTL(config->cs);
+       } else {
+               cfg &= ~MX51_ECSPI_CONFIG_SCLKPOL(config->cs);
+               cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(config->cs);
        }
        if (config->mode & SPI_CS_HIGH)
                cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs);
+       else
+               cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(config->cs);
 
        writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL);
        writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG);
index 3d09e0b69b73241c58d50e788dbdaf5cd16bf7ea..1f8903d356e5581f48d6935177906bba6bc7e302 100644 (file)
@@ -1217,6 +1217,33 @@ out:
        return status;
 }
 
+static int omap2_mcspi_prepare_message(struct spi_master *master,
+                                      struct spi_message *msg)
+{
+       struct omap2_mcspi      *mcspi = spi_master_get_devdata(master);
+       struct omap2_mcspi_regs *ctx = &mcspi->ctx;
+       struct omap2_mcspi_cs   *cs;
+
+       /* Only a single channel can have the FORCE bit enabled
+        * in its chconf0 register.
+        * Scan all channels and disable them except the current one.
+        * A FORCE can remain from a last transfer having cs_change enabled
+        */
+       list_for_each_entry(cs, &ctx->cs, node) {
+               if (msg->spi->controller_state == cs)
+                       continue;
+
+               if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE)) {
+                       cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
+                       writel_relaxed(cs->chconf0,
+                                       cs->base + OMAP2_MCSPI_CHCONF0);
+                       readl_relaxed(cs->base + OMAP2_MCSPI_CHCONF0);
+               }
+       }
+
+       return 0;
+}
+
 static int omap2_mcspi_transfer_one(struct spi_master *master,
                struct spi_device *spi, struct spi_transfer *t)
 {
@@ -1344,6 +1371,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
        master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
        master->setup = omap2_mcspi_setup;
        master->auto_runtime_pm = true;
+       master->prepare_message = omap2_mcspi_prepare_message;
        master->transfer_one = omap2_mcspi_transfer_one;
        master->set_cs = omap2_mcspi_set_cs;
        master->cleanup = omap2_mcspi_cleanup;
index aa6d284131e0fd99fd19ef92dc0adff73ee18a02..81b84858cfeed2d8baebd959af2fbcfc51fc8108 100644 (file)
@@ -410,11 +410,10 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,
 
        mutex_unlock(&qspi->list_lock);
 
+       ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG);
        m->status = status;
        spi_finalize_current_message(master);
 
-       ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG);
-
        return status;
 }
 
index a339c1e9997a93a431cf5ce9be5947b6333ac3e9..3009121173cdbc9ad1a0537a4cf19a029ceb86b8 100644 (file)
@@ -270,6 +270,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
 
        while (remaining_words) {
                int n_words, tx_words, rx_words;
+               u32 sr;
 
                n_words = min(remaining_words, xspi->buffer_size);
 
@@ -284,24 +285,33 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
                if (use_irq) {
                        xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
                        wait_for_completion(&xspi->done);
-               } else
-                       while (!(xspi->read_fn(xspi->regs + XSPI_SR_OFFSET) &
-                                               XSPI_SR_TX_EMPTY_MASK))
-                               ;
-
-               /* A transmit has just completed. Process received data and
-                * check for more data to transmit. Always inhibit the
-                * transmitter while the Isr refills the transmit register/FIFO,
-                * or make sure it is stopped if we're done.
-                */
-               if (use_irq)
+                       /* A transmit has just completed. Process received data
+                        * and check for more data to transmit. Always inhibit
+                        * the transmitter while the Isr refills the transmit
+                        * register/FIFO, or make sure it is stopped if we're
+                        * done.
+                        */
                        xspi->write_fn(cr | XSPI_CR_TRANS_INHIBIT,
-                              xspi->regs + XSPI_CR_OFFSET);
+                                      xspi->regs + XSPI_CR_OFFSET);
+                       sr = XSPI_SR_TX_EMPTY_MASK;
+               } else
+                       sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
 
                /* Read out all the data from the Rx FIFO */
                rx_words = n_words;
-               while (rx_words--)
-                       xilinx_spi_rx(xspi);
+               while (rx_words) {
+                       if ((sr & XSPI_SR_TX_EMPTY_MASK) && (rx_words > 1)) {
+                               xilinx_spi_rx(xspi);
+                               rx_words--;
+                               continue;
+                       }
+
+                       sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
+                       if (!(sr & XSPI_SR_RX_EMPTY_MASK)) {
+                               xilinx_spi_rx(xspi);
+                               rx_words--;
+                       }
+               }
 
                remaining_words -= n_words;
        }