diff mbox series

[1/2] mmc: sdhci-of-esdhc: convert to use esdhc_tuning_window_ptr()

Message ID 20191212075219.48625-1-yangbo.lu@nxp.com (mailing list archive)
State New, archived
Headers show
Series [1/2] mmc: sdhci-of-esdhc: convert to use esdhc_tuning_window_ptr() | expand

Commit Message

Yangbo Lu Dec. 12, 2019, 7:52 a.m. UTC
Convert to use a new function esdhc_tuning_window_ptr() to
get tuning window start point and end point.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
 drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

Comments

Adrian Hunter Dec. 13, 2019, 12:20 p.m. UTC | #1
Is there a fix for below coming?

	https://lore.kernel.org/lkml/8afd0f53-eba8-e000-d8cc-b464e65850c3@rasmusvillemoes.dk/
Yangbo Lu Dec. 16, 2019, 3:23 a.m. UTC | #2
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

> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org <linux-mmc-owner@vger.kernel.org>
> On Behalf Of Adrian Hunter
> Sent: Friday, December 13, 2019 8:20 PM
> To: Y.b. Lu <yangbo.lu@nxp.com>; Yinbo Zhu <yinbo.zhu@nxp.com>
> Cc: linux-mmc@vger.kernel.org; Ulf Hansson <ulf.hansson@linaro.org>;
> Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Subject: Re: [PATCH 1/2] mmc: sdhci-of-esdhc: convert to use
> esdhc_tuning_window_ptr()
> 
> Is there a fix for below coming?
> 
> 	https://lore.kernel.org/lkml/8afd0f53-eba8-e000-d8cc-b464e65850c3@rasmusvillemoes.dk/
Adrian Hunter Dec. 20, 2019, 7:45 a.m. UTC | #3
On 12/12/19 9:52 am, Yangbo Lu wrote:
> Convert to use a new function esdhc_tuning_window_ptr() to
> get tuning window start point and end point.
> 
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++-------------
>  1 file changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index 7f87a90..cd0f21e 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -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 {
>
Ulf Hansson Jan. 16, 2020, 2:39 p.m. UTC | #4
On Thu, 12 Dec 2019 at 08:53, Yangbo Lu <yangbo.lu@nxp.com> wrote:
>
> Convert to use a new function esdhc_tuning_window_ptr() to
> get tuning window start point and end point.
>
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 34 +++++++++++++++++++++-------------
>  1 file changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index 7f87a90..cd0f21e 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -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
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 7f87a90..cd0f21e 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -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 {