mmc: sdhci: remove the unnecessary arguments for sdhci_setup_cfg

Some arguments don't need to pass to sdhci_setup_cfg.
Generic variable can be used in sdhci_setup_cfg, and some arguments are
already included in sdhci_host struct.

It's enough that just pass the board specific things to sdhci_setup_cfg().
After removing the unnecessary arguments, it's more simpler than before.
It doesn't consider "Version" and "Capabilities" anymore in each SoC
driver.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
master
Jaehoon Chung 8 years ago
parent 6a879ec8e7
commit 14bed52d27
  1. 4
      drivers/mmc/msm_sdhci.c
  2. 8
      drivers/mmc/rockchip_sdhci.c
  3. 26
      drivers/mmc/sdhci.c
  4. 6
      drivers/mmc/zynq_sdhci.c
  5. 12
      include/sdhci.h

@ -143,9 +143,7 @@ static int msm_sdc_probe(struct udevice *dev)
/* Set host controller version */ /* Set host controller version */
host->version = sdhci_readw(host, SDHCI_HOST_VERSION); host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
caps = sdhci_readl(host, SDHCI_CAPABILITIES); ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
ret = sdhci_setup_cfg(&plat->cfg, dev->name, caps,
0, 0, host->version, host->quirks, 0);
host->mmc = &plat->mmc; host->mmc = &plat->mmc;
if (ret) if (ret)
return ret; return ret;

@ -33,15 +33,11 @@ static int arasan_sdhci_probe(struct udevice *dev)
struct rockchip_sdhc *prv = dev_get_priv(dev); struct rockchip_sdhc *prv = dev_get_priv(dev);
struct sdhci_host *host = &prv->host; struct sdhci_host *host = &prv->host;
int ret; int ret;
u32 caps;
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD; host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD;
caps = sdhci_readl(host, SDHCI_CAPABILITIES); ret = sdhci_setup_cfg(&plat->cfg, host, CONFIG_ROCKCHIP_SDHCI_MAX_FREQ,
ret = sdhci_setup_cfg(&plat->cfg, dev->name, host->bus_width, EMMC_MIN_FREQ);
caps, CONFIG_ROCKCHIP_SDHCI_MAX_FREQ, EMMC_MIN_FREQ,
host->version, host->quirks, 0);
host->mmc = &plat->mmc; host->mmc = &plat->mmc;
if (ret) if (ret)

@ -511,18 +511,22 @@ static const struct mmc_ops sdhci_ops = {
}; };
#endif #endif
int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host,
uint caps, u32 max_clk, u32 min_clk, uint version, u32 max_clk, u32 min_clk)
uint quirks, uint host_caps)
{ {
cfg->name = name; u32 caps;
caps = sdhci_readl(host, SDHCI_CAPABILITIES);
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
cfg->name = host->name;
#ifndef CONFIG_DM_MMC_OPS #ifndef CONFIG_DM_MMC_OPS
cfg->ops = &sdhci_ops; cfg->ops = &sdhci_ops;
#endif #endif
if (max_clk) if (max_clk)
cfg->f_max = max_clk; cfg->f_max = max_clk;
else { else {
if (version >= SDHCI_SPEC_300) if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300)
cfg->f_max = (caps & SDHCI_CLOCK_V3_BASE_MASK) >> cfg->f_max = (caps & SDHCI_CLOCK_V3_BASE_MASK) >>
SDHCI_CLOCK_BASE_SHIFT; SDHCI_CLOCK_BASE_SHIFT;
else else
@ -535,7 +539,7 @@ int sdhci_setup_cfg(struct mmc_config *cfg, const char *name,
if (min_clk) if (min_clk)
cfg->f_min = min_clk; cfg->f_min = min_clk;
else { else {
if (version >= SDHCI_SPEC_300) if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300)
cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_300; cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_300;
else else
cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_200; cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_200;
@ -549,13 +553,13 @@ int sdhci_setup_cfg(struct mmc_config *cfg, const char *name,
cfg->voltages |= MMC_VDD_165_195; cfg->voltages |= MMC_VDD_165_195;
cfg->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT; cfg->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT;
if (version >= SDHCI_SPEC_300) { if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) {
if (caps & SDHCI_CAN_DO_8BIT) if (caps & SDHCI_CAN_DO_8BIT)
cfg->host_caps |= MMC_MODE_8BIT; cfg->host_caps |= MMC_MODE_8BIT;
} }
if (host_caps) if (host->host_caps)
cfg->host_caps |= host_caps; cfg->host_caps |= host->host_caps;
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
@ -582,9 +586,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
} }
#endif #endif
if (sdhci_setup_cfg(&host->cfg, host->name, caps, if (sdhci_setup_cfg(&host->cfg, host, max_clk, min_clk)) {
max_clk, min_clk, SDHCI_GET_VERSION(host),
host->quirks, host->host_caps)) {
printf("%s: Hardware doesn't specify base clock frequency\n", printf("%s: Hardware doesn't specify base clock frequency\n",
__func__); __func__);
return -EINVAL; return -EINVAL;

@ -40,10 +40,8 @@ static int arasan_sdhci_probe(struct udevice *dev)
host->version = sdhci_readw(host, SDHCI_HOST_VERSION); host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
caps = sdhci_readl(host, SDHCI_CAPABILITIES); caps = sdhci_readl(host, SDHCI_CAPABILITIES);
ret = sdhci_setup_cfg(&plat->cfg, dev->name, ret = sdhci_setup_cfg(&plat->cfg, host, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
caps, CONFIG_ZYNQ_SDHCI_MAX_FREQ, CONFIG_ZYNQ_SDHCI_MIN_FREQ);
CONFIG_ZYNQ_SDHCI_MIN_FREQ, host->version,
host->quirks, 0);
host->mmc = &plat->mmc; host->mmc = &plat->mmc;
if (ret) if (ret)
return ret; return ret;

@ -367,18 +367,12 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg)
* See msm_sdhci.c for an example. * See msm_sdhci.c for an example.
* *
* @cfg: Configuration structure to fill in (generally &plat->mmc) * @cfg: Configuration structure to fill in (generally &plat->mmc)
* @name: Device name (normally dev->name) * @host: SDHCI host structure
* @caps: Host capabilities (MMC_MODE_...)
* @max_clk: Maximum supported clock speed in HZ (0 for default) * @max_clk: Maximum supported clock speed in HZ (0 for default)
* @min_clk: Minimum supported clock speed in HZ (0 for default) * @min_clk: Minimum supported clock speed in HZ (0 for default)
* @version: Host controller version (generally read from the
* SDHCI_HOST_VERSION register)
* @quirks: Quick flags (SDHCI_QUIRK_...)
* @host_caps: Additional host capabilities (0 if none)
*/ */
int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host,
uint caps, u32 max_clk, u32 min_clk, uint version, u32 max_clk, u32 min_clk);
uint quirks, uint host_caps);
/** /**
* sdhci_bind() - Set up a new MMC block device * sdhci_bind() - Set up a new MMC block device

Loading…
Cancel
Save