74dd63d8e5a46abf01b2b2d5fb1713ad94d886bb
[oweals/openwrt.git] /
1 From e95c04bd6d9ebe081126184fb228461b1b3fa7aa Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Thu, 12 Dec 2019 15:52:18 +0800
4 Subject: [PATCH] LF-605 mmc: sdhci-of-esdhc: convert to use
5  esdhc_tuning_window_ptr()
6
7 Convert to use a new function esdhc_tuning_window_ptr() to
8 get tuning window start point and end point.
9
10 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
11 Acked-by: Adrian Hunter <adrian.hunter@intel.com>
12 ---
13  drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++-------------
14  1 file changed, 21 insertions(+), 13 deletions(-)
15
16 --- a/drivers/mmc/host/sdhci-of-esdhc.c
17 +++ b/drivers/mmc/host/sdhci-of-esdhc.c
18 @@ -888,20 +888,11 @@ static void esdhc_tuning_block_enable(st
19         esdhc_clock_enable(host, true);
20  }
21  
22 -static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,
23 +static void esdhc_tuning_window_ptr(struct sdhci_host *host, u8 *window_start,
24                                     u8 *window_end)
25  {
26 -       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
27 -       struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
28 -       u8 tbstat_15_8, tbstat_7_0;
29         u32 val;
30  
31 -       if (esdhc->quirk_tuning_erratum_type1) {
32 -               *window_start = 5 * esdhc->div_ratio;
33 -               *window_end = 3 * esdhc->div_ratio;
34 -               return;
35 -       }
36 -
37         /* Write TBCTL[11:8]=4'h8 */
38         val = sdhci_readl(host, ESDHC_TBCTL);
39         val &= ~(0xf << 8);
40 @@ -920,6 +911,25 @@ static void esdhc_prepare_sw_tuning(stru
41         val = sdhci_readl(host, ESDHC_TBSTAT);
42         val = sdhci_readl(host, ESDHC_TBSTAT);
43  
44 +       *window_end = val & 0xff;
45 +       *window_start = (val >> 8) & 0xff;
46 +}
47 +
48 +static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,
49 +                                   u8 *window_end)
50 +{
51 +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
52 +       struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
53 +       u8 start_ptr, end_ptr;
54 +
55 +       if (esdhc->quirk_tuning_erratum_type1) {
56 +               *window_start = 5 * esdhc->div_ratio;
57 +               *window_end = 3 * esdhc->div_ratio;
58 +               return;
59 +       }
60 +
61 +       esdhc_tuning_window_ptr(host, &start_ptr, &end_ptr);
62 +
63         /* Reset data lines by setting ESDHCCTL[RSTD] */
64         sdhci_reset(host, SDHCI_RESET_DATA);
65         /* Write 32'hFFFF_FFFF to IRQSTAT register */
66 @@ -930,10 +940,8 @@ static void esdhc_prepare_sw_tuning(stru
67          * then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio
68          * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio.
69          */
70 -       tbstat_7_0 = val & 0xff;
71 -       tbstat_15_8 = (val >> 8) & 0xff;
72  
73 -       if (abs(tbstat_15_8 - tbstat_7_0) > (4 * esdhc->div_ratio)) {
74 +       if (abs(start_ptr - end_ptr) > (4 * esdhc->div_ratio)) {
75                 *window_start = 8 * esdhc->div_ratio;
76                 *window_end = 4 * esdhc->div_ratio;
77         } else {