Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6
[safe/jmp/linux-2.6] / drivers / mmc / host / tmio_mmc.c
index 10951b7..ee7d0a5 100644 (file)
@@ -10,7 +10,7 @@
  *
  * Driver for the MMC / SD / SDIO cell found in:
  *
- * TC6393XB TC6391XB TC6387XB T7L66XB
+ * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
  *
  * This driver draws mainly on scattered spec sheets, Reverse engineering
  * of the toshiba e800  SD driver and some parts of the 2.4 ASIC3 driver (4 bit
@@ -29,6 +29,7 @@
 #include <linux/irq.h>
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/dmaengine.h>
 #include <linux/mmc/host.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/tmio.h>
@@ -46,7 +47,9 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
                clk |= 0x100;
        }
 
-       sd_config_write8(host, CNF_SD_CLK_MODE, clk >> 22);
+       if (host->set_clk_div)
+               host->set_clk_div(host->pdev, (clk>>22) & 1);
+
        sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & 0x1ff);
 }
 
@@ -129,8 +132,8 @@ tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command *cmd)
 
        host->cmd = cmd;
 
-/* FIXME - this seems to be ok comented out but the spec suggest this bit should
- *         be set when issuing app commands.
+/* FIXME - this seems to be ok commented out but the spec suggest this bit
+ *         should be set when issuing app commands.
  *     if(cmd->flags & MMC_FLAG_ACMD)
  *             c |= APP_CMD;
  */
@@ -153,12 +156,12 @@ tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command *cmd)
        return 0;
 }
 
-/* This chip always returns (at least?) as much data as you ask for.
+/*
+ * This chip always returns (at least?) as much data as you ask for.
  * I'm unsure what happens if you ask for less than a block. This should be
  * looked into to ensure that a funny length read doesnt hose the controller.
- *
  */
-static inline void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
+static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
 {
        struct mmc_data *data = host->data;
        unsigned short *buf;
@@ -178,7 +181,7 @@ static inline void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
                count = data->blksz;
 
        pr_debug("count: %08x offset: %08x flags %08x\n",
-           count, host->sg_off, data->flags);
+                count, host->sg_off, data->flags);
 
        /* Transfer the data */
        if (data->flags & MMC_DATA_READ)
@@ -196,7 +199,7 @@ static inline void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
        return;
 }
 
-static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host)
+static void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 {
        struct mmc_data *data = host->data;
        struct mmc_command *stop;
@@ -204,7 +207,7 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host)
        host->data = NULL;
 
        if (!data) {
-               pr_debug("Spurious data end IRQ\n");
+               dev_warn(&host->pdev->dev, "Spurious data end IRQ\n");
                return;
        }
        stop = data->stop;
@@ -217,7 +220,8 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host)
 
        pr_debug("Completed data request\n");
 
-       /*FIXME - other drivers allow an optional stop command of any given type
+       /*
+        * FIXME: other drivers allow an optional stop command of any given type
         *        which we dont do, as the chip can auto generate them.
         *        Perhaps we can be smarter about when to use auto CMD12 and
         *        only issue the auto request when we know this is the desired
@@ -225,10 +229,17 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host)
         *        upper layers expect. For now, we do what works.
         */
 
-       if (data->flags & MMC_DATA_READ)
-               disable_mmc_irqs(host, TMIO_MASK_READOP);
-       else
-               disable_mmc_irqs(host, TMIO_MASK_WRITEOP);
+       if (data->flags & MMC_DATA_READ) {
+               if (!host->chan_rx)
+                       disable_mmc_irqs(host, TMIO_MASK_READOP);
+               dev_dbg(&host->pdev->dev, "Complete Rx request %p\n",
+                       host->mrq);
+       } else {
+               if (!host->chan_tx)
+                       disable_mmc_irqs(host, TMIO_MASK_WRITEOP);
+               dev_dbg(&host->pdev->dev, "Complete Tx request %p\n",
+                       host->mrq);
+       }
 
        if (stop) {
                if (stop->opcode == 12 && !stop->arg)
@@ -240,7 +251,35 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host)
        tmio_mmc_finish_request(host);
 }
 
-static inline void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
+static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
+{
+       struct mmc_data *data = host->data;
+
+       if (!data)
+               return;
+
+       if (host->chan_tx && (data->flags & MMC_DATA_WRITE)) {
+               /*
+                * Has all data been written out yet? Testing on SuperH showed,
+                * that in most cases the first interrupt comes already with the
+                * BUSY status bit clear, but on some operations, like mount or
+                * in the beginning of a write / sync / umount, there is one
+                * DATAEND interrupt with the BUSY bit set, in this cases
+                * waiting for one more interrupt fixes the problem.
+                */
+               if (!(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_CMD_BUSY)) {
+                       disable_mmc_irqs(host, TMIO_STAT_DATAEND);
+                       tasklet_schedule(&host->dma_complete);
+               }
+       } else if (host->chan_rx && (data->flags & MMC_DATA_READ)) {
+               disable_mmc_irqs(host, TMIO_STAT_DATAEND);
+               tasklet_schedule(&host->dma_complete);
+       } else {
+               tmio_mmc_do_data_irq(host);
+       }
+}
+
+static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
        unsigned int stat)
 {
        struct mmc_command *cmd = host->cmd;
@@ -280,10 +319,16 @@ static inline void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
         * If theres no data or we encountered an error, finish now.
         */
        if (host->data && !cmd->error) {
-               if (host->data->flags & MMC_DATA_READ)
-                       enable_mmc_irqs(host, TMIO_MASK_READOP);
-               else
-                       enable_mmc_irqs(host, TMIO_MASK_WRITEOP);
+               if (host->data->flags & MMC_DATA_READ) {
+                       if (!host->chan_rx)
+                               enable_mmc_irqs(host, TMIO_MASK_READOP);
+               } else {
+                       struct dma_chan *chan = host->chan_tx;
+                       if (!chan)
+                               enable_mmc_irqs(host, TMIO_MASK_WRITEOP);
+                       else
+                               tasklet_schedule(&host->dma_issue);
+               }
        } else {
                tmio_mmc_finish_request(host);
        }
@@ -291,7 +336,6 @@ static inline void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
        return;
 }
 
-
 static irqreturn_t tmio_mmc_irq(int irq, void *devid)
 {
        struct tmio_mmc_host *host = devid;
@@ -309,7 +353,7 @@ static irqreturn_t tmio_mmc_irq(int irq, void *devid)
        if (!ireg) {
                disable_mmc_irqs(host, status & ~irq_mask);
 
-               pr_debug("tmio_mmc: Spurious irq, disabling! "
+               pr_warning("tmio_mmc: Spurious irq, disabling! "
                        "0x%08x 0x%08x 0x%08x\n", status, irq_mask, ireg);
                pr_debug_status(status);
 
@@ -321,7 +365,7 @@ static irqreturn_t tmio_mmc_irq(int irq, void *devid)
                if (ireg & (TMIO_STAT_CARD_INSERT | TMIO_STAT_CARD_REMOVE)) {
                        ack_mmc_irqs(host, TMIO_STAT_CARD_INSERT |
                                TMIO_STAT_CARD_REMOVE);
-                       mmc_detect_change(host->mmc, 0);
+                       mmc_detect_change(host->mmc, msecs_to_jiffies(100));
                }
 
                /* CRC and other errors */
@@ -361,16 +405,265 @@ out:
        return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_TMIO_MMC_DMA
+static void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
+{
+#if defined(CONFIG_SUPERH) || defined(CONFIG_ARCH_SHMOBILE)
+       /* Switch DMA mode on or off - SuperH specific? */
+       sd_ctrl_write16(host, 0xd8, enable ? 2 : 0);
+#endif
+}
+
+static void tmio_dma_complete(void *arg)
+{
+       struct tmio_mmc_host *host = arg;
+
+       dev_dbg(&host->pdev->dev, "Command completed\n");
+
+       if (!host->data)
+               dev_warn(&host->pdev->dev, "NULL data in DMA completion!\n");
+       else
+               enable_mmc_irqs(host, TMIO_STAT_DATAEND);
+}
+
+static int tmio_mmc_start_dma_rx(struct tmio_mmc_host *host)
+{
+       struct scatterlist *sg = host->sg_ptr;
+       struct dma_async_tx_descriptor *desc = NULL;
+       struct dma_chan *chan = host->chan_rx;
+       int ret;
+
+       ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, DMA_FROM_DEVICE);
+       if (ret > 0) {
+               host->dma_sglen = ret;
+               desc = chan->device->device_prep_slave_sg(chan, sg, ret,
+                       DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+       }
+
+       if (desc) {
+               host->desc = desc;
+               desc->callback = tmio_dma_complete;
+               desc->callback_param = host;
+               host->cookie = desc->tx_submit(desc);
+               if (host->cookie < 0) {
+                       host->desc = NULL;
+                       ret = host->cookie;
+               } else {
+                       chan->device->device_issue_pending(chan);
+               }
+       }
+       dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n",
+               __func__, host->sg_len, ret, host->cookie, host->mrq);
+
+       if (!host->desc) {
+               /* DMA failed, fall back to PIO */
+               if (ret >= 0)
+                       ret = -EIO;
+               host->chan_rx = NULL;
+               dma_release_channel(chan);
+               /* Free the Tx channel too */
+               chan = host->chan_tx;
+               if (chan) {
+                       host->chan_tx = NULL;
+                       dma_release_channel(chan);
+               }
+               dev_warn(&host->pdev->dev,
+                        "DMA failed: %d, falling back to PIO\n", ret);
+               tmio_mmc_enable_dma(host, false);
+               reset(host);
+               /* Fail this request, let above layers recover */
+               host->mrq->cmd->error = ret;
+               tmio_mmc_finish_request(host);
+       }
+
+       dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__,
+               desc, host->cookie, host->sg_len);
+
+       return ret > 0 ? 0 : ret;
+}
+
+static int tmio_mmc_start_dma_tx(struct tmio_mmc_host *host)
+{
+       struct scatterlist *sg = host->sg_ptr;
+       struct dma_async_tx_descriptor *desc = NULL;
+       struct dma_chan *chan = host->chan_tx;
+       int ret;
+
+       ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, DMA_TO_DEVICE);
+       if (ret > 0) {
+               host->dma_sglen = ret;
+               desc = chan->device->device_prep_slave_sg(chan, sg, ret,
+                       DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+       }
+
+       if (desc) {
+               host->desc = desc;
+               desc->callback = tmio_dma_complete;
+               desc->callback_param = host;
+               host->cookie = desc->tx_submit(desc);
+               if (host->cookie < 0) {
+                       host->desc = NULL;
+                       ret = host->cookie;
+               }
+       }
+       dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n",
+               __func__, host->sg_len, ret, host->cookie, host->mrq);
+
+       if (!host->desc) {
+               /* DMA failed, fall back to PIO */
+               if (ret >= 0)
+                       ret = -EIO;
+               host->chan_tx = NULL;
+               dma_release_channel(chan);
+               /* Free the Rx channel too */
+               chan = host->chan_rx;
+               if (chan) {
+                       host->chan_rx = NULL;
+                       dma_release_channel(chan);
+               }
+               dev_warn(&host->pdev->dev,
+                        "DMA failed: %d, falling back to PIO\n", ret);
+               tmio_mmc_enable_dma(host, false);
+               reset(host);
+               /* Fail this request, let above layers recover */
+               host->mrq->cmd->error = ret;
+               tmio_mmc_finish_request(host);
+       }
+
+       dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d\n", __func__,
+               desc, host->cookie);
+
+       return ret > 0 ? 0 : ret;
+}
+
+static int tmio_mmc_start_dma(struct tmio_mmc_host *host,
+                              struct mmc_data *data)
+{
+       if (data->flags & MMC_DATA_READ) {
+               if (host->chan_rx)
+                       return tmio_mmc_start_dma_rx(host);
+       } else {
+               if (host->chan_tx)
+                       return tmio_mmc_start_dma_tx(host);
+       }
+
+       return 0;
+}
+
+static void tmio_issue_tasklet_fn(unsigned long priv)
+{
+       struct tmio_mmc_host *host = (struct tmio_mmc_host *)priv;
+       struct dma_chan *chan = host->chan_tx;
+
+       chan->device->device_issue_pending(chan);
+}
+
+static void tmio_tasklet_fn(unsigned long arg)
+{
+       struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg;
+
+       if (host->data->flags & MMC_DATA_READ)
+               dma_unmap_sg(&host->pdev->dev, host->sg_ptr, host->dma_sglen,
+                            DMA_FROM_DEVICE);
+       else
+               dma_unmap_sg(&host->pdev->dev, host->sg_ptr, host->dma_sglen,
+                            DMA_TO_DEVICE);
+
+       tmio_mmc_do_data_irq(host);
+}
+
+/* It might be necessary to make filter MFD specific */
+static bool tmio_mmc_filter(struct dma_chan *chan, void *arg)
+{
+       dev_dbg(chan->device->dev, "%s: slave data %p\n", __func__, arg);
+       chan->private = arg;
+       return true;
+}
+
+static void tmio_mmc_request_dma(struct tmio_mmc_host *host,
+                                struct tmio_mmc_data *pdata)
+{
+       host->cookie = -EINVAL;
+       host->desc = NULL;
+
+       /* We can only either use DMA for both Tx and Rx or not use it at all */
+       if (pdata->dma) {
+               dma_cap_mask_t mask;
+
+               dma_cap_zero(mask);
+               dma_cap_set(DMA_SLAVE, mask);
+
+               host->chan_tx = dma_request_channel(mask, tmio_mmc_filter,
+                                                   pdata->dma->chan_priv_tx);
+               dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__,
+                       host->chan_tx);
+
+               if (!host->chan_tx)
+                       return;
+
+               host->chan_rx = dma_request_channel(mask, tmio_mmc_filter,
+                                                   pdata->dma->chan_priv_rx);
+               dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__,
+                       host->chan_rx);
+
+               if (!host->chan_rx) {
+                       dma_release_channel(host->chan_tx);
+                       host->chan_tx = NULL;
+                       return;
+               }
+
+               tasklet_init(&host->dma_complete, tmio_tasklet_fn, (unsigned long)host);
+               tasklet_init(&host->dma_issue, tmio_issue_tasklet_fn, (unsigned long)host);
+
+               tmio_mmc_enable_dma(host, true);
+       }
+}
+
+static void tmio_mmc_release_dma(struct tmio_mmc_host *host)
+{
+       if (host->chan_tx) {
+               struct dma_chan *chan = host->chan_tx;
+               host->chan_tx = NULL;
+               dma_release_channel(chan);
+       }
+       if (host->chan_rx) {
+               struct dma_chan *chan = host->chan_rx;
+               host->chan_rx = NULL;
+               dma_release_channel(chan);
+       }
+
+       host->cookie = -EINVAL;
+       host->desc = NULL;
+}
+#else
+static int tmio_mmc_start_dma(struct tmio_mmc_host *host,
+                              struct mmc_data *data)
+{
+       return 0;
+}
+
+static void tmio_mmc_request_dma(struct tmio_mmc_host *host,
+                                struct tmio_mmc_data *pdata)
+{
+       host->chan_tx = NULL;
+       host->chan_rx = NULL;
+}
+
+static void tmio_mmc_release_dma(struct tmio_mmc_host *host)
+{
+}
+#endif
+
 static int tmio_mmc_start_data(struct tmio_mmc_host *host,
        struct mmc_data *data)
 {
        pr_debug("setup data transfer: blocksize %08x  nr_blocks %d\n",
-           data->blksz, data->blocks);
+                data->blksz, data->blocks);
 
        /* Hardware cannot perform 1 and 2 byte requests in 4 bit mode */
        if (data->blksz < 4 && host->mmc->ios.bus_width == MMC_BUS_WIDTH_4) {
-               printk(KERN_ERR "%s: %d byte block unsupported in 4 bit mode\n",
-                       mmc_hostname(host->mmc), data->blksz);
+               pr_err("%s: %d byte block unsupported in 4 bit mode\n",
+                      mmc_hostname(host->mmc), data->blksz);
                return -EINVAL;
        }
 
@@ -381,7 +674,7 @@ static int tmio_mmc_start_data(struct tmio_mmc_host *host,
        sd_ctrl_write16(host, CTL_SD_XFER_LEN, data->blksz);
        sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);
 
-       return 0;
+       return tmio_mmc_start_dma(host, data);
 }
 
 /* Process requests from the MMC layer */
@@ -402,7 +695,6 @@ static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
        }
 
        ret = tmio_mmc_start_command(host, mrq->cmd);
-
        if (!ret)
                return;
 
@@ -427,12 +719,13 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        /* Power sequence - OFF -> ON -> UP */
        switch (ios->power_mode) {
        case MMC_POWER_OFF: /* power down SD bus */
-               sd_config_write8(host, CNF_PWR_CTL_2, 0x00);
+               if (host->set_pwr)
+                       host->set_pwr(host->pdev, 0);
                tmio_mmc_clk_stop(host);
                break;
        case MMC_POWER_ON: /* power up SD bus */
-
-               sd_config_write8(host, CNF_PWR_CTL_2, 0x02);
+               if (host->set_pwr)
+                       host->set_pwr(host->pdev, 1);
                break;
        case MMC_POWER_UP: /* start bus clock */
                tmio_mmc_clk_start(host);
@@ -455,11 +748,14 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 static int tmio_mmc_get_ro(struct mmc_host *mmc)
 {
        struct tmio_mmc_host *host = mmc_priv(mmc);
+       struct mfd_cell *cell = host->pdev->dev.platform_data;
+       struct tmio_mmc_data *pdata = cell->driver_data;
 
-       return (sd_ctrl_read16(host, CTL_STATUS) & TMIO_STAT_WRPROTECT) ? 0 : 1;
+       return ((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) ||
+               (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0 : 1;
 }
 
-static struct mmc_host_ops tmio_mmc_ops = {
+static const struct mmc_host_ops tmio_mmc_ops = {
        .request        = tmio_mmc_request,
        .set_ios        = tmio_mmc_set_ios,
        .get_ro         = tmio_mmc_get_ro,
@@ -472,7 +768,7 @@ static int tmio_mmc_suspend(struct platform_device *dev, pm_message_t state)
        struct mmc_host *mmc = platform_get_drvdata(dev);
        int ret;
 
-       ret = mmc_suspend_host(mmc, state);
+       ret = mmc_suspend_host(mmc);
 
        /* Tell MFD core it can disable us now.*/
        if (!ret && cell->disable)
@@ -485,21 +781,15 @@ static int tmio_mmc_resume(struct platform_device *dev)
 {
        struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data;
        struct mmc_host *mmc = platform_get_drvdata(dev);
-       struct tmio_mmc_host *host = mmc_priv(mmc);
        int ret = 0;
 
        /* Tell the MFD core we are ready to be enabled */
-       if (cell->enable) {
-               ret = cell->enable(dev);
+       if (cell->resume) {
+               ret = cell->resume(dev);
                if (ret)
                        goto out;
        }
 
-       /* Enable the MMC/SD Control registers */
-       sd_config_write16(host, CNF_CMD, SDCREN);
-       sd_config_write32(host, CNF_CTL_BASE,
-               (dev->resource[0].start >> host->bus_shift) & 0xfffe);
-
        mmc_resume_host(mmc);
 
 out:
@@ -514,17 +804,17 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
 {
        struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data;
        struct tmio_mmc_data *pdata;
-       struct resource *res_ctl, *res_cnf;
+       struct resource *res_ctl;
        struct tmio_mmc_host *host;
        struct mmc_host *mmc;
        int ret = -EINVAL;
+       u32 irq_mask = TMIO_MASK_CMD;
 
-       if (dev->num_resources != 3)
+       if (dev->num_resources != 2)
                goto out;
 
        res_ctl = platform_get_resource(dev, IORESOURCE_MEM, 0);
-       res_cnf = platform_get_resource(dev, IORESOURCE_MEM, 1);
-       if (!res_ctl || !res_cnf)
+       if (!res_ctl)
                goto out;
 
        pdata = cell->driver_data;
@@ -539,8 +829,12 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
 
        host = mmc_priv(mmc);
        host->mmc = mmc;
+       host->pdev = dev;
        platform_set_drvdata(dev, mmc);
 
+       host->set_pwr = pdata->set_pwr;
+       host->set_clk_div = pdata->set_clk_div;
+
        /* SD control register space size is 0x200, 0x400 for bus_shift=1 */
        host->bus_shift = resource_size(res_ctl) >> 10;
 
@@ -548,37 +842,23 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
        if (!host->ctl)
                goto host_free;
 
-       host->cnf = ioremap(res_cnf->start, resource_size(res_cnf));
-       if (!host->cnf)
-               goto unmap_ctl;
-
        mmc->ops = &tmio_mmc_ops;
        mmc->caps = MMC_CAP_4_BIT_DATA;
+       mmc->caps |= pdata->capabilities;
        mmc->f_max = pdata->hclk;
        mmc->f_min = mmc->f_max / 512;
-       mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+       if (pdata->ocr_mask)
+               mmc->ocr_avail = pdata->ocr_mask;
+       else
+               mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
 
        /* Tell the MFD core we are ready to be enabled */
        if (cell->enable) {
                ret = cell->enable(dev);
                if (ret)
-                       goto unmap_cnf;
+                       goto unmap_ctl;
        }
 
-       /* Enable the MMC/SD Control registers */
-       sd_config_write16(host, CNF_CMD, SDCREN);
-       sd_config_write32(host, CNF_CTL_BASE,
-               (dev->resource[0].start >> host->bus_shift) & 0xfffe);
-
-       /* Disable SD power during suspend */
-       sd_config_write8(host, CNF_PWR_CTL_3, 0x01);
-
-       /* The below is required but why? FIXME */
-       sd_config_write8(host, CNF_STOP_CLK_CTL, 0x1f);
-
-       /* Power down SD bus*/
-       sd_config_write8(host, CNF_PWR_CTL_2, 0x00);
-
        tmio_mmc_clk_stop(host);
        reset(host);
 
@@ -586,27 +866,35 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
        if (ret >= 0)
                host->irq = ret;
        else
-               goto unmap_cnf;
+               goto cell_disable;
 
        disable_mmc_irqs(host, TMIO_MASK_ALL);
 
        ret = request_irq(host->irq, tmio_mmc_irq, IRQF_DISABLED |
-               IRQF_TRIGGER_FALLING, "tmio-mmc", host);
+               IRQF_TRIGGER_FALLING, dev_name(&dev->dev), host);
        if (ret)
-               goto unmap_cnf;
+               goto cell_disable;
+
+       /* See if we also get DMA */
+       tmio_mmc_request_dma(host, pdata);
 
        mmc_add_host(mmc);
 
-       printk(KERN_INFO "%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc),
-              (unsigned long)host->ctl, host->irq);
+       pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc),
+               (unsigned long)host->ctl, host->irq);
 
        /* Unmask the IRQs we want to know about */
-       enable_mmc_irqs(host, TMIO_MASK_IRQ);
+       if (!host->chan_rx)
+               irq_mask |= TMIO_MASK_READOP;
+       if (!host->chan_tx)
+               irq_mask |= TMIO_MASK_WRITEOP;
+       enable_mmc_irqs(host, irq_mask);
 
        return 0;
 
-unmap_cnf:
-       iounmap(host->cnf);
+cell_disable:
+       if (cell->disable)
+               cell->disable(dev);
 unmap_ctl:
        iounmap(host->ctl);
 host_free:
@@ -617,6 +905,7 @@ out:
 
 static int __devexit tmio_mmc_remove(struct platform_device *dev)
 {
+       struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data;
        struct mmc_host *mmc = platform_get_drvdata(dev);
 
        platform_set_drvdata(dev, NULL);
@@ -624,9 +913,11 @@ static int __devexit tmio_mmc_remove(struct platform_device *dev)
        if (mmc) {
                struct tmio_mmc_host *host = mmc_priv(mmc);
                mmc_remove_host(mmc);
+               tmio_mmc_release_dma(host);
                free_irq(host->irq, host);
+               if (cell->disable)
+                       cell->disable(dev);
                iounmap(host->ctl);
-               iounmap(host->cnf);
                mmc_free_host(mmc);
        }