From: Andre Przywara <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>,
Mikhail Kalashnikov <iuncuim@gmail.com>,
Yixun Lan <dlan@gentoo.org>,
Paul Kocialkowski <paulk@sys-base.io>,
linux-sunxi@lists.linux.dev, Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v2 09/20] sunxi: mmc: add support for Allwinner A523 MMC mod clock
Date: Tue, 22 Jul 2025 01:32:00 +0100 [thread overview]
Message-ID: <20250722013200.25622e40@minigeek.lan> (raw)
In-Reply-To: <20250717235455.32528-10-andre.przywara@arm.com>
On Fri, 18 Jul 2025 00:54:44 +0100
Andre Przywara <andre.przywara@arm.com> wrote:
> The Allwinner A523 SoC has a slightly changed mod clock, where the P
> factor, formerly a shift value, is now a second divider value.
> Also the input clock is not PLL_PERIPH0_2X (1200MHz) anymore, but
> PLL_PERIPH0_400M, so adjust the input rate calculation accordingly.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> drivers/mmc/sunxi_mmc.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
> index 06c1e09bf26..7c85030be16 100644
> --- a/drivers/mmc/sunxi_mmc.c
> +++ b/drivers/mmc/sunxi_mmc.c
> @@ -99,6 +99,15 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
> */
> if (IS_ENABLED(CONFIG_MACH_SUN8I_R528))
> pll_hz /= 2;
> +
> + /*
> + * The A523/T527 uses PERIPH0_400M as the MMC input clock,
> + * which is the PERIPH0 nominal rate (1200MHz) / 3.
As Yixun figured correctly, a recent patch fixed the PLL PERIPH0 clock
calculation for NCAT2 chips, so the routine reports 600 MHz, to stay
compatible with older SoCs. So the divider here must be 3, really, not
6.
But this is only half the truth, since for MMC2 the base clock is
PLL_PERIPH0_800M, so we must multiply this by 2 again afterwards, to
reach the proper eMMC frequency.
Fixed in my tree.
Cheers,
Andre
> + * Together with the fixed post-divider of 2 of the MMC mod
> + * clock, that gives a divider of 6.
> + */
> + if (IS_ENABLED(CONFIG_MACH_SUN55I_A523))
> + pll_hz /= 6;
> }
>
> div = pll_hz / hz;
> @@ -153,6 +162,10 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
> CCM_MMC_CTRL_SCLK_DLY(sclk_dly);
> }
>
> + /* The A523 has a second divider, not a shift. */
> + if (IS_ENABLED(CONFIG_MACH_SUN55I_A523))
> + n = (1U << n) - 1;
> +
> writel(CCM_MMC_CTRL_ENABLE| pll | CCM_MMC_CTRL_N(n) |
> CCM_MMC_CTRL_M(div) | val, priv->mclkreg);
>
> @@ -559,7 +572,8 @@ struct mmc *sunxi_mmc_init(int sdc_no)
> cfg->host_caps = MMC_MODE_4BIT;
>
> if ((IS_ENABLED(CONFIG_MACH_SUN50I) || IS_ENABLED(CONFIG_MACH_SUN8I) ||
> - IS_ENABLED(CONFIG_SUN50I_GEN_H6)) && (sdc_no == 2))
> + IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_MACH_SUN55I_A523)) &&
> + (sdc_no == 2))
> cfg->host_caps = MMC_MODE_8BIT;
>
> cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
next prev parent reply other threads:[~2025-07-22 0:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-17 23:54 [PATCH v2 00/20] sunxi: Add Allwinner A523 support Andre Przywara
2025-07-17 23:54 ` [PATCH v2 01/20] sunxi: clock: H6: unify PLL control bit definitions Andre Przywara
2025-07-17 23:54 ` [PATCH v2 02/20] sunxi: clock: H6: factor out clock_set_pll() Andre Przywara
2025-07-17 23:54 ` [PATCH v2 03/20] sunxi: clock: H6: factor out H6/H616 CPU clock setup Andre Przywara
2025-07-17 23:54 ` [PATCH v2 04/20] sunxi: clock: H6: add A523 CPU PLL support Andre Przywara
2025-07-17 23:54 ` [PATCH v2 05/20] sunxi: spl: add support for Allwinner A523 watchdog Andre Przywara
2025-07-17 23:54 ` [PATCH v2 06/20] clk: sunxi: Add support for the A523 CCU Andre Przywara
2025-07-17 23:54 ` [PATCH v2 07/20] clk: sunxi: Add support for the A523 -R CCU Andre Przywara
2025-07-17 23:54 ` [PATCH v2 08/20] pinctrl: sunxi: add Allwinner A523 pinctrl description Andre Przywara
2025-07-17 23:54 ` [PATCH v2 09/20] sunxi: mmc: add support for Allwinner A523 MMC mod clock Andre Przywara
2025-07-22 0:32 ` Andre Przywara [this message]
2025-07-17 23:54 ` [PATCH v2 10/20] power: regulator: add AXP323 support Andre Przywara
2025-07-17 23:54 ` [PATCH v2 11/20] sunxi: update cpu_sunxi_ncat2.h Andre Przywara
2025-07-17 23:54 ` [PATCH v2 12/20] sunxi: sun50i_h6: add A523 SPL clock setup code Andre Przywara
2025-07-22 0:14 ` Andre Przywara
2025-07-27 20:15 ` Jernej Škrabec
2025-07-17 23:54 ` [PATCH v2 13/20] sunxi: A523: add DRAM initialisation routine Andre Przywara
2025-07-27 20:16 ` Jernej Škrabec
2025-07-17 23:54 ` [PATCH v2 14/20] sunxi: A523: add DDR3 DRAM support Andre Przywara
2025-07-25 4:44 ` Mikhail Kalashnikov
2025-07-25 23:48 ` Andre Przywara
2025-07-26 0:04 ` [PATCH] FIXUP! a523: DDR3: rework Andre Przywara
2025-07-17 23:54 ` [PATCH v2 15/20] sunxi: add basic A523 support Andre Przywara
2025-07-17 23:54 ` [PATCH v2 16/20] arm64: dts: allwinner: Add Allwinner A523 .dtsi file Andre Przywara
2025-07-17 23:54 ` [PATCH v2 17/20] arm64: dts: allwinner: a523: add X96Q-Pro+ support Andre Przywara
2025-07-17 23:54 ` [PATCH v2 18/20] arm64: dts: allwinner: a523: add Radxa A5E support Andre Przywara
2025-07-17 23:54 ` [PATCH v2 19/20] arm64: dts: allwinner: a523: add Avaota-A1 router support Andre Przywara
2025-07-17 23:54 ` [PATCH v2 20/20] sunxi: A523: add defconfigs for three boards Andre Przywara
2025-07-22 0:35 ` Andre Przywara
2025-07-22 2:49 ` Yixun Lan
2025-07-22 10:30 ` Andre Przywara
2025-07-19 2:05 ` [PATCH v2 00/20] sunxi: Add Allwinner A523 support Yixun Lan
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=20250722013200.25622e40@minigeek.lan \
--to=andre.przywara@arm.com \
--cc=dlan@gentoo.org \
--cc=iuncuim@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=paulk@sys-base.io \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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