[PATCH] mmc: stm32_sdmmc2: Use mmc_of_parse() to read host capabilities

Jaehoon Chung jh80.chung at samsung.com
Wed Sep 16 03:50:07 CEST 2020


On 9/11/20 8:46 PM, Patrick DELAUNAY wrote:
> Hi Jaehoon
> 
>> From: Jaehoon Chung <jh80.chung at samsung.com>
>> Sent: vendredi 11 septembre 2020 09:50
>>
>> On 9/10/20 6:54 AM, Alexandru Gagniuc wrote:
>>> mmc_of_parse() can populate the 'f_max' and 'host_caps' fields of
>>> struct mmc_config from devicetree.
>>> The same logic is duplicated in stm32_sdmmc2_probe(). Use
>>> mmc_of_parse(), which is more generic.
>>>
>>> Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>

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

Best Regards,
Jaehoon Chung

>>> ---
>>>  drivers/mmc/stm32_sdmmc2.c | 18 ++----------------
>>>  1 file changed, 2 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
>>> index 6d50356217..77871d5afc 100644
>>> --- a/drivers/mmc/stm32_sdmmc2.c
>>> +++ b/drivers/mmc/stm32_sdmmc2.c
>>> @@ -676,27 +676,13 @@ static int stm32_sdmmc2_probe(struct udevice *dev)
>>>  			     GPIOD_IS_IN);
>>>
>>>  	cfg->f_min = 400000;
>>> -	cfg->f_max = dev_read_u32_default(dev, "max-frequency", 52000000);
>>>  	cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 |
>> MMC_VDD_165_195;
>>>  	cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
>>>  	cfg->name = "STM32 SD/MMC";
>>>
>>>  	cfg->host_caps = 0;
>>> -	if (cfg->f_max > 25000000)
>>> -		cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
>>> -
>>> -	switch (dev_read_u32_default(dev, "bus-width", 1)) {
>>> -	case 8:
>>> -		cfg->host_caps |= MMC_MODE_8BIT;
>>> -		/* fall through */
>>> -	case 4:
>>> -		cfg->host_caps |= MMC_MODE_4BIT;
>>> -		break;
>>> -	case 1:
>>> -		break;
>>> -	default:
>>> -		pr_err("invalid \"bus-width\" property, force to 1\n");
>>> -	}
>>> +	cfg->f_max = 52000000;
>>
>> cfg->f_max can be also removed?
>>
>> Best Regards,
>> Jaehoon Chung
> 
> I don't think because " max-frequency" is optional in device tree (only "reg" is required)
> 
> Here 52MHz is a default value when it is absent in device tree
> That avoids cfg->f_max = 0 after mmc_of_parse() call.
> 
>>
>>> +	mmc_of_parse(dev, cfg);
>>>
>>>  	upriv->mmc = &plat->mmc;
>>>
>>>
> 
> Patrick
> 



More information about the U-Boot mailing list