* [PATCH 0/3] Fix sd card support for RK3576
@ 2026-01-12 3:49 Shawn Lin
2026-01-12 3:49 ` [PATCH 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Shawn Lin @ 2026-01-12 3:49 UTC (permalink / raw)
To: Heiko Stuebner
Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister,
John Clark, Tianling Shen, Detlev Casanova, Shawn Lin
SD card support for RK3576 is totally broken. This is because sd cards
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
intead 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 board they are using.
Please review and test
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 | 61 ++++++++++++------------
2 files changed, 32 insertions(+), 30 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition
2026-01-12 3:49 [PATCH 0/3] Fix sd card support for RK3576 Shawn Lin
@ 2026-01-12 3:49 ` Shawn Lin
2026-01-12 11:10 ` Chaoyi Chen
2026-01-12 3:49 ` [PATCH 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin
2026-01-12 3:49 ` [PATCH 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin
2 siblings, 1 reply; 8+ messages in thread
From: Shawn Lin @ 2026-01-12 3:49 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")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
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 2/3] soc: rockchip: grf: Support multiple grf to be handled
2026-01-12 3:49 [PATCH 0/3] Fix sd card support for RK3576 Shawn Lin
2026-01-12 3:49 ` [PATCH 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin
@ 2026-01-12 3:49 ` Shawn Lin
2026-01-12 11:04 ` Chaoyi Chen
2026-01-12 11:07 ` Heiko Stübner
2026-01-12 3:49 ` [PATCH 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin
2 siblings, 2 replies; 8+ messages in thread
From: Shawn Lin @ 2026-01-12 3:49 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 node to fix
the problem.
Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/soc/rockchip/grf.c | 59 +++++++++++++++++++++++-----------------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c
index 8974d1c..6d1c624e 100644
--- a/drivers/soc/rockchip/grf.c
+++ b/drivers/soc/rockchip/grf.c
@@ -213,40 +213,41 @@ static int __init rockchip_grf_init(void)
{
const struct rockchip_grf_info *grf_info;
const struct of_device_id *match;
- struct device_node *np;
+ struct device_node *np, *from_np = NULL;
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__);
- of_node_put(np);
- return -EINVAL;
- }
+ while (1) {
+ np = of_find_matching_node_and_match(from_np,
+ rockchip_grf_dt_match, &match);
+ if (!np)
+ return 0;
+ 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);
- if (IS_ERR(grf)) {
- pr_err("%s: could not get grf syscon\n", __func__);
- return PTR_ERR(grf);
- }
+ grf_info = match->data;
- 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);
+ 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_info("%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);
+ }
+ from_np = np;
}
-
- return 0;
}
postcore_initcall(rockchip_grf_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1
2026-01-12 3:49 [PATCH 0/3] Fix sd card support for RK3576 Shawn Lin
2026-01-12 3:49 ` [PATCH 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin
2026-01-12 3:49 ` [PATCH 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin
@ 2026-01-12 3:49 ` Shawn Lin
2026-01-12 11:08 ` Heiko Stübner
2 siblings, 1 reply; 8+ messages in thread
From: Shawn Lin @ 2026-01-12 3:49 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.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
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 2/3] soc: rockchip: grf: Support multiple grf to be handled
2026-01-12 3:49 ` [PATCH 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin
@ 2026-01-12 11:04 ` Chaoyi Chen
2026-01-12 11:07 ` Heiko Stübner
1 sibling, 0 replies; 8+ messages in thread
From: Chaoyi Chen @ 2026-01-12 11:04 UTC (permalink / raw)
To: Shawn Lin
Cc: Heiko Stuebner, linux-rockchip, devicetree, FUKAUMI Naoki,
Marco Schirrmeister, John Clark, Tianling Shen, Detlev Casanova
Hi Shawn,
On 1/12/2026 11:49 AM, Shawn Lin wrote:
> 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 node to fix
> the problem.
>
> Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values")
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> drivers/soc/rockchip/grf.c | 59 +++++++++++++++++++++++-----------------------
> 1 file changed, 30 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c
> index 8974d1c..6d1c624e 100644
> --- a/drivers/soc/rockchip/grf.c
> +++ b/drivers/soc/rockchip/grf.c
> @@ -213,40 +213,41 @@ static int __init rockchip_grf_init(void)
> {
> const struct rockchip_grf_info *grf_info;
> const struct of_device_id *match;
> - struct device_node *np;
> + struct device_node *np, *from_np = NULL;
> 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__);
> - of_node_put(np);
> - return -EINVAL;
> - }
> + while (1) {
> + np = of_find_matching_node_and_match(from_np,
> + rockchip_grf_dt_match, &match);
> + if (!np)
> + return 0;
> + 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);
> - if (IS_ERR(grf)) {
> - pr_err("%s: could not get grf syscon\n", __func__);
> - return PTR_ERR(grf);
> - }
> + grf_info = match->data;
>
> - 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);
> + 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_info("%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);
> + }
> + from_np = np;
> }
You called of_node_put() on from_np/np here, and the next time
of_find_matching_node_and_match() is called, this function will
internally call of_node_put() on from_np.
Would this cause a double put?
--
Best,
Chaoyi
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] soc: rockchip: grf: Support multiple grf to be handled
2026-01-12 3:49 ` [PATCH 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin
2026-01-12 11:04 ` Chaoyi Chen
@ 2026-01-12 11:07 ` Heiko Stübner
1 sibling, 0 replies; 8+ messages in thread
From: Heiko Stübner @ 2026-01-12 11:07 UTC (permalink / raw)
To: Shawn Lin
Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister,
John Clark, Tianling Shen, Detlev Casanova, Shawn Lin
Am Montag, 12. Januar 2026, 04:49:27 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 node to fix
> the problem.
>
> Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values")
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> drivers/soc/rockchip/grf.c | 59 +++++++++++++++++++++++-----------------------
> 1 file changed, 30 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c
> index 8974d1c..6d1c624e 100644
> --- a/drivers/soc/rockchip/grf.c
> +++ b/drivers/soc/rockchip/grf.c
> @@ -213,40 +213,41 @@ static int __init rockchip_grf_init(void)
> {
> const struct rockchip_grf_info *grf_info;
> const struct of_device_id *match;
> - struct device_node *np;
> + struct device_node *np, *from_np = NULL;
> 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__);
> - of_node_put(np);
> - return -EINVAL;
> - }
> + while (1) {
> + np = of_find_matching_node_and_match(from_np,
> + rockchip_grf_dt_match, &match);
I think this loop could be simplified by using
for_each_matching_node_and_match
(i.e. like in https://elixir.bootlin.com/linux/v6.18.4/source/drivers/clk/clk.c#L5545)
Heiko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1
2026-01-12 3:49 ` [PATCH 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin
@ 2026-01-12 11:08 ` Heiko Stübner
0 siblings, 0 replies; 8+ messages in thread
From: Heiko Stübner @ 2026-01-12 11:08 UTC (permalink / raw)
To: Shawn Lin
Cc: linux-rockchip, devicetree, FUKAUMI Naoki, Marco Schirrmeister,
John Clark, Tianling Shen, Detlev Casanova, Shawn Lin
Hi,
Am Montag, 12. Januar 2026, 04:49:28 Mitteleuropäische Normalzeit schrieb 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.
>
this could use a fixes-tag perhaps?
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> 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;
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition
2026-01-12 3:49 ` [PATCH 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin
@ 2026-01-12 11:10 ` Chaoyi Chen
0 siblings, 0 replies; 8+ messages in thread
From: Chaoyi Chen @ 2026-01-12 11:10 UTC (permalink / raw)
To: Shawn Lin
Cc: Heiko Stuebner, linux-rockchip, devicetree, FUKAUMI Naoki,
Marco Schirrmeister, John Clark, Tianling Shen, Detlev Casanova
On 1/12/2026 11:49 AM, Shawn Lin wrote:
> RK3576_IOCGRF_MISC_CON is IOC_GRF + 0x40F0, fix it.
>
> Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values")
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> 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) },
LGTM :)
Reviewed-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
--
Best,
Chaoyi
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-01-12 11:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 3:49 [PATCH 0/3] Fix sd card support for RK3576 Shawn Lin
2026-01-12 3:49 ` [PATCH 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin
2026-01-12 11:10 ` Chaoyi Chen
2026-01-12 3:49 ` [PATCH 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin
2026-01-12 11:04 ` Chaoyi Chen
2026-01-12 11:07 ` Heiko Stübner
2026-01-12 3:49 ` [PATCH 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin
2026-01-12 11:08 ` Heiko Stübner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox