[PATCH] TIFM should depend on PCI - TIFM_CORE leads to use of pci primitives
[pandora-kernel.git] / drivers / mmc / mmci.c
index 1886562..5941dd9 100644 (file)
@@ -42,6 +42,8 @@ mmci_request_end(struct mmci_host *host, struct mmc_request *mrq)
 {
        writel(0, host->base + MMCICOMMAND);
 
+       BUG_ON(host->data);
+
        host->mrq = NULL;
        host->cmd = NULL;
 
@@ -69,12 +71,13 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
        unsigned int datactrl, timeout, irqmask;
        unsigned long long clks;
        void __iomem *base;
+       int blksz_bits;
 
        DBG(host, "blksz %04x blks %04x flags %08x\n",
-           1 << data->blksz_bits, data->blocks, data->flags);
+           data->blksz, data->blocks, data->flags);
 
        host->data = data;
-       host->size = data->blocks << data->blksz_bits;
+       host->size = data->blksz;
        host->data_xfered = 0;
 
        mmci_init_sg(host, data);
@@ -88,7 +91,10 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
        writel(timeout, base + MMCIDATATIMER);
        writel(host->size, base + MMCIDATALENGTH);
 
-       datactrl = MCI_DPSM_ENABLE | data->blksz_bits << 4;
+       blksz_bits = ffs(data->blksz) - 1;
+       BUG_ON(1 << blksz_bits != data->blksz);
+
+       datactrl = MCI_DPSM_ENABLE | blksz_bits << 4;
        if (data->flags & MMC_DATA_READ) {
                datactrl |= MCI_DPSM_DIRECTION;
                irqmask = MCI_RXFIFOHALFFULLMASK;
@@ -145,7 +151,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
              unsigned int status)
 {
        if (status & MCI_DATABLOCKEND) {
-               host->data_xfered += 1 << data->blksz_bits;
+               host->data_xfered += data->blksz;
        }
        if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
                if (status & MCI_DATACRCFAIL)
@@ -194,6 +200,8 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
        }
 
        if (!cmd->data || cmd->error != MMC_ERR_NONE) {
+               if (host->data)
+                       mmci_stop_data(host);
                mmci_request_end(host, cmd->mrq);
        } else if (!(cmd->data->flags & MMC_DATA_READ)) {
                mmci_start_data(host, cmd->data);
@@ -257,7 +265,7 @@ static int mmci_pio_write(struct mmci_host *host, char *buffer, unsigned int rem
 /*
  * PIO data transfer IRQ handler.
  */
-static irqreturn_t mmci_pio_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
 {
        struct mmci_host *host = dev_id;
        void __iomem *base = host->base;
@@ -343,7 +351,7 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id, struct pt_regs *regs)
 /*
  * Handle completion of command and data transfers.
  */
-static irqreturn_t mmci_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t mmci_irq(int irq, void *dev_id)
 {
        struct mmci_host *host = dev_id;
        u32 status;
@@ -439,7 +447,7 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        }
 }
 
-static struct mmc_host_ops mmci_ops = {
+static const struct mmc_host_ops mmci_ops = {
        .request        = mmci_request,
        .set_ios        = mmci_set_ios,
 };
@@ -505,6 +513,7 @@ static int mmci_probe(struct amba_device *dev, void *id)
        mmc->f_min = (host->mclk + 511) / 512;
        mmc->f_max = min(host->mclk, fmax);
        mmc->ocr_avail = plat->ocr_mask;
+       mmc->caps = MMC_CAP_MULTIWRITE;
 
        /*
         * We can do SGIO
@@ -515,15 +524,24 @@ static int mmci_probe(struct amba_device *dev, void *id)
        /*
         * Since we only have a 16-bit data length register, we must
         * ensure that we don't exceed 2^16-1 bytes in a single request.
-        * Choose 64 (512-byte) sectors as the limit.
         */
-       mmc->max_sectors = 64;
+       mmc->max_req_size = 65535;
 
        /*
         * Set the maximum segment size.  Since we aren't doing DMA
         * (yet) we are only limited by the data length register.
         */
-       mmc->max_seg_size = mmc->max_sectors << 9;
+       mmc->max_seg_size = mmc->max_req_size;
+
+       /*
+        * Block size can be up to 2048 bytes, but must be a power of two.
+        */
+       mmc->max_blk_size = 2048;
+
+       /*
+        * No limit on the number of blocks transferred.
+        */
+       mmc->max_blk_count = mmc->max_req_size;
 
        spin_lock_init(&host->lock);