Re: [RFC PATCH v3.1 12/27] mmc: sdhci-uhs2: add reset function

Adrian Hunter
2020-11-30T07:38:35Z

On 30/11/20 8:20 am, AKASHI Takahiro wrote:
> On Thu, Nov 26, 2020 at 10:16:11AM +0200, Adrian Hunter wrote:
>> On 6/11/20 4:27 am, AKASHI Takahiro wrote:
>>> Sdhci_uhs2_reset() does a UHS-II specific reset operation.
>>>
>>> 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 | 49 +++++++++++++++++++++++++++++++++++
>>> drivers/mmc/host/sdhci-uhs2.h | 1 +
>>> drivers/mmc/host/sdhci.c | 3 ++-
>>> drivers/mmc/host/sdhci.h | 1 +
>>> 4 files changed, 53 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
>>> index 08905ed081fb..e2b9743fe17d 100644
>>> --- a/drivers/mmc/host/sdhci-uhs2.c
>>> +++ b/drivers/mmc/host/sdhci-uhs2.c
>>> @@ -10,6 +10,7 @@
>>> * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
>>> */
>>>
>>> +#include <linux/delay.h>
>>> #include <linux/module.h>
>>>
>>> #include "sdhci.h"
>>> @@ -49,6 +50,54 @@ void sdhci_uhs2_dump_regs(struct sdhci_host *host)
>>> }
>>> EXPORT_SYMBOL_GPL(sdhci_uhs2_dump_regs);
>>>
>>> +/*****************************************************************************\
>>> + * *
>>> + * Low level functions *
>>> + * *
>>> +\*****************************************************************************/
>>> +
>>> +/**
>>> + * sdhci_uhs2_reset - invoke SW reset
>>> + * @host: SDHCI host
>>> + * @mask: Control mask
>>> + *
>>> + * Invoke SW reset, depending on a bit in @mask and wait for completion.
>>> + */
>>> +void sdhci_uhs2_reset(struct sdhci_host *host, u16 mask)
>>> +{
>>> + unsigned long timeout;
>>> +
>>> + if (!(host->mmc->caps & MMC_CAP_UHS2))
>>
>> Please make a helper so this can be like:
>>
>> if (!sdhci_uhs2_mode(host))
>>
>> The capability will be always present for hosts that support UHS2, but not
>> all cards support UHS2 mode. I suggest just adding a bool to struct
>> sdhci_host to keep track of when the host is in UHS2 mode.
>
> Given the fact that UHS-2 host may (potentially) support a topology like
> a ring, this kind of status should be attributed to a card (structure)
> rather than a host.

It is very unlikely we would ever need to support that, so don't let it make
things more complicated.