Fix sd card support for RK3576
Subsystems (2)
v3 cover Fix sd card support for RK3576
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 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
Changes in v3:
- remove of_node_put() (Heiko)
- collect tags
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 | 57 ++++++++++++------------ 2 files changed, 29 insertions(+), 29 deletions(-)
Signature · 7 lines
2.7.4 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v3 1/3 soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition
RK3576_IOCGRF_MISC_CON is IOC_GRF + 0x40F0, fix it.
---
Changes in v3: None
Changes in v2: None
drivers/soc/rockchip/grf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/rockchip/grf.c +1 -1
@@ -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 0x40F0static const struct rockchip_grf_value rk3576_defaults_ioc_grf[]__initconst = { {"jtag switching" ,RK3576_IOCGRF_MISC_CON ,FIELD_PREP_WM16_CONST (BIT (1 ),0 ) },
Signature · 1 line
2.7.4
PATCH v3 2/3 soc: rockchip: grf: Support multiple grf to be handled
In reply to Shawn LinCurrently, 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.
---
Changes in v3:
- remove of_node_put() (Heiko)
Changes in v2:
- use for_each_matching_node_and_match(Heiko)
drivers/soc/rockchip/grf.c | 55 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 28 deletions(-)
drivers/soc/rockchip/grf.c +27 -28
@@ -217,34 +217,33 @@ 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__); -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); +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); +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 ;
Signature · 7 lines
2.7.4 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v3 3/3 arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1
In reply to Shawn LinWithout cd-gpios, the sdmmc would not be detected, because during runtime PM, the clock is gated which prevents the irq from issuing.
---
Changes in v3: None
Changes in v2:
- add fixes tag
arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts +1 -0
@@ -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;
Signature · 7 lines
2.7.4 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Hello Shawn,
Quoted 8 lines · Shawn Lin
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
Quoted 7 lines
Changes in v3:
- removeof_node_put()(Heiko)
- collect tagsChanges in v2:
- usefor_each_matching_node_and_match(Heiko)
- add fixes tag
I tested this v3 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, the separate problem that I reported in your v2 version still exists.