* [PATCH v2 0/3] Fix sd card support for RK3576
@ 2026-01-13 1:18 Shawn Lin
2026-01-13 1:18 ` [PATCH v2 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Shawn Lin @ 2026-01-13 1:18 UTC (permalink / raw)
To: Heiko Stuebner
Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister,
John Clark, Tianling Shen, Detlev Casanova, Shawn Lin
SD card hot-plug support for RK3576 is totally broken. This is because sd slot
should try to use slot-gpio(cd-gpios) instead of function IO for supporting
runtime PM. In order to support slot-gpio method, we should disable jtag
switching for RK3576.
But the rockchip_grf_init fails to handle this because it couldn't handle
multiple grf nodes. In this case, iocgrf is in behind of sysgrf, so only
sysgrf is handled. We should scan all possible nodes.
Moreover, the offset is wrong as well. Per the TRM, the address of
TOP_IOC_IOC_MISC_CON is 0x260440F0, which means the offset if 0x40F0
instead of 0x040F
This series fixes this mess but only adds slot-gpio support for RK3576-EVB1.
Other boards are also missing slot-gpio support, but folks are all cced for
checking the boards they are using.
Please review and test
Changes in v2:
- use for_each_matching_node_and_match(Heiko)
- add fixes tag
Shawn Lin (3):
soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition
soc: rockchip: grf: Support multiple grf to be handled
arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1
arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts | 1 +
drivers/soc/rockchip/grf.c | 54 ++++++++++++------------
2 files changed, 28 insertions(+), 27 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition 2026-01-13 1:18 [PATCH v2 0/3] Fix sd card support for RK3576 Shawn Lin @ 2026-01-13 1:18 ` Shawn Lin 2026-01-13 1:18 ` [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin ` (2 subsequent siblings) 3 siblings, 0 replies; 8+ messages in thread From: Shawn Lin @ 2026-01-13 1:18 UTC (permalink / raw) To: Heiko Stuebner Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister, John Clark, Tianling Shen, Detlev Casanova, Shawn Lin RK3576_IOCGRF_MISC_CON is IOC_GRF + 0x40F0, fix it. Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values") Cc: Detlev Casanova <detlev.casanova@collabora.com> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Reviewed-by: Chaoyi Chen <chaoyi.chen@rock-chips.com> --- Changes in v2: None drivers/soc/rockchip/grf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c index 27bfa09..8974d1c 100644 --- a/drivers/soc/rockchip/grf.c +++ b/drivers/soc/rockchip/grf.c @@ -146,7 +146,7 @@ static const struct rockchip_grf_info rk3576_sysgrf __initconst = { .num_values = ARRAY_SIZE(rk3576_defaults_sys_grf), }; -#define RK3576_IOCGRF_MISC_CON 0x04F0 +#define RK3576_IOCGRF_MISC_CON 0x40F0 static const struct rockchip_grf_value rk3576_defaults_ioc_grf[] __initconst = { { "jtag switching", RK3576_IOCGRF_MISC_CON, FIELD_PREP_WM16_CONST(BIT(1), 0) }, -- 2.7.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled 2026-01-13 1:18 [PATCH v2 0/3] Fix sd card support for RK3576 Shawn Lin 2026-01-13 1:18 ` [PATCH v2 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin @ 2026-01-13 1:18 ` Shawn Lin 2026-01-13 17:43 ` Heiko Stübner 2026-01-13 1:18 ` [PATCH v2 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin 2026-01-13 20:35 ` [PATCH v2 0/3] Fix sd card support for RK3576 Marco Schirrmeister 3 siblings, 1 reply; 8+ messages in thread From: Shawn Lin @ 2026-01-13 1:18 UTC (permalink / raw) To: Heiko Stuebner Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister, John Clark, Tianling Shen, Detlev Casanova, Shawn Lin Currently, only the first matched node will be handled. This leads to jtag switching broken for RK3576, as rk3576-sys-grf is found before rk3576-ioc-grf. Change the code to scan all the possible nodes to fix the problem. Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values") Cc: Detlev Casanova <detlev.casanova@collabora.com> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> --- Changes in v2: - use for_each_matching_node_and_match(Heiko) drivers/soc/rockchip/grf.c | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c index 8974d1c..9b36390 100644 --- a/drivers/soc/rockchip/grf.c +++ b/drivers/soc/rockchip/grf.c @@ -217,34 +217,34 @@ static int __init rockchip_grf_init(void) struct regmap *grf; int ret, i; - np = of_find_matching_node_and_match(NULL, rockchip_grf_dt_match, - &match); - if (!np) - return -ENODEV; - if (!match || !match->data) { - pr_err("%s: missing grf data\n", __func__); + for_each_matching_node_and_match(np, rockchip_grf_dt_match, &match) { + if (!of_device_is_available(np)) + continue; + if (!match || !match->data) { + pr_err("%s: missing grf data\n", __func__); + of_node_put(np); + return -EINVAL; + } + + grf_info = match->data; + + grf = syscon_node_to_regmap(np); of_node_put(np); - return -EINVAL; - } - - grf_info = match->data; - - grf = syscon_node_to_regmap(np); - of_node_put(np); - if (IS_ERR(grf)) { - pr_err("%s: could not get grf syscon\n", __func__); - return PTR_ERR(grf); - } - - for (i = 0; i < grf_info->num_values; i++) { - const struct rockchip_grf_value *val = &grf_info->values[i]; - - pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__, - val->desc, val->reg, val->val); - ret = regmap_write(grf, val->reg, val->val); - if (ret < 0) - pr_err("%s: write to %#6x failed with %d\n", - __func__, val->reg, ret); + if (IS_ERR(grf)) { + pr_err("%s: could not get grf syscon\n", __func__); + return PTR_ERR(grf); + } + + for (i = 0; i < grf_info->num_values; i++) { + const struct rockchip_grf_value *val = &grf_info->values[i]; + + pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__, + val->desc, val->reg, val->val); + ret = regmap_write(grf, val->reg, val->val); + if (ret < 0) + pr_err("%s: write to %#6x failed with %d\n", + __func__, val->reg, ret); + } } return 0; -- 2.7.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled 2026-01-13 1:18 ` [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin @ 2026-01-13 17:43 ` Heiko Stübner 2026-01-14 1:34 ` Shawn Lin 0 siblings, 1 reply; 8+ messages in thread From: Heiko Stübner @ 2026-01-13 17:43 UTC (permalink / raw) To: Shawn Lin Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister, John Clark, Tianling Shen, Detlev Casanova, Shawn Lin Hi Shawn, Am Dienstag, 13. Januar 2026, 02:18:24 Mitteleuropäische Normalzeit schrieb Shawn Lin: > Currently, only the first matched node will be handled. This leads > to jtag switching broken for RK3576, as rk3576-sys-grf is found before > rk3576-ioc-grf. Change the code to scan all the possible nodes to fix > the problem. > > Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values") > Cc: Detlev Casanova <detlev.casanova@collabora.com> > Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> > --- > > Changes in v2: > - use for_each_matching_node_and_match(Heiko) > > drivers/soc/rockchip/grf.c | 54 +++++++++++++++++++++++----------------------- > 1 file changed, 27 insertions(+), 27 deletions(-) > > diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c > index 8974d1c..9b36390 100644 > --- a/drivers/soc/rockchip/grf.c > +++ b/drivers/soc/rockchip/grf.c > @@ -217,34 +217,34 @@ static int __init rockchip_grf_init(void) > struct regmap *grf; > int ret, i; > > - np = of_find_matching_node_and_match(NULL, rockchip_grf_dt_match, > - &match); > - if (!np) > - return -ENODEV; > - if (!match || !match->data) { > - pr_err("%s: missing grf data\n", __func__); > + for_each_matching_node_and_match(np, rockchip_grf_dt_match, &match) { > + if (!of_device_is_available(np)) > + continue; > + if (!match || !match->data) { > + pr_err("%s: missing grf data\n", __func__); > + of_node_put(np); > + return -EINVAL; > + } > + > + grf_info = match->data; > + > + grf = syscon_node_to_regmap(np); > of_node_put(np); This of_node_put can go away I think. for_each_matching_node_and_match iterates over the nodes via of_find_matching_node_and_match(dn, matches, match) [0] and of_find_matching_node_and_match() will of_node_put() the from node [1] Heiko [0] https://elixir.bootlin.com/linux/v6.18.4/source/include/linux/of.h#L1469 [1] https://elixir.bootlin.com/linux/v6.18.4/source/drivers/of/base.c#L1147 > - return -EINVAL; > - } > - > - grf_info = match->data; > - > - grf = syscon_node_to_regmap(np); > - of_node_put(np); > - if (IS_ERR(grf)) { > - pr_err("%s: could not get grf syscon\n", __func__); > - return PTR_ERR(grf); > - } > - > - for (i = 0; i < grf_info->num_values; i++) { > - const struct rockchip_grf_value *val = &grf_info->values[i]; > - > - pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__, > - val->desc, val->reg, val->val); > - ret = regmap_write(grf, val->reg, val->val); > - if (ret < 0) > - pr_err("%s: write to %#6x failed with %d\n", > - __func__, val->reg, ret); > + if (IS_ERR(grf)) { > + pr_err("%s: could not get grf syscon\n", __func__); > + return PTR_ERR(grf); > + } > + > + for (i = 0; i < grf_info->num_values; i++) { > + const struct rockchip_grf_value *val = &grf_info->values[i]; > + > + pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__, > + val->desc, val->reg, val->val); > + ret = regmap_write(grf, val->reg, val->val); > + if (ret < 0) > + pr_err("%s: write to %#6x failed with %d\n", > + __func__, val->reg, ret); > + } > } > > return 0; > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled 2026-01-13 17:43 ` Heiko Stübner @ 2026-01-14 1:34 ` Shawn Lin 0 siblings, 0 replies; 8+ messages in thread From: Shawn Lin @ 2026-01-14 1:34 UTC (permalink / raw) To: Heiko Stübner Cc: shawn.lin, linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister, John Clark, Tianling Shen, Detlev Casanova 在 2026/01/14 星期三 1:43, Heiko Stübner 写道: > Hi Shawn, > > Am Dienstag, 13. Januar 2026, 02:18:24 Mitteleuropäische Normalzeit schrieb Shawn Lin: >> Currently, only the first matched node will be handled. This leads >> to jtag switching broken for RK3576, as rk3576-sys-grf is found before >> rk3576-ioc-grf. Change the code to scan all the possible nodes to fix >> the problem. >> >> Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values") >> Cc: Detlev Casanova <detlev.casanova@collabora.com> >> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> >> --- >> >> Changes in v2: >> - use for_each_matching_node_and_match(Heiko) >> >> drivers/soc/rockchip/grf.c | 54 +++++++++++++++++++++++----------------------- >> 1 file changed, 27 insertions(+), 27 deletions(-) >> >> diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c >> index 8974d1c..9b36390 100644 >> --- a/drivers/soc/rockchip/grf.c >> +++ b/drivers/soc/rockchip/grf.c >> @@ -217,34 +217,34 @@ static int __init rockchip_grf_init(void) >> struct regmap *grf; >> int ret, i; >> >> - np = of_find_matching_node_and_match(NULL, rockchip_grf_dt_match, >> - &match); >> - if (!np) >> - return -ENODEV; >> - if (!match || !match->data) { >> - pr_err("%s: missing grf data\n", __func__); >> + for_each_matching_node_and_match(np, rockchip_grf_dt_match, &match) { >> + if (!of_device_is_available(np)) >> + continue; >> + if (!match || !match->data) { >> + pr_err("%s: missing grf data\n", __func__); >> + of_node_put(np); >> + return -EINVAL; >> + } >> + >> + grf_info = match->data; >> + >> + grf = syscon_node_to_regmap(np); >> of_node_put(np); > > This of_node_put can go away I think. > > for_each_matching_node_and_match iterates over the nodes via > of_find_matching_node_and_match(dn, matches, match) [0] > > and of_find_matching_node_and_match() will of_node_put() the from node [1] > > Oops, will fix. Thanks. > Heiko > > [0] https://elixir.bootlin.com/linux/v6.18.4/source/include/linux/of.h#L1469 > [1] https://elixir.bootlin.com/linux/v6.18.4/source/drivers/of/base.c#L1147 > >> - return -EINVAL; >> - } >> - >> - grf_info = match->data; >> - >> - grf = syscon_node_to_regmap(np); >> - of_node_put(np); >> - if (IS_ERR(grf)) { >> - pr_err("%s: could not get grf syscon\n", __func__); >> - return PTR_ERR(grf); >> - } >> - >> - for (i = 0; i < grf_info->num_values; i++) { >> - const struct rockchip_grf_value *val = &grf_info->values[i]; >> - >> - pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__, >> - val->desc, val->reg, val->val); >> - ret = regmap_write(grf, val->reg, val->val); >> - if (ret < 0) >> - pr_err("%s: write to %#6x failed with %d\n", >> - __func__, val->reg, ret); >> + if (IS_ERR(grf)) { >> + pr_err("%s: could not get grf syscon\n", __func__); >> + return PTR_ERR(grf); >> + } >> + >> + for (i = 0; i < grf_info->num_values; i++) { >> + const struct rockchip_grf_value *val = &grf_info->values[i]; >> + >> + pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__, >> + val->desc, val->reg, val->val); >> + ret = regmap_write(grf, val->reg, val->val); >> + if (ret < 0) >> + pr_err("%s: write to %#6x failed with %d\n", >> + __func__, val->reg, ret); >> + } >> } >> >> return 0; >> > > > > > > _______________________________________________ > Linux-rockchip mailing list > Linux-rockchip@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-rockchip ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 2026-01-13 1:18 [PATCH v2 0/3] Fix sd card support for RK3576 Shawn Lin 2026-01-13 1:18 ` [PATCH v2 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin 2026-01-13 1:18 ` [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin @ 2026-01-13 1:18 ` Shawn Lin 2026-01-13 20:35 ` [PATCH v2 0/3] Fix sd card support for RK3576 Marco Schirrmeister 3 siblings, 0 replies; 8+ messages in thread From: Shawn Lin @ 2026-01-13 1:18 UTC (permalink / raw) To: Heiko Stuebner Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister, John Clark, Tianling Shen, Detlev Casanova, Shawn Lin Without cd-gpios, the sdmmc would not be detected, because during runtime PM, the clock is gated which prevents the irq from issuing. Fixes: f135a1a07352 ("arm64: dts: rockchip: Add rk3576 evb1 board") Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> --- Changes in v2: - add fixes tag arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts b/arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts index 0789733..b583cec 100644 --- a/arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts +++ b/arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts @@ -958,6 +958,7 @@ bus-width = <4>; cap-mmc-highspeed; cap-sd-highspeed; + cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>; disable-wp; max-frequency = <200000000>; no-sdio; -- 2.7.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] Fix sd card support for RK3576 2026-01-13 1:18 [PATCH v2 0/3] Fix sd card support for RK3576 Shawn Lin ` (2 preceding siblings ...) 2026-01-13 1:18 ` [PATCH v2 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin @ 2026-01-13 20:35 ` Marco Schirrmeister 2026-01-14 2:01 ` Shawn Lin 3 siblings, 1 reply; 8+ messages in thread From: Marco Schirrmeister @ 2026-01-13 20:35 UTC (permalink / raw) To: Shawn Lin Cc: Heiko Stuebner, linux-rockchip, devicetree, FUKAUMI Naoki, John Clark, Tianling Shen, Detlev Casanova Hi Shawn, On Tue, Jan 13, 2026 at 2:19 AM Shawn Lin <shawn.lin@rock-chips.com> wrote: > > This series fixes this mess but only adds slot-gpio support for RK3576-EVB1. > Other boards are also missing slot-gpio support, but folks are all cced for > checking the boards they are using. > > Please review and test I tested this series on the FriendlyElec NanoPi R76S. With the addition of 'cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;' in the board DTS, the µSD hot-plug now works correctly. However, even with this fix, the NanoPi R76S still suffers from the constant 400kHz retuning loop when runtime PM is enabled. I will send a v2 of my driver quirk to address this board-specific instability. Link to v1: https://lore.kernel.org/all/20260110010715.1610159-1-mschirrmeister@gmail.com/T/#t Tested-by: Marco Schirrmeister <mschirrmeister@gmail.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] Fix sd card support for RK3576 2026-01-13 20:35 ` [PATCH v2 0/3] Fix sd card support for RK3576 Marco Schirrmeister @ 2026-01-14 2:01 ` Shawn Lin 0 siblings, 0 replies; 8+ messages in thread From: Shawn Lin @ 2026-01-14 2:01 UTC (permalink / raw) To: Marco Schirrmeister Cc: shawn.lin, Heiko Stuebner, linux-rockchip, devicetree, FUKAUMI Naoki, John Clark, Tianling Shen, Detlev Casanova 在 2026/01/14 星期三 4:35, Marco Schirrmeister 写道: > Hi Shawn, > > On Tue, Jan 13, 2026 at 2:19 AM Shawn Lin <shawn.lin@rock-chips.com> wrote: >> >> This series fixes this mess but only adds slot-gpio support for RK3576-EVB1. >> Other boards are also missing slot-gpio support, but folks are all cced for >> checking the boards they are using. >> >> Please review and test > > I tested this series on the FriendlyElec NanoPi R76S. > With the addition of 'cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;' > in the board DTS, the µSD hot-plug now works correctly. > Thanks for testing. > However, even with this fix, the NanoPi R76S still suffers from the > constant 400kHz retuning loop when runtime PM is enabled. I will send > a v2 of my driver quirk to address this board-specific instability. > When talking about board-specific instability of SD support, the intuitive reaction is bus more or frequency related. I never came across this kind of problem which caused by runtime PM support. That being said, there is potential unveiled problems for your boards. I will comment your v2 to see if we could sort them out. > Link to v1: https://lore.kernel.org/all/20260110010715.1610159-1-mschirrmeister@gmail.com/T/#t > > Tested-by: Marco Schirrmeister <mschirrmeister@gmail.com> > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-01-14 3:16 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-13 1:18 [PATCH v2 0/3] Fix sd card support for RK3576 Shawn Lin 2026-01-13 1:18 ` [PATCH v2 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin 2026-01-13 1:18 ` [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin 2026-01-13 17:43 ` Heiko Stübner 2026-01-14 1:34 ` Shawn Lin 2026-01-13 1:18 ` [PATCH v2 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin 2026-01-13 20:35 ` [PATCH v2 0/3] Fix sd card support for RK3576 Marco Schirrmeister 2026-01-14 2:01 ` Shawn Lin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox