Pass the EDMA CC instance being used throgh MMC platform data. Also pass the
EDMA channel controller instance number as argument to all the EDMA APIs in
MMC driver.

Signed-off-by: Sudhakar Rajashekhara <[email protected]>
---
 arch/arm/mach-davinci/include/mach/mmc.h |    3 ++
 drivers/mmc/host/davinci_mmc.c           |   45 ++++++++++++++++-------------
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-davinci/include/mach/mmc.h 
b/arch/arm/mach-davinci/include/mach/mmc.h
index 5a85e24..b82dc41 100644
--- a/arch/arm/mach-davinci/include/mach/mmc.h
+++ b/arch/arm/mach-davinci/include/mach/mmc.h
@@ -22,6 +22,9 @@ struct davinci_mmc_config {
 
        /* Version of the MMC/SD controller */
        u8      version;
+
+       /* Instance of EDMA Channel Controller this MMC is on */
+       u8      cc_inst;
 };
 void davinci_setup_mmc(int module, struct davinci_mmc_config *config);
 
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index 9b23802..c69ec1e 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -198,6 +198,9 @@ struct mmc_davinci_host {
 
        /* Version of the MMC/SD controller */
        u8 version;
+
+       /* Instance of EDMA Channel Controller this MMC is on */
+       u8 cc_inst;
 };
 
 
@@ -381,8 +384,8 @@ static void davinci_abort_dma(struct mmc_davinci_host *host)
        else
                sync_dev = host->txdma;
 
-       edma_stop(sync_dev);
-       edma_clean_channel(sync_dev);
+       edma_stop(host->cc_inst, sync_dev);
+       edma_clean_channel(host->cc_inst, sync_dev);
 }
 
 static void
@@ -455,15 +458,16 @@ static void __init mmc_davinci_dma_setup(struct 
mmc_davinci_host *host,
         * are not 256-bit (32-byte) aligned.  So we use INCR, and the W8BIT
         * parameter is ignored.
         */
-       edma_set_src(sync_dev, src_port, INCR, W8BIT);
-       edma_set_dest(sync_dev, dst_port, INCR, W8BIT);
+       edma_set_src(host->cc_inst, sync_dev, src_port, INCR, W8BIT);
+       edma_set_dest(host->cc_inst, sync_dev, dst_port, INCR, W8BIT);
 
-       edma_set_src_index(sync_dev, src_bidx, src_cidx);
-       edma_set_dest_index(sync_dev, dst_bidx, dst_cidx);
+       edma_set_src_index(host->cc_inst, sync_dev, src_bidx, src_cidx);
+       edma_set_dest_index(host->cc_inst, sync_dev, dst_bidx, dst_cidx);
 
-       edma_set_transfer_params(sync_dev, acnt, bcnt, ccnt, 8, ABSYNC);
+       edma_set_transfer_params(host->cc_inst, sync_dev, acnt, bcnt, ccnt, 8,
+                               ABSYNC);
 
-       edma_read_slot(sync_dev, template);
+       edma_read_slot(host->cc_inst, sync_dev, template);
 
        /* don't bother with irqs or chaining */
        template->opt |= sync_dev << 12;
@@ -513,13 +517,13 @@ static void mmc_davinci_send_dma_request(struct 
mmc_davinci_host *host,
                        template->dst = buf;
                template->ccnt = count >> shift;
 
-               edma_write_slot(slot, template);
+               edma_write_slot(host->cc_inst, slot, template);
        }
 
        if (host->version == MMC_CTLR_VERSION_2)
-               edma_clear_event(channel);
+               edma_clear_event(host->cc_inst, channel);
 
-       edma_start(channel);
+       edma_start(host->cc_inst, channel);
 }
 
 static int mmc_davinci_start_dma_transfer(struct mmc_davinci_host *host,
@@ -560,10 +564,10 @@ davinci_release_dma_channels(struct mmc_davinci_host 
*host)
                return;
 
        for (i = 0; i < host->n_link; i++)
-               edma_free_slot(host->links[i]);
+               edma_free_slot(host->cc_inst, host->links[i]);
 
-       edma_free_channel(host->txdma);
-       edma_free_channel(host->rxdma);
+       edma_free_channel(host->cc_inst, host->txdma);
+       edma_free_channel(host->cc_inst, host->rxdma);
 }
 
 static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
@@ -571,8 +575,8 @@ static int __init davinci_acquire_dma_channels(struct 
mmc_davinci_host *host)
        int r, i;
 
        /* Acquire master DMA write channel */
-       r = edma_alloc_channel(host->txdma, mmc_davinci_dma_cb, host,
-                       EVENTQ_DEFAULT);
+       r = edma_alloc_channel(host->cc_inst, host->txdma, mmc_davinci_dma_cb,
+                       host, EVENTQ_DEFAULT);
        if (r < 0) {
                dev_warn(mmc_dev(host->mmc), "alloc %s channel err %d\n",
                                "tx", r);
@@ -581,8 +585,8 @@ static int __init davinci_acquire_dma_channels(struct 
mmc_davinci_host *host)
        mmc_davinci_dma_setup(host, true, &host->tx_template);
 
        /* Acquire master DMA read channel */
-       r = edma_alloc_channel(host->rxdma, mmc_davinci_dma_cb, host,
-                       EVENTQ_DEFAULT);
+       r = edma_alloc_channel(host->cc_inst, host->rxdma, mmc_davinci_dma_cb,
+                       host, EVENTQ_DEFAULT);
        if (r < 0) {
                dev_warn(mmc_dev(host->mmc), "alloc %s channel err %d\n",
                                "rx", r);
@@ -594,7 +598,7 @@ static int __init davinci_acquire_dma_channels(struct 
mmc_davinci_host *host)
         * channel as needed to handle a scatterlist.
         */
        for (i = 0; i < ARRAY_SIZE(host->links); i++) {
-               r = edma_alloc_slot(EDMA_SLOT_ANY);
+               r = edma_alloc_slot(host->cc_inst, EDMA_SLOT_ANY);
                if (r < 0) {
                        dev_dbg(mmc_dev(host->mmc), "dma PaRAM alloc --> %d\n",
                                r);
@@ -607,7 +611,7 @@ static int __init davinci_acquire_dma_channels(struct 
mmc_davinci_host *host)
        return 0;
 
 free_master_write:
-       edma_free_channel(host->txdma);
+       edma_free_channel(host->cc_inst, host->txdma);
 
        return r;
 }
@@ -1117,6 +1121,7 @@ static int __init davinci_mmcsd_probe(struct 
platform_device *pdev)
 
        host->use_dma = use_dma;
        host->irq = irq;
+       host->cc_inst = pdata->cc_inst;
 
        if (host->use_dma && davinci_acquire_dma_channels(host) != 0)
                host->use_dma = 0;
-- 
1.5.6

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to