All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Bough Chen <haibo.chen@nxp.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	Shawn Guo <shawnguo@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Sascha Hauer <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>,
	DTML <devicetree@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 4/6] mmc: host: sdhci-esdhc-imx.c: correct the auto-tuning setting for sdio device
Date: Tue, 17 Aug 2021 10:00:56 +0200	[thread overview]
Message-ID: <CAPDyKFpr9E6xxe2egiRGGWhUSY5aVr29rj1Hb_TwCzrY5bcvpg@mail.gmail.com> (raw)
In-Reply-To: <VI1PR04MB52948F36F428AA3476A1F9D590FE9@VI1PR04MB5294.eurprd04.prod.outlook.com>

On Tue, 17 Aug 2021 at 08:57, Bough Chen <haibo.chen@nxp.com> wrote:
>
> > -----Original Message-----
> > From: Ulf Hansson [mailto:ulf.hansson@linaro.org]
> > Sent: 2021年8月16日 21:53
> > To: Bough Chen <haibo.chen@nxp.com>
> > Cc: Adrian Hunter <adrian.hunter@intel.com>; Shawn Guo
> > <shawnguo@kernel.org>; Rob Herring <robh+dt@kernel.org>; Sascha Hauer
> > <s.hauer@pengutronix.de>; Sascha Hauer <kernel@pengutronix.de>; Fabio
> > Estevam <festevam@gmail.com>; linux-mmc <linux-mmc@vger.kernel.org>;
> > dl-linux-imx <linux-imx@nxp.com>; DTML <devicetree@vger.kernel.org>; Linux
> > ARM <linux-arm-kernel@lists.infradead.org>
> > Subject: Re: [PATCH 4/6] mmc: host: sdhci-esdhc-imx.c: correct the auto-tuning
> > setting for sdio device
> >
> > On Mon, 16 Aug 2021 at 15:00, <haibo.chen@nxp.com> wrote:
> > >
> > > From: Haibo Chen <haibo.chen@nxp.com>
> > >
> > > USDHC contain auto tuning circuit, this circuit will work
> > > automatically after the tuning procedurae, it can increase/decrease
> > > the delay cell according to the outside environment change (like
> > temperature).
> > >
> > > Unfortunately, this auto tuning circuit can not handle the async sdio
> > > device interrupt correctly. When sdio device use 4 data line, async
> > > sdio interrupt will use DAT[1], if we enable auto tuning circuit check
> > > 4 data lines, include the DAT[1], this circuit will detect this
> > > interrupt, take this as a data on DAT[1], and adjust the delay cell wrongly.
> > >
> > > This is the hardware design limitation, to avoid this, when sdio
> > > device enable async interrupt, auto tuning circuit only check DAT[0] and CMD
> > lines.
> >
> > SDIO irqs are being enabled/disabled dynamically in runtime by the mmc core
> > via the host ops ->enable_sdio_irq().
> >
> > Rather than forcing the autotuning circuit to stay unused statically, perhaps an
> > option would be to disable it when the SDIO irqs becomes enabled? Or maybe
> > that becomes too complicated?
>
> For interrupt in 4-bit mode, there is a definition of interrupt period, only in this period can the interrupt be
> detect and recognize. The interrupt period can exist during data transfer.
>
> So to fix this issue, one method is to disable auto tuning circuit. Another is my current method, just detect CMD
> and DAT0, but at least auto tuning still can work (this method need board design keep align all data lines).

To allow DAT1 being used for SDIO irqs (async or not), the irqs needs
to be enabled internally in the SDIO card first. This is done by
writing to the CCCR register, which happens in sdio_claim_irq(). At
this point in sdio_claim_irq() the core also invokes the
->enable_sdio_irq() host ops, to allow the host to prepare itself to
accept SDIO irqs.

It sounds to me that you should be able to use the ->enable_sdio_irq
ops, as a way of understanding that the auto-tuning feature also needs
to be turned off, because it's not compatible with SDIO irqs.

Kind regards
Uffe

>
>
> Best Regards
> Haibo chen
>
> >
> > >
> > > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> > > ---
> > >  drivers/mmc/host/sdhci-esdhc-imx.c | 18 ++++++++++++++++++
> > >  1 file changed, 18 insertions(+)
> > >
> > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> > > b/drivers/mmc/host/sdhci-esdhc-imx.c
> > > index f18d169bc8ff..ab84c29777e5 100644
> > > --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> > > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> > > @@ -226,6 +226,7 @@ struct esdhc_platform_data {
> > >         unsigned int tuning_step;       /* The delay cell steps in tuning
> > procedure */
> > >         unsigned int tuning_start_tap;  /* The start delay cell point in
> > tuning procedure */
> > >         unsigned int strobe_dll_delay_target;   /* The delay cell for
> > strobe pad (read clock) */
> > > +       bool sdio_async_interrupt_enabled;      /* sdio device enable
> > the async interrupt */
> > >  };
> > >
> > >  struct esdhc_soc_data {
> > > @@ -416,6 +417,8 @@ static inline void
> > > esdhc_wait_for_card_clock_gate_off(struct sdhci_host *host)
> > >  /* Enable the auto tuning circuit to check the CMD line and BUS line
> > > */  static inline void usdhc_auto_tuning_mode_sel(struct sdhci_host
> > > *host)  {
> > > +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> > > +       struct pltfm_imx_data *imx_data =
> > > + sdhci_pltfm_priv(pltfm_host);
> > >         u32 buswidth, auto_tune_buswidth;
> > >
> > >         buswidth = USDHC_GET_BUSWIDTH(readl(host->ioaddr +
> > > SDHCI_HOST_CONTROL)); @@ -432,6 +435,18 @@ static inline void
> > usdhc_auto_tuning_mode_sel(struct sdhci_host *host)
> > >                 break;
> > >         }
> > >
> > > +       /*
> > > +        * If sdio device use async interrupt, it will use DAT[1] to signal
> > > +        * the device's interrupt asynchronous when use 4 data lines.
> > > +        * Then hardware auto tuning circuit MUST NOT check the DAT[1]
> > line,
> > > +        * otherwise auto tuning will be impacted by this async interrupt,
> > > +        * and change the delay cell incorrectly, which then cause
> > data/cmd
> > > +        * errors.
> > > +        * This is the hardware auto tuning circuit limitation.
> > > +        */
> > > +       if (imx_data->boarddata.sdio_async_interrupt_enabled)
> > > +               auto_tune_buswidth =
> > > + ESDHC_VEND_SPEC2_AUTO_TUNE_1BIT_EN;
> > > +
> > >         esdhc_clrset_le(host,
> > ESDHC_VEND_SPEC2_AUTO_TUNE_MODE_MASK,
> > >                         auto_tune_buswidth |
> > ESDHC_VEND_SPEC2_AUTO_TUNE_CMD_EN,
> > >                         ESDHC_VEND_SPEC2); @@ -1531,6 +1546,9
> > @@
> > > sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
> > >         if (of_property_read_u32(np, "fsl,delay-line",
> > &boarddata->delay_line))
> > >                 boarddata->delay_line = 0;
> > >
> > > +       if (of_property_read_bool(np,
> > > + "fsl,sdio-async-interrupt-enabled"))
> >
> > As stated on the DT patch, I think you can use the "cap-sdio-irq" instead.
> >
> > > +               boarddata->sdio_async_interrupt_enabled = true;
> > > +
> > >         mmc_of_parse_voltage(host->mmc, &host->ocr_mask);
> > >
> > >         if (esdhc_is_usdhc(imx_data) && !IS_ERR(imx_data->pinctrl)) {
> > > --
> > > 2.17.1
> > >
> >
> > Kind regards
> > Uffe

WARNING: multiple messages have this Message-ID (diff)
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Bough Chen <haibo.chen@nxp.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	Shawn Guo <shawnguo@kernel.org>,
	 Rob Herring <robh+dt@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	 Sascha Hauer <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	 linux-mmc <linux-mmc@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>,
	 DTML <devicetree@vger.kernel.org>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 4/6] mmc: host: sdhci-esdhc-imx.c: correct the auto-tuning setting for sdio device
Date: Tue, 17 Aug 2021 10:00:56 +0200	[thread overview]
Message-ID: <CAPDyKFpr9E6xxe2egiRGGWhUSY5aVr29rj1Hb_TwCzrY5bcvpg@mail.gmail.com> (raw)
In-Reply-To: <VI1PR04MB52948F36F428AA3476A1F9D590FE9@VI1PR04MB5294.eurprd04.prod.outlook.com>

On Tue, 17 Aug 2021 at 08:57, Bough Chen <haibo.chen@nxp.com> wrote:
>
> > -----Original Message-----
> > From: Ulf Hansson [mailto:ulf.hansson@linaro.org]
> > Sent: 2021年8月16日 21:53
> > To: Bough Chen <haibo.chen@nxp.com>
> > Cc: Adrian Hunter <adrian.hunter@intel.com>; Shawn Guo
> > <shawnguo@kernel.org>; Rob Herring <robh+dt@kernel.org>; Sascha Hauer
> > <s.hauer@pengutronix.de>; Sascha Hauer <kernel@pengutronix.de>; Fabio
> > Estevam <festevam@gmail.com>; linux-mmc <linux-mmc@vger.kernel.org>;
> > dl-linux-imx <linux-imx@nxp.com>; DTML <devicetree@vger.kernel.org>; Linux
> > ARM <linux-arm-kernel@lists.infradead.org>
> > Subject: Re: [PATCH 4/6] mmc: host: sdhci-esdhc-imx.c: correct the auto-tuning
> > setting for sdio device
> >
> > On Mon, 16 Aug 2021 at 15:00, <haibo.chen@nxp.com> wrote:
> > >
> > > From: Haibo Chen <haibo.chen@nxp.com>
> > >
> > > USDHC contain auto tuning circuit, this circuit will work
> > > automatically after the tuning procedurae, it can increase/decrease
> > > the delay cell according to the outside environment change (like
> > temperature).
> > >
> > > Unfortunately, this auto tuning circuit can not handle the async sdio
> > > device interrupt correctly. When sdio device use 4 data line, async
> > > sdio interrupt will use DAT[1], if we enable auto tuning circuit check
> > > 4 data lines, include the DAT[1], this circuit will detect this
> > > interrupt, take this as a data on DAT[1], and adjust the delay cell wrongly.
> > >
> > > This is the hardware design limitation, to avoid this, when sdio
> > > device enable async interrupt, auto tuning circuit only check DAT[0] and CMD
> > lines.
> >
> > SDIO irqs are being enabled/disabled dynamically in runtime by the mmc core
> > via the host ops ->enable_sdio_irq().
> >
> > Rather than forcing the autotuning circuit to stay unused statically, perhaps an
> > option would be to disable it when the SDIO irqs becomes enabled? Or maybe
> > that becomes too complicated?
>
> For interrupt in 4-bit mode, there is a definition of interrupt period, only in this period can the interrupt be
> detect and recognize. The interrupt period can exist during data transfer.
>
> So to fix this issue, one method is to disable auto tuning circuit. Another is my current method, just detect CMD
> and DAT0, but at least auto tuning still can work (this method need board design keep align all data lines).

To allow DAT1 being used for SDIO irqs (async or not), the irqs needs
to be enabled internally in the SDIO card first. This is done by
writing to the CCCR register, which happens in sdio_claim_irq(). At
this point in sdio_claim_irq() the core also invokes the
->enable_sdio_irq() host ops, to allow the host to prepare itself to
accept SDIO irqs.

It sounds to me that you should be able to use the ->enable_sdio_irq
ops, as a way of understanding that the auto-tuning feature also needs
to be turned off, because it's not compatible with SDIO irqs.

Kind regards
Uffe

>
>
> Best Regards
> Haibo chen
>
> >
> > >
> > > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> > > ---
> > >  drivers/mmc/host/sdhci-esdhc-imx.c | 18 ++++++++++++++++++
> > >  1 file changed, 18 insertions(+)
> > >
> > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> > > b/drivers/mmc/host/sdhci-esdhc-imx.c
> > > index f18d169bc8ff..ab84c29777e5 100644
> > > --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> > > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> > > @@ -226,6 +226,7 @@ struct esdhc_platform_data {
> > >         unsigned int tuning_step;       /* The delay cell steps in tuning
> > procedure */
> > >         unsigned int tuning_start_tap;  /* The start delay cell point in
> > tuning procedure */
> > >         unsigned int strobe_dll_delay_target;   /* The delay cell for
> > strobe pad (read clock) */
> > > +       bool sdio_async_interrupt_enabled;      /* sdio device enable
> > the async interrupt */
> > >  };
> > >
> > >  struct esdhc_soc_data {
> > > @@ -416,6 +417,8 @@ static inline void
> > > esdhc_wait_for_card_clock_gate_off(struct sdhci_host *host)
> > >  /* Enable the auto tuning circuit to check the CMD line and BUS line
> > > */  static inline void usdhc_auto_tuning_mode_sel(struct sdhci_host
> > > *host)  {
> > > +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> > > +       struct pltfm_imx_data *imx_data =
> > > + sdhci_pltfm_priv(pltfm_host);
> > >         u32 buswidth, auto_tune_buswidth;
> > >
> > >         buswidth = USDHC_GET_BUSWIDTH(readl(host->ioaddr +
> > > SDHCI_HOST_CONTROL)); @@ -432,6 +435,18 @@ static inline void
> > usdhc_auto_tuning_mode_sel(struct sdhci_host *host)
> > >                 break;
> > >         }
> > >
> > > +       /*
> > > +        * If sdio device use async interrupt, it will use DAT[1] to signal
> > > +        * the device's interrupt asynchronous when use 4 data lines.
> > > +        * Then hardware auto tuning circuit MUST NOT check the DAT[1]
> > line,
> > > +        * otherwise auto tuning will be impacted by this async interrupt,
> > > +        * and change the delay cell incorrectly, which then cause
> > data/cmd
> > > +        * errors.
> > > +        * This is the hardware auto tuning circuit limitation.
> > > +        */
> > > +       if (imx_data->boarddata.sdio_async_interrupt_enabled)
> > > +               auto_tune_buswidth =
> > > + ESDHC_VEND_SPEC2_AUTO_TUNE_1BIT_EN;
> > > +
> > >         esdhc_clrset_le(host,
> > ESDHC_VEND_SPEC2_AUTO_TUNE_MODE_MASK,
> > >                         auto_tune_buswidth |
> > ESDHC_VEND_SPEC2_AUTO_TUNE_CMD_EN,
> > >                         ESDHC_VEND_SPEC2); @@ -1531,6 +1546,9
> > @@
> > > sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
> > >         if (of_property_read_u32(np, "fsl,delay-line",
> > &boarddata->delay_line))
> > >                 boarddata->delay_line = 0;
> > >
> > > +       if (of_property_read_bool(np,
> > > + "fsl,sdio-async-interrupt-enabled"))
> >
> > As stated on the DT patch, I think you can use the "cap-sdio-irq" instead.
> >
> > > +               boarddata->sdio_async_interrupt_enabled = true;
> > > +
> > >         mmc_of_parse_voltage(host->mmc, &host->ocr_mask);
> > >
> > >         if (esdhc_is_usdhc(imx_data) && !IS_ERR(imx_data->pinctrl)) {
> > > --
> > > 2.17.1
> > >
> >
> > Kind regards
> > Uffe

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-08-17  8:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 12:38 [PATCH 1/6] mmc: sdhci-esdhc-imx: remove redundant code for manual tuning haibo.chen
2021-08-16 12:38 ` haibo.chen
2021-08-16 12:38 ` [PATCH 2/6] mmc: sdhci-eadhc-imx: select the correct mode for auto tuning haibo.chen
2021-08-16 12:38   ` haibo.chen
2021-08-16 12:38 ` [PATCH 3/6] dt-bindings: mmc: fsl-imx-esdhc: add fsl,sdio-async-interrupt-enabled binding haibo.chen
2021-08-16 12:38   ` [PATCH 3/6] dt-bindings: mmc: fsl-imx-esdhc: add fsl, sdio-async-interrupt-enabled binding haibo.chen
2021-08-16 13:43   ` [PATCH 3/6] dt-bindings: mmc: fsl-imx-esdhc: add fsl,sdio-async-interrupt-enabled binding Ulf Hansson
2021-08-16 13:43     ` Ulf Hansson
2021-08-17  6:41     ` Bough Chen
2021-08-17  6:41       ` Bough Chen
2021-08-17  7:37       ` Ulf Hansson
2021-08-17  7:37         ` Ulf Hansson
2021-08-16 12:38 ` [PATCH 4/6] mmc: host: sdhci-esdhc-imx.c: correct the auto-tuning setting for sdio device haibo.chen
2021-08-16 12:38   ` haibo.chen
2021-08-16 13:53   ` Ulf Hansson
2021-08-16 13:53     ` Ulf Hansson
2021-08-17  6:57     ` Bough Chen
2021-08-17  6:57       ` Bough Chen
2021-08-17  8:00       ` Ulf Hansson [this message]
2021-08-17  8:00         ` Ulf Hansson
2021-08-17 12:29         ` Bough Chen
2021-08-17 12:29           ` Bough Chen
2021-08-16 12:38 ` [PATCH 5/6] arm64: dts: imx8mm-evk: add sdio wifi support haibo.chen
2021-08-16 12:38   ` haibo.chen
2021-08-16 12:38 ` [PATCH 6/6] arm64: dts: imx8mn-evk: " haibo.chen
2021-08-16 12:38   ` haibo.chen
2021-08-24 13:52 ` [PATCH 1/6] mmc: sdhci-esdhc-imx: remove redundant code for manual tuning Ulf Hansson
2021-08-24 13:52   ` Ulf Hansson
2021-08-25  2:16   ` Bough Chen
2021-08-25  2:16     ` Bough Chen
2021-08-25  9:22     ` Ulf Hansson
2021-08-25  9:22       ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPDyKFpr9E6xxe2egiRGGWhUSY5aVr29rj1Hb_TwCzrY5bcvpg@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=haibo.chen@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.