mmc: sdhci: Add support for sdhci-caps-mask
Add Support for masking some bits in the capabilities register of a host controller. Also remove the redundant readl() into caps1. Signed-off-by: Faiz Abbas <faiz_abbas@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
		
							parent
							
								
									55a1a09b2a
								
							
						
					
					
						commit
						3d296365e4
					
				|  | @ -8,6 +8,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <common.h> | #include <common.h> | ||||||
|  | #include <dm.h> | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
| #include <mmc.h> | #include <mmc.h> | ||||||
|  | @ -681,8 +682,18 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, | ||||||
| 		u32 f_max, u32 f_min) | 		u32 f_max, u32 f_min) | ||||||
| { | { | ||||||
| 	u32 caps, caps_1 = 0; | 	u32 caps, caps_1 = 0; | ||||||
|  | #if CONFIG_IS_ENABLED(DM_MMC) | ||||||
|  | 	u32 mask[2] = {0}; | ||||||
|  | 	int ret; | ||||||
|  | 	ret = dev_read_u32_array(host->mmc->dev, "sdhci-caps-mask", | ||||||
|  | 				 mask, 2); | ||||||
|  | 	if (ret && ret != -1) | ||||||
|  | 		return ret; | ||||||
| 
 | 
 | ||||||
|  | 	caps = ~mask[1] & sdhci_readl(host, SDHCI_CAPABILITIES); | ||||||
|  | #else | ||||||
| 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_MMC_SDHCI_SDMA | #ifdef CONFIG_MMC_SDHCI_SDMA | ||||||
| 	if (!(caps & SDHCI_CAN_DO_SDMA)) { | 	if (!(caps & SDHCI_CAN_DO_SDMA)) { | ||||||
|  | @ -722,7 +733,11 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, | ||||||
| 
 | 
 | ||||||
| 	/* Check whether the clock multiplier is supported or not */ | 	/* Check whether the clock multiplier is supported or not */ | ||||||
| 	if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) { | 	if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) { | ||||||
|  | #if CONFIG_IS_ENABLED(DM_MMC) | ||||||
|  | 		caps_1 = ~mask[0] & sdhci_readl(host, SDHCI_CAPABILITIES_1); | ||||||
|  | #else | ||||||
| 		caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); | 		caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); | ||||||
|  | #endif | ||||||
| 		host->clk_mul = (caps_1 & SDHCI_CLOCK_MUL_MASK) >> | 		host->clk_mul = (caps_1 & SDHCI_CLOCK_MUL_MASK) >> | ||||||
| 				SDHCI_CLOCK_MUL_SHIFT; | 				SDHCI_CLOCK_MUL_SHIFT; | ||||||
| 	} | 	} | ||||||
|  | @ -779,9 +794,6 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, | ||||||
| 		cfg->host_caps &= ~MMC_MODE_HS_52MHz; | 		cfg->host_caps &= ~MMC_MODE_HS_52MHz; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) |  | ||||||
| 		caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); |  | ||||||
| 
 |  | ||||||
| 	if (!(cfg->voltages & MMC_VDD_165_195) || | 	if (!(cfg->voltages & MMC_VDD_165_195) || | ||||||
| 	    (host->quirks & SDHCI_QUIRK_NO_1_8_V)) | 	    (host->quirks & SDHCI_QUIRK_NO_1_8_V)) | ||||||
| 		caps_1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | | 		caps_1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue