emmc: clear line_dly on calibration
authorNan Li <nan.li@amlogic.com>
Tue, 1 Aug 2017 05:28:57 +0000 (13:28 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 14 Aug 2017 02:50:59 +0000 (19:50 -0700)
PD#148637: clear line_delay on every line calibration,
so any line's line_delay will not interfere with each other.

Change-Id: I784f66ab9df111b886ab0e45fa007f3bb2dc111e
Signed-off-by: Nan Li <nan.li@amlogic.com>
drivers/amlogic/mmc/aml_sd_emmc.c

index 8df5bcf..8d72ef2 100644 (file)
@@ -191,6 +191,9 @@ static int aml_cali_auto(struct mmc_host *mmc, struct cali_data *c_data)
                pdata->c_ctrl.line_x = line_x;
                /* for each delay index! */
                for (dly_tmp = 0; dly_tmp < MAX_DELAY_CNT; dly_tmp++) {
+                       max_cali_count = 0;
+                       max_cali_i = 0;
+                       line_delay = 0;
                        line_delay = dly_tmp << (4 * line_x);
                        writel(line_delay, host->base + SD_EMMC_DELAY);
                        pdata->caling = 1;
@@ -492,7 +495,6 @@ static int aml_sd_emmc_execute_calibration(struct mmc_host *mmc,
        u8 i;
 #endif
 
-       memset(&c_data, 0, sizeof(struct cali_data));
 #ifdef SD_EMMC_CLK_CTRL
        vclk = readl(host->base + SD_EMMC_CLOCK);
        clk_div_tmp = clkc->div;
@@ -509,6 +511,7 @@ static int aml_sd_emmc_execute_calibration(struct mmc_host *mmc,
        pdata->c_ctrl.max_index = (vclk & 0x3f) - 1;
 
 _cali_retry:
+       memset(&c_data, 0, sizeof(struct cali_data));
        c_data.base_index_min = pdata->c_ctrl.max_index + 1;
        c_data.base_index_max = 0;
        pr_info("%s: trying cali %d-th time(s)\n",