]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/spi/spi-omap2-mcspi.c
Merge branch 'karo-tx6-mainline' into stable
[karo-tx-linux.git] / drivers / spi / spi-omap2-mcspi.c
index 1f8903d356e5581f48d6935177906bba6bc7e302..9ccd5a5c8b65c633809b67eb7a14b80de79116ab 100644 (file)
@@ -439,10 +439,9 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
                } else {
                        /* FIXME: fall back to PIO? */
                }
+               dma_async_issue_pending(mcspi_dma->dma_tx);
        }
-       dma_async_issue_pending(mcspi_dma->dma_tx);
        omap2_mcspi_set_dma_req(spi, 0, 1);
-
 }
 
 static unsigned
@@ -567,10 +566,10 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
        const u8                *tx;
        struct dma_slave_config cfg;
        enum dma_slave_buswidth width;
-       unsigned es;
+       unsigned                es;
        u32                     burst;
        void __iomem            *chstat_reg;
-       void __iomem            *irqstat_reg;
+       void __iomem            *irqstat_reg;
        int                     wait_res;
 
        mcspi = spi_master_get_devdata(spi->master);
@@ -1024,6 +1023,16 @@ static int omap2_mcspi_setup(struct spi_device *spi)
                spi->controller_state = cs;
                /* Link this to context save list */
                list_add_tail(&cs->node, &ctx->cs);
+
+               if (gpio_is_valid(spi->cs_gpio)) {
+                       ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
+                       if (ret) {
+                               dev_err(&spi->dev, "failed to request gpio\n");
+                               return ret;
+                       }
+                       gpio_direction_output(spi->cs_gpio,
+                                        !(spi->mode & SPI_CS_HIGH));
+               }
        }
 
        if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
@@ -1032,15 +1041,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
                        return ret;
        }
 
-       if (gpio_is_valid(spi->cs_gpio)) {
-               ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
-               if (ret) {
-                       dev_err(&spi->dev, "failed to request gpio\n");
-                       return ret;
-               }
-               gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
-       }
-
        ret = pm_runtime_get_sync(mcspi->dev);
        if (ret < 0)
                return ret;
@@ -1344,7 +1344,7 @@ static const struct of_device_id omap_mcspi_of_match[] = {
                .compatible = "ti,omap4-mcspi",
                .data = &omap4_pdata,
        },
-       { },
+       { }
 };
 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
 
@@ -1355,7 +1355,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
        struct omap2_mcspi      *mcspi;
        struct resource         *r;
        int                     status = 0, i;
-       u32                     regs_offset = 0;
+       u32                     regs_offset;
        static int              bus_num = 1;
        struct device_node      *node = pdev->dev.of_node;
        const struct of_device_id *match;
@@ -1409,15 +1409,13 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
                goto free_master;
        }
 
-       r->start += regs_offset;
-       r->end += regs_offset;
-       mcspi->phys = r->start;
-
        mcspi->base = devm_ioremap_resource(&pdev->dev, r);
        if (IS_ERR(mcspi->base)) {
                status = PTR_ERR(mcspi->base);
                goto free_master;
        }
+       mcspi->phys = r->start + regs_offset;
+       mcspi->base += regs_offset;
 
        mcspi->dev = &pdev->dev;