[PATCH 3/4] mmc: arm_pl180_mmci: Simplify code using mmc_of_parse()

Jaehoon Chung jh80.chung at samsung.com
Fri Jul 9 11:30:48 CEST 2021


On 7/6/21 11:54 PM, Stephan Gerhold wrote:
> 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 at gerhold.net>

Reviewed-by: Jaehoon Chung <jh80.chung at samsung.com>

Best Regards,
Jaehoon Chung

> ---
> 
>  drivers/mmc/arm_pl180_mmci.c | 19 ++++---------------
>  1 file changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
> index e632eed03f..809b86570a 100644
> --- a/drivers/mmc/arm_pl180_mmci.c
> +++ b/drivers/mmc/arm_pl180_mmci.c
> @@ -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;
> 



More information about the U-Boot mailing list