mmc: fix wrong mszs calculation for edmac.
authorlintao <lintao@rock-chips.com>
Tue, 21 Oct 2014 07:14:13 +0000 (15:14 +0800)
committerlintao <lintao@rock-chips.com>
Tue, 21 Oct 2014 07:14:13 +0000 (15:14 +0800)
Internal dmac set mszs from 0 ~ 7, means {1, 4, 8, 16,
32, 64, 128, 256} respectively. But mszs is difference from another
if it's edmac been used indeed.External dmac limit it from 0 ~ 16
, and we select mszs from FIFOTH calculated before to lookup table
in order to find mszs fitable for edmac.

Signed-off-by: lintao <lintao@rock-chips.com>
Tested-and-acked-by: lw <lw@rock-chips.com>
arch/arm/boot/dts/rk312x-sdk.dtsi
drivers/mmc/host/rk_sdmmc.c

index f33a9a11b38294a21fd0d15e0bfba832459688a6..ac7b2b3bc9d728293725feb51a182d5b5d4925db 100755 (executable)
@@ -74,8 +74,8 @@
 };
 
 &emmc {
-       clock-frequency = <37500000>;
-       clock-freq-min-max = <400000 37500000>;
+       clock-frequency = <50000000>;
+       clock-freq-min-max = <400000 50000000>;
        supports-highspeed;
        supports-emmc;
        bootpart-no-access;
index 0f50c70b6a13ed0fd71b7644a4126c6217a47ec8..3a7dc971f8a192e7d31a95d515b911acc05995fd 100755 (executable)
@@ -614,7 +614,9 @@ static void dw_mci_edmac_start_dma(struct dw_mci *host, unsigned int sg_len)
         struct dma_slave_config slave_config;
         struct dma_async_tx_descriptor *desc = NULL;
         struct scatterlist *sgl = host->data->sg;
+        const u32 mszs[] = {1, 4, 8, 16, 32, 64, 128, 256};
         u32 sg_elems = host->data->sg_len;
+        u32 fifoth_val, mburst;
         int ret = 0;
 
         /* Set external dma config: burst size, burst width*/
@@ -624,7 +626,11 @@ static void dw_mci_edmac_start_dma(struct dw_mci *host, unsigned int sg_len)
         slave_config.src_addr_width = slave_config.dst_addr_width;
 
         /* Match FIFO dma burst MSIZE with external dma config*/
-        slave_config.dst_maxburst = ((host->fifoth_val) >> 28) && 0x7;
+        fifoth_val = mci_readl(host, FIFOTH);
+        mburst = mszs[(fifoth_val >> 28) && 0x7];
+
+        /* edmac limit burst to 16 */
+        slave_config.dst_maxburst = (mburst > 16) ? 16 : mburst;
         slave_config.src_maxburst = slave_config.dst_maxburst;
 
         if(host->data->flags & MMC_DATA_WRITE){
@@ -837,6 +843,7 @@ static void dw_mci_adjust_fifoth(struct dw_mci *host, struct mmc_data *data)
 done:
        fifoth_val = SDMMC_SET_FIFOTH(msize, rx_wmark, tx_wmark);
        mci_writel(host, FIFOTH, fifoth_val);
+
 #endif
 }
 
@@ -4274,5 +4281,5 @@ MODULE_DESCRIPTION("Rockchip specific DW Multimedia Card Interface driver");
 MODULE_AUTHOR("NXP Semiconductor VietNam");
 MODULE_AUTHOR("Imagination Technologies Ltd");
 MODULE_AUTHOR("Shawn Lin <lintao@rock-chips.com>");
-MODULE_AUTHOR("Rockchip Electronics£¬Bangwang Xie < xbw@rock-chips.com> ");
-MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Bangwang Xie <xbw@rock-chips.com>");
+MODULE_LICENSE("GPL v2");
\ No newline at end of file