1 From f3d460fb85677a5f62324771e5715ceb11726ecc Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Thu, 12 Dec 2019 15:52:19 +0800
4 Subject: [PATCH] LF-605 mmc: sdhci-of-esdhc: update tuning erratum A-008171
6 There is an official update for eSDHC tuning erratum A-008171.
7 This patch is to implement the changes,
8 - Affect all revisions of SoC.
9 - Changes for tuning window checking.
10 - Hardware hits a new condition that tuning succeeds although
11 the eSDHC might not have tuned properly for type2 SoCs
12 (soc_tuning_erratum_type2[] array in driver). So check
13 tuning window after tuning succeeds.
15 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
16 Acked-by: Adrian Hunter <adrian.hunter@intel.com>
18 drivers/mmc/host/sdhci-of-esdhc.c | 39 ++++++++++++++++++++++++++-------------
19 1 file changed, 26 insertions(+), 13 deletions(-)
21 --- a/drivers/mmc/host/sdhci-of-esdhc.c
22 +++ b/drivers/mmc/host/sdhci-of-esdhc.c
23 @@ -890,20 +890,20 @@ static int esdhc_signal_voltage_switch(s
26 static struct soc_device_attribute soc_tuning_erratum_type1[] = {
27 - { .family = "QorIQ T1023", .revision = "1.0", },
28 - { .family = "QorIQ T1040", .revision = "1.0", },
29 - { .family = "QorIQ T2080", .revision = "1.0", },
30 - { .family = "QorIQ LS1021A", .revision = "1.0", },
31 + { .family = "QorIQ T1023", },
32 + { .family = "QorIQ T1040", },
33 + { .family = "QorIQ T2080", },
34 + { .family = "QorIQ LS1021A", },
38 static struct soc_device_attribute soc_tuning_erratum_type2[] = {
39 - { .family = "QorIQ LS1012A", .revision = "1.0", },
40 - { .family = "QorIQ LS1043A", .revision = "1.*", },
41 - { .family = "QorIQ LS1046A", .revision = "1.0", },
42 - { .family = "QorIQ LS1080A", .revision = "1.0", },
43 - { .family = "QorIQ LS2080A", .revision = "1.0", },
44 - { .family = "QorIQ LA1575A", .revision = "1.0", },
45 + { .family = "QorIQ LS1012A", },
46 + { .family = "QorIQ LS1043A", },
47 + { .family = "QorIQ LS1046A", },
48 + { .family = "QorIQ LS1080A", },
49 + { .family = "QorIQ LS2080A", },
50 + { .family = "QorIQ LA1575A", },
54 @@ -971,13 +971,13 @@ static void esdhc_prepare_sw_tuning(stru
55 /* Write 32'hFFFF_FFFF to IRQSTAT register */
56 sdhci_writel(host, 0xFFFFFFFF, SDHCI_INT_STATUS);
58 - /* If TBSTAT[15:8]-TBSTAT[7:0] > 4 * div_ratio
59 - * or TBSTAT[7:0]-TBSTAT[15:8] > 4 * div_ratio,
60 + /* If TBSTAT[15:8]-TBSTAT[7:0] > (4 * div_ratio) + 2
61 + * or TBSTAT[7:0]-TBSTAT[15:8] > (4 * div_ratio) + 2,
62 * then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio
63 * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio.
66 - if (abs(start_ptr - end_ptr) > (4 * esdhc->div_ratio)) {
67 + if (abs(start_ptr - end_ptr) > (4 * esdhc->div_ratio + 2)) {
68 *window_start = 8 * esdhc->div_ratio;
69 *window_end = 4 * esdhc->div_ratio;
71 @@ -1050,6 +1050,19 @@ static int esdhc_execute_tuning(struct m
75 + /* For type2 affected platforms of the tuning erratum,
76 + * tuning may succeed although eSDHC might not have
77 + * tuned properly. Need to check tuning window.
79 + if (esdhc->quirk_tuning_erratum_type2 &&
80 + !host->tuning_err) {
81 + esdhc_tuning_window_ptr(host, &window_start,
83 + if (abs(window_start - window_end) >
84 + (4 * esdhc->div_ratio + 2))
85 + host->tuning_err = -EAGAIN;
88 /* If HW tuning fails and triggers erratum,