Re: [RFC PATCH v3.1 13/27] mmc: sdhci-uhs2: add set_power() to support vdd2

Adrian Hunter
2020-11-30T07:46:02Z

On 30/11/20 9:15 am, AKASHI Takahiro wrote:
> On Thu, Nov 26, 2020 at 10:16:27AM +0200, Adrian Hunter wrote:
>> On 6/11/20 4:27 am, AKASHI Takahiro wrote:
>>> This is a UHS-II version of sdhci's set_power operation.
>>> VDD2, as well as VDD, is handled here.
>>>
>>> Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw>
>>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
>>> ---
>>> drivers/mmc/host/sdhci-uhs2.c | 80 +++++++++++++++++++++++++++++++++++
>>> drivers/mmc/host/sdhci-uhs2.h | 2 +
>>> drivers/mmc/host/sdhci.c | 58 +++++++++++++++----------
>>> drivers/mmc/host/sdhci.h | 2 +
>>> 4 files changed, 119 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
>>> index e2b9743fe17d..2bf78cc4e9ed 100644
>>> --- a/drivers/mmc/host/sdhci-uhs2.c
>>> +++ b/drivers/mmc/host/sdhci-uhs2.c
>>> @@ -98,6 +98,86 @@ void sdhci_uhs2_reset(struct sdhci_host *host, u16 mask)
>>> }
>>> EXPORT_SYMBOL_GPL(sdhci_uhs2_reset);
>>>
>>> +void sdhci_uhs2_set_power(struct sdhci_host *host, unsigned char mode,
>>> + unsigned short vdd)
>>
>> This function isn't used, so let's rename it sdhci_uhs2_set_power_noreg and
>> drop regulator support.
>
> I have no strong opinion, but here Ben might want to further rework
> the new sdhci_uhs2_set_power_noreg() now that it is almost the same as
> GLI's gl9755_set_power()(, adding a new quirk?).
>
>>> +{
>>> + struct mmc_host *mmc = host->mmc;
>>> + u8 pwr;
>>> +
>>> + /* FIXME: check if flags & MMC_UHS2_SUPPORT? */
>>> + if (!(host->mmc->caps & MMC_CAP_UHS2)) {
>>
>> As commented in another patch, please use a helper fn
>
> As said, I would defer this.
>
>>> + sdhci_set_power(host, mode, vdd);
>>> + return;
>>> + }
>>> +
>>> + if (mode != MMC_POWER_OFF) {
>>> + pwr = sdhci_get_vdd_value(vdd);
>>
>> Simpler to open code this esp. as there are only 2 valid values:
>>
>> switch (1 << vdd) {
>
> Can you ignore MMC_VDD_165_195 and MMC_VDD_20_21 here?

They are outside UHS-II spec, but you decide.