From: Siva Durga Prasad Paladugu Date: Wed, 1 Feb 2017 19:40:40 +0000 (+0530) Subject: mmc: sdhci: Update host capabilities about host controller X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f41b55e85365e74f04292570a2239e661980fa30;p=thirdparty%2Fu-boot.git mmc: sdhci: Update host capabilities about host controller Update host capabilities for driver with host controller information related to UHS modes incase of SD and HS200 mode incase of eMMC. Signed-off-by: Siva Durga Prasad Paladugu Signed-off-by: Michal Simek --- diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index cbf5f56221c..acae3eaf492 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -536,7 +536,8 @@ static const struct mmc_ops sdhci_ops = { int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, u32 max_clk, u32 min_clk) { - u32 caps, caps_1; + u32 caps; + u32 caps_1 = 0; caps = sdhci_readl(host, SDHCI_CAPABILITIES); @@ -598,10 +599,37 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, cfg->host_caps |= MMC_MODE_8BIT; } + if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) + caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); + + if (!(cfg->voltages & MMC_VDD_165_195)) + caps_1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | + SDHCI_SUPPORT_DDR50); + + if (caps_1 & (SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | + SDHCI_SUPPORT_DDR50)) + cfg->host_caps |= MMC_MODE_UHS_SDR12 | MMC_MODE_UHS_SDR25; + + if (caps_1 & SDHCI_SUPPORT_SDR104) { + cfg->host_caps |= MMC_MODE_UHS_SDR104 | MMC_MODE_UHS_SDR50; + /* + * SD3.0: SDR104 is supported so (for eMMC) the caps2 + * field can be promoted to support HS200. + */ + cfg->host_caps |= MMC_MODE_HS200; + } else if (caps_1 & SDHCI_SUPPORT_SDR50) { + cfg->host_caps |= MMC_MODE_UHS_SDR50; + } + + if (caps_1 & SDHCI_SUPPORT_DDR50) + cfg->host_caps |= MMC_MODE_UHS_DDR50; + + if (caps_1 & SDHCI_USE_SDR50_TUNING) + cfg->host_caps |= MMC_MODE_NEEDS_TUNING; + if (host->host_caps) cfg->host_caps |= host->host_caps; - cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; /* diff --git a/include/mmc.h b/include/mmc.h index 1720955a4c9..7415acfdf23 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -58,6 +58,13 @@ #define MMC_MODE_8BIT (1 << 3) #define MMC_MODE_SPI (1 << 4) #define MMC_MODE_DDR_52MHz (1 << 5) +#define MMC_MODE_UHS_SDR12 (1 << 6) +#define MMC_MODE_UHS_SDR25 (1 << 7) +#define MMC_MODE_UHS_SDR50 (1 << 8) +#define MMC_MODE_UHS_SDR104 (1 << 9) +#define MMC_MODE_UHS_DDR50 (1 << 10) +#define MMC_MODE_NEEDS_TUNING (1 << 11) +#define MMC_MODE_HS200 (1 << 12) #define SD_DATA_4BIT 0x00040000 diff --git a/include/sdhci.h b/include/sdhci.h index 144570f2be9..1c6e9bd96ec 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -167,6 +167,12 @@ #define SDHCI_CAN_64BIT 0x10000000 #define SDHCI_CAPABILITIES_1 0x44 +#define SDHCI_SUPPORT_SDR50 0x00000001 +#define SDHCI_SUPPORT_SDR104 0x00000002 +#define SDHCI_SUPPORT_DDR50 0x00000004 +#define SDHCI_USE_SDR50_TUNING 0x00002000 +#define SDHCI_SUPPORT_HS400 0x80000000 /* Non-standard */ + #define SDHCI_CLOCK_MUL_MASK 0x00FF0000 #define SDHCI_CLOCK_MUL_SHIFT 16