dmaengine: axi-dmac: Sanity check memory mapped interface support
[linux-2.6-block.git] / drivers / dma / dma-axi-dmac.c
index 8e64b81c2d3c7a78860ed988c0d3e919f1e746d6..0984ae6eb155477b634734312ec1f0832886731a 100644 (file)
@@ -637,7 +637,7 @@ static int axi_dmac_parse_chan_dt(struct device_node *of_chan,
        return 0;
 }
 
-static void axi_dmac_detect_caps(struct axi_dmac *dmac)
+static int axi_dmac_detect_caps(struct axi_dmac *dmac)
 {
        struct axi_dmac_chan *chan = &dmac->chan;
 
@@ -653,6 +653,24 @@ static void axi_dmac_detect_caps(struct axi_dmac *dmac)
        chan->max_length = axi_dmac_read(dmac, AXI_DMAC_REG_X_LENGTH);
        if (chan->max_length != UINT_MAX)
                chan->max_length++;
+
+       axi_dmac_write(dmac, AXI_DMAC_REG_DEST_ADDRESS, 0xffffffff);
+       if (axi_dmac_read(dmac, AXI_DMAC_REG_DEST_ADDRESS) == 0 &&
+           chan->dest_type == AXI_DMAC_BUS_TYPE_AXI_MM) {
+               dev_err(dmac->dma_dev.dev,
+                       "Destination memory-mapped interface not supported.");
+               return -ENODEV;
+       }
+
+       axi_dmac_write(dmac, AXI_DMAC_REG_SRC_ADDRESS, 0xffffffff);
+       if (axi_dmac_read(dmac, AXI_DMAC_REG_SRC_ADDRESS) == 0 &&
+           chan->src_type == AXI_DMAC_BUS_TYPE_AXI_MM) {
+               dev_err(dmac->dma_dev.dev,
+                       "Source memory-mapped interface not supported.");
+               return -ENODEV;
+       }
+
+       return 0;
 }
 
 static int axi_dmac_probe(struct platform_device *pdev)
@@ -728,7 +746,9 @@ static int axi_dmac_probe(struct platform_device *pdev)
        if (ret < 0)
                return ret;
 
-       axi_dmac_detect_caps(dmac);
+       ret = axi_dmac_detect_caps(dmac);
+       if (ret)
+               goto err_clk_disable;
 
        axi_dmac_write(dmac, AXI_DMAC_REG_IRQ_MASK, 0x00);