mmc: sdhci-of-esdhc: convert to use esdhc_tuning_window_ptr()
PATCH 1/2 mmc: sdhci-of-esdhc: convert to use esdhc_tuning_window_ptr()
Convert to use a new function esdhc_tuning_window_ptr() to get tuning window start point and end point.
--- drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +21 -13
@@ -882,20 +882,11 @@ static void esdhc_tuning_block_enable(struct sdhci_host *host, bool enable)esdhc_clock_enable (host, true); } -static void esdhc_prepare_sw_tuning (struct sdhci_host *host,u8 *window_start, +static void esdhc_tuning_window_ptr (struct sdhci_host *host,u8 *window_start,u8 *window_end) { -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct sdhci_esdhc *esdhc =sdhci_pltfm_priv (pltfm_host); -u8 tbstat_15_8, tbstat_7_0;u32 val; -if (esdhc->quirk_tuning_erratum_type1) { - *window_start =5 * esdhc->div_ratio; - *window_end =3 * esdhc->div_ratio; -return ; - } -/* Write TBCTL[11:8]=4'h8 */ val =sdhci_readl (host,ESDHC_TBCTL ); val &= ~(0xf <<8 );
@@ -914,6 +905,25 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start, val =sdhci_readl (host,ESDHC_TBSTAT ); val =sdhci_readl (host,ESDHC_TBSTAT ); + *window_end = val &0xff ; + *window_start = (val >>8 ) &0xff ; +} + +static void esdhc_prepare_sw_tuning (struct sdhci_host *host,u8 *window_start, +u8 *window_end) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_esdhc *esdhc =sdhci_pltfm_priv (pltfm_host); +u8 start_ptr, end_ptr; + +if (esdhc->quirk_tuning_erratum_type1) { + *window_start =5 * esdhc->div_ratio; + *window_end =3 * esdhc->div_ratio; +return ; + } + +esdhc_tuning_window_ptr (host, &start_ptr, &end_ptr); +/* Reset data lines by setting ESDHCCTL[RSTD] */ sdhci_reset (host,SDHCI_RESET_DATA );/* Write 32'hFFFF_FFFF to IRQSTAT register */
@@ -924,10 +934,8 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,* then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio. */ - tbstat_7_0 = val &0xff ; - tbstat_15_8 = (val >>8 ) &0xff ; -if (abs (tbstat_15_8 - tbstat_7_0) > (4 * esdhc->div_ratio)) { +if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio)) { *window_start =8 * esdhc->div_ratio; *window_end =4 * esdhc->div_ratio; }else {
Signature · 1 line
2.7.4
PATCH 2/2 mmc: sdhci-of-esdhc: update tuning erratum A-008171
There is an official update for eSDHC tuning erratum A-008171. This patch is to implement the changes,
- Affect all revisions of SoC.
- Changes for tuning window checking.
- Hardware hits a new condition that tuning succeeds although the eSDHC might not have tuned properly for type2 SoCs (soc_tuning_erratum_type2[] array in driver). So check tuning window after tuning succeeds.
--- drivers/mmc/host/sdhci-of-esdhc.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +26 -13
@@ -848,20 +848,20 @@ static int esdhc_signal_voltage_switch(struct mmc_host *mmc, }static struct soc_device_attribute soc_tuning_erratum_type1[] = { - { .family ="QorIQ T1023" , .revision ="1.0" , }, - { .family ="QorIQ T1040" , .revision ="1.0" , }, - { .family ="QorIQ T2080" , .revision ="1.0" , }, - { .family ="QorIQ LS1021A" , .revision ="1.0" , }, + { .family ="QorIQ T1023" , }, + { .family ="QorIQ T1040" , }, + { .family ="QorIQ T2080" , }, + { .family ="QorIQ LS1021A" , }, { }, };static struct soc_device_attribute soc_tuning_erratum_type2[] = { - { .family ="QorIQ LS1012A" , .revision ="1.0" , }, - { .family ="QorIQ LS1043A" , .revision ="1.*" , }, - { .family ="QorIQ LS1046A" , .revision ="1.0" , }, - { .family ="QorIQ LS1080A" , .revision ="1.0" , }, - { .family ="QorIQ LS2080A" , .revision ="1.0" , }, - { .family ="QorIQ LA1575A" , .revision ="1.0" , }, + { .family ="QorIQ LS1012A" , }, + { .family ="QorIQ LS1043A" , }, + { .family ="QorIQ LS1046A" , }, + { .family ="QorIQ LS1080A" , }, + { .family ="QorIQ LS2080A" , }, + { .family ="QorIQ LA1575A" , }, { }, };
@@ -929,13 +929,13 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,/* Write 32'hFFFF_FFFF to IRQSTAT register */ sdhci_writel (host,0xFFFFFFFF ,SDHCI_INT_STATUS ); -/* If TBSTAT[15:8]-TBSTAT[7:0] > 4 * div_ratio -* or TBSTAT[7:0]-TBSTAT[15:8] > 4 * div_ratio, +/* If TBSTAT[15:8]-TBSTAT[7:0] > (4 * div_ratio) + 2 +* or TBSTAT[7:0]-TBSTAT[15:8] > (4 * div_ratio) + 2, * then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio. */ -if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio)) { +if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio +2 )) { *window_start =8 * esdhc->div_ratio; *window_end =4 * esdhc->div_ratio; }else {
@@ -1008,6 +1008,19 @@ static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode)if (ret)break ; +/* For type2 affected platforms of the tuning erratum, +* tuning may succeed although eSDHC might not have +* tuned properly. Need to check tuning window. +*/ +if (esdhc->quirk_tuning_erratum_type2 && + !host->tuning_err) { +esdhc_tuning_window_ptr (host, &window_start, + &window_end); +if (abs (window_start - window_end) > + (4 * esdhc->div_ratio +2 )) + host->tuning_err = -EAGAIN ; + } +/* If HW tuning fails and triggers erratum, * try workaround. */
Signature · 1 line
2.7.4
Re: [PATCH 2/2] mmc: sdhci-of-esdhc: update tuning erratum A-008171
Quoted 10 lines · Yangbo Lu
There is an official update for eSDHC tuning erratum A-008171. This patch is to implement the changes,
- Affect all revisions of SoC.
- Changes for tuning window checking.
- Hardware hits a new condition that tuning succeeds although the eSDHC might not have tuned properly for type2 SoCs (soc_tuning_erratum_type2[] array in driver). So check tuning window after tuning succeeds.Signed-off-by Yangbo Lu <[email protected]>
Quoted 77 lines
--- drivers/mmc/host/sdhci-of-esdhc.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-esdhc.c +26
-13@@ -848,20 +848,20 @@ static int esdhc_signal_voltage_switch(struct mmc_host *mmc, }static struct soc_device_attribute soc_tuning_erratum_type1[] = { - { .family ="QorIQ T1023" , .revision ="1.0" , }, - { .family ="QorIQ T1040" , .revision ="1.0" , }, - { .family ="QorIQ T2080" , .revision ="1.0" , }, - { .family ="QorIQ LS1021A" , .revision ="1.0" , }, + { .family ="QorIQ T1023" , }, + { .family ="QorIQ T1040" , }, + { .family ="QorIQ T2080" , }, + { .family ="QorIQ LS1021A" , }, { }, };static struct soc_device_attribute soc_tuning_erratum_type2[] = { - { .family ="QorIQ LS1012A" , .revision ="1.0" , }, - { .family ="QorIQ LS1043A" , .revision ="1.*" , }, - { .family ="QorIQ LS1046A" , .revision ="1.0" , }, - { .family ="QorIQ LS1080A" , .revision ="1.0" , }, - { .family ="QorIQ LS2080A" , .revision ="1.0" , }, - { .family ="QorIQ LA1575A" , .revision ="1.0" , }, + { .family ="QorIQ LS1012A" , }, + { .family ="QorIQ LS1043A" , }, + { .family ="QorIQ LS1046A" , }, + { .family ="QorIQ LS1080A" , }, + { .family ="QorIQ LS2080A" , }, + { .family ="QorIQ LA1575A" , }, { }, };@@ -929,13 +929,13 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,/* Write 32'hFFFF_FFFF to IRQSTAT register */ sdhci_writel (host,0xFFFFFFFF ,SDHCI_INT_STATUS ); -/* If TBSTAT[15:8]-TBSTAT[7:0] > 4 * div_ratio -* or TBSTAT[7:0]-TBSTAT[15:8] > 4 * div_ratio, +/* If TBSTAT[15:8]-TBSTAT[7:0] > (4 * div_ratio) + 2 +* or TBSTAT[7:0]-TBSTAT[15:8] > (4 * div_ratio) + 2, * then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio. */ -if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio)) { +if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio +2 )) { *window_start =8 * esdhc->div_ratio; *window_end =4 * esdhc->div_ratio; }else {@@ -1008,6 +1008,19 @@ static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode)if (ret)break ; +/* For type2 affected platforms of the tuning erratum, +* tuning may succeed although eSDHC might not have +* tuned properly. Need to check tuning window. +*/ +if (esdhc->quirk_tuning_erratum_type2 && + !host->tuning_err) { +esdhc_tuning_window_ptr (host, &window_start, + &window_end); +if (abs (window_start - window_end) > + (4 * esdhc->div_ratio +2 )) + host->tuning_err = -EAGAIN ; + } +/* If HW tuning fails and triggers erratum, * try workaround. */
Re: [PATCH 2/2] mmc: sdhci-of-esdhc: update tuning erratum A-008171
In reply to Yangbo LuQuoted 11 lines · Yangbo Lu
There is an official update for eSDHC tuning erratum A-008171. This patch is to implement the changes,
- Affect all revisions of SoC.
- Changes for tuning window checking.
- Hardware hits a new condition that tuning succeeds although the eSDHC might not have tuned properly for type2 SoCs (soc_tuning_erratum_type2[] array in driver). So check tuning window after tuning succeeds.Signed-off-by Yangbo Lu <[email protected]>
Applied for next, thanks!
Kind regards
Uffe
Quoted 79 lines
--- drivers/mmc/host/sdhci-of-esdhc.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-esdhc.c +26
-14@@ -848,20 +848,20 @@ static int esdhc_signal_voltage_switch(struct mmc_host *mmc, }static struct soc_device_attribute soc_tuning_erratum_type1[] = { - { .family ="QorIQ T1023" , .revision ="1.0" , }, - { .family ="QorIQ T1040" , .revision ="1.0" , }, - { .family ="QorIQ T2080" , .revision ="1.0" , }, - { .family ="QorIQ LS1021A" , .revision ="1.0" , }, + { .family ="QorIQ T1023" , }, + { .family ="QorIQ T1040" , }, + { .family ="QorIQ T2080" , }, + { .family ="QorIQ LS1021A" , }, { }, };static struct soc_device_attribute soc_tuning_erratum_type2[] = { - { .family ="QorIQ LS1012A" , .revision ="1.0" , }, - { .family ="QorIQ LS1043A" , .revision ="1.*" , }, - { .family ="QorIQ LS1046A" , .revision ="1.0" , }, - { .family ="QorIQ LS1080A" , .revision ="1.0" , }, - { .family ="QorIQ LS2080A" , .revision ="1.0" , }, - { .family ="QorIQ LA1575A" , .revision ="1.0" , }, + { .family ="QorIQ LS1012A" , }, + { .family ="QorIQ LS1043A" , }, + { .family ="QorIQ LS1046A" , }, + { .family ="QorIQ LS1080A" , }, + { .family ="QorIQ LS2080A" , }, + { .family ="QorIQ LA1575A" , }, { }, };@@ -929,13 +929,13 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,/* Write 32'hFFFF_FFFF to IRQSTAT register */ sdhci_writel (host,0xFFFFFFFF ,SDHCI_INT_STATUS ); -/* If TBSTAT[15:8]-TBSTAT[7:0] > 4 * div_ratio -* or TBSTAT[7:0]-TBSTAT[15:8] > 4 * div_ratio, +/* If TBSTAT[15:8]-TBSTAT[7:0] > (4 * div_ratio) + 2 +* or TBSTAT[7:0]-TBSTAT[15:8] > (4 * div_ratio) + 2, * then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio. */ -if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio)) { +if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio +2 )) { *window_start =8 * esdhc->div_ratio; *window_end =4 * esdhc->div_ratio; }else {@@ -1008,6 +1008,19 @@ static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode)if (ret)break ; +/* For type2 affected platforms of the tuning erratum, +* tuning may succeed although eSDHC might not have +* tuned properly. Need to check tuning window. +*/ +if (esdhc->quirk_tuning_erratum_type2 && + !host->tuning_err) { +esdhc_tuning_window_ptr (host, &window_start, + &window_end); +if (abs (window_start - window_end) > + (4 * esdhc->div_ratio +2 )) + host->tuning_err = -EAGAIN ; + } +/* If HW tuning fails and triggers erratum, * try workaround. */ --2.7.4
Adrian Hunter
maintainerIs there a fix for below coming?
https://lore.kernel.org/lkml/[email protected]/
Sorry Adrian. I missed that email. I sent out a fix up patch for reviewing.
https://patchwork.kernel.org/patch/11293337/
Thanks!
Best regards,
Yangbo Lu
Quoted 13 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Adrian Hunter
Sent: Friday, December 13, 2019 8:20 PM
To: Y.b. Lu <[email protected]>; Yinbo Zhu <[email protected]>
Cc: [email protected]; Ulf Hansson <[email protected]>; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 1/2] mmc: sdhci-of-esdhc: convert to useesdhc_tuning_window_ptr()Is there a fix for below coming?
https://lore.kernel.org/lkml/[email protected]/
Quoted 4 lines · Yangbo Lu
Convert to use a new function
esdhc_tuning_window_ptr()to get tuning window start point and end point.Signed-off-by Yangbo Lu <[email protected]>
Quoted 69 lines
--- drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-esdhc.c +21
-13@@ -882,20 +882,11 @@ static void esdhc_tuning_block_enable(struct sdhci_host *host, bool enable)esdhc_clock_enable (host, true); } -static void esdhc_prepare_sw_tuning (struct sdhci_host *host,u8 *window_start, +static void esdhc_tuning_window_ptr (struct sdhci_host *host,u8 *window_start,u8 *window_end) { -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct sdhci_esdhc *esdhc =sdhci_pltfm_priv (pltfm_host); -u8 tbstat_15_8, tbstat_7_0;u32 val; -if (esdhc->quirk_tuning_erratum_type1) { - *window_start =5 * esdhc->div_ratio; - *window_end =3 * esdhc->div_ratio; -return ; - } -/* Write TBCTL[11:8]=4'h8 */ val =sdhci_readl (host,ESDHC_TBCTL ); val &= ~(0xf <<8 );@@ -914,6 +905,25 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start, val =sdhci_readl (host,ESDHC_TBSTAT ); val =sdhci_readl (host,ESDHC_TBSTAT ); + *window_end = val &0xff ; + *window_start = (val >>8 ) &0xff ; +} + +static void esdhc_prepare_sw_tuning (struct sdhci_host *host,u8 *window_start, +u8 *window_end) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_esdhc *esdhc =sdhci_pltfm_priv (pltfm_host); +u8 start_ptr, end_ptr; + +if (esdhc->quirk_tuning_erratum_type1) { + *window_start =5 * esdhc->div_ratio; + *window_end =3 * esdhc->div_ratio; +return ; + } + +esdhc_tuning_window_ptr (host, &start_ptr, &end_ptr); +/* Reset data lines by setting ESDHCCTL[RSTD] */ sdhci_reset (host,SDHCI_RESET_DATA );/* Write 32'hFFFF_FFFF to IRQSTAT register */ @@ -924,10 +934,8 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,* then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio. */ - tbstat_7_0 = val &0xff ; - tbstat_15_8 = (val >>8 ) &0xff ; -if (abs (tbstat_15_8 - tbstat_7_0) > (4 * esdhc->div_ratio)) { +if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio)) { *window_start =8 * esdhc->div_ratio; *window_end =4 * esdhc->div_ratio; }else {
Quoted 5 lines · Yangbo Lu
Convert to use a new function
esdhc_tuning_window_ptr()to get tuning window start point and end point.Signed-off-by Yangbo Lu <[email protected]>
Applied for next, thanks!
Kind regards
Uffe
Quoted 71 lines
--- drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-of-esdhc.c +21
-14@@ -882,20 +882,11 @@ static void esdhc_tuning_block_enable(struct sdhci_host *host, bool enable)esdhc_clock_enable (host, true); } -static void esdhc_prepare_sw_tuning (struct sdhci_host *host,u8 *window_start, +static void esdhc_tuning_window_ptr (struct sdhci_host *host,u8 *window_start,u8 *window_end) { -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct sdhci_esdhc *esdhc =sdhci_pltfm_priv (pltfm_host); -u8 tbstat_15_8, tbstat_7_0;u32 val; -if (esdhc->quirk_tuning_erratum_type1) { - *window_start =5 * esdhc->div_ratio; - *window_end =3 * esdhc->div_ratio; -return ; - } -/* Write TBCTL[11:8]=4'h8 */ val =sdhci_readl (host,ESDHC_TBCTL ); val &= ~(0xf <<8 );@@ -914,6 +905,25 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start, val =sdhci_readl (host,ESDHC_TBSTAT ); val =sdhci_readl (host,ESDHC_TBSTAT ); + *window_end = val &0xff ; + *window_start = (val >>8 ) &0xff ; +} + +static void esdhc_prepare_sw_tuning (struct sdhci_host *host,u8 *window_start, +u8 *window_end) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_esdhc *esdhc =sdhci_pltfm_priv (pltfm_host); +u8 start_ptr, end_ptr; + +if (esdhc->quirk_tuning_erratum_type1) { + *window_start =5 * esdhc->div_ratio; + *window_end =3 * esdhc->div_ratio; +return ; + } + +esdhc_tuning_window_ptr (host, &start_ptr, &end_ptr); +/* Reset data lines by setting ESDHCCTL[RSTD] */ sdhci_reset (host,SDHCI_RESET_DATA );/* Write 32'hFFFF_FFFF to IRQSTAT register */ @@ -924,10 +934,8 @@ static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start,* then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio. */ - tbstat_7_0 = val &0xff ; - tbstat_15_8 = (val >>8 ) &0xff ; -if (abs (tbstat_15_8 - tbstat_7_0) > (4 * esdhc->div_ratio)) { +if (abs (start_ptr - end_ptr) > (4 * esdhc->div_ratio)) { *window_start =8 * esdhc->div_ratio; *window_end =4 * esdhc->div_ratio; }else { --2.7.4