sdio: optimize mmc tuning operation [1/1]
authorNan Li <nan.li@amlogic.com>
Mon, 9 Sep 2019 10:09:08 +0000 (18:09 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 16 Sep 2019 01:37:16 +0000 (18:37 -0700)
PD#SWPL-13914

Problem:
G12A TDMA affects the tuning, make tuning process
+/- dly is useless.

Solution:
add pdata save val operation.

Verify:
G12A_u212

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

index 67be738..16b1335 100644 (file)
@@ -1558,10 +1558,11 @@ static void pr_adj_info(char *name,
                                ((x >> i) & 0x1) ? 1 : 0);
 }
 
-static unsigned long _test_fixed_adj(struct amlsd_host *host,
+static unsigned long _test_fixed_adj(struct amlsd_platform *pdata,
                struct aml_tuning_data *tuning_data, u32 opcode,
                u32 adj, u32 div)
 {
+       struct amlsd_host *host = pdata->host;
        int i = 0;
        u32 nmatch = 0;
        u32 adjust = readl(host->base + SD_EMMC_ADJUST_V3);
@@ -1577,6 +1578,7 @@ static unsigned long _test_fixed_adj(struct amlsd_host *host,
                gadjust->adj_enable = 1;
                gadjust->cali_enable = 0;
                gadjust->cali_rise = 0;
+               pdata->adj = adjust;
                writel(adjust, host->base + SD_EMMC_ADJUST_V3);
                nmatch = aml_sd_emmc_tuning_transfer(host->mmc, opcode,
                                blk_pattern, host->blk_test, blksz);
@@ -1622,8 +1624,12 @@ static unsigned long _swap_fixed_adj_win(unsigned long map,
 }
 
 static void set_fixed_adj_line_delay(u32 step,
-               struct amlsd_host *host)
+               struct amlsd_platform *pdata)
 {
+       struct amlsd_host *host = pdata->host;
+
+       pdata->dly1 = AML_MOVE_DELAY1(step);
+       pdata->dly2 = AML_MOVE_DELAY2(step);
        writel(AML_MOVE_DELAY1(step), host->base + SD_EMMC_DELAY1_V3);
        writel(AML_MOVE_DELAY2(step), host->base + SD_EMMC_DELAY2_V3);
        pr_info("step:%u, delay1:0x%x, delay2:0x%x\n",
@@ -1635,7 +1641,7 @@ static void set_fixed_adj_line_delay(u32 step,
  *     2. re-range fixed adj point
  *     3. retry
  */
-static u32 _find_fixed_adj_valid_win(struct amlsd_host *host,
+static u32 _find_fixed_adj_valid_win(struct amlsd_platform *pdata,
                struct aml_tuning_data *tuning_data, u32 opcode,
                unsigned long *fixed_adj_map, u32 div)
 {
@@ -1652,8 +1658,8 @@ static u32 _find_fixed_adj_valid_win(struct amlsd_host *host,
        for (; step <= 63;) {
                pr_info("[%s]retry test fixed adj...\n", __func__);
                step += AML_FIXED_ADJ_STEP;
-               set_fixed_adj_line_delay(step, host);
-               *cur_map = _test_fixed_adj(host, tuning_data, opcode, 0, div);
+               set_fixed_adj_line_delay(step, pdata);
+               *cur_map = _test_fixed_adj(pdata, tuning_data, opcode, 0, div);
                /*pr_adj_info("cur_map", *cur_map, 0, div);*/
                bitmap_and(tmp, prev_map, cur_map, div);
                bitmap_xor(dst, prev_map, tmp, div);
@@ -1668,7 +1674,7 @@ static u32 _find_fixed_adj_valid_win(struct amlsd_host *host,
                                        *prev_map, fir_adj, div);
                        ret = _find_fixed_adj_mid(*prev_map, fir_adj, div);
                        if (ret != NO_FIXED_ADJ_MID) {
-                               set_fixed_adj_line_delay(0, host);
+                               set_fixed_adj_line_delay(0, pdata);
                                return ret;
                        }
 
@@ -1830,7 +1836,7 @@ tunning:
                        && (clk_div <= AML_FIXED_ADJ_MAX)
                        && (clk_div >= AML_FIXED_ADJ_MIN)
                        && !all_flag) {
-               adj_delay_find = _find_fixed_adj_valid_win(host,
+               adj_delay_find = _find_fixed_adj_valid_win(pdata,
                                tuning_data, opcode, fixed_adj_map, clk_div);
        } else if (best_win_size == clk_div) {
                all_flag = true;