Merge branch 'topic/dmaengine_cleanups' into for-linus
authorVinod Koul <vinod.koul@intel.com>
Thu, 28 Jul 2016 04:40:37 +0000 (10:10 +0530)
committerVinod Koul <vinod.koul@intel.com>
Thu, 28 Jul 2016 04:40:37 +0000 (10:10 +0530)
drivers/dma/k3dma.c
drivers/dma/omap-dma.c
drivers/dma/qcom/hidma_mgmt.c
drivers/dma/xilinx/zynqmp_dma.c

index 9364dac..39de898 100644 (file)
@@ -760,7 +760,7 @@ static int k3_dma_probe(struct platform_device *op)
 
        ret = dma_async_device_register(&d->slave);
        if (ret)
-               return ret;
+               goto dma_async_register_fail;
 
        ret = of_dma_controller_register((&op->dev)->of_node,
                                        k3_of_dma_simple_xlate, d);
@@ -777,6 +777,8 @@ static int k3_dma_probe(struct platform_device *op)
 
 of_dma_register_fail:
        dma_async_device_unregister(&d->slave);
+dma_async_register_fail:
+       clk_disable_unprepare(d->clk);
        return ret;
 }
 
index 5ff5299..d99ca2b 100644 (file)
@@ -59,6 +59,8 @@ struct omap_sg {
        dma_addr_t addr;
        uint32_t en;            /* number of elements (24-bit) */
        uint32_t fn;            /* number of frames (16-bit) */
+       int32_t fi;             /* for double indexing */
+       int16_t ei;             /* for double indexing */
 };
 
 struct omap_desc {
@@ -66,7 +68,8 @@ struct omap_desc {
        enum dma_transfer_direction dir;
        dma_addr_t dev_addr;
 
-       int16_t fi;             /* for OMAP_DMA_SYNC_PACKET */
+       int32_t fi;             /* for OMAP_DMA_SYNC_PACKET / double indexing */
+       int16_t ei;             /* for double indexing */
        uint8_t es;             /* CSDP_DATA_TYPE_xxx */
        uint32_t ccr;           /* CCR value */
        uint16_t clnk_ctrl;     /* CLNK_CTRL value */
@@ -379,8 +382,8 @@ static void omap_dma_start_sg(struct omap_chan *c, struct omap_desc *d,
        }
 
        omap_dma_chan_write(c, cxsa, sg->addr);
-       omap_dma_chan_write(c, cxei, 0);
-       omap_dma_chan_write(c, cxfi, 0);
+       omap_dma_chan_write(c, cxei, sg->ei);
+       omap_dma_chan_write(c, cxfi, sg->fi);
        omap_dma_chan_write(c, CEN, sg->en);
        omap_dma_chan_write(c, CFN, sg->fn);
 
@@ -425,7 +428,7 @@ static void omap_dma_start_desc(struct omap_chan *c)
        }
 
        omap_dma_chan_write(c, cxsa, d->dev_addr);
-       omap_dma_chan_write(c, cxei, 0);
+       omap_dma_chan_write(c, cxei, d->ei);
        omap_dma_chan_write(c, cxfi, d->fi);
        omap_dma_chan_write(c, CSDP, d->csdp);
        omap_dma_chan_write(c, CLNK_CTRL, d->clnk_ctrl);
@@ -971,6 +974,89 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_memcpy(
        return vchan_tx_prep(&c->vc, &d->vd, tx_flags);
 }
 
+static struct dma_async_tx_descriptor *omap_dma_prep_dma_interleaved(
+       struct dma_chan *chan, struct dma_interleaved_template *xt,
+       unsigned long flags)
+{
+       struct omap_chan *c = to_omap_dma_chan(chan);
+       struct omap_desc *d;
+       struct omap_sg *sg;
+       uint8_t data_type;
+       size_t src_icg, dst_icg;
+
+       /* Slave mode is not supported */
+       if (is_slave_direction(xt->dir))
+               return NULL;
+
+       if (xt->frame_size != 1 || xt->numf == 0)
+               return NULL;
+
+       d = kzalloc(sizeof(*d) + sizeof(d->sg[0]), GFP_ATOMIC);
+       if (!d)
+               return NULL;
+
+       data_type = __ffs((xt->src_start | xt->dst_start | xt->sgl[0].size));
+       if (data_type > CSDP_DATA_TYPE_32)
+               data_type = CSDP_DATA_TYPE_32;
+
+       sg = &d->sg[0];
+       d->dir = DMA_MEM_TO_MEM;
+       d->dev_addr = xt->src_start;
+       d->es = data_type;
+       sg->en = xt->sgl[0].size / BIT(data_type);
+       sg->fn = xt->numf;
+       sg->addr = xt->dst_start;
+       d->sglen = 1;
+       d->ccr = c->ccr;
+
+       src_icg = dmaengine_get_src_icg(xt, &xt->sgl[0]);
+       dst_icg = dmaengine_get_dst_icg(xt, &xt->sgl[0]);
+       if (src_icg) {
+               d->ccr |= CCR_SRC_AMODE_DBLIDX;
+               d->ei = 1;
+               d->fi = src_icg;
+       } else if (xt->src_inc) {
+               d->ccr |= CCR_SRC_AMODE_POSTINC;
+               d->fi = 0;
+       } else {
+               dev_err(chan->device->dev,
+                       "%s: SRC constant addressing is not supported\n",
+                       __func__);
+               kfree(d);
+               return NULL;
+       }
+
+       if (dst_icg) {
+               d->ccr |= CCR_DST_AMODE_DBLIDX;
+               sg->ei = 1;
+               sg->fi = dst_icg;
+       } else if (xt->dst_inc) {
+               d->ccr |= CCR_DST_AMODE_POSTINC;
+               sg->fi = 0;
+       } else {
+               dev_err(chan->device->dev,
+                       "%s: DST constant addressing is not supported\n",
+                       __func__);
+               kfree(d);
+               return NULL;
+       }
+
+       d->cicr = CICR_DROP_IE | CICR_FRAME_IE;
+
+       d->csdp = data_type;
+
+       if (dma_omap1()) {
+               d->cicr |= CICR_TOUT_IE;
+               d->csdp |= CSDP_DST_PORT_EMIFF | CSDP_SRC_PORT_EMIFF;
+       } else {
+               d->csdp |= CSDP_DST_PACKED | CSDP_SRC_PACKED;
+               d->cicr |= CICR_MISALIGNED_ERR_IE | CICR_TRANS_ERR_IE;
+               d->csdp |= CSDP_DST_BURST_64 | CSDP_SRC_BURST_64;
+       }
+
+       return vchan_tx_prep(&c->vc, &d->vd, flags);
+}
+
 static int omap_dma_slave_config(struct dma_chan *chan, struct dma_slave_config *cfg)
 {
        struct omap_chan *c = to_omap_dma_chan(chan);
@@ -1116,6 +1202,7 @@ static int omap_dma_probe(struct platform_device *pdev)
        dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
        dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);
        dma_cap_set(DMA_MEMCPY, od->ddev.cap_mask);
+       dma_cap_set(DMA_INTERLEAVE, od->ddev.cap_mask);
        od->ddev.device_alloc_chan_resources = omap_dma_alloc_chan_resources;
        od->ddev.device_free_chan_resources = omap_dma_free_chan_resources;
        od->ddev.device_tx_status = omap_dma_tx_status;
@@ -1123,6 +1210,7 @@ static int omap_dma_probe(struct platform_device *pdev)
        od->ddev.device_prep_slave_sg = omap_dma_prep_slave_sg;
        od->ddev.device_prep_dma_cyclic = omap_dma_prep_dma_cyclic;
        od->ddev.device_prep_dma_memcpy = omap_dma_prep_dma_memcpy;
+       od->ddev.device_prep_interleaved_dma = omap_dma_prep_dma_interleaved;
        od->ddev.device_config = omap_dma_slave_config;
        od->ddev.device_pause = omap_dma_pause;
        od->ddev.device_resume = omap_dma_resume;
index 6416ded..82f36e4 100644 (file)
@@ -392,8 +392,7 @@ static int __init hidma_mgmt_init(void)
 #if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
        struct device_node *child;
 
-       for (child = of_find_matching_node(NULL, hidma_mgmt_match); child;
-            child = of_find_matching_node(child, hidma_mgmt_match)) {
+       for_each_matching_node(child, hidma_mgmt_match) {
                /* device tree based firmware here */
                hidma_mgmt_of_populate_channels(child);
                of_node_put(child);
index f777a5b..6d221e5 100644 (file)
@@ -970,12 +970,17 @@ static int zynqmp_dma_chan_probe(struct zynqmp_dma_device *zdev,
        chan->dst_burst_len = ZYNQMP_DMA_AWLEN_RST_VAL;
        chan->src_burst_len = ZYNQMP_DMA_ARLEN_RST_VAL;
        err = of_property_read_u32(node, "xlnx,bus-width", &chan->bus_width);
-       if ((err < 0) && ((chan->bus_width != ZYNQMP_DMA_BUS_WIDTH_64) ||
-                         (chan->bus_width != ZYNQMP_DMA_BUS_WIDTH_128))) {
-               dev_err(zdev->dev, "invalid bus-width value");
+       if (err < 0) {
+               dev_err(&pdev->dev, "missing xlnx,bus-width property\n");
                return err;
        }
 
+       if (chan->bus_width != ZYNQMP_DMA_BUS_WIDTH_64 &&
+           chan->bus_width != ZYNQMP_DMA_BUS_WIDTH_128) {
+               dev_err(zdev->dev, "invalid bus-width value");
+               return -EINVAL;
+       }
+
        chan->is_dmacoherent =  of_property_read_bool(node, "dma-coherent");
        zdev->chan = chan;
        tasklet_init(&chan->tasklet, zynqmp_dma_do_tasklet, (ulong)chan);
@@ -1141,5 +1146,6 @@ static struct platform_driver zynqmp_dma_driver = {
 
 module_platform_driver(zynqmp_dma_driver);
 
+MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Xilinx, Inc.");
 MODULE_DESCRIPTION("Xilinx ZynqMP DMA driver");