rockchip: Clock fixes for RK3568
Subsystems (3)
cover rockchip: Clock fixes for RK3568
This series include fixes for minor clock related issues observed while working on other series.
Patch 1-2 fixes real issues in the clock driver. Patch 3 change to include support for UART clock in SPL. Patcj 4 adds dummy support for GMAC speed clocks. Patch 5 set a common max-frequency value for sdhci
Damon Ding (1):
clk: rockchip: rk3568: Fix clk selection in rk3568_pwm_get_clk
Jonas Karlman (4):
clk: rockchip: rk3568: Fix mask for clk_cpll_div_25m_div
clk: rockchip: rk3568: Include UART clocks in SPL
clk: rockchip: rk3568: Add dummy support for GMAC speed clocks
rockchip: rk356x-u-boot: Set max-frequency prop in sdhci node
arch/arm/dts/rk356x-u-boot.dtsi | 3 +-- arch/arm/include/asm/arch-rockchip/cru_rk3568.h | 2 +- drivers/clk/rockchip/clk_rk3568.c | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/5 clk: rockchip: rk3568: Fix clk selection in rk3568_pwm_get_clk
From: Damon Ding <[email protected]>
Fix use of wrong clk selection for CLK_PWM1 on RK3568.
--- drivers/clk/rockchip/clk_rk3568.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3568.c +1 -1
@@ -1142,7 +1142,7 @@ static ulong rk3568_pwm_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)switch (clk_id) {case CLK_PWM1 : - sel = (con &CLK_PWM1_SEL_MASK ) >>CLK_PWM3_SEL_SHIFT ; + sel = (con &CLK_PWM1_SEL_MASK ) >>CLK_PWM1_SEL_SHIFT ;break ;case CLK_PWM2 : sel = (con &CLK_PWM2_SEL_MASK ) >>CLK_PWM2_SEL_SHIFT ;
Signature · 1 line
2.41.0
Re: [PATCH 1/5] clk: rockchip: rk3568: Fix clk selection in rk3568_pwm_get_clk
Quoted 7 lines · Jonas Karlman
From: Damon Ding <[email protected]>
Fix use of wrong clk selection for
CLK_PWM1on RK3568.Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")Signed-off-by Damon Ding <[email protected]>Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 17 lines
--- drivers/clk/rockchip/clk_rk3568.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/clk/rockchip/clk_rk3568.c +1
-1@@ -1142,7 +1142,7 @@ static ulong rk3568_pwm_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)switch (clk_id) {case CLK_PWM1 : - sel = (con &CLK_PWM1_SEL_MASK ) >>CLK_PWM3_SEL_SHIFT ; + sel = (con &CLK_PWM1_SEL_MASK ) >>CLK_PWM1_SEL_SHIFT ;break ;case CLK_PWM2 : sel = (con &CLK_PWM2_SEL_MASK ) >>CLK_PWM2_SEL_SHIFT ;
PATCH 2/5 clk: rockchip: rk3568: Fix mask for clk_cpll_div_25m_div
In reply to Jonas KarlmanThe field for clk_cpll_div_25m_div in CRU_CLKSEL_CON81 is 6 bits wide, not 5 bits wide as currently defined in CPLL_25M_DIV_MASK.
Fix this and the assert so that CPLL_25M can be assigned a 25 MHz rate.
--- arch/arm/include/asm/arch-rockchip/cru_rk3568.h | 2 +- drivers/clk/rockchip/clk_rk3568.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3568.h +1 -1
@@ -493,7 +493,7 @@ enum {/* CRU_CLK_SEL81_CON */ CPLL_25M_DIV_SHIFT =8 , -CPLL_25M_DIV_MASK =0x1f <<CPLL_25M_DIV_SHIFT , +CPLL_25M_DIV_MASK =0x3f <<CPLL_25M_DIV_SHIFT ,CPLL_50M_DIV_SHIFT =0 , CPLL_50M_DIV_MASK = 0x1f << CPLL_50M_DIV_SHIFT,
drivers/clk/rockchip/clk_rk3568.c +4 -1
@@ -702,7 +702,10 @@ static ulong rk3568_cpll_div_set_rate(struct rk3568_clk_priv *priv, } div =DIV_ROUND_UP (priv->cpll_hz, rate); -assert (div -1 <=31 ); +if (clk_id ==CPLL_25M ) +assert (div -1 <=63 ); +else +assert (div -1 <=31 );rk_clrsetreg (&cru->clksel_con[con], mask, (div -1 ) << shift);return rk3568_cpll_div_get_rate (priv, clk_id);
Signature · 1 line
2.41.0
Re: [PATCH 2/5] clk: rockchip: rk3568: Fix mask for clk_cpll_div_25m_div
Quoted 7 lines · Jonas Karlman
The field for
clk_cpll_div_25m_divinCRU_CLKSEL_CON81is 6 bits wide, not 5 bits wide as currently defined inCPLL_25M_DIV_MASK.Fix this and the assert so that
CPLL_25Mcan be assigned a 25 MHz rate.Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 34 lines
--- arch/arm/include/asm/arch-rockchip/cru_rk3568.h | 2 +- drivers/clk/rockchip/clk_rk3568.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)arch/arm/include/asm/arch-rockchip/cru_rk3568.h +1
-1@@ -493,7 +493,7 @@ enum {/* CRU_CLK_SEL81_CON */ CPLL_25M_DIV_SHIFT =8 , -CPLL_25M_DIV_MASK =0x1f <<CPLL_25M_DIV_SHIFT , +CPLL_25M_DIV_MASK =0x3f <<CPLL_25M_DIV_SHIFT ,CPLL_50M_DIV_SHIFT =0 , CPLL_50M_DIV_MASK = 0x1f << CPLL_50M_DIV_SHIFT,drivers/clk/rockchip/clk_rk3568.c +4
-1@@ -702,7 +702,10 @@ static ulong rk3568_cpll_div_set_rate(struct rk3568_clk_priv *priv, } div =DIV_ROUND_UP (priv->cpll_hz, rate); -assert (div -1 <=31 ); +if (clk_id ==CPLL_25M ) +assert (div -1 <=63 ); +else +assert (div -1 <=31 );rk_clrsetreg (&cru->clksel_con[con], mask, (div -1 ) << shift);return rk3568_cpll_div_get_rate (priv, clk_id);
PATCH 3/5 clk: rockchip: rk3568: Include UART clocks in SPL
In reply to Jonas KarlmanThe clock driver for RK3568 does not include support for UART clocks in SPL. This result in the following message with high enough loglevel.
ns16550_serial serial@fe660000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19
Fix this by including support for UART clocks in SPL.
--- drivers/clk/rockchip/clk_rk3568.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/rockchip/clk_rk3568.c +3 -3
@@ -2189,6 +2189,7 @@ static ulong rk3568_rkvdec_set_clk(struct rk3568_clk_priv *priv, return rk3568_rkvdec_get_clk(priv, clk_id); } +#endif static ulong rk3568_uart_get_rate (struct rk3568_clk_priv *priv,ulong clk_id) {
@@ -2324,7 +2325,6 @@ static ulong rk3568_uart_set_rate(struct rk3568_clk_priv *priv,return rk3568_uart_get_rate (priv, clk_id); } -#endif static ulong rk3568_clk_get_rate (struct clk *clk) {
@@ -2463,6 +2463,7 @@ static ulong rk3568_clk_get_rate(struct clk *clk)case TCLK_WDT_NS : rate =OSC_HZ ;break ; +#endif case SCLK_UART1 :case SCLK_UART2 :case SCLK_UART3 :
@@ -2474,7 +2475,6 @@ static ulong rk3568_clk_get_rate(struct clk *clk)case SCLK_UART9 : rate =rk3568_uart_get_rate (priv, clk->id);break ; -#endif case ACLK_SECURE_FLASH :case ACLK_CRYPTO_NS :case HCLK_SECURE_FLASH :
@@ -2648,6 +2648,7 @@ static ulong rk3568_clk_set_rate(struct clk *clk, ulong rate)case TCLK_WDT_NS : ret =OSC_HZ ;break ; +#endif case SCLK_UART1 :case SCLK_UART2 :case SCLK_UART3 :
@@ -2659,7 +2660,6 @@ static ulong rk3568_clk_set_rate(struct clk *clk, ulong rate)case SCLK_UART9 : ret =rk3568_uart_set_rate (priv, clk->id, rate);break ; -#endif case ACLK_SECURE_FLASH :case ACLK_CRYPTO_NS :case HCLK_SECURE_FLASH :
Signature · 1 line
2.41.0
Re: [PATCH 3/5] clk: rockchip: rk3568: Include UART clocks in SPL
Quoted 10 lines · Jonas Karlman
The clock driver for RK3568 does not include support for UART clocks in SPL. This result in the following message with high enough loglevel.
ns16550_serial serial@fe660000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19Fix this by including support for UART clocks in SPL.
Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")Signed-off-by Jonas Karlman <[email protected]>---
Something like this it's also done for the 3588, and I still have not figured out why. When the rk3588 clock driver was added, I commented on this, but the result was just that the 'clock not found' message was removed.
I am happy that you found some time to do these changes
Re: [PATCH 3/5] clk: rockchip: rk3568: Include UART clocks in SPL
Quoted 5 lines · Eugen Hristev
Quoted 4 lines · Jonas Karlman
The clock driver for RK3568 does not include support for UART clocks in SPL. This result in the following message with high enough loglevel.
ns16550_serial serial@fe660000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19
The change to include UART clocks in SPL does not fix above warning message. Instead the patch at [1] fixes this warning.
This change is however fixing that the ns16550_serial can get the UART clock rate from clock instead of falling back on clock-frequency property in DT. Will re-spin with an updated commit message.
[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Regards,
Jonas
Quoted 16 lines
Quoted 6 lines
Fix this by including support for UART clocks in SPL.
Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")Signed-off-by Jonas Karlman <[email protected]>---
Something like this it's also done for the 3588, and I still have not figured out why. When the rk3588 clock driver was added, I commented on this, but the result was just that the 'clock not found' message was removed.
I am happy that you found some time to do these changes
Reviewed-by Eugen Hristev <[email protected]>
Re: [PATCH 3/5] clk: rockchip: rk3568: Include UART clocks in SPL
In reply to Jonas KarlmanQuoted 9 lines · Jonas Karlman
The clock driver for RK3568 does not include support for UART clocks in SPL. This result in the following message with high enough loglevel.
ns16550_serial serial@fe660000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19Fix this by including support for UART clocks in SPL.
Fixes 4a262feba3a5 ("rockchip: rk3568: add clock driver")Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 56 lines
--- drivers/clk/rockchip/clk_rk3568.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/rockchip/clk_rk3568.c +3
-3@@ -2189,6 +2189,7 @@ static ulong rk3568_rkvdec_set_clk(struct rk3568_clk_priv *priv, return rk3568_rkvdec_get_clk(priv, clk_id); } +#endif static ulong rk3568_uart_get_rate (struct rk3568_clk_priv *priv,ulong clk_id) {@@ -2324,7 +2325,6 @@ static ulong rk3568_uart_set_rate(struct rk3568_clk_priv *priv,return rk3568_uart_get_rate (priv, clk_id); } -#endif static ulong rk3568_clk_get_rate (struct clk *clk) {@@ -2463,6 +2463,7 @@ static ulong rk3568_clk_get_rate(struct clk *clk)case TCLK_WDT_NS : rate =OSC_HZ ;break ; +#endif case SCLK_UART1 :case SCLK_UART2 :case SCLK_UART3 :@@ -2474,7 +2475,6 @@ static ulong rk3568_clk_get_rate(struct clk *clk)case SCLK_UART9 : rate =rk3568_uart_get_rate (priv, clk->id);break ; -#endif case ACLK_SECURE_FLASH :case ACLK_CRYPTO_NS :case HCLK_SECURE_FLASH :@@ -2648,6 +2648,7 @@ static ulong rk3568_clk_set_rate(struct clk *clk, ulong rate)case TCLK_WDT_NS : ret =OSC_HZ ;break ; +#endif case SCLK_UART1 :case SCLK_UART2 :case SCLK_UART3 :@@ -2659,7 +2660,6 @@ static ulong rk3568_clk_set_rate(struct clk *clk, ulong rate)case SCLK_UART9 : ret =rk3568_uart_set_rate (priv, clk->id, rate);break ; -#endif case ACLK_SECURE_FLASH :case ACLK_CRYPTO_NS :case HCLK_SECURE_FLASH :
PATCH 4/5 clk: rockchip: rk3568: Add dummy support for GMAC speed clocks
In reply to Jonas KarlmanPine64 Quartz64 boards DT reference SCLK_GMAC1_RGMII_SPEED in the assigned-clocks property of the gmac1 node. This result in a ENOENT error when driver core tries to set a parent for this clock.
The clock speed in rgmii/rmii mode is changed using clk_set_rate of the tx_rx clock and not using clk_set_parent of the speed clock.
Add dummy support for SCLK_GMAC1_RGMII_SPEED and similar clocks to clk driver to allow a driver for gmac node to probe.
--- drivers/clk/rockchip/clk_rk3568.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/rockchip/clk_rk3568.c +4 -0
@@ -2843,6 +2843,10 @@ static int rk3568_clk_set_parent(struct clk *clk, struct clk *parent)case CLK_RKVDEC_CORE :return rk3568_rkvdec_set_parent (clk, parent);case I2S1_MCLKOUT_TX : +case SCLK_GMAC0_RGMII_SPEED : +case SCLK_GMAC0_RMII_SPEED : +case SCLK_GMAC1_RGMII_SPEED : +case SCLK_GMAC1_RMII_SPEED :break ;default :return -ENOENT ;
Signature · 1 line
2.41.0
Re: [PATCH 4/5] clk: rockchip: rk3568: Add dummy support for GMAC speed clocks
Quoted 11 lines · Jonas Karlman
Pine64 Quartz64 boards DT reference
SCLK_GMAC1_RGMII_SPEEDin the assigned-clocks property of the gmac1 node. This result in a ENOENT error when driver core tries to set a parent for this clock.The clock speed in rgmii/rmii mode is changed using
clk_set_rateof thetx_rxclock and not usingclk_set_parentof the speed clock.Add dummy support for
SCLK_GMAC1_RGMII_SPEEDand similar clocks to clk driver to allow a driver for gmac node to probe.Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 19 lines
--- drivers/clk/rockchip/clk_rk3568.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/clk/rockchip/clk_rk3568.c +4
-0@@ -2843,6 +2843,10 @@ static int rk3568_clk_set_parent(struct clk *clk, struct clk *parent)case CLK_RKVDEC_CORE :return rk3568_rkvdec_set_parent (clk, parent);case I2S1_MCLKOUT_TX : +case SCLK_GMAC0_RGMII_SPEED : +case SCLK_GMAC0_RMII_SPEED : +case SCLK_GMAC1_RGMII_SPEED : +case SCLK_GMAC1_RMII_SPEED :break ;default :return -ENOENT ;
PATCH 5/5 rockchip: rk356x-u-boot: Set max-frequency prop in sdhci node
In reply to Jonas KarlmanMost board device trees for RK356x set max-frequency = <200000000> in the sdhci node, some boards like Quartz64 do not. This result in an error message due to sdhci driver trying to set a clock rate of 0 instead of the max-frequency value.
rockchip_sdhci_probe clk set rate fail!
Fix this by setting a common max-frequency in rk356x-u-boot.dtsi. A patch to set default max-frequency of sdhci node in linux is planned.
Also remove the forced status = "okay" for the sdhci and sdmmc0 nodes, boards already set correct state for these nodes.
--- arch/arm/dts/rk356x-u-boot.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/dts/rk356x-u-boot.dtsi +1 -2
@@ -126,12 +126,11 @@ &sdhci { bootph-pre-ram; - status = "okay"; + max-frequency = <200000000>; }; &sdmmc0 { bootph-pre-ram; - status = "okay"; }; #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
Signature · 1 line
2.41.0
Re: [PATCH 5/5] rockchip: rk356x-u-boot: Set max-frequency prop in sdhci node
Quoted 7 lines · Jonas Karlman
Most board device trees for RK356x set max-frequency = <200000000> in the sdhci node, some boards like Quartz64 do not. This result in an error message due to sdhci driver trying to set a clock rate of 0 instead of the max-frequency value.
rockchip_sdhci_probeclk set rate fail!
Quoted 7 lines
Fix this by setting a common max-frequency in
rk356x-u-boot.dtsi. A patch to set default max-frequency of sdhci node in linux is planned.Also remove the forced status = "okay" for the sdhci and sdmmc0 nodes, boards already set correct state for these nodes.
Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 22 lines
--- arch/arm/dts/rk356x-u-boot.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm/dts/rk356x-u-boot.dtsi +1
-2@@ -126,12 +126,11 @@ &sdhci { bootph-pre-ram; - status = "okay"; + max-frequency = <200000000>; }; &sdmmc0 { bootph-pre-ram; - status = "okay"; }; #ifdef CONFIG_ROCKCHIP_SPI_IMAGE