diff mbox series

[13/14] mmc: sdhci-esdhc-imx: handle 'auto-cmd23-broken' from devicetree

Message ID 1573816712-26841-4-git-send-email-haibo.chen@nxp.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Bough Chen Nov. 15, 2019, 11:18 a.m. UTC
From: Haibo Chen <haibo.chen@nxp.com>

Since L4.15, community involve the commit 105819c8a545 ("mmc: core: use mrq->sbc
when sending CMD23 for RPMB"), let the usdhc to decide whether to use ACMD23 for
RPMB. This CMD23 for RPMB need to set the bit 31 to its argument, if not, the
RPMB write operation will return general fail.

According to the sdhci logic, SDMA mode will disable the ACMD23, and only in
ADMA mode, it will chose to use ACMD23 if the host support. But according to
debug, and confirm with IC, the imx6qpdl/imx6sx/imx6sl/imx7d do not support
the ACMD23 feature completely. These SoCs only use the 16 bit block count of
the register 0x4 (BLOCK_ATT) as the CMD23's argument in ACMD23 mode, which
means it will ignore the upper 16 bit of the CMD23's argument. This will block
the reliable write operation in RPMB, because RPMB reliable write need to set
the bit31 of the CMD23's argument. This is the hardware limitation. Due to
imx6sl use SDMA, so for imx6qpdl/imx6sx/imx7d, it need to broke the ACMD23 for
eMMC, SD card do not has this limitation, because SD card do not support reliable
write.

For imx6ul/imx6ull/imx6sll/imx7ulp/imx8, it support the ACMD23 completely, it
change to use the 0x0 register (DS_ADDR) to put the CMD23's argument in ADMA mode.

This patch handle 'fsl,auto-cmd23-broken' from devicetree.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Adrian Hunter Nov. 26, 2019, 1:43 p.m. UTC | #1
On 15/11/19 1:18 PM, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> Since L4.15, community involve the commit 105819c8a545 ("mmc: core: use mrq->sbc
> when sending CMD23 for RPMB"), let the usdhc to decide whether to use ACMD23 for
> RPMB. This CMD23 for RPMB need to set the bit 31 to its argument, if not, the
> RPMB write operation will return general fail.
> 
> According to the sdhci logic, SDMA mode will disable the ACMD23, and only in
> ADMA mode, it will chose to use ACMD23 if the host support. But according to
> debug, and confirm with IC, the imx6qpdl/imx6sx/imx6sl/imx7d do not support
> the ACMD23 feature completely. These SoCs only use the 16 bit block count of
> the register 0x4 (BLOCK_ATT) as the CMD23's argument in ACMD23 mode, which
> means it will ignore the upper 16 bit of the CMD23's argument. This will block
> the reliable write operation in RPMB, because RPMB reliable write need to set
> the bit31 of the CMD23's argument. This is the hardware limitation. Due to
> imx6sl use SDMA, so for imx6qpdl/imx6sx/imx7d, it need to broke the ACMD23 for
> eMMC, SD card do not has this limitation, because SD card do not support reliable
> write.
> 
> For imx6ul/imx6ull/imx6sll/imx7ulp/imx8, it support the ACMD23 completely, it
> change to use the 0x0 register (DS_ADDR) to put the CMD23's argument in ADMA mode.
> 
> This patch handle 'fsl,auto-cmd23-broken' from devicetree.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 80a148f8009e..83b4156b2cf4 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1374,6 +1374,9 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
>  	if (of_find_property(np, "no-1-8-v", NULL))
>  		host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
>  
> +	if (of_find_property(np, "fsl,auto-cmd23-broken", NULL))
> +		host->quirks2 |= SDHCI_QUIRK2_ACMD23_BROKEN;

I guess it could be "sdhci,auto-cmd23-broken" and you could put it in
sdhci_get_property() and use that.

> +
>  	if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))
>  		boarddata->delay_line = 0;
>  
>
Bough Chen Nov. 27, 2019, 10:51 a.m. UTC | #2
> -----Original Message-----
> From: Adrian Hunter <adrian.hunter@intel.com>
> Sent: 2019年11月26日 21:43
> To: BOUGH CHEN <haibo.chen@nxp.com>; ulf.hansson@linaro.org;
> shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de
> Cc: festevam@gmail.com; linux-mmc@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>
> Subject: Re: [PATCH 13/14] mmc: sdhci-esdhc-imx: handle 'auto-cmd23-broken'
> from devicetree
> 
> On 15/11/19 1:18 PM, haibo.chen@nxp.com wrote:
> > From: Haibo Chen <haibo.chen@nxp.com>
> >
> > Since L4.15, community involve the commit 105819c8a545 ("mmc: core:
> > use mrq->sbc when sending CMD23 for RPMB"), let the usdhc to decide
> > whether to use ACMD23 for RPMB. This CMD23 for RPMB need to set the
> > bit 31 to its argument, if not, the RPMB write operation will return general
> fail.
> >
> > According to the sdhci logic, SDMA mode will disable the ACMD23, and
> > only in ADMA mode, it will chose to use ACMD23 if the host support.
> > But according to debug, and confirm with IC, the
> > imx6qpdl/imx6sx/imx6sl/imx7d do not support the ACMD23 feature
> > completely. These SoCs only use the 16 bit block count of the register
> > 0x4 (BLOCK_ATT) as the CMD23's argument in ACMD23 mode, which means
> it
> > will ignore the upper 16 bit of the CMD23's argument. This will block
> > the reliable write operation in RPMB, because RPMB reliable write need
> > to set the bit31 of the CMD23's argument. This is the hardware
> > limitation. Due to imx6sl use SDMA, so for imx6qpdl/imx6sx/imx7d, it
> > need to broke the ACMD23 for eMMC, SD card do not has this limitation,
> because SD card do not support reliable write.
> >
> > For imx6ul/imx6ull/imx6sll/imx7ulp/imx8, it support the ACMD23
> > completely, it change to use the 0x0 register (DS_ADDR) to put the CMD23's
> argument in ADMA mode.
> >
> > This patch handle 'fsl,auto-cmd23-broken' from devicetree.
> >
> > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> > ---
> >  drivers/mmc/host/sdhci-esdhc-imx.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> > b/drivers/mmc/host/sdhci-esdhc-imx.c
> > index 80a148f8009e..83b4156b2cf4 100644
> > --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> > @@ -1374,6 +1374,9 @@ sdhci_esdhc_imx_probe_dt(struct
> platform_device *pdev,
> >  	if (of_find_property(np, "no-1-8-v", NULL))
> >  		host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
> >
> > +	if (of_find_property(np, "fsl,auto-cmd23-broken", NULL))
> > +		host->quirks2 |= SDHCI_QUIRK2_ACMD23_BROKEN;
> 
> I guess it could be "sdhci,auto-cmd23-broken" and you could put it in
> sdhci_get_property() and use that.
> 

Okay, will do that in next version patch.

> > +
> >  	if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))
> >  		boarddata->delay_line = 0;
> >
> >
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 80a148f8009e..83b4156b2cf4 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1374,6 +1374,9 @@  sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 	if (of_find_property(np, "no-1-8-v", NULL))
 		host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
 
+	if (of_find_property(np, "fsl,auto-cmd23-broken", NULL))
+		host->quirks2 |= SDHCI_QUIRK2_ACMD23_BROKEN;
+
 	if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))
 		boarddata->delay_line = 0;