mmc: arm_pl180_mmci: Simplify code using mmc_of_parse()
Simplify the code a bit by using the common mmc_of_parse() function instead of duplicating the device tree parsing code. We can still get a default value for cfg->f_max by assigning it before calling mmc_of_parse(). Another advantage of this refactoring is that we parse more properties now, e.g. "non-removable" can be used to disable CD entirely. Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com> on stm32f769-disco Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
This commit is contained in:
parent
19e1da0c66
commit
4daf2ec357
1 changed files with 4 additions and 15 deletions
|
@ -424,7 +424,6 @@ static int arm_pl180_mmc_probe(struct udevice *dev)
|
|||
struct pl180_mmc_host *host = dev_get_priv(dev);
|
||||
struct mmc_config *cfg = &pdata->cfg;
|
||||
struct clk clk;
|
||||
u32 bus_width;
|
||||
u32 periphid;
|
||||
int ret;
|
||||
|
||||
|
@ -457,24 +456,14 @@ static int arm_pl180_mmc_probe(struct udevice *dev)
|
|||
cfg->voltages = VOLTAGE_WINDOW_SD;
|
||||
cfg->host_caps = 0;
|
||||
cfg->f_min = host->clock_in / (2 * (SDI_CLKCR_CLKDIV_INIT_V1 + 1));
|
||||
cfg->f_max = dev_read_u32_default(dev, "max-frequency", MMC_CLOCK_MAX);
|
||||
cfg->f_max = MMC_CLOCK_MAX;
|
||||
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
|
||||
|
||||
gpio_request_by_name(dev, "cd-gpios", 0, &host->cd_gpio, GPIOD_IS_IN);
|
||||
|
||||
bus_width = dev_read_u32_default(dev, "bus-width", 1);
|
||||
switch (bus_width) {
|
||||
case 8:
|
||||
cfg->host_caps |= MMC_MODE_8BIT;
|
||||
/* Hosts capable of 8-bit transfers can also do 4 bits */
|
||||
case 4:
|
||||
cfg->host_caps |= MMC_MODE_4BIT;
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "Invalid bus-width value %u\n", bus_width);
|
||||
}
|
||||
ret = mmc_of_parse(dev, cfg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
arm_pl180_mmc_init(host);
|
||||
mmc->priv = host;
|
||||
|
|
Loading…
Reference in a new issue