u-boot-amlogic archives
 help / color / mirror / Atom feed
From: Yao Zi <ziyao@disroot.org>
To: Ferass El Hafidi <funderscore@postmarketos.org>,
	Tom Rini <trini@konsulko.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Peng Fan <peng.fan@nxp.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Beniamino Galvani <b.galvani@gmail.com>
Cc: Jonas Karlman <jonas@kwiboo.se>, Simon Glass <sjg@chromium.org>,
	u-boot@lists.denx.de, u-boot-amlogic@groups.io,
	~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH RFC v3 2/8] mmc: meson_gx_mmc: add minimal non-DM driver
Date: Thu, 9 Oct 2025 09:09:48 +0000	[thread overview]
Message-ID: <aOd73MIbAhvilmWK@pie> (raw)
In-Reply-To: <20251008-spl-gx-v3-2-5999637df4b9@postmarketos.org>

On Wed, Oct 08, 2025 at 10:00:38AM +0000, Ferass El Hafidi wrote:
> Add a minimal non-DM MMC driver for use in size-constrained
> environments.
> 
> Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
> ---
>  arch/arm/include/asm/arch-meson/gx.h |  5 +++
>  drivers/mmc/meson_gx_mmc.c           | 75 +++++++++++++++++++++++++++++++++++-
>  2 files changed, 79 insertions(+), 1 deletion(-)
> 
> --- a/drivers/mmc/meson_gx_mmc.c
> +++ b/drivers/mmc/meson_gx_mmc.c

...

> +#if !CONFIG_IS_ENABLED(DM_MMC)

This is a large conditional compilation block with nested #if's, do you
think commenting #else and #endif with the condition improves the
readibility? i.e.

	#if !CONFIG_IS_ENABLED(DM_MMC)

	...

	#else /* !CONFIG_IS_ENALBED(DM_MMC) */

	...

	#endif /* CONFIG_IS_ENALBED(DM_MMC) */

Best regards,
Yao Zi

> +struct meson_mmc_plat mmc_plat[2];
> +
> +static int meson_legacy_mmc_init(struct mmc *mmc)
> +{
> +	/* reset all status bits */
> +	meson_write(mmc, STATUS_MASK, MESON_SD_EMMC_STATUS);
> +
> +	/* disable interrupts */
> +	meson_write(mmc, 0, MESON_SD_EMMC_IRQ_EN);
> +
> +	return 0;
> +}
> +
> +static const struct mmc_ops meson_mmc_ops = {
> +	.send_cmd	= meson_legacy_mmc_send_cmd,
> +	.set_ios	= meson_legacy_mmc_set_ios,
> +	.init		= meson_legacy_mmc_init,
> +};
> +
> +struct mmc *meson_mmc_init(int mmc_no)
> +{
> +	struct meson_mmc_plat *pdata = &mmc_plat[mmc_no];
> +	struct mmc_config *cfg = &pdata->cfg;
> +
> +	cfg->voltages = MMC_VDD_33_34 | MMC_VDD_32_33 |
> +			MMC_VDD_31_32 | MMC_VDD_165_195;
> +	cfg->host_caps = MMC_MODE_8BIT | MMC_MODE_4BIT;
> +	cfg->f_min = DIV_ROUND_UP(SD_EMMC_CLKSRC_24M, CLK_MAX_DIV);
> +	cfg->f_max = 6000000; /* 6 MHz */
> +	cfg->b_max = 127; /* max 128 - 1 block */
> +	cfg->name = "Meson SD/eMMC";
> +	cfg->ops = &meson_mmc_ops;
> +
> +	if (mmc_no == 0) /* MMC1: SD card */
> +		pdata->regbase = (void *)0xd0072000;
> +	else if (mmc_no == 1) /* MMC2: eMMC */
> +		pdata->regbase = (void *)0xd0074000;
> +
> +#if CONFIG_IS_ENABLED(MMC_PWRSEQ)
> +	/* Enable power if needed */
> +	ret = mmc_pwrseq_get_power(dev, cfg);
> +	if (!ret) {
> +		ret = pwrseq_set_power(cfg->pwr_dev, true);
> +		if (ret)
> +			return ret;
> +	}
> +#endif
> +
> +	return mmc_create(cfg, pdata);
> +}
> +
> +#else
>  static const struct dm_mmc_ops meson_dm_mmc_ops = {
>  	.send_cmd = meson_dm_mmc_send_cmd,
>  	.set_ios = meson_dm_mmc_set_ios,
> @@ -282,6 +348,12 @@ static int meson_mmc_probe(struct udevice *dev)
>  	cfg->b_max = 511; /* max 512 - 1 blocks */
>  	cfg->name = dev->name;
>  
> +	if (IS_ENABLED(CONFIG_SPL_BUILD)) {
> +		cfg->host_caps &= ~(MMC_MODE_HS_52MHz | MMC_MODE_HS);
> +		cfg->f_max = 6000000; /* 6 MHz */
> +		cfg->b_max = 127; /* max 128 - 1 block */
> +	}
> +
>  	mmc->priv = pdata;
>  	upriv->mmc = mmc;
>  
> @@ -336,3 +408,4 @@ U_BOOT_DRIVER(meson_mmc) = {
>  	.of_to_plat = meson_mmc_of_to_plat,
>  	.plat_auto	= sizeof(struct meson_mmc_plat),
>  };
> +#endif
> 
> -- 
> 2.51.0
> 


  parent reply	other threads:[~2025-10-14  7:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 10:00 [PATCH RFC v3 0/8] initial U-Boot SPL support on Amlogic GX SoCs Ferass El Hafidi
2025-10-08 10:00 ` [PATCH RFC v3 1/8] tools: mkimage: Add Amlogic Boot Image type Ferass El Hafidi
2025-10-08 10:00 ` [PATCH RFC v3 2/8] mmc: meson_gx_mmc: add minimal non-DM driver Ferass El Hafidi
2025-10-08 13:33   ` Neil Armstrong
2025-10-08 13:55     ` Ferass El Hafidi
2025-10-09  9:09   ` Yao Zi [this message]
2025-10-09  9:12     ` Ferass El Hafidi
2025-10-08 10:00 ` [PATCH RFC v3 3/8] serial: serial_meson: " Ferass El Hafidi
2025-10-08 13:31   ` Neil Armstrong
2025-10-08 10:00 ` [PATCH RFC v3 4/8] arm: meson: initial u-boot SPL support for GX SoCs Ferass El Hafidi
2025-10-08 13:32   ` Neil Armstrong
2025-10-08 10:00 ` [PATCH RFC v3 5/8] arm: meson: spl: add support for SPL DRAM init Ferass El Hafidi
2025-10-08 10:00 ` [PATCH RFC v3 6/8] arm: dts: meson-gx-u-boot: add binman configuration for U-Boot SPL Ferass El Hafidi
2025-10-08 10:00 ` [PATCH RFC v3 7/8] board: amlogic: add kconfig fragments for SPL Ferass El Hafidi
2025-10-08 10:00 ` [PATCH RFC v3 8/8] doc: board: amlogic: add u-boot-spl documentation Ferass El Hafidi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aOd73MIbAhvilmWK@pie \
    --to=ziyao@disroot.org \
    --cc=b.galvani@gmail.com \
    --cc=funderscore@postmarketos.org \
    --cc=jh80.chung@samsung.com \
    --cc=jonas@kwiboo.se \
    --cc=neil.armstrong@linaro.org \
    --cc=peng.fan@nxp.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot-amlogic@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox