From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew F. Davis Date: Wed, 27 Mar 2019 09:55:01 -0500 Subject: [U-Boot] [PATCH v3 06/13] mmc: sdhci: Add support for sdhci-caps-mask In-Reply-To: <20190212085819.31395-7-faiz_abbas@ti.com> References: <20190212085819.31395-1-faiz_abbas@ti.com> <20190212085819.31395-7-faiz_abbas@ti.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 2/12/19 2:58 AM, Faiz Abbas wrote: > 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 > Reviewed-by: Tom Rini > --- > drivers/mmc/sdhci.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c > index cdeba914f9..c8a8a299ba 100644 > --- a/drivers/mmc/sdhci.c > +++ b/drivers/mmc/sdhci.c > @@ -8,6 +8,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -561,8 +562,15 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, > u32 f_max, u32 f_min) > { > u32 caps, caps_1 = 0; > + u32 mask[2] = {0}; > + int ret; > + > + ret = dev_read_u32_array(host->mmc->dev, "sdhci-caps-mask", > + mask, 2); You can't do this, host->mmc is not setup at this point, you will get a null pointer deref here. (On K3 dereferencing zero does not throw an error so it masks this problem, other platforms (and HS K3) are not so lucky) Andrew > + if (ret && ret != -1) > + return ret; > > - caps = sdhci_readl(host, SDHCI_CAPABILITIES); > + caps = ~mask[1] & sdhci_readl(host, SDHCI_CAPABILITIES); > > #ifdef CONFIG_MMC_SDHCI_SDMA > if (!(caps & SDHCI_CAN_DO_SDMA)) { > @@ -584,7 +592,7 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, > > /* Check whether the clock multiplier is supported or not */ > if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) { > - caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); > + caps_1 = ~mask[0] & sdhci_readl(host, SDHCI_CAPABILITIES_1); > host->clk_mul = (caps_1 & SDHCI_CLOCK_MUL_MASK) >> > SDHCI_CLOCK_MUL_SHIFT; > } > @@ -641,9 +649,6 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, > 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) || > (host->quirks & SDHCI_QUIRK_NO_1_8_V)) > caps_1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | >