From: "NG, TZE YEE" <tze.yee.ng@altera.com>
To: "Kathpalia, Tanmay" <tanmay.kathpalia@altera.com>, u-boot@lists.denx.de
Cc: Peng Fan <peng.fan@nxp.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Tom Rini <trini@konsulko.com>,
Marek Vasut <marek.vasut+socfpga@mailbox.org>,
Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>,
Tien Fong Chee <tien.fong.chee@altera.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
u-boot@lists.u-boot-project.org,
Chen Huei Lok <chen.huei.lok@altera.com>,
Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>,
Dinesh Maniyam <dinesh.maniyam@altera.com>,
Boon Khai Ng <boon.khai.ng@altera.com>,
Kok Kiang Hea <kok.kiang.hea@altera.com>
Subject: Re: [PATCH 2/4] mmc: sdhci-cadence6: name PHY and controller config table slots
Date: Mon, 21 Sep 2026 11:40:11 +0800 [thread overview]
Message-ID: <3a972195-e654-48ec-abc2-089af3934a02@altera.com> (raw)
In-Reply-To: <327b821c-3f0b-4f1f-8784-5f53c4afabe5@altera.com>
On 13/9/2026 4:36 am, Kathpalia, Tanmay wrote:
>
> On 26-08-2026 08:23, tze.yee.ng@altera.com wrote:
>> From: Tze Yee Ng <tze.yee.ng@altera.com>
>>
>> sdhci_cdns6_phy_adj() programs the PHY and HRS controller registers by
>> indexing the *_phy_cfgs[] and *_ctrl_cfgs[] tables with bare positional
>> constants. This is fragile: reordering or inserting a table entry
>> silently changes which register each slot programs.
>>
>> Introduce enums that name every PHY and controller configuration slot,
>> whose terminators double as the table sizes (SDHCI_CDNS6_PHY_CFG_NUM and
>> SDHCI_CDNS6_CTRL_CFG_NUM), and use those names when programming the
>> registers. No functional change.
>>
>> Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
>> ---
>> drivers/mmc/sdhci-cadence6.c | 54 ++++++++++++++++++++++++++++--------
>> 1 file changed, 43 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/mmc/sdhci-cadence6.c b/drivers/mmc/sdhci-cadence6.c
>> index 1ff974ecd44..7bd47b462a4 100644
>> --- a/drivers/mmc/sdhci-cadence6.c
>> +++ b/drivers/mmc/sdhci-cadence6.c
>> @@ -59,8 +59,6 @@
>> #define PHY_DLL_SLAVE_CTRL_REG_READ_DQS_CMD_DELAY GENMASK(31, 24)
>> #define PHY_DLL_SLAVE_CTRL_REG_READ_DQS_DELAY GENMASK(7, 0)
>> -#define SDHCI_CDNS6_PHY_CFG_NUM 5
>> -#define SDHCI_CDNS6_CTRL_CFG_NUM 4
>
> Dropping the two size macros leaves a double blank line.
Hi Tanmay,
I will drop the blank line in v2.
Thanks,
Tze Yee
>
>> struct sdhci_cdns6_phy_cfg {
>> const char *property;
>> @@ -72,6 +70,33 @@ struct sdhci_cdns6_ctrl_cfg {
>> u32 val;
>> };
>> +/*
>> + * PHY configuration slots. The enumeration order must match the entry
>> + * order in every *_phy_cfgs[] table; SDHCI_CDNS6_PHY_CFG_NUM tracks the
>> + * table size so the two never drift out of sync.
>> + */
>> +enum {
>> + SDHCI_CDNS6_PHY_CFG_DQS_TIMING,
>> + SDHCI_CDNS6_PHY_CFG_GATE_LPBK_CTRL,
>> + SDHCI_CDNS6_PHY_CFG_DLL_SLAVE_CTRL,
>> + SDHCI_CDNS6_PHY_CFG_DQ_TIMING,
>> + SDHCI_CDNS6_PHY_CFG_DLL_MASTER_CTRL,
>> + SDHCI_CDNS6_PHY_CFG_NUM,
>> +};
>> +
>> +/*
>> + * Controller (HRS) configuration slots. The enumeration order must
>> match
>> + * the entry order in every *_ctrl_cfgs[] table;
>> SDHCI_CDNS6_CTRL_CFG_NUM
>> + * tracks the table size so the two never drift out of sync.
>> + */
>> +enum {
>> + SDHCI_CDNS6_CTRL_CFG_HRS09,
>> + SDHCI_CDNS6_CTRL_CFG_HRS10,
>> + SDHCI_CDNS6_CTRL_CFG_HRS16,
>> + SDHCI_CDNS6_CTRL_CFG_HRS07,
>> + SDHCI_CDNS6_CTRL_CFG_NUM,
>> +};
>> +
>> static const struct sdhci_cdns6_phy_cfg sd_ds_phy_cfgs[] = {
>> { "cdns,phy-dqs-timing-delay-sd-ds", 0x00380004, },
>> { "cdns,phy-gate-lpbk-ctrl-delay-sd-ds", 0x01A00040, },
>> @@ -277,10 +302,14 @@ int sdhci_cdns6_phy_adj(struct udevice *dev,
>> struct sdhci_cdns_plat *plat, u32 m
>> /* Switch On the DLL Reset */
>> sdhci_cdns6_reset_phy_dll(plat, true);
>> - sdhci_cdns6_write_phy_reg(plat, PHY_DQS_TIMING_REG_ADDR,
>> phy_cfgs[0].val);
>> - sdhci_cdns6_write_phy_reg(plat, PHY_GATE_LPBK_CTRL_REG_ADDR,
>> phy_cfgs[1].val);
>> - sdhci_cdns6_write_phy_reg(plat, PHY_DLL_MASTER_CTRL_REG_ADDR,
>> phy_cfgs[4].val);
>> - sdhci_cdns6_write_phy_reg(plat, PHY_DLL_SLAVE_CTRL_REG_ADDR,
>> phy_cfgs[2].val);
>> + sdhci_cdns6_write_phy_reg(plat, PHY_DQS_TIMING_REG_ADDR,
>> + phy_cfgs[SDHCI_CDNS6_PHY_CFG_DQS_TIMING].val);
>> + sdhci_cdns6_write_phy_reg(plat, PHY_GATE_LPBK_CTRL_REG_ADDR,
>> + phy_cfgs[SDHCI_CDNS6_PHY_CFG_GATE_LPBK_CTRL].val);
>> + sdhci_cdns6_write_phy_reg(plat, PHY_DLL_MASTER_CTRL_REG_ADDR,
>> + phy_cfgs[SDHCI_CDNS6_PHY_CFG_DLL_MASTER_CTRL].val);
>> + sdhci_cdns6_write_phy_reg(plat, PHY_DLL_SLAVE_CTRL_REG_ADDR,
>> + phy_cfgs[SDHCI_CDNS6_PHY_CFG_DLL_SLAVE_CTRL].val);
>> /* Switch Off the DLL Reset */
>> ret = sdhci_cdns6_reset_phy_dll(plat, false);
>> @@ -290,7 +319,8 @@ int sdhci_cdns6_phy_adj(struct udevice *dev,
>> struct sdhci_cdns_plat *plat, u32 m
>> }
>> /* Set PHY DQ TIMING control register */
>> - sdhci_cdns6_write_phy_reg(plat, PHY_DQ_TIMING_REG_ADDR,
>> phy_cfgs[3].val);
>> + sdhci_cdns6_write_phy_reg(plat, PHY_DQ_TIMING_REG_ADDR,
>> + phy_cfgs[SDHCI_CDNS6_PHY_CFG_DQ_TIMING].val);
>> /* Set HRS09 register */
>> tmp = readl(plat->hrs_addr + SDHCI_CDNS_HRS09);
>> @@ -298,20 +328,22 @@ int sdhci_cdns6_phy_adj(struct udevice *dev,
>> struct sdhci_cdns_plat *plat, u32 m
>> SDHCI_CDNS_HRS09_EXTENDED_RD_MODE |
>> SDHCI_CDNS_HRS09_RDDATA_EN |
>> SDHCI_CDNS_HRS09_RDCMD_EN);
>> - tmp |= ctrl_cfgs[0].val;
>> + tmp |= ctrl_cfgs[SDHCI_CDNS6_CTRL_CFG_HRS09].val;
>> writel(tmp, plat->hrs_addr + SDHCI_CDNS_HRS09);
>> /* Set HRS10 register */
>> tmp = readl(plat->hrs_addr + SDHCI_CDNS_HRS10);
>> tmp &= ~SDHCI_CDNS_HRS10_HCSDCLKADJ;
>> - tmp |= ctrl_cfgs[1].val;
>> + tmp |= ctrl_cfgs[SDHCI_CDNS6_CTRL_CFG_HRS10].val;
>> writel(tmp, plat->hrs_addr + SDHCI_CDNS_HRS10);
>> /* Set HRS16 register */
>> - writel(ctrl_cfgs[2].val, plat->hrs_addr + SDHCI_CDNS_HRS16);
>> + writel(ctrl_cfgs[SDHCI_CDNS6_CTRL_CFG_HRS16].val,
>> + plat->hrs_addr + SDHCI_CDNS_HRS16);
>> /* Set HRS07 register */
>> - writel(ctrl_cfgs[3].val, plat->hrs_addr + SDHCI_CDNS_HRS07);
>> + writel(ctrl_cfgs[SDHCI_CDNS6_CTRL_CFG_HRS07].val,
>> + plat->hrs_addr + SDHCI_CDNS_HRS07);
>> /*
>> * Wait for the PHY/DLL to settle before the first data transfer.
next prev parent reply other threads:[~2026-09-21 12:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 2:52 [PATCH 0/4] mmc: sdhci-cadence6: harden PHY config tables and enable Agilex5 UHS modes tze.yee.ng
2026-08-26 2:53 ` [PATCH 1/4] mmc: sdhci-cadence6: use const PHY config tables with per-call overrides tze.yee.ng
2026-09-12 20:26 ` Kathpalia, Tanmay
2026-09-21 3:39 ` NG, TZE YEE
2026-08-26 2:53 ` [PATCH 2/4] mmc: sdhci-cadence6: name PHY and controller config table slots tze.yee.ng
2026-09-12 20:36 ` Kathpalia, Tanmay
2026-09-21 3:40 ` NG, TZE YEE [this message]
2026-08-26 2:53 ` [PATCH 3/4] mmc: sdhci-cadence6: configure PHY control register per speed mode tze.yee.ng
2026-09-12 21:06 ` Kathpalia, Tanmay
2026-09-21 3:50 ` NG, TZE YEE
2026-10-03 18:53 ` Kathpalia, Tanmay
2026-10-05 8:06 ` NG, TZE YEE
2026-08-26 2:53 ` [PATCH 4/4] arm: dts: socfpga: agilex5: add SD/eMMC UHS PHY timing tze.yee.ng
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=3a972195-e654-48ec-abc2-089af3934a02@altera.com \
--to=tze.yee.ng@altera.com \
--cc=alif.zakuan.yuslaimi@altera.com \
--cc=boon.khai.ng@altera.com \
--cc=chen.huei.lok@altera.com \
--cc=dinesh.maniyam@altera.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jh80.chung@samsung.com \
--cc=kok.kiang.hea@altera.com \
--cc=marek.vasut+socfpga@mailbox.org \
--cc=peng.fan@nxp.com \
--cc=simon.k.r.goldschmidt@gmail.com \
--cc=tanmay.kathpalia@altera.com \
--cc=tien.fong.chee@altera.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=u-boot@lists.u-boot-project.org \
/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