]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: arm_pl180_mmci: Simplify code using mmc_of_parse()
authorStephan Gerhold <stephan@gerhold.net>
Tue, 6 Jul 2021 14:54:35 +0000 (16:54 +0200)
committerPeng Fan <peng.fan@nxp.com>
Fri, 30 Jul 2021 09:13:02 +0000 (17:13 +0800)
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>
drivers/mmc/arm_pl180_mmci.c

index e632eed03fa34feec9e9b646c8a3da9134479c57..809b86570af85e254530f1dd79c608707a1c5db8 100644 (file)
@@ -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;