rockchip: clk: rv1108: remove duplicate reset init
Subsystems (2)
Heiko Stuebner
maintainerPATCH 1/2 rockchip: clk: rv1108: remove duplicate reset init
rockchip_reset_bind() already does the needed init for the reset registers, only referenced the wrong cru structure.
So we can get rid of the open-coded reset init and just fix the correct cru reference.
--- drivers/clk/rockchip/clk_rv1108.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/clk/rockchip/clk_rv1108.c +1 -12
@@ -698,22 +698,11 @@ static int rv1108_clk_bind(struct udevice *dev) }#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) - ret = offsetof(struct rk3368_cru, softrst_con[0]); + ret = offsetof(struct rv1108_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,13 );if (ret)debug ("Warning: software reset driver bind faile\n" );#endif - ret =device_bind_driver_to_node (dev,"rockchip_reset" ,"reset" , -dev_ofnode (dev), &sf_child); -if (ret) { -debug ("Warning: No rockchip reset driver: ret=%d\n" , ret); - }else { - sf_priv =malloc (sizeof (struct softreset_reg )); - sf_priv->sf_reset_offset = offsetof(struct rv1108_cru , - softrst_con[0]); - sf_priv->sf_reset_num =13 ; - sf_child->priv = sf_priv; - }return 0 ; }
Signature · 1 line
2.23.0
Heiko Stuebner
maintainerPATCH 2/2 rockchip: clk: fix wrong CONFIG_IS_ENABLED handling
CONFIG_IS_ENABLED() needs the config name like used in Kconfig, so without the leading CONFIG_. The clock drivers all wrongly check for CONFIG_RESET_ROCKCHIP, fix that
--- drivers/clk/rockchip/clk_rk3036.c | 2 +- drivers/clk/rockchip/clk_rk3188.c | 2 +- drivers/clk/rockchip/clk_rk322x.c | 2 +- drivers/clk/rockchip/clk_rk3288.c | 2 +- drivers/clk/rockchip/clk_rk3328.c | 2 +- drivers/clk/rockchip/clk_rk3368.c | 2 +- drivers/clk/rockchip/clk_rk3399.c | 2 +- drivers/clk/rockchip/clk_rv1108.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-)
drivers/clk/rockchip/clk_rk3036.c +1 -1
@@ -352,7 +352,7 @@ static int rk3036_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3036_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,9 );if (ret)
drivers/clk/rockchip/clk_rk3188.c +1 -1
@@ -590,7 +590,7 @@ static int rk3188_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3188_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,9 );if (ret)
drivers/clk/rockchip/clk_rk322x.c +1 -1
@@ -508,7 +508,7 @@ static int rk322x_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk322x_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,9 );if (ret)
drivers/clk/rockchip/clk_rk3288.c +1 -1
@@ -1015,7 +1015,7 @@ static int rk3288_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3288_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,12 );if (ret)
drivers/clk/rockchip/clk_rk3328.c +1 -1
@@ -791,7 +791,7 @@ static int rk3328_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3328_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,12 );if (ret)
drivers/clk/rockchip/clk_rk3368.c +1 -1
@@ -620,7 +620,7 @@ static int rk3368_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3368_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,15 );if (ret)
drivers/clk/rockchip/clk_rk3399.c +1 -1
@@ -1195,7 +1195,7 @@ static int rk3399_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3399_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,21 );if (ret)
drivers/clk/rockchip/clk_rv1108.c +1 -1
@@ -697,7 +697,7 @@ static int rv1108_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rv1108_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,13 );if (ret)
Signature · 1 line
2.23.0
PATCH 2/2 rockchip: clk: fix wrong CONFIG_IS_ENABLED handling
Quoted 5 lines · Heiko Stuebner
CONFIG_IS_ENABLED()needs the config name like used inKconfig, so without the leadingCONFIG_. The clock drivers all wrongly check forCONFIG_RESET_ROCKCHIP, fix thatSigned-off-by Heiko Stuebner <[email protected]>
Thanks,
- Kever
Quoted 115 lines
--- drivers/clk/rockchip/clk_rk3036.c | 2 +- drivers/clk/rockchip/clk_rk3188.c | 2 +- drivers/clk/rockchip/clk_rk322x.c | 2 +- drivers/clk/rockchip/clk_rk3288.c | 2 +- drivers/clk/rockchip/clk_rk3328.c | 2 +- drivers/clk/rockchip/clk_rk3368.c | 2 +- drivers/clk/rockchip/clk_rk3399.c | 2 +- drivers/clk/rockchip/clk_rv1108.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-)drivers/clk/rockchip/clk_rk3036.c +1
-1@@ -352,7 +352,7 @@ static int rk3036_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3036_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,9 );if (ret)drivers/clk/rockchip/clk_rk3188.c +1
-1@@ -590,7 +590,7 @@ static int rk3188_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3188_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,9 );if (ret)drivers/clk/rockchip/clk_rk322x.c +1
-1@@ -508,7 +508,7 @@ static int rk322x_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk322x_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,9 );if (ret)drivers/clk/rockchip/clk_rk3288.c +1
-1@@ -1015,7 +1015,7 @@ static int rk3288_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3288_cru, cru_softrst_con[0]); ret =rockchip_reset_bind (dev, ret,12 );if (ret)drivers/clk/rockchip/clk_rk3328.c +1
-1@@ -791,7 +791,7 @@ static int rk3328_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3328_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,12 );if (ret)drivers/clk/rockchip/clk_rk3368.c +1
-1@@ -620,7 +620,7 @@ static int rk3368_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3368_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,15 );if (ret)drivers/clk/rockchip/clk_rk3399.c +1
-1@@ -1195,7 +1195,7 @@ static int rk3399_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rk3399_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,21 );if (ret)drivers/clk/rockchip/clk_rv1108.c +1
-1@@ -697,7 +697,7 @@ static int rv1108_clk_bind(struct udevice *dev) sys_child->priv = priv; } -#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) +#if CONFIG_IS_ENABLED (RESET_ROCKCHIP ) ret = offsetof(struct rv1108_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,13 );if (ret)
PATCH 1/2 rockchip: clk: rv1108: remove duplicate reset init
In reply to Heiko StuebnerHeiko,
Quoted 17 lines · Heiko Stuebner
rockchip_reset_bind()already does the needed init for the reset registers, only referenced the wrong cru structure.So we can get rid of the open-coded reset init and just fix the correct cru reference.
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/clk/rockchip/clk_rv1108.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/clk/rockchip/clk_rv1108.c +0
-0@@ -698,22 +698,11 @@ static int rv1108_clk_bind(struct udevice *dev) }
drivers/clk/rockchip/clk_rv1108.c static int rv1108_clk_bind(struct udevice *dev) · line 707
Quoted 10 lines
drivers/clk/rockchip/clk_rv1108.c +1
-3#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) - ret = offsetof(struct rk3368_cru, softrst_con[0]); + ret = offsetof(struct rv1108_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,13 );if (ret)debug ("Warning: software reset driver bind faile\n" );#endif - ret =device_bind_driver_to_node (dev,"rockchip_reset" ,"reset" , -dev_ofnode (dev), &sf_child);
You can't just remove this blob of code, for there is a 'sysreset' driver and a 'reset' driver, they are
different, so you should fix this part to be available 'sysreset' driver so that the software can reset the SoC.
Thanks,
- Kever
Quoted 12 lines
drivers/clk/rockchip/clk_rv1108.c +0
-9-if (ret) { -debug ("Warning: No rockchip reset driver: ret=%d\n" , ret); - }else { - sf_priv =malloc (sizeof (struct softreset_reg )); - sf_priv->sf_reset_offset = offsetof(struct rv1108_cru , - softrst_con[0]); - sf_priv->sf_reset_num =13 ; - sf_child->priv = sf_priv; - }return 0 ; }
Heiko Stübner
maintainerPATCH 1/2 rockchip: clk: rv1108: remove duplicate reset init
Hi Kever,
Am Donnerstag, 7. November 2019, 10:03:19 CET schrieb Kever Yang:
Quoted 32 lines · Heiko Stuebner
Quoted 17 lines
rockchip_reset_bind()already does the needed init for the reset registers, only referenced the wrong cru structure.So we can get rid of the open-coded reset init and just fix the correct cru reference.
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/clk/rockchip/clk_rv1108.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/clk/rockchip/clk_rv1108.c +0
-0@@ -698,22 +698,11 @@ static int rv1108_clk_bind(struct udevice *dev) }drivers/clk/rockchip/clk_rv1108.c static int rv1108_clk_bind(struct udevice *dev) · line 707
Quoted 10 lines
drivers/clk/rockchip/clk_rv1108.c +1
-3#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) - ret = offsetof(struct rk3368_cru, softrst_con[0]); + ret = offsetof(struct rv1108_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,13 );if (ret)debug ("Warning: software reset driver bind faile\n" );#endif - ret =device_bind_driver_to_node (dev,"rockchip_reset" ,"reset" , -dev_ofnode (dev), &sf_child);You can't just remove this blob of code, for there is a 'sysreset' driver and a 'reset' driver, they are
Quoted 2 lines
different, so you should fix this part to be available 'sysreset' driver so that the software can reset the SoC.
While there is a sysreset driver, it seems the rv1108 only did init the softrst code here and not the sysreset at all.
So rockchip_reset_bind really only does the same as the remove part of code. What I did see was that struct softreset_reg still is defined in the rockchip clock.h and after this patch no-one is using at all anymore. The rockchip_reset driver uses a different struct altogether it seems.
Adding an appropriate sysreset driver for rv1108
should likely be a separate patch though.
Heiko
Quoted 15 lines
Quoted 12 lines
drivers/clk/rockchip/clk_rv1108.c +0
-9-if (ret) { -debug ("Warning: No rockchip reset driver: ret=%d\n" , ret); - }else { - sf_priv =malloc (sizeof (struct softreset_reg )); - sf_priv->sf_reset_offset = offsetof(struct rv1108_cru , - softrst_con[0]); - sf_priv->sf_reset_num =13 ; - sf_child->priv = sf_priv; - }return 0 ; }
Heiko Stuebner
maintainerPATCH 1/2 rockchip: clk: rv1108: remove duplicate reset init
Hi Kever,
Am Donnerstag, 7. November 2019, 10:13:02 CET schrieb Heiko Stübner:
Quoted 39 lines
Am Donnerstag, 7. November 2019, 10:03:19 CET schrieb Kever Yang:
Quoted 32 lines · Heiko Stuebner
Quoted 17 lines
rockchip_reset_bind()already does the needed init for the reset registers, only referenced the wrong cru structure.So we can get rid of the open-coded reset init and just fix the correct cru reference.
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/clk/rockchip/clk_rv1108.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/clk/rockchip/clk_rv1108.c +0
-0@@ -698,22 +698,11 @@ static int rv1108_clk_bind(struct udevice *dev) }drivers/clk/rockchip/clk_rv1108.c static int rv1108_clk_bind(struct udevice *dev) · line 707
Quoted 10 lines
drivers/clk/rockchip/clk_rv1108.c +1
-3#if CONFIG_IS_ENABLED (CONFIG_RESET_ROCKCHIP ) - ret = offsetof(struct rk3368_cru, softrst_con[0]); + ret = offsetof(struct rv1108_cru, softrst_con[0]); ret =rockchip_reset_bind (dev, ret,13 );if (ret)debug ("Warning: software reset driver bind faile\n" );#endif - ret =device_bind_driver_to_node (dev,"rockchip_reset" ,"reset" , -dev_ofnode (dev), &sf_child);You can't just remove this blob of code, for there is a 'sysreset' driver and a 'reset' driver, they are
Quoted 2 lines
different, so you should fix this part to be available 'sysreset' driver so that the software can reset the SoC.
While there is a sysreset driver, it seems the rv1108 only did init the softrst code here and not the sysreset at all.
Quoted 8 lines
So
rockchip_reset_bindreally only does the same as the remove part of code. What I did see was that structsoftreset_regstill is defined in the rockchipclock.hand after this patch no-one is using at all anymore. Therockchip_resetdriver uses a different struct altogether it seems.Adding an appropriate sysreset driver for rv1108
should likely be a separate patch though.
I just sent a v2, dropping the unused softreset_reg struct as well.
When reviewing please take into account, the rv1108 had the following situation before:
-registration of sysreset
- registration of old softreset - broken because that driver code is gone
- registration of new softreset - broken because of the CONFIG_* from patch2
and also because it was using the wrong struct (rk3368 instead of rv1108)
now after the patch (in v2), we have the expected
- registration of sysreset
- registration of new softreset with correct cru struct
Heiko