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()
7 Convert to use a new function esdhc_tuning_window_ptr() to
8 get tuning window start point and end point.
10 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
11 Acked-by: Adrian Hunter <adrian.hunter@intel.com>
13 drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++-------------
14 1 file changed, 21 insertions(+), 13 deletions(-)
16 --- a/drivers/mmc/host/sdhci-of-esdhc.c
17 +++ b/drivers/mmc/host/sdhci-of-esdhc.c
18 @@ -923,20 +923,11 @@ static void esdhc_tuning_block_enable(st
19 esdhc_clock_enable(host, true);
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,
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;
31 - if (esdhc->quirk_tuning_erratum_type1) {
32 - *window_start = 5 * esdhc->div_ratio;
33 - *window_end = 3 * esdhc->div_ratio;
37 /* Write TBCTL[11:8]=4'h8 */
38 val = sdhci_readl(host, ESDHC_TBCTL);
40 @@ -955,6 +946,25 @@ static void esdhc_prepare_sw_tuning(stru
41 val = sdhci_readl(host, ESDHC_TBSTAT);
42 val = sdhci_readl(host, ESDHC_TBSTAT);
44 + *window_end = val & 0xff;
45 + *window_start = (val >> 8) & 0xff;
48 +static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,
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;
55 + if (esdhc->quirk_tuning_erratum_type1) {
56 + *window_start = 5 * esdhc->div_ratio;
57 + *window_end = 3 * esdhc->div_ratio;
61 + esdhc_tuning_window_ptr(host, &start_ptr, &end_ptr);
63 /* Reset data lines by setting ESDHCCTL[RSTD] */
64 sdhci_reset(host, SDHCI_RESET_DATA);
65 /* Write 32'hFFFF_FFFF to IRQSTAT register */
66 @@ -965,10 +975,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.
70 - tbstat_7_0 = val & 0xff;
71 - tbstat_15_8 = (val >> 8) & 0xff;
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;