diff mbox

mmc: sdhci-of-esdhc: support ESDHC_CAPABILITIES_1 accessing

Message ID 1502281490-975-1-git-send-email-yangbo.lu@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yangbo Lu Aug. 9, 2017, 12:24 p.m. UTC
eSDHC is not a standard SD host controller. SDHCI_CAPABILITIES_1
register address is 0x44 while it's 0x114 (ESDHC_CAPABILITIES_1)
for eSDHC.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
 drivers/mmc/host/sdhci-esdhc.h    |  3 +++
 drivers/mmc/host/sdhci-of-esdhc.c | 23 +++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

Comments

Adrian Hunter Aug. 14, 2017, 11:43 a.m. UTC | #1
On 09/08/17 15:24, Yangbo Lu wrote:
> eSDHC is not a standard SD host controller. SDHCI_CAPABILITIES_1
> register address is 0x44 while it's 0x114 (ESDHC_CAPABILITIES_1)
> for eSDHC.
> 
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

Apart from the redundant parenthesis:

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

> ---
>  drivers/mmc/host/sdhci-esdhc.h    |  3 +++
>  drivers/mmc/host/sdhci-of-esdhc.c | 23 +++++++++++++++++++++--
>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
> index c4bbd74..98898a3 100644
> --- a/drivers/mmc/host/sdhci-esdhc.h
> +++ b/drivers/mmc/host/sdhci-esdhc.h
> @@ -53,6 +53,9 @@
>  #define ESDHC_CLOCK_HCKEN		0x00000002
>  #define ESDHC_CLOCK_IPGEN		0x00000001
>  
> +/* Host Controller Capabilities Register 2 */
> +#define ESDHC_CAPABILITIES_1		0x114
> +
>  /* Tuning Block Control Register */
>  #define ESDHC_TBCTL			0x120
>  #define ESDHC_TB_EN			0x00000004
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index d10f831..cd85a18 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -86,6 +86,17 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
>  		return ret;
>  	}
>  
> +	/*
> +	 * DTS properties of mmc host are used to enable each speed mode
> +	 * according to soc and board capability. So clean up
> +	 * SDR50/SDR104/DDR50 support bits here.
> +	 */
> +	if (spec_reg == SDHCI_CAPABILITIES_1) {
> +		ret = value & (~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |

Redundant parenthesis.

> +				 SDHCI_SUPPORT_DDR50));
> +		return ret;
> +	}
> +
>  	ret = value;
>  	return ret;
>  }
> @@ -249,7 +260,11 @@ static u32 esdhc_be_readl(struct sdhci_host *host, int reg)
>  	u32 ret;
>  	u32 value;
>  
> -	value = ioread32be(host->ioaddr + reg);
> +	if (reg == SDHCI_CAPABILITIES_1)
> +		value = ioread32be(host->ioaddr + ESDHC_CAPABILITIES_1);
> +	else
> +		value = ioread32be(host->ioaddr + reg);
> +
>  	ret = esdhc_readl_fixup(host, reg, value);
>  
>  	return ret;
> @@ -260,7 +275,11 @@ static u32 esdhc_le_readl(struct sdhci_host *host, int reg)
>  	u32 ret;
>  	u32 value;
>  
> -	value = ioread32(host->ioaddr + reg);
> +	if (reg == SDHCI_CAPABILITIES_1)
> +		value = ioread32(host->ioaddr + ESDHC_CAPABILITIES_1);
> +	else
> +		value = ioread32(host->ioaddr + reg);
> +
>  	ret = esdhc_readl_fixup(host, reg, value);
>  
>  	return ret;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index c4bbd74..98898a3 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -53,6 +53,9 @@ 
 #define ESDHC_CLOCK_HCKEN		0x00000002
 #define ESDHC_CLOCK_IPGEN		0x00000001
 
+/* Host Controller Capabilities Register 2 */
+#define ESDHC_CAPABILITIES_1		0x114
+
 /* Tuning Block Control Register */
 #define ESDHC_TBCTL			0x120
 #define ESDHC_TB_EN			0x00000004
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index d10f831..cd85a18 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -86,6 +86,17 @@  static u32 esdhc_readl_fixup(struct sdhci_host *host,
 		return ret;
 	}
 
+	/*
+	 * DTS properties of mmc host are used to enable each speed mode
+	 * according to soc and board capability. So clean up
+	 * SDR50/SDR104/DDR50 support bits here.
+	 */
+	if (spec_reg == SDHCI_CAPABILITIES_1) {
+		ret = value & (~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
+				 SDHCI_SUPPORT_DDR50));
+		return ret;
+	}
+
 	ret = value;
 	return ret;
 }
@@ -249,7 +260,11 @@  static u32 esdhc_be_readl(struct sdhci_host *host, int reg)
 	u32 ret;
 	u32 value;
 
-	value = ioread32be(host->ioaddr + reg);
+	if (reg == SDHCI_CAPABILITIES_1)
+		value = ioread32be(host->ioaddr + ESDHC_CAPABILITIES_1);
+	else
+		value = ioread32be(host->ioaddr + reg);
+
 	ret = esdhc_readl_fixup(host, reg, value);
 
 	return ret;
@@ -260,7 +275,11 @@  static u32 esdhc_le_readl(struct sdhci_host *host, int reg)
 	u32 ret;
 	u32 value;
 
-	value = ioread32(host->ioaddr + reg);
+	if (reg == SDHCI_CAPABILITIES_1)
+		value = ioread32(host->ioaddr + ESDHC_CAPABILITIES_1);
+	else
+		value = ioread32(host->ioaddr + reg);
+
 	ret = esdhc_readl_fixup(host, reg, value);
 
 	return ret;