omap_hsmmc: avoid useless dto set
[pandora-kernel.git] / drivers / mmc / host / omap_hsmmc.c
index 8a585f6..c0f583a 100644 (file)
@@ -1527,21 +1527,15 @@ static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host,
        return 0;
 }
 
-static void set_data_timeout(struct omap_hsmmc_host *host)
+/* pandora wifi small transfer hack */
+static int check_mmc3_dma_hack(struct omap_hsmmc_host *host,
+                              struct mmc_request *req)
 {
-       uint32_t reg, clkd, dto = 0;
-
-       reg = OMAP_HSMMC_READ(host->base, SYSCTL);
-       clkd = (reg & CLKD_MASK) >> CLKD_SHIFT;
-       if (clkd == 0)
-               clkd = 1;
-
-    /* Use the maximum timeout value allowed in the standard of 14 or 0xE */
-       dto = 14;
-
-       reg &= ~DTO_MASK;
-       reg |= dto << DTO_SHIFT;
-       OMAP_HSMMC_WRITE(host->base, SYSCTL, reg);
+       if (req->data != NULL && req->data->sg_len == 1
+           && req->data->sg->length <= 16)
+               return 0;
+       else
+               return 1;
 }
 
 /*
@@ -1555,18 +1549,11 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req)
 
        if (req->data == NULL) {
                OMAP_HSMMC_WRITE(host->base, BLK, 0);
-               /*
-                * Set an arbitrary 100ms data timeout for commands with
-                * busy signal.
-                */
-               if (req->cmd->flags & MMC_RSP_BUSY)
-                       set_data_timeout(host);
                return 0;
        }
 
        OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
                                        | (req->data->blocks << 16));
-       set_data_timeout(host);
 
        if (host->use_dma) {
                ret = omap_hsmmc_start_dma_transfer(host, req);
@@ -1597,13 +1584,16 @@ static void omap_hsmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq,
                               bool is_first_req)
 {
        struct omap_hsmmc_host *host = mmc_priv(mmc);
+       int use_dma = host->use_dma;
 
        if (mrq->data->host_cookie) {
                mrq->data->host_cookie = 0;
                return ;
        }
 
-       if (host->use_dma)
+       if (host->id == OMAP_MMC3_DEVID)
+               use_dma = check_mmc3_dma_hack(host, mrq);
+       if (use_dma)
                if (omap_hsmmc_pre_dma_transfer(host, mrq->data,
                                                &host->next_data))
                        mrq->data->host_cookie = 0;
@@ -1695,13 +1685,9 @@ static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
        } else if (host->reqs_blocked)
                host->reqs_blocked = 0;
 
-       /* pandora wifi hack.. */
-       if (host->id == OMAP_MMC3_DEVID && req->data != NULL
-           && req->data->sg_len == 1 && req->data->sg->length <= 16) {
-               host->use_dma = 0;
-       } else {
-               host->use_dma = 1;
-       }
+       /* pandora wifi hack... */
+       if (host->id == OMAP_MMC3_DEVID)
+               host->use_dma = check_mmc3_dma_hack(host, req);
 
        WARN_ON(host->mrq != NULL);
        host->mrq = req;