diff mbox series

[v2,5/6] mmc: sdhci: add quirk to ignore command inhibit for data

Message ID 20190228073618.16061-5-yinbo.zhu@nxp.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/6] mmc: sdhci-of-esdhc: add erratum eSDHC5 support | expand

Commit Message

Yinbo Zhu Feb. 28, 2019, 7:35 a.m. UTC
From: Yangbo Lu <yangbo.lu@nxp.com>

For some controllers, in Present State Register, Data Line
Active bit is not reliable for commands (such as CMD6, CMD7,
CMD12, CMD28, CMD29, or CMD38) with busy signal. DLA affects
Command with Data Inhibit bit. Therefore, software driver
may not know the busy status in DLA/CDIHB.

Futunately MMC core driver has already polled card status
with CMD13 after sending any command with busy signal. So
we can just ignore CDIHB never released issue for such
controllers. This patch is to add a quirk to handle this.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
Change in v2:
		Instead masking the bit in esdhc_readl_fixup()

 drivers/mmc/host/sdhci-of-esdhc.c |   13 +++++++++++++
 drivers/mmc/host/sdhci.h          |    2 +-
 2 files changed, 14 insertions(+), 1 deletions(-)

Comments

Adrian Hunter Feb. 28, 2019, 1:34 p.m. UTC | #1
On 28/02/19 9:35 AM, Yinbo Zhu wrote:
> From: Yangbo Lu <yangbo.lu@nxp.com>
> 
> For some controllers, in Present State Register, Data Line
> Active bit is not reliable for commands (such as CMD6, CMD7,
> CMD12, CMD28, CMD29, or CMD38) with busy signal. DLA affects
> Command with Data Inhibit bit. Therefore, software driver
> may not know the busy status in DLA/CDIHB.
> 
> Futunately MMC core driver has already polled card status
> with CMD13 after sending any command with busy signal. So
> we can just ignore CDIHB never released issue for such
> controllers. This patch is to add a quirk to handle this.
> 
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
> Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
> ---
> Change in v2:
> 		Instead masking the bit in esdhc_readl_fixup()
> 
>  drivers/mmc/host/sdhci-of-esdhc.c |   13 +++++++++++++
>  drivers/mmc/host/sdhci.h          |    2 +-
>  2 files changed, 14 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index 7e0eae8..8c78ad8 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -147,6 +147,19 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
>  		return ret;
>  	}
>  
> +	/*
> +	 * Some controllers have unreliable Data Line Active
> +	 * bit for commands with busy signal. This affects
> +	 * Command Inhibit (data) bit. Just ignore it since
> +	 * MMC core driver has already polled card status
> +	 * with CMD13 after any command with busy siganl.
> +	 */
> +	if ((spec_reg == SDHCI_PRESENT_STATE) &&
> +	(host->quirks2 & SDHCI_QUIRK2_IGNORE_DATA_INHIBIT)) {

Can you do this without adding a new quirk in sdhci.h?  Perhaps add a flag
to sdhci_esdhc.


> +		ret = value & ~SDHCI_DATA_INHIBIT;
> +		return ret;
> +	}
> +
>  	ret = value;
>  	return ret;
>  }
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 01002cb..65075b8 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -485,7 +485,7 @@ struct sdhci_host {
>   * block count.
>   */
>  #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
> -
> +#define SDHCI_QUIRK2_IGNORE_DATA_INHIBIT		(1<<19)
>  	int irq;		/* Device IRQ */
>  	void __iomem *ioaddr;	/* Mapped address */
>  	char *bounce_buffer;	/* For packing SDMA reads/writes */
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 7e0eae8..8c78ad8 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -147,6 +147,19 @@  static u32 esdhc_readl_fixup(struct sdhci_host *host,
 		return ret;
 	}
 
+	/*
+	 * Some controllers have unreliable Data Line Active
+	 * bit for commands with busy signal. This affects
+	 * Command Inhibit (data) bit. Just ignore it since
+	 * MMC core driver has already polled card status
+	 * with CMD13 after any command with busy siganl.
+	 */
+	if ((spec_reg == SDHCI_PRESENT_STATE) &&
+	(host->quirks2 & SDHCI_QUIRK2_IGNORE_DATA_INHIBIT)) {
+		ret = value & ~SDHCI_DATA_INHIBIT;
+		return ret;
+	}
+
 	ret = value;
 	return ret;
 }
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 01002cb..65075b8 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -485,7 +485,7 @@  struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
-
+#define SDHCI_QUIRK2_IGNORE_DATA_INHIBIT		(1<<19)
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
 	char *bounce_buffer;	/* For packing SDMA reads/writes */