Re: [PATCH V12 20/23] mmc: sdhci-uhs2: add add_host() and others to set up the driver

From: Ulf Hansson
Date: Thu Oct 05 2023 - 10:09:35 EST


On Fri, 15 Sept 2023 at 11:44, Victor Shih <victorshihgli@xxxxxxxxx> wrote:
>
> From: Victor Shih <victor.shih@xxxxxxxxxxxxxxxxxxx>
>
> This is a UHS-II version of sdhci's add_host/remove_host operation.
> Any sdhci drivers which are capable of handling UHS-II cards must
> call those functions instead of the corresponding sdhci's.
>
> Signed-off-by: Ben Chuang <ben.chuang@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx>
> Signed-off-by: Victor Shih <victor.shih@xxxxxxxxxxxxxxxxxxx>
> Acked-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>

[...]

Just a few nitpicks, see below.

> +static void __sdhci_uhs2_add_host_v4(struct sdhci_host *host, u32 caps1)
> +{
> + struct mmc_host *mmc;
> + u32 max_current_caps2;
> +
> + mmc = host->mmc;
> +
> + /* Support UHS2 */
> + if (caps1 & SDHCI_SUPPORT_UHS2)
> + mmc->caps2 |= MMC_CAP2_SD_UHS2;
> +
> + max_current_caps2 = sdhci_readl(host, SDHCI_MAX_CURRENT_1);
> +
> + if ((caps1 & SDHCI_CAN_VDD2_180) &&
> + !max_current_caps2 &&
> + !IS_ERR(mmc->supply.vmmc2)) {
> + /* UHS2 - VDD2 */
> + int curr = regulator_get_current_limit(mmc->supply.vmmc2);

As I also stated in another reply, please use vqmmc2 instead, which we
added in patch4.

> +
> + if (curr > 0) {
> + /* convert to SDHCI_MAX_CURRENT format */
> + curr = curr / 1000; /* convert to mA */
> + curr = curr / SDHCI_MAX_CURRENT_MULTIPLIER;
> + curr = min_t(u32, curr, SDHCI_MAX_CURRENT_LIMIT);
> + max_current_caps2 = curr;
> + }
> + }
> +
> + if (!(caps1 & SDHCI_CAN_VDD2_180))
> + mmc->caps2 &= ~MMC_CAP2_SD_UHS2;
> +}
> +
> +static int sdhci_uhs2_host_ops_init(struct sdhci_host *host);

Please try to re-order the code so this declaration isn't needed.

> +
> +static void __sdhci_uhs2_remove_host(struct sdhci_host *host, int dead)
> +{
> + if (!sdhci_uhs2_mode(host))
> + return;
> +
> + if (!dead)
> + sdhci_uhs2_reset(host, SDHCI_UHS2_SW_RESET_FULL);
> +}
> +

[...]

Kind regards
Uffe