rockchip: Remove unused rockchip_get_clk() helpers for RK35xx
Subsystems (4)
cover rockchip: Remove unused rockchip_get_clk() helpers for RK35xx
This series takes the initial steps to try and remove use of rockchip_get_clk() to get the clock device or rockchip_get_cru() to get the CRU base address at runtime for the Rockchip platform.
This series is similar to the "rockchip: Remove unneeded syscon driver for RK35xx" [1] series, but focuses on CRU instead of GRF.
The CRU base addresses are fixed and known at compile time, yet drivers keep trying to resolve them at runtime delaying some operations by several ms.
In this initial part the RK3568 and RK3588 specific helpers are updated to use CRU base address constants, similar to the other RK35xx SoCs, and the rockchip_get_clk() helper is removed for all RK35xx SoCs.
The changes included in this series have no intended behavior change for the affected RK35xx SoCs.
A follow-up series will introduce a rockchip_sysreset_bind() helper that passes the CRU base address to the sysreset_rockchip driver, drops the call to rockchip_get_cru() along with implementing the get_status() ops.
[1] https://patchwork.ozlabs.org/cover/2280781/
Jonas Karlman (10):
rockchip: rk3588: Rename CRU_BASE to RK3588_CRU_BASE
rockchip: rk3588: Use fixed CRU base address
rockchip: rk3568: Use fixed CRU and PMU CRU base addresses
clk: rockchip: rk3568: Use fixed PMU CRU base address for PLL access
rockchip: rk3568: Remove unused rockchip_get_pmucru() helper
rockchip: rk3568: Remove unused rockchip_get_clk() helper
rockchip: rk3588: Remove unused rockchip_get_clk() helper
rockchip: rk3576: Remove unused rockchip_get_clk() helper
rockchip: rk3528: Remove unused rockchip_get_clk() helper
rockchip: rk3506: Remove unused rockchip_get_clk() helper
.../include/asm/arch-rockchip/cru_rk3568.h | 5 ++- .../include/asm/arch-rockchip/cru_rk3588.h | 2 +- arch/arm/mach-rockchip/rk3506/clk_rk3506.c | 8 +--- arch/arm/mach-rockchip/rk3528/clk_rk3528.c | 8 +--- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 44 +------------------ arch/arm/mach-rockchip/rk3576/clk_rk3576.c | 8 +--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 23 +--------- .../jaguar_rk3588/jaguar_rk3588.c | 2 +- .../tiger_rk3588/tiger_rk3588.c | 2 +- drivers/clk/rockchip/clk_rk3568.c | 34 +++----------- 10 files changed, 18 insertions(+), 118 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/10 rockchip: rk3588: Rename CRU_BASE to RK3588_CRU_BASE
RK3588 is using a generic CRU_BASE name for its SoC specific CRU base address constant.
Add a RK3588 SoC prefix to the CRU_BASE constant, similar to how other RK35xx CRU base address constants are named, to more easily distinguish what SoC specific CRU base address the constant refers to.
--- arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 2 +- board/theobroma-systems/jaguar_rk3588/jaguar_rk3588.c | 2 +- board/theobroma-systems/tiger_rk3588/tiger_rk3588.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3588.h +1 -1
@@ -63,7 +63,7 @@ struct rk3588_pll {unsigned int reserved0[3 ]; }; -#define CRU_BASE 0xfd7c0000 +#define RK3588_CRU_BASE 0xfd7c0000struct rk3588_cru {struct rk3588_pll pll[18 ];
board/theobroma-systems/jaguar_rk3588/jaguar_rk3588.c +1 -1
@@ -31,7 +31,7 @@ void setup_eth0refclko(void) {/* Configure and enable ETH0_REFCLKO_25MHz */ static struct rk3588_bus_ioc *const bus_ioc = (void *)BUS_IOC_BASE ; -static struct rk3588_cru *const cru = (void *)CRU_BASE ; +static struct rk3588_cru *const cru = (void *)RK3588_CRU_BASE ;/* 1. Pinmux */ rk_clrsetreg (&bus_ioc->gpio2c_iomux_sel_l,GPIO2C3_SEL_MASK ,GPIO2C3_ETH0_REFCLKO_25M );
board/theobroma-systems/tiger_rk3588/tiger_rk3588.c +1 -1
@@ -31,7 +31,7 @@ void setup_eth0refclko(void) {/* Configure and enable ETH0_REFCLKO_25MHz */ static struct rk3588_bus_ioc *const bus_ioc = (void *)BUS_IOC_BASE ; -static struct rk3588_cru *const cru = (void *)CRU_BASE ; +static struct rk3588_cru *const cru = (void *)RK3588_CRU_BASE ;/* 1. Pinmux */ rk_clrsetreg (&bus_ioc->gpio2c_iomux_sel_l,GPIO2C3_SEL_MASK ,GPIO2C3_ETH0_REFCLKO_25M );
Signature · 1 line
2.54.0
Re: [PATCH 01/10] rockchip: rk3588: Rename CRU_BASE to RK3588_CRU_BASE
Hi Jonas,
Quoted 7 lines · Jonas Karlman
RK3588 is using a generic
CRU_BASEname for its SoC specific CRU base address constant.Add a RK3588 SoC prefix to the
CRU_BASEconstant, similar to how other RK35xx CRU base address constants are named, to more easily distinguish what SoC specific CRU base address the constant refers to.
Thanks!
Quentin
PATCH 2/10 rockchip: rk3588: Use fixed CRU base address
In reply to Jonas KarlmanThe rockchip_get_cru() helper is used by the sysreset_rockchip to get the SoC specific CRU base address. The helper may trigger a full clock driver probe to get the fixed CRU base address from the clock driver private data, something that can take several ms.
Change to return the fixed RK3588 specific CRU base address directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +1 -14
@@ -4,10 +4,7 @@*/ #include <dm.h> -#include <syscon.h> -#include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3588.h> -#include <linux/err.h> int rockchip_get_clk (struct udevice **devp) {
@@ -17,15 +14,5 @@ int rockchip_get_clk(struct udevice **devp)void *rockchip_get_cru (void ) { -struct rk3588_clk_priv *priv; -struct udevice *dev; -int ret; - - ret =rockchip_get_clk (&dev); -if (ret) -return ERR_PTR (ret); - - priv =dev_get_priv (dev); - -return priv->cru; +return (void *)RK3588_CRU_BASE ; }
Signature · 1 line
2.54.0
Re: [PATCH 02/10] rockchip: rk3588: Use fixed CRU base address
Hi Jonas,
Quoted 5 lines · Jonas Karlman
The
rockchip_get_cru()helper is used by thesysreset_rockchipto get the SoC specific CRU base address. The helper may trigger a full clock driver probe to get the fixed CRU base address from the clock driver private data, something that can take several ms.
OK, but isn't probing the clock driver actually making sure the assigned-clocks, assigned-clock-parents and assigned-clock-rates properties are respected? There's *some* side effect. Considering the current user of that function, they aren't doing anything with clocks so I guess this is fine on that side. But I'm getting a bit worried, is there anything actually probing the clock controller driver if we don't have this anymore? I guess it's fine right now because we only have an SPL for RK35xx and thus have a Device Tree, but what happens when we have an open TPL?
Quoted 14 lines
Change to return the fixed RK3588 specific CRU base address directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-0
arch/arm/mach-rockchip/rk3588/clk_rk3588.c line 10
Quoted 10 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-3@@ -4,10 +4,7 @@*/ #include <dm.h> -#include <syscon.h> -#include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3588.h> -#include <linux/err.h> int rockchip_get_clk (struct udevice **devp) {
There's no user of that function anymore after this patch, so just squash the patch removing it later in this series with this patch here.
Thanks!
Quentin
Re: [PATCH 02/10] rockchip: rk3588: Use fixed CRU base address
Hi Quentin,
Quoted 9 lines · Quentin Schulz
Hi Jonas,
Quoted 5 lines · Jonas Karlman
The
rockchip_get_cru()helper is used by thesysreset_rockchipto get the SoC specific CRU base address. The helper may trigger a full clock driver probe to get the fixed CRU base address from the clock driver private data, something that can take several ms.
Quoted 9 lines
OK, but isn't probing the clock driver actually making sure the assigned-clocks, assigned-clock-parents and assigned-clock-rates properties are respected? There's *some* side effect. Considering the current user of that function, they aren't doing anything with clocks so I guess this is fine on that side. But I'm getting a bit worried, is there anything actually probing the clock controller driver if we don't have this anymore? I guess it's fine right now because we only have an SPL for RK35xx and thus have a Device Tree, but what happens when we have an open TPL?
Currently probing of clock driver is very nondeterministic, hence the series "rockchip: Always init clocks in SPL build for RK35xx" to help ensure clock driver is probed in a deterministic way/stage.
For TPL the clock driver may or may not be required, the DRAM clocks are typically not handled by the clock driver so the DRAM init code may not even need to probe the clock driver.
For DEBUG_UART in bare minimum TPL for RK35xx I have been playing with, I use the macros defined in cru_<soc>.h directly in debug_uart_init(). Something like that could be possible in size constrained TPL, or the clock driver could be extended to handle clocks needed for DRAM init.
Snip of board_debug_uart_init() for RK3572 that ensure that the UART clock use correct parent and divider, full at [1]:
/* sclk_uart0_sel=osc sclk_uart0_div=0 */ writel(FIELD_PREP_WM16(CLK_UART_SEL_MASK, CLK_UART_SEL_24M) | FIELD_PREP_WM16(CLK_UART_DIV_MASK, 0), RK3572_CLKSEL_CON(71));
When it comes to CRU assigned-clocks, they are typically stripped from xPL DT and will instead be applied at U-Boot proper phase. Currently they are even applied 2-3 times due to clk_set_defaults() being called multiple times for clock driver and also for the reset driver. Something I will be addressing in a separate series.
Quoted 23 lines
Quoted 23 lines
Change to return the fixed RK3588 specific CRU base address directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-3@@ -4,10 +4,7 @@*/ #include <dm.h> -#include <syscon.h> -#include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3588.h> -#include <linux/err.h>
Quoted 5 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c line 10
Quoted 2 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-0int rockchip_get_clk (struct udevice **devp) {There's no user of that function anymore after this patch, so just squash the patch removing it later in this series with this patch here.
This is a public function declared in asm/arch-rockchip/clock.h, so dropping it in a separate commit seem more appropriate, to avoid doing two separate things in same commit ;-)
Will send a v2 addressing your other review comments.
Regards,
Jonas
Quoted 3 lines
Thanks!
Quentin
PATCH 3/10 rockchip: rk3568: Use fixed CRU and PMU CRU base addresses
In reply to Jonas KarlmanThe rockchip_get_cru() helper is used by the sysreset_rockchip to get the SoC specific CRU base address, and the rockchip_get_pmucru() helper is only used by the RK3399 specific RAM driver. These helpers may trigger a full clock driver probe to get the fixed CRU base address from the clock driver private data, something that can take several ms.
Change to return the fixed RK3568 specific CRU or PMU CRU base address directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
--- .../include/asm/arch-rockchip/cru_rk3568.h | 5 +-- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 33 ++----------------- 2 files changed, 5 insertions(+), 33 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3568.h +3 -2
@@ -35,7 +35,6 @@ struct rk3568_clk_info {bool is_cru; }; -/* Private data for the clock driver - used by rockchip_get_cru() */ struct rk3568_pmuclk_priv {struct rk3568_pmucru *pmucru;ulong ppll_hz;
@@ -120,8 +119,10 @@ struct pll_rate_table {unsigned int frac; }; -#define RK3568_PMU_MODE 0x80 +#define RK3568_PMU_CRU_BASE 0xfdd00000#define RK3568_PMU_PLL_CON (x) ((x) * 0x4) +#define RK3568_PMU_MODE 0x80 +#define RK3568_CRU_BASE 0xfdd20000#define RK3568_PLL_CON (x) ((x) * 0x4)#define RK3568_MODE_CON 0xc0
arch/arm/mach-rockchip/rk3568/clk_rk3568.c +2 -31
@@ -4,10 +4,7 @@*/ #include <dm.h> -#include <syscon.h> -#include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3568.h> -#include <linux/err.h> int rockchip_get_clk (struct udevice **devp) {
@@ -17,36 +14,10 @@ int rockchip_get_clk(struct udevice **devp)void *rockchip_get_cru (void ) { -struct rk3568_clk_priv *priv; -struct udevice *dev; -int ret; - - ret =rockchip_get_clk (&dev); -if (ret) -return ERR_PTR (ret); - - priv =dev_get_priv (dev); - -return priv->cru; -} - -static int rockchip_get_pmucruclk (struct udevice **devp) -{ -return uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), devp); +return (void *)RK3568_CRU_BASE ; }void *rockchip_get_pmucru (void ) { -struct rk3568_pmuclk_priv *priv; -struct udevice *dev; -int ret; - - ret =rockchip_get_pmucruclk (&dev); -if (ret) -return ERR_PTR (ret); - - priv =dev_get_priv (dev); - -return priv->pmucru; +return (void *)RK3568_PMU_CRU_BASE ; }
Signature · 1 line
2.54.0
Re: [PATCH 03/10] rockchip: rk3568: Use fixed CRU and PMU CRU base addresses
Hi Jonas,
Quoted 45 lines · Jonas Karlman
The
rockchip_get_cru()helper is used by thesysreset_rockchipto get the SoC specific CRU base address, and therockchip_get_pmucru()helper is only used by the RK3399 specific RAM driver. These helpers may trigger a full clock driver probe to get the fixed CRU base address from the clock driver private data, something that can take several ms.Change to return the fixed RK3568 specific CRU or PMU CRU base address directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Signed-off-by Jonas Karlman <[email protected]>--- .../include/asm/arch-rockchip/cru_rk3568.h | 5 +-- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 33 ++----------------- 2 files changed, 5 insertions(+), 33 deletions(-)arch/arm/include/asm/arch-rockchip/cru_rk3568.h +3
-2@@ -35,7 +35,6 @@ struct rk3568_clk_info {bool is_cru; }; -/* Private data for the clock driver - used by rockchip_get_cru() */ struct rk3568_pmuclk_priv {struct rk3568_pmucru *pmucru;ulong ppll_hz;@@ -120,8 +119,10 @@ struct pll_rate_table {unsigned int frac; }; -#define RK3568_PMU_MODE 0x80 +#define RK3568_PMU_CRU_BASE 0xfdd00000#define RK3568_PMU_PLL_CON (x) ((x) * 0x4) +#define RK3568_PMU_MODE 0x80 +#define RK3568_CRU_BASE 0xfdd20000#define RK3568_PLL_CON (x) ((x) * 0x4)#define RK3568_MODE_CON 0xc0arch/arm/mach-rockchip/rk3568/clk_rk3568.c +0
-0
arch/arm/mach-rockchip/rk3568/clk_rk3568.c line 10
Quoted 10 lines
arch/arm/mach-rockchip/rk3568/clk_rk3568.c +0
-3@@ -4,10 +4,7 @@*/ #include <dm.h> -#include <syscon.h> -#include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3568.h> -#include <linux/err.h> int rockchip_get_clk (struct udevice **devp) {
There's no user of that function anymore after this patch, so just squash the patch removing it later in this series with this patch here.
Cheers,
Quentin
Re: [PATCH 03/10] rockchip: rk3568: Use fixed CRU and PMU CRU base addresses
Hi Quentin,
Quoted 56 lines · Quentin Schulz
Hi Jonas,
Quoted 53 lines · Jonas Karlman
The
rockchip_get_cru()helper is used by thesysreset_rockchipto get the SoC specific CRU base address, and therockchip_get_pmucru()helper is only used by the RK3399 specific RAM driver. These helpers may trigger a full clock driver probe to get the fixed CRU base address from the clock driver private data, something that can take several ms.Change to return the fixed RK3568 specific CRU or PMU CRU base address directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Signed-off-by Jonas Karlman <[email protected]>--- .../include/asm/arch-rockchip/cru_rk3568.h | 5 +-- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 33 ++----------------- 2 files changed, 5 insertions(+), 33 deletions(-)arch/arm/include/asm/arch-rockchip/cru_rk3568.h +3
-2@@ -35,7 +35,6 @@ struct rk3568_clk_info {bool is_cru; }; -/* Private data for the clock driver - used by rockchip_get_cru() */ struct rk3568_pmuclk_priv {struct rk3568_pmucru *pmucru;ulong ppll_hz;@@ -120,8 +119,10 @@ struct pll_rate_table {unsigned int frac; }; -#define RK3568_PMU_MODE 0x80 +#define RK3568_PMU_CRU_BASE 0xfdd00000#define RK3568_PMU_PLL_CON (x) ((x) * 0x4) +#define RK3568_PMU_MODE 0x80 +#define RK3568_CRU_BASE 0xfdd20000#define RK3568_PLL_CON (x) ((x) * 0x4)#define RK3568_MODE_CON 0xc0arch/arm/mach-rockchip/rk3568/clk_rk3568.c +0
-3@@ -4,10 +4,7 @@*/ #include <dm.h> -#include <syscon.h> -#include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3568.h> -#include <linux/err.h>
Quoted 5 lines
arch/arm/mach-rockchip/rk3568/clk_rk3568.c line 10
Quoted 2 lines
arch/arm/mach-rockchip/rk3568/clk_rk3568.c +0
-0int rockchip_get_clk (struct udevice **devp) {There's no user of that function anymore after this patch, so just squash the patch removing it later in this series with this patch here.
This function is technically a public function declared in asm/arch-rockchip/clock.h. Removing it in same patch that refactors to use a constant seem like it would go against your normal stand on not doing two different things in one patch, and a reason why it was split to begin with ;-)
Regards,
Jonas
Quoted 3 lines
Cheers,
Quentin
Re: [PATCH 03/10] rockchip: rk3568: Use fixed CRU and PMU CRU base addresses
Quoted 65 lines · Jonas Karlman
Hi Quentin,
Quoted 56 lines · Quentin Schulz
Hi Jonas,
Quoted 53 lines · Jonas Karlman
The
rockchip_get_cru()helper is used by thesysreset_rockchipto get the SoC specific CRU base address, and therockchip_get_pmucru()helper is only used by the RK3399 specific RAM driver. These helpers may trigger a full clock driver probe to get the fixed CRU base address from the clock driver private data, something that can take several ms.Change to return the fixed RK3568 specific CRU or PMU CRU base address directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Signed-off-by Jonas Karlman <[email protected]>--- .../include/asm/arch-rockchip/cru_rk3568.h | 5 +-- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 33 ++----------------- 2 files changed, 5 insertions(+), 33 deletions(-)arch/arm/include/asm/arch-rockchip/cru_rk3568.h +3
-2@@ -35,7 +35,6 @@ struct rk3568_clk_info {bool is_cru; }; -/* Private data for the clock driver - used by rockchip_get_cru() */ struct rk3568_pmuclk_priv {struct rk3568_pmucru *pmucru;ulong ppll_hz;@@ -120,8 +119,10 @@ struct pll_rate_table {unsigned int frac; }; -#define RK3568_PMU_MODE 0x80 +#define RK3568_PMU_CRU_BASE 0xfdd00000#define RK3568_PMU_PLL_CON (x) ((x) * 0x4) +#define RK3568_PMU_MODE 0x80 +#define RK3568_CRU_BASE 0xfdd20000#define RK3568_PLL_CON (x) ((x) * 0x4)#define RK3568_MODE_CON 0xc0arch/arm/mach-rockchip/rk3568/clk_rk3568.c +0
-3@@ -4,10 +4,7 @@*/ #include <dm.h> -#include <syscon.h> -#include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3568.h> -#include <linux/err.h> Quoted 5 lines
arch/arm/mach-rockchip/rk3568/clk_rk3568.c line 10
Quoted 2 lines
arch/arm/mach-rockchip/rk3568/clk_rk3568.c +0
-0int rockchip_get_clk (struct udevice **devp) {There's no user of that function anymore after this patch, so just squash the patch removing it later in this series with this patch here.
Quoted 6 lines
This function is technically a public function declared in
asm/arch-rockchip/clock.h. Removing it in same patch that refactors to use a constant seem like it would go against your normal stand on not doing two different things in one patch, and a reason why it was split to begin with ;-)
Oh well, it was clear in my head this was a case of "it obviously must be together" but now that you put it into words, I can see an argument for it. I guess you could say the same for the last driver of a subsystem, you likely will remove the driver separately from the subsystem. Eh, pick for yourself for v2 what you want to do, it's not too important :) This reminds me I probably should start using Conventional Comments (https://conventionalcomments.org/) to make it clear what is required to changed/nice-to-haves (obviously, something marked as an issue/blocker can always be discussed and argued against :) ).
Cheers,
Quentin
PATCH 4/10 clk: rockchip: rk3568: Use fixed PMU CRU base address for PLL access
In reply to Jonas KarlmanThe RK3568 PMU PLL helpers lookup the PMU CRU udevice before accessing PMU PLL regs. This may trigger a full PMU clock driver probe to get the PMU CRU base address from the clock driver private data, something that can take several ms.
Change to use the RK3568 specific PMU CRU base address consant directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
--- drivers/clk/rockchip/clk_rk3568.c | 34 +++++-------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
drivers/clk/rockchip/clk_rk3568.c +5 -29
@@ -94,44 +94,20 @@ static ulong rk3568_pmu_pll_set_rate(struct rk3568_clk_priv *priv, ulong pll_id, ulong rate) { - struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); - -rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id, rate); + static void * const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE; -return 0 ; +return rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], + pmu_cru_base, pll_id, rate); }#endif static ulong rk3568_pmu_pll_get_rate (struct rk3568_clk_priv *priv,ulong pll_id) { -struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); +static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ;return rockchip_pll_get_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id); + pmu_cru_base, pll_id); }/*
Signature · 1 line
2.54.0
Re: [PATCH 04/10] clk: rockchip: rk3568: Use fixed PMU CRU base address
Hi Jonas,
Quoted 9 lines · Jonas Karlman
The RK3568 PMU PLL helpers lookup the PMU CRU udevice before accessing PMU PLL regs. This may trigger a full PMU clock driver probe to get the PMU CRU base address from the clock driver private data, something that can take several ms.
Change to use the RK3568 specific PMU CRU base address consant directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
If we agree on using constants, we should do this throughout the whole source file, replacing any reference to priv->cru and priv->pmucru with constants. I know it sounds quite old-fashioned, but if abstraction provides no advantage, IMO it's just obfuscating the triviality, thus I would drop it and focus on consistency, instead.
drivers/clk/rockchip/clk_rk3568.c static ulong · line 95
Quoted 13 lines
Signed-off-by Jonas Karlman <[email protected]>--- drivers/clk/rockchip/clk_rk3568.c | 34 +++++-------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)drivers/clk/rockchip/clk_rk3568.c +0
-0@@ -94,44 +94,20 @@ static ulong rk3568_pmu_pll_set_rate(struct rk3568_clk_priv *priv, ulong pll_id, ulong rate)
Please, drop the priv argument too, as unused (it was already, of course).
Quoted 16 lines
drivers/clk/rockchip/clk_rk3568.c +0
-15{ -struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); - -rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id, rate);
drivers/clk/rockchip/clk_rk3568.c static ulong · line 105
Quoted 10 lines
drivers/clk/rockchip/clk_rk3568.c +3
-1+static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ; - return 0; +return rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], + pmu_cru_base, pll_id, rate); }#endif static ulong rk3568_pmu_pll_get_rate (struct rk3568_clk_priv *priv,ulong pll_id)
Ditto.
Quoted 23 lines
drivers/clk/rockchip/clk_rk3568.c +2
-14{ -struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); +static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ;return rockchip_pll_get_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id); + pmu_cru_base, pll_id); }/* -- 2.54.0
Re: [PATCH 04/10] clk: rockchip: rk3568: Use fixed PMU CRU base address
Hi Massimo,
Quoted 13 lines · Massimo Pegorer
Hi Jonas,
Quoted 9 lines · Jonas Karlman
The RK3568 PMU PLL helpers lookup the PMU CRU udevice before accessing PMU PLL regs. This may trigger a full PMU clock driver probe to get the PMU CRU base address from the clock driver private data, something that can take several ms.
Change to use the RK3568 specific PMU CRU base address consant directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Quoted 5 lines
If we agree on using constants, we should do this throughout the whole source file, replacing any reference to
priv->cruandpriv->pmucruwith constants. I know it sounds quite old-fashioned, but if abstraction provides no advantage, IMO it's just obfuscating the triviality, thus I would drop it and focus on consistency, instead.
Refactoring the clock drivers to fully use constants is in works for a future series, at the moment this is only something I have in my local tree. The most recent added RK clock driver already only uses constants and there are some discussions related in a thread at [1], and in my rk3562 branch [2] I have transitioned all clock drivers for the added rk3562, rv1106, rv1103b, rv1126b, rk3538 and rk3572 SoCs to use constants and other proposed changes.
This series tries to reduce impact on callers, and exclude any refactoring not tied to reading CRU base address from clock driver private data. I see no reason to bundle full clock driver refactoring to this series, that is better suited in a separate future series.
[1] https://lore.kernel.org/u-boot/[email protected]/T/
[2] https://git.u-boot-project.org/u-boot/contributors/kwiboo/u-boot/-/tree/rk3562/drivers/clk/rockchip
Quoted 7 lines
Quoted 7 lines
Signed-off-by Jonas Karlman <[email protected]>--- drivers/clk/rockchip/clk_rk3568.c | 34 +++++-------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)
Quoted 9 lines
drivers/clk/rockchip/clk_rk3568.c static ulong · line 95
Quoted 7 lines
drivers/clk/rockchip/clk_rk3568.c +0
-0@@ -94,44 +94,20 @@ static ulong rk3568_pmu_pll_set_rate(struct rk3568_clk_priv *priv, ulong pll_id, ulong rate)Please, drop the priv argument too, as unused (it was already, of course).
Such refactoring is better handled in a separate patch/series, and I partially disagree with dropping the priv argument, keeping arguments consistent for all set_rate/get_rate helpers tend to weight higher for my taste.
Regards,
Jonas
Quoted 53 lines
Quoted 17 lines
drivers/clk/rockchip/clk_rk3568.c +0
-15{ -struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); - -rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id, rate);drivers/clk/rockchip/clk_rk3568.c static ulong · line 105
Quoted 10 lines
drivers/clk/rockchip/clk_rk3568.c +3
-1+static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ; - return 0; +return rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], + pmu_cru_base, pll_id, rate); }#endif static ulong rk3568_pmu_pll_get_rate (struct rk3568_clk_priv *priv,ulong pll_id)Ditto.
Quoted 23 lines
drivers/clk/rockchip/clk_rk3568.c +2
-14{ -struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); +static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ;return rockchip_pll_get_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id); + pmu_cru_base, pll_id); }/* -- 2.54.0
Re: [PATCH 04/10] clk: rockchip: rk3568: Use fixed PMU CRU base address for PLL access
In reply to Jonas KarlmanHi Jonas,
Quoted 28 lines · Jonas Karlman
The RK3568 PMU PLL helpers lookup the PMU CRU udevice before accessing PMU PLL regs. This may trigger a full PMU clock driver probe to get the PMU CRU base address from the clock driver private data, something that can take several ms.
Change to use the RK3568 specific PMU CRU base address consant directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Signed-off-by Jonas Karlman <[email protected]>--- drivers/clk/rockchip/clk_rk3568.c | 34 +++++-------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)drivers/clk/rockchip/clk_rk3568.c +0
-6@@ -94,44 +94,20 @@ static ulong rk3568_pmu_pll_set_rate(struct rk3568_clk_priv *priv, ulong pll_id, ulong rate) { - struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_DRIVER_GET(rockchip_rk3568_pmucru),
drivers/clk/rockchip/clk_rk3568.c static ulong · line 97
Quoted 10 lines
drivers/clk/rockchip/clk_rk3568.c +1
-9- &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); - -rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id, rate); +static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ;
Do we really need a static variable here?
drivers/clk/rockchip/clk_rk3568.c static ulong · line 100
Quoted 4 lines
drivers/clk/rockchip/clk_rk3568.c +2
-1-return 0 ; +return rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], + pmu_cru_base, pll_id, rate);
This is a change in behavior, please have the change from return 0 to return rockchip_pll_set_rate in a separate commit.
Quoted 10 lines
drivers/clk/rockchip/clk_rk3568.c +0
-4}#endif static ulong rk3568_pmu_pll_get_rate (struct rk3568_clk_priv *priv,ulong pll_id) { -struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; -
drivers/clk/rockchip/clk_rk3568.c static ulong · line 108
Quoted 10 lines
drivers/clk/rockchip/clk_rk3568.c +1
-8- ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); +static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ;
Ditto for the static keyword here.
Changes are fine otherwise.
Cheers,
Quentin
Re: [PATCH 04/10] clk: rockchip: rk3568: Use fixed PMU CRU base address for PLL access
Hi Quentin,
Quoted 35 lines · Quentin Schulz
Hi Jonas,
Quoted 32 lines · Jonas Karlman
The RK3568 PMU PLL helpers lookup the PMU CRU udevice before accessing PMU PLL regs. This may trigger a full PMU clock driver probe to get the PMU CRU base address from the clock driver private data, something that can take several ms.
Change to use the RK3568 specific PMU CRU base address consant directly to simplify and remove the unneeded complexity of using runtime lookup in SoC specific code.
Signed-off-by Jonas Karlman <[email protected]>--- drivers/clk/rockchip/clk_rk3568.c | 34 +++++-------------------------- 1 file changed, 5 insertions(+), 29 deletions(-)drivers/clk/rockchip/clk_rk3568.c +0
-10@@ -94,44 +94,20 @@ static ulong rk3568_pmu_pll_set_rate(struct rk3568_clk_priv *priv, ulong pll_id, ulong rate) { - struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) { -printf ("%s: could not find pmucru device\n" , __func__); -return ret;
Quoted 8 lines
drivers/clk/rockchip/clk_rk3568.c static ulong · line 97
Quoted 6 lines
drivers/clk/rockchip/clk_rk3568.c +1
-5- } - pmu_priv =dev_get_priv (pmucru_dev); - -rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], - pmu_priv->pmucru, pll_id, rate); +static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ;Do we really need a static variable here?
I guess not, there seem to be a mix use of static vs non-static for similar variables in Rockchip code, have changed to following for v2:
struct rk3568_pmucru * const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE;
There is no change in code so the compiler strips out the static vs non-static variable away the same.
Quoted 8 lines
drivers/clk/rockchip/clk_rk3568.c static ulong · line 100
Quoted 5 lines
drivers/clk/rockchip/clk_rk3568.c +2
-1-return 0 ; +return rockchip_pll_set_rate (&rk3568_pll_clks[pll_id], + pmu_cru_base, pll_id, rate);This is a change in behavior, please have the change from return 0 to return
rockchip_pll_set_ratein a separate commit.
Sure, I will split the change to make set_rate return the configured rate to a separate patch.
Quoted 15 lines
Quoted 15 lines
drivers/clk/rockchip/clk_rk3568.c +0
-8}#endif static ulong rk3568_pmu_pll_get_rate (struct rk3568_clk_priv *priv,ulong pll_id) { -struct udevice *pmucru_dev; -struct rk3568_pmuclk_priv *pmu_priv; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_pmucru), - &pmucru_dev); -if (ret) {
Quoted 8 lines
drivers/clk/rockchip/clk_rk3568.c static ulong · line 98
Quoted 6 lines
drivers/clk/rockchip/clk_rk3568.c +1
-4-printf ("%s: could not find pmucru device\n" , __func__); -return ret; - } - pmu_priv =dev_get_priv (pmucru_dev); +static void *const pmu_cru_base = (void *)RK3568_PMU_CRU_BASE ;Ditto for the static keyword here.
Have made same change here as above for v2.
Regards,
Jonas
Quoted 5 lines
Changes are fine otherwise.
Cheers,
Quentin
PATCH 5/10 rockchip: rk3568: Remove unused rockchip_get_pmucru() helper
In reply to Jonas KarlmanThe rockchip_get_pmucru() helper is only used by RK3399 SDRAM init code to help get the PMU CRU base address from the clock driver private data.
RK3568 has no uses for the rockchip_get_pmucru() helper, let's drop it.
--- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 5 ----- 1 file changed, 5 deletions(-)
arch/arm/mach-rockchip/rk3568/clk_rk3568.c +0 -5
@@ -16,8 +16,3 @@ void *rockchip_get_cru(void) {return (void *)RK3568_CRU_BASE ; } - -void *rockchip_get_pmucru (void ) -{ -return (void *)RK3568_PMU_CRU_BASE ; -}
Signature · 1 line
2.54.0
Re: [PATCH 05/10] rockchip: rk3568: Remove unused rockchip_get_pmucru() helper
Hi Jonas,
Quoted 5 lines · Jonas Karlman
The
rockchip_get_pmucru()helper is only used by RK3399 SDRAM init code to help get the PMU CRU base address from the clock driver private data.RK3568 has no uses for the
rockchip_get_pmucru()helper, let's drop it.
Maybe move this patch before the one where you switch to use hardcoded register address to make the diff smaller?
Thanks!
Quentin
Re: [PATCH 05/10] rockchip: rk3568: Remove unused rockchip_get_pmucru() helper
Hi Quentin,
Quoted 11 lines · Quentin Schulz
Hi Jonas,
Quoted 5 lines · Jonas Karlman
The
rockchip_get_pmucru()helper is only used by RK3399 SDRAM init code to help get the PMU CRU base address from the clock driver private data.RK3568 has no uses for the
rockchip_get_pmucru()helper, let's drop it.Maybe move this patch before the one where you switch to use hardcoded register address to make the diff smaller?
Sure, I will move removal of rockchip_get_pmucru() before any refactoring is made for v2.
Regards,
Jonas
Quoted 5 lines
Reviewed-by Quentin Schulz <[email protected]>Thanks!
Quentin
PATCH 6/10 rockchip: rk3568: Remove unused rockchip_get_clk() helper
In reply to Jonas KarlmanThe rockchip_get_clk() helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.
RK3568 has no uses for the rockchip_get_clk() helper, let's drop it.
--- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/mach-rockchip/rk3568/clk_rk3568.c +1 -7
@@ -3,15 +3,9 @@* (C) Copyright 2021 Rockchip Electronics Co., Ltd */ -#include <dm.h> +#include <linux/kernel.h> #include <asm/arch-rockchip/cru_rk3568.h> -int rockchip_get_clk (struct udevice **devp) -{ -return uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3568_cru), devp); -} -void *rockchip_get_cru (void ) {return (void *)RK3568_CRU_BASE ;
Signature · 1 line
2.54.0
PATCH 7/10 rockchip: rk3588: Remove unused rockchip_get_clk() helper
In reply to Jonas KarlmanThe rockchip_get_clk() helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.
RK3588 has no uses for the rockchip_get_clk() helper, let's drop it.
--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +1 -7
@@ -3,15 +3,9 @@* (C) Copyright 2020 Rockchip Electronics Co., Ltd. */ -#include <dm.h> +#include <linux/kernel.h> #include <asm/arch-rockchip/cru_rk3588.h> -int rockchip_get_clk (struct udevice **devp) -{ -return uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3588_cru), devp); -} -void *rockchip_get_cru (void ) {return (void *)RK3588_CRU_BASE ;
Signature · 1 line
2.54.0
Re: [PATCH 07/10] rockchip: rk3588: Remove unused rockchip_get_clk() helper
Hi Jonas,
Quoted 16 lines · Jonas Karlman
The
rockchip_get_clk()helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.RK3588 has no uses for the
rockchip_get_clk()helper, let's drop it.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-0
arch/arm/mach-rockchip/rk3588/clk_rk3588.c line 6
Quoted 5 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +1
-1@@ -3,15 +3,9 @@* (C) Copyright 2020 Rockchip Electronics Co., Ltd. */ -#include <dm.h> +#include <linux/kernel.h>
Why do we need this included now?
Otherwise looks good to me.
Cheers,
Quentin
Re: [PATCH 07/10] rockchip: rk3588: Remove unused rockchip_get_clk() helper
Hi Quentin,
Quoted 22 lines · Quentin Schulz
Hi Jonas,
Quoted 19 lines · Jonas Karlman
The
rockchip_get_clk()helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.RK3588 has no uses for the
rockchip_get_clk()helper, let's drop it.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-0@@ -3,15 +3,9 @@* (C) Copyright 2020 Rockchip Electronics Co., Ltd. */
Quoted 4 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c line 6
Quoted 2 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +1
-1-#include <dm.h> +#include <linux/kernel.h> Why do we need this included now?
It seems to be needed due to use of check_member() in the CRU header. Will make a note of it in the commit message for v2.
Regards,
Jonas
Quoted 5 lines
Otherwise looks good to me.
Cheers,
Quentin
Re: [PATCH 07/10] rockchip: rk3588: Remove unused rockchip_get_clk() helper
Hi Jonas,
Quoted 25 lines · Jonas Karlman
Hi Quentin,
Quoted 22 lines · Quentin Schulz
Hi Jonas,
Quoted 19 lines · Jonas Karlman
The
rockchip_get_clk()helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.RK3588 has no uses for the
rockchip_get_clk()helper, let's drop it.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-0@@ -3,15 +3,9 @@* (C) Copyright 2020 Rockchip Electronics Co., Ltd. */
Quoted 8 lines
Quoted 4 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c line 6
Quoted 2 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +1
-1-#include <dm.h> +#include <linux/kernel.h> Why do we need this included now?
It seems to be needed due to use of
check_member()in the CRU header. Will make a note of it in the commit message for v2.
Please instead fix the CRU header so it lists what it needs in its own include file (separate commit prior to removing the unused function please), otherwise we'll need all includers of the CRU header also include this.
Cheers,
Quentin
Re: [PATCH 07/10] rockchip: rk3588: Remove unused rockchip_get_clk() helper
Hi Quentin,
Quoted 33 lines · Quentin Schulz
Hi Jonas,
Quoted 30 lines · Jonas Karlman
Hi Quentin,
Quoted 26 lines · Quentin Schulz
Hi Jonas,
Quoted 16 lines · Jonas Karlman
The
rockchip_get_clk()helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.RK3588 has no uses for the
rockchip_get_clk()helper, let's drop it.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)arch/arm/mach-rockchip/rk3588/clk_rk3588.c +0
-0arch/arm/mach-rockchip/rk3588/clk_rk3588.c line 6
Quoted 5 lines
arch/arm/mach-rockchip/rk3588/clk_rk3588.c +1
-1@@ -3,15 +3,9 @@* (C) Copyright 2020 Rockchip Electronics Co., Ltd. */ -#include <dm.h> +#include <linux/kernel.h> Why do we need this included now?
Quoted 8 lines
Quoted 3 lines
It seems to be needed due to use of
check_member()in the CRU header. Will make a note of it in the commit message for v2.Please instead fix the CRU header so it lists what it needs in its own include file (separate commit prior to removing the unused function please), otherwise we'll need all includers of the CRU header also include this.
Sure, I will instead update the CRU headers to include any required header for v2.
Regards,
Jonas
Quoted 3 lines
Cheers,
Quentin
PATCH 8/10 rockchip: rk3576: Remove unused rockchip_get_clk() helper
In reply to Jonas KarlmanThe rockchip_get_clk() helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.
RK3576 has no uses for the rockchip_get_clk() helper, let's drop it.
--- arch/arm/mach-rockchip/rk3576/clk_rk3576.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/mach-rockchip/rk3576/clk_rk3576.c +1 -7
@@ -3,15 +3,9 @@* (C) Copyright 2020 Rockchip Electronics Co., Ltd. */ -#include <dm.h> +#include <linux/kernel.h> #include <asm/arch-rockchip/cru_rk3576.h> -int rockchip_get_clk (struct udevice **devp) -{ -return uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3576_cru), devp); -} -void *rockchip_get_cru (void ) {return (void *)RK3576_CRU_BASE ;
Signature · 1 line
2.54.0
PATCH 9/10 rockchip: rk3528: Remove unused rockchip_get_clk() helper
In reply to Jonas KarlmanThe rockchip_get_clk() helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.
RK3528 has no uses for the rockchip_get_clk() helper, let's drop it.
--- arch/arm/mach-rockchip/rk3528/clk_rk3528.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/mach-rockchip/rk3528/clk_rk3528.c +1 -7
@@ -1,15 +1,9 @@// SPDX-License-Identifier: GPL-2.0-or-later // Copyright Contributors to the U-Boot project. -#include <dm.h> +#include <linux/kernel.h> #include <asm/arch-rockchip/cru_rk3528.h> -int rockchip_get_clk (struct udevice **devp) -{ -return uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3528_cru), devp); -} -void *rockchip_get_cru (void ) {return RK3528_CRU_BASE ;
Signature · 1 line
2.54.0
PATCH 10/10 rockchip: rk3506: Remove unused rockchip_get_clk() helper
In reply to Jonas KarlmanThe rockchip_get_clk() helper is typically used by SDRAM init code of older SoC generations or to help get the CRU base address from the clock driver private data.
RK3506 has no uses for the rockchip_get_clk() helper, let's drop it.
--- arch/arm/mach-rockchip/rk3506/clk_rk3506.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/mach-rockchip/rk3506/clk_rk3506.c +1 -7
@@ -1,15 +1,9 @@// SPDX-License-Identifier: GPL-2.0-or-later // Copyright Contributors to the U-Boot project. -#include <dm.h> +#include <linux/kernel.h> #include <asm/arch-rockchip/cru_rk3506.h> -int rockchip_get_clk (struct udevice **devp) -{ -return uclass_get_device_by_driver (UCLASS_CLK , -DM_DRIVER_GET (rockchip_rk3506_cru), devp); -} -void *rockchip_get_cru (void ) {return (void *)RK3506_CRU_BASE ;
Signature · 1 line
2.54.0
Hi Jonas,
Quoted 11 lines · Jonas Karlman
This series takes the initial steps to try and remove use of
rockchip_get_clk()to get the clock device orrockchip_get_cru()to get the CRU base address at runtime for the Rockchip platform.This series is similar to the "rockchip: Remove unneeded syscon driver for RK35xx" [1] series, but focuses on CRU instead of GRF.
The CRU base addresses are fixed and known at compile time, yet drivers keep trying to resolve them at runtime delaying some operations by several ms.
I would rather use device tree whenever possible, instead of relying on hardcoded constants. Considering the contexts in which rockchip_get_cru() and rockchip_get_pmucru() are called (that is, in the DRAM driver will eventually be called only in DM-less TPL so cannot rely on DT being present to fetch CRU from it, and in the sysreset driver which doesn't have a description in the device tree), this here is acceptable to me as is. But we should think about documenting the exceptions to the "please get the info from device tree and do not use hardcoded addresses" rule. A problem for later :)
Cheers,
Quentin
Quoted 37 lines
In this initial part the RK3568 and RK3588 specific helpers are updated to use CRU base address constants, similar to the other RK35xx SoCs, and the
rockchip_get_clk()helper is removed for all RK35xx SoCs.The changes included in this series have no intended behavior change for the affected RK35xx SoCs.
A follow-up series will introduce a
rockchip_sysreset_bind()helper that passes the CRU base address to thesysreset_rockchipdriver, drops the call torockchip_get_cru()along with implementing theget_status()ops.[1] https://patchwork.ozlabs.org/cover/2280781/
Jonas Karlman (10):
rockchip: rk3588: RenameCRU_BASEtoRK3588_CRU_BASE
rockchip: rk3588: Use fixed CRU base address
rockchip: rk3568: Use fixed CRU and PMU CRU base addresses
clk: rockchip: rk3568: Use fixed PMU CRU base address for PLL access
rockchip: rk3568: Remove unusedrockchip_get_pmucru()helper
rockchip: rk3568: Remove unusedrockchip_get_clk()helper
rockchip: rk3588: Remove unusedrockchip_get_clk()helper
rockchip: rk3576: Remove unusedrockchip_get_clk()helper
rockchip: rk3528: Remove unusedrockchip_get_clk()helper
rockchip: rk3506: Remove unusedrockchip_get_clk()helper.../include/asm/arch-rockchip/cru_rk3568.h | 5 ++- .../include/asm/arch-rockchip/cru_rk3588.h | 2 +- arch/arm/mach-rockchip/rk3506/clk_rk3506.c | 8 +--- arch/arm/mach-rockchip/rk3528/clk_rk3528.c | 8 +--- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 44 +------------------ arch/arm/mach-rockchip/rk3576/clk_rk3576.c | 8 +--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 23 +--------- .../jaguar_rk3588/jaguar_rk3588.c | 2 +- .../tiger_rk3588/tiger_rk3588.c | 2 +- drivers/clk/rockchip/clk_rk3568.c | 34 +++----------- 10 files changed, 18 insertions(+), 118 deletions(-)
Hi Quentin,
Quoted 15 lines · Quentin Schulz
Hi Jonas,
Quoted 11 lines · Jonas Karlman
This series takes the initial steps to try and remove use of
rockchip_get_clk()to get the clock device orrockchip_get_cru()to get the CRU base address at runtime for the Rockchip platform.This series is similar to the "rockchip: Remove unneeded syscon driver for RK35xx" [1] series, but focuses on CRU instead of GRF.
The CRU base addresses are fixed and known at compile time, yet drivers keep trying to resolve them at runtime delaying some operations by several ms.
Quoted 9 lines
I would rather use device tree whenever possible, instead of relying on hardcoded constants. Considering the contexts in which
rockchip_get_cru()androckchip_get_pmucru()are called (that is, in the DRAM driver will eventually be called only in DM-less TPL so cannot rely on DT being present to fetch CRU from it, and in the sysreset driver which doesn't have a description in the device tree), this here is acceptable to me as is. But we should think about documenting the exceptions to the "please get the info from device tree and do not use hardcoded addresses" rule. A problem for later :)
I agree, we should use values from device tree where possible and appropriate. And as mentioned in the other thread, my acceptable exceptions are CRU, RAM and arch_cpu_init()+board_debug_uart_init() in xPL. With main reason being that anything in TPL (dram init) may or may not have access to DT, DM or otherwise be size constrained. And in SPL typically because of consistency, e.g. code may be shared with TPL, or we may need to do some one-off thing for a specific SoC, e.g. disable JTAG in arch_cpu_init().
Regards,
Jonas
Quoted 42 lines
Cheers,
QuentinQuoted 37 lines
In this initial part the RK3568 and RK3588 specific helpers are updated to use CRU base address constants, similar to the other RK35xx SoCs, and the
rockchip_get_clk()helper is removed for all RK35xx SoCs.The changes included in this series have no intended behavior change for the affected RK35xx SoCs.
A follow-up series will introduce a
rockchip_sysreset_bind()helper that passes the CRU base address to thesysreset_rockchipdriver, drops the call torockchip_get_cru()along with implementing theget_status()ops.[1] https://patchwork.ozlabs.org/cover/2280781/
Jonas Karlman (10):
rockchip: rk3588: RenameCRU_BASEtoRK3588_CRU_BASE
rockchip: rk3588: Use fixed CRU base address
rockchip: rk3568: Use fixed CRU and PMU CRU base addresses
clk: rockchip: rk3568: Use fixed PMU CRU base address for PLL access
rockchip: rk3568: Remove unusedrockchip_get_pmucru()helper
rockchip: rk3568: Remove unusedrockchip_get_clk()helper
rockchip: rk3588: Remove unusedrockchip_get_clk()helper
rockchip: rk3576: Remove unusedrockchip_get_clk()helper
rockchip: rk3528: Remove unusedrockchip_get_clk()helper
rockchip: rk3506: Remove unusedrockchip_get_clk()helper.../include/asm/arch-rockchip/cru_rk3568.h | 5 ++- .../include/asm/arch-rockchip/cru_rk3588.h | 2 +- arch/arm/mach-rockchip/rk3506/clk_rk3506.c | 8 +--- arch/arm/mach-rockchip/rk3528/clk_rk3528.c | 8 +--- arch/arm/mach-rockchip/rk3568/clk_rk3568.c | 44 +------------------ arch/arm/mach-rockchip/rk3576/clk_rk3576.c | 8 +--- arch/arm/mach-rockchip/rk3588/clk_rk3588.c | 23 +--------- .../jaguar_rk3588/jaguar_rk3588.c | 2 +- .../tiger_rk3588/tiger_rk3588.c | 2 +- drivers/clk/rockchip/clk_rk3568.c | 34 +++----------- 10 files changed, 18 insertions(+), 118 deletions(-)
Quoted 28 lines · Jonas Karlman
Hi Quentin,
Quoted 15 lines · Quentin Schulz
Hi Jonas,
Quoted 11 lines · Jonas Karlman
This series takes the initial steps to try and remove use of
rockchip_get_clk()to get the clock device orrockchip_get_cru()to get the CRU base address at runtime for the Rockchip platform.This series is similar to the "rockchip: Remove unneeded syscon driver for RK35xx" [1] series, but focuses on CRU instead of GRF.
The CRU base addresses are fixed and known at compile time, yet drivers keep trying to resolve them at runtime delaying some operations by several ms.
Quoted 9 lines
I would rather use device tree whenever possible, instead of relying on hardcoded constants. Considering the contexts in which
rockchip_get_cru()androckchip_get_pmucru()are called (that is, in the DRAM driver will eventually be called only in DM-less TPL so cannot rely on DT being present to fetch CRU from it, and in the sysreset driver which doesn't have a description in the device tree), this here is acceptable to me as is. But we should think about documenting the exceptions to the "please get the info from device tree and do not use hardcoded addresses" rule. A problem for later :)
Quoted 9 lines
I agree, we should use values from device tree where possible and appropriate. And as mentioned in the other thread, my acceptable exceptions are CRU, RAM and arch_cpu_init()+board_debug_uart_init() in xPL. With main reason being that anything in TPL (dram init) may or may not have access to DT, DM or otherwise be size constrained. And in SPL typically because of consistency, e.g. code may be shared with TPL, or we may need to do some one-off thing for a specific SoC, e.g. disable JTAG in
arch_cpu_init().
What I meant to say is that we should add this documentation to doc/ somewhere so *other* contributors know about these rules too. It's good to have it written here so there's somewhere we can look at until we have this written somewhere in the docs. I'm also not asking you to write this documentation, just to be clear :)
Cheers,
Quentin