Make the clock dt-bindings and DT nodes consistent with Linux
Subsystems (4)
Hal Feng
maintainercover Make the clock dt-bindings and DT nodes consistent with Linux
The clock dt-bindings and DT nodes are not consistent with Linux now. Let's sync them with Linux, so the same dtb can work for Linux & U-Boot.
To achieve this goal, the PLL clock driver is separated and some clock IDs conversion is needed in clock drivers.
For the motivation, please see the discussion in the link below.
[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/
Xingyu Wu (5):
clk: starfive: jh7110: Separate the PLL driver
riscv: dts: jh7110: Add PLL clock controller node
riscv: dts: jh7110: Add clock source from PLL
dt-bindings: clock: jh7110: Modify clock id to be same with Linux
clk: starfive: jh7110: Add of_xlate ops and macros for clock id
conversion
.../dts/jh7110-starfive-visionfive-2.dtsi | 6 +- arch/riscv/dts/jh7110-u-boot.dtsi | 1 - arch/riscv/dts/jh7110.dtsi | 16 +- drivers/clk/starfive/clk-jh7110-pll.c | 103 +++++- drivers/clk/starfive/clk-jh7110.c | 306 +++++++++++------- drivers/clk/starfive/clk.h | 58 +--- .../dt-bindings/clock/starfive,jh7110-crg.h | 101 +++--- 7 files changed, 365 insertions(+), 226 deletions(-)
base-commit: e1bebc16e1d9aa0ddd56c53c0b781f7186dce557
Signature · 1 line
2.38.1
Hal Feng
maintainerPATCH 3/5 riscv: dts: jh7110: Add clock source from PLL
From: Xingyu Wu <[email protected]>
Change the PLL clock source from syscrg to sys_syscon child node.
--- arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi | 6 +++--- arch/riscv/dts/jh7110-u-boot.dtsi | 1 - arch/riscv/dts/jh7110.dtsi | 8 ++++++-- 3 files changed, 9 insertions(+), 6 deletions(-)
arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi +3 -3
@@ -305,9 +305,9 @@ <&syscrg JH7110_SYSCLK_BUS_ROOT>, <&syscrg JH7110_SYSCLK_PERH_ROOT>, <&syscrg JH7110_SYSCLK_QSPI_REF>; - assigned-clock-parents = <&syscrg JH7110_SYSCLK_PLL0_OUT>, - <&syscrg JH7110_SYSCLK_PLL2_OUT>, - <&syscrg JH7110_SYSCLK_PLL2_OUT>, + assigned-clock-parents = <&pllclk JH7110_SYSCLK_PLL0_OUT>, + <&pllclk JH7110_SYSCLK_PLL2_OUT>, + <&pllclk JH7110_SYSCLK_PLL2_OUT>, <&syscrg JH7110_SYSCLK_QSPI_REF_SRC>; assigned-clock-rates = <0>, <0>, <0>, <0>; };
arch/riscv/dts/jh7110-u-boot.dtsi +0 -1
@@ -83,7 +83,6 @@ &syscrg { bootph-pre-ram; - starfive,sys-syscon = <&sys_syscon>; }; &stgcrg {
arch/riscv/dts/jh7110.dtsi +6 -2
@@ -480,12 +480,16 @@ <&gmac1_rgmii_rxin>, <&i2stx_bclk_ext>, <&i2stx_lrck_ext>, <&i2srx_bclk_ext>, <&i2srx_lrck_ext>, - <&tdm_ext>, <&mclk_ext>; + <&tdm_ext>, <&mclk_ext>, + <&pllclk JH7110_SYSCLK_PLL0_OUT>, + <&pllclk JH7110_SYSCLK_PLL1_OUT>, + <&pllclk JH7110_SYSCLK_PLL2_OUT>; clock-names = "osc", "gmac1_rmii_refin", "gmac1_rgmii_rxin", "i2stx_bclk_ext", "i2stx_lrck_ext", "i2srx_bclk_ext", "i2srx_lrck_ext", - "tdm_ext", "mclk_ext"; + "tdm_ext", "mclk_ext", + "pll0_out", "pll1_out", "pll2_out"; #clock-cells = <1>; #reset-cells = <1>; };
Signature · 1 line
2.38.1
Hal Feng
maintainerPATCH 4/5 dt-bindings: clock: jh7110: Modify clock id to be same with Linux
In reply to Hal FengFrom: Xingyu Wu <[email protected]>
The clock id needs to be changed to be consistent with Linux.
--- .../dt-bindings/clock/starfive,jh7110-crg.h | 101 +++++++++--------- 1 file changed, 51 insertions(+), 50 deletions(-)
include/dt-bindings/clock/starfive,jh7110-crg.h +51 -50
@@ -8,6 +8,11 @@#ifndef __DT_BINDINGS_CLOCK_STARFIVE_JH7110_H__#define __DT_BINDINGS_CLOCK_STARFIVE_JH7110_H__ +#define JH7110_SYSCLK_PLL0_OUT 0 +#define JH7110_SYSCLK_PLL1_OUT 1 +#define JH7110_SYSCLK_PLL2_OUT 2 +#define JH7110_PLLCLK_END 3 +#define JH7110_SYSCLK_CPU_ROOT 0#define JH7110_SYSCLK_CPU_CORE 1#define JH7110_SYSCLK_CPU_BUS 2
@@ -199,59 +204,55 @@#define JH7110_SYSCLK_TDM_CLK_TDM_N 188#define JH7110_SYSCLK_JTAG_CERTIFICATION_TRNG 189 -#define JH7110_SYSCLK_PLL0_OUT 190 -#define JH7110_SYSCLK_PLL1_OUT 191 -#define JH7110_SYSCLK_PLL2_OUT 192 - -#define JH7110_SYSCLK_END 193 +#define JH7110_SYSCLK_END 190 -#define JH7110_AONCLK_OSC_DIV4 (JH7110_SYSCLK_END + 0) -#define JH7110_AONCLK_APB_FUNC (JH7110_SYSCLK_END + 1) -#define JH7110_AONCLK_GMAC0_AHB (JH7110_SYSCLK_END + 2) -#define JH7110_AONCLK_GMAC0_AXI (JH7110_SYSCLK_END + 3) -#define JH7110_AONCLK_GMAC0_RMII_RTX (JH7110_SYSCLK_END + 4) -#define JH7110_AONCLK_GMAC0_TX (JH7110_SYSCLK_END + 5) -#define JH7110_AONCLK_GMAC0_TX_INV (JH7110_SYSCLK_END + 6) -#define JH7110_AONCLK_GMAC0_RX (JH7110_SYSCLK_END + 7) -#define JH7110_AONCLK_GMAC0_RX_INV (JH7110_SYSCLK_END + 8) -#define JH7110_AONCLK_OTPC_APB (JH7110_SYSCLK_END + 9) -#define JH7110_AONCLK_RTC_APB (JH7110_SYSCLK_END + 10) -#define JH7110_AONCLK_RTC_INTERNAL (JH7110_SYSCLK_END + 11) -#define JH7110_AONCLK_RTC_32K (JH7110_SYSCLK_END + 12) -#define JH7110_AONCLK_RTC_CAL (JH7110_SYSCLK_END + 13) +#define JH7110_AONCLK_OSC_DIV4 0 +#define JH7110_AONCLK_APB_FUNC 1 +#define JH7110_AONCLK_GMAC0_AHB 2 +#define JH7110_AONCLK_GMAC0_AXI 3 +#define JH7110_AONCLK_GMAC0_RMII_RTX 4 +#define JH7110_AONCLK_GMAC0_TX 5 +#define JH7110_AONCLK_GMAC0_TX_INV 6 +#define JH7110_AONCLK_GMAC0_RX 7 +#define JH7110_AONCLK_GMAC0_RX_INV 8 +#define JH7110_AONCLK_OTPC_APB 9 +#define JH7110_AONCLK_RTC_APB 10 +#define JH7110_AONCLK_RTC_INTERNAL 11 +#define JH7110_AONCLK_RTC_32K 12 +#define JH7110_AONCLK_RTC_CAL 13 -#define JH7110_AONCLK_END (JH7110_SYSCLK_END + 14) +#define JH7110_AONCLK_END 14 -#define JH7110_STGCLK_HIFI4_CORE (JH7110_AONCLK_END + 0) -#define JH7110_STGCLK_USB_APB (JH7110_AONCLK_END + 1) -#define JH7110_STGCLK_USB_UTMI_APB (JH7110_AONCLK_END + 2) -#define JH7110_STGCLK_USB_AXI (JH7110_AONCLK_END + 3) -#define JH7110_STGCLK_USB_LPM (JH7110_AONCLK_END + 4) -#define JH7110_STGCLK_USB_STB (JH7110_AONCLK_END + 5) -#define JH7110_STGCLK_USB_APP_125 (JH7110_AONCLK_END + 6) -#define JH7110_STGCLK_USB_REFCLK (JH7110_AONCLK_END + 7) -#define JH7110_STGCLK_PCIE0_AXI (JH7110_AONCLK_END + 8) -#define JH7110_STGCLK_PCIE0_APB (JH7110_AONCLK_END + 9) -#define JH7110_STGCLK_PCIE0_TL (JH7110_AONCLK_END + 10) -#define JH7110_STGCLK_PCIE1_AXI (JH7110_AONCLK_END + 11) -#define JH7110_STGCLK_PCIE1_APB (JH7110_AONCLK_END + 12) -#define JH7110_STGCLK_PCIE1_TL (JH7110_AONCLK_END + 13) -#define JH7110_STGCLK_PCIE01_MAIN (JH7110_AONCLK_END + 14) -#define JH7110_STGCLK_SEC_HCLK (JH7110_AONCLK_END + 15) -#define JH7110_STGCLK_SEC_MISCAHB (JH7110_AONCLK_END + 16) -#define JH7110_STGCLK_MTRX_GRP0_MAIN (JH7110_AONCLK_END + 17) -#define JH7110_STGCLK_MTRX_GRP0_BUS (JH7110_AONCLK_END + 18) -#define JH7110_STGCLK_MTRX_GRP0_STG (JH7110_AONCLK_END + 19) -#define JH7110_STGCLK_MTRX_GRP1_MAIN (JH7110_AONCLK_END + 20) -#define JH7110_STGCLK_MTRX_GRP1_BUS (JH7110_AONCLK_END + 21) -#define JH7110_STGCLK_MTRX_GRP1_STG (JH7110_AONCLK_END + 22) -#define JH7110_STGCLK_MTRX_GRP1_HIFI (JH7110_AONCLK_END + 23) -#define JH7110_STGCLK_E2_RTC (JH7110_AONCLK_END + 24) -#define JH7110_STGCLK_E2_CORE (JH7110_AONCLK_END + 25) -#define JH7110_STGCLK_E2_DBG (JH7110_AONCLK_END + 26) -#define JH7110_STGCLK_DMA1P_AXI (JH7110_AONCLK_END + 27) -#define JH7110_STGCLK_DMA1P_AHB (JH7110_AONCLK_END + 28) +#define JH7110_STGCLK_HIFI4_CORE 0 +#define JH7110_STGCLK_USB_APB 1 +#define JH7110_STGCLK_USB_UTMI_APB 2 +#define JH7110_STGCLK_USB_AXI 3 +#define JH7110_STGCLK_USB_LPM 4 +#define JH7110_STGCLK_USB_STB 5 +#define JH7110_STGCLK_USB_APP_125 6 +#define JH7110_STGCLK_USB_REFCLK 7 +#define JH7110_STGCLK_PCIE0_AXI 8 +#define JH7110_STGCLK_PCIE0_APB 9 +#define JH7110_STGCLK_PCIE0_TL 10 +#define JH7110_STGCLK_PCIE1_AXI 11 +#define JH7110_STGCLK_PCIE1_APB 12 +#define JH7110_STGCLK_PCIE1_TL 13 +#define JH7110_STGCLK_PCIE01_MAIN 14 +#define JH7110_STGCLK_SEC_HCLK 15 +#define JH7110_STGCLK_SEC_MISCAHB 16 +#define JH7110_STGCLK_MTRX_GRP0_MAIN 17 +#define JH7110_STGCLK_MTRX_GRP0_BUS 18 +#define JH7110_STGCLK_MTRX_GRP0_STG 19 +#define JH7110_STGCLK_MTRX_GRP1_MAIN 20 +#define JH7110_STGCLK_MTRX_GRP1_BUS 21 +#define JH7110_STGCLK_MTRX_GRP1_STG 22 +#define JH7110_STGCLK_MTRX_GRP1_HIFI 23 +#define JH7110_STGCLK_E2_RTC 24 +#define JH7110_STGCLK_E2_CORE 25 +#define JH7110_STGCLK_E2_DBG 26 +#define JH7110_STGCLK_DMA1P_AXI 27 +#define JH7110_STGCLK_DMA1P_AHB 28 -#define JH7110_STGCLK_END (JH7110_AONCLK_END + 29) +#define JH7110_STGCLK_END 29#endif /* __DT_BINDINGS_CLOCK_STARFIVE_JH7110_H__ */
Signature · 1 line
2.38.1
Hal Feng
maintainerPATCH 5/5 clk: starfive: jh7110: Add of_xlate ops and macros for clock id conversion
In reply to Hal FengFrom: Xingyu Wu <[email protected]>
Modify the drivers to add of_xlate ops and transform clock id.
--- drivers/clk/starfive/clk-jh7110-pll.c | 29 ++- drivers/clk/starfive/clk-jh7110.c | 287 +++++++++++++++++--------- drivers/clk/starfive/clk.h | 25 +++ 3 files changed, 235 insertions(+), 106 deletions(-) create mode 100644 drivers/clk/starfive/clk.h
drivers/clk/starfive/clk-jh7110-pll.c +25 -4
@@ -19,6 +19,8 @@#include <linux/delay.h> #include <linux/err.h> +#include "clk.h" +#define UBOOT_DM_CLK_JH7110_PLLX "jh7110_clk_pllx"#define PLL_PD_OFF 1
@@ -31,6 +33,8 @@#define CLK_DDR_BUS_PLL1_DIV4 2#define CLK_DDR_BUS_PLL1_DIV8 3 +#define JH7110_PLL_ID_TRANS (id) ((id) + JH7110_EXTCLK_END) +enum starfive_pll_type {PLL0 =0 ,PLL1 ,
@@ -371,29 +375,46 @@ static int jh7110_pll_clk_probe(struct udevice *dev)if (sysreg ==FDT_ADDR_T_NONE )return -EINVAL ; -clk_dm (JH7110_SYSCLK_PLL0_OUT , +clk_dm (JH7110_PLL_ID_TRANS (JH7110_SYSCLK_PLL0_OUT ),starfive_jh7110_pll ("pll0_out" ,"oscillator" , reg, (void __iomem *)sysreg, &starfive_jh7110_pll0)); -clk_dm (JH7110_SYSCLK_PLL1_OUT , +clk_dm (JH7110_PLL_ID_TRANS (JH7110_SYSCLK_PLL1_OUT ),starfive_jh7110_pll ("pll1_out" ,"oscillator" , reg, (void __iomem *)sysreg, &starfive_jh7110_pll1)); -clk_dm (JH7110_SYSCLK_PLL2_OUT , +clk_dm (JH7110_PLL_ID_TRANS (JH7110_SYSCLK_PLL2_OUT ),starfive_jh7110_pll ("pll2_out" ,"oscillator" , reg, (void __iomem *)sysreg, &starfive_jh7110_pll2));return 0 ; } +static int jh7110_pll_clk_of_xlate (struct clk *clk,struct ofnode_phandle_args *args) +{ +if (args->args_count >1 ) { +debug ("Invalid args_count: %d\n" , args->args_count); +return -EINVAL ; + } + +if (args->args_count) + clk->id =JH7110_PLL_ID_TRANS (args->args[0 ]); +else + clk->id =0 ; + +return 0 ; +} +static const struct udevice_id jh7110_pll_clk_of_match[] = { { .compatible ="starfive,jh7110-pll" , }, { } }; +JH7110_CLK_OPS (pll); +/* PLL clk device */ U_BOOT_DRIVER (jh7110_pll_clk) = { .name ="jh7110_pll_clk" , .id =UCLASS_CLK , .of_match = jh7110_pll_clk_of_match, .probe = jh7110_pll_clk_probe, - .ops = &ccf_clk_ops, + .ops = &jh7110_pll_clk_ops, };
drivers/clk/starfive/clk-jh7110.c +185 -102
522 lines not on this page · raw message
drivers/clk/starfive/clk.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2022 StarFive Technology Co., Ltd. +* Author: Yanhong Wang <[email protected]> +*/ + +#ifndef __CLK_STARFIVE_H +#define __CLK_STARFIVE_H + +/* the number of fixed clocks in DTS */ +#define JH7110_EXTCLK_END 12 + +#define _JH7110_CLK_OPS (_name) \ +static const struct clk_ops jh7110_##_name##_clk_ops = { \ + .set_rate = ccf_clk_set_rate, \ + .get_rate = ccf_clk_get_rate, \ + .set_parent = ccf_clk_set_parent, \ + .enable = ccf_clk_enable, \ + .disable = ccf_clk_disable, \ + .of_xlate = jh7110_##_name##_clk_of_xlate, \ +} + +#define JH7110_CLK_OPS (name) _JH7110_CLK_OPS(name) + +#endif
Signature · 1 line
2.38.1
Hal Feng
maintainerPATCH 1/5 clk: starfive: jh7110: Separate the PLL driver
In reply to Hal FengFrom: Xingyu Wu <[email protected]>
Drop the PLL part in SYSCRG driver and separate to be a single PLL driver of which the compatible is "starfive,jh7110-pll".
--- drivers/clk/starfive/clk-jh7110-pll.c | 86 +++++++++++++++++++++++++-- drivers/clk/starfive/clk-jh7110.c | 25 +------- drivers/clk/starfive/clk.h | 57 ------------------ 3 files changed, 84 insertions(+), 84 deletions(-) delete mode 100644 drivers/clk/starfive/clk.h
drivers/clk/starfive/clk-jh7110-pll.c +82 -4
@@ -3,6 +3,7 @@* Copyright (C) 2022-23 StarFive Technology Co., Ltd. * * Author: Yanhong Wang <[email protected]> +* Xingyu Wu <[email protected]> */ #include <common.h>
@@ -11,13 +12,13 @@#include <clk-uclass.h> #include <div64.h> #include <dm/device.h> +#include <dm/read.h> +#include <dt-bindings/clock/starfive,jh7110-crg.h> #include <linux/bitops.h> #include <linux/clk-provider.h> #include <linux/delay.h> #include <linux/err.h> -#include "clk.h" -#define UBOOT_DM_CLK_JH7110_PLLX "jh7110_clk_pllx"#define PLL_PD_OFF 1
@@ -30,6 +31,45 @@#define CLK_DDR_BUS_PLL1_DIV4 2#define CLK_DDR_BUS_PLL1_DIV8 3 +enum starfive_pll_type { +PLL0 =0 , +PLL1 , +PLL2 , +PLL_MAX =PLL2 +}; + +struct starfive_pllx_rate { +u64 rate; +u32 prediv; +u32 fbdiv; +u32 frac; +}; + +struct starfive_pllx_offset { +u32 pd; +u32 prediv; +u32 fbdiv; +u32 frac; +u32 postdiv1; +u32 dacpd; +u32 dsmpd; +u32 pd_mask; +u32 prediv_mask; +u32 fbdiv_mask; +u32 frac_mask; +u32 postdiv1_mask; +u32 dacpd_mask; +u32 dsmpd_mask; +}; + +struct starfive_pllx_clk { +enum starfive_pll_type type; +const struct starfive_pllx_offset *offset; +const struct starfive_pllx_rate *rate_table; +int rate_count; +int flags; +}; +struct clk_jh7110_pllx {struct clk clk;void __iomem *base;
@@ -271,7 +311,7 @@ static ulong jh7110_pllx_set_rate(struct clk *clk, ulong drate)return jh7110_pllx_recalc_rate (clk); } -static const struct clk_ops clk_jh7110_ops = { +static const struct clk_ops jh7110_clk_pllx_ops = { .set_rate = jh7110_pllx_set_rate, .get_rate = jh7110_pllx_recalc_rate, };
@@ -314,8 +354,46 @@ struct clk *starfive_jh7110_pll(const char *name, const char *parent_name,return clk; } +/* PLLx clock implementation */ U_BOOT_DRIVER (jh7110_clk_pllx) = { .name =UBOOT_DM_CLK_JH7110_PLLX , .id =UCLASS_CLK , - .ops = &clk_jh7110_ops, + .ops = &jh7110_clk_pllx_ops, + .flags =DM_FLAG_PRE_RELOC , +}; + +static int jh7110_pll_clk_probe (struct udevice *dev) +{ +void __iomem *reg = (void __iomem *)dev_read_addr_ptr (dev->parent); +fdt_addr_t sysreg =ofnode_get_addr (ofnode_by_compatible (ofnode_null (), +"starfive,jh7110-syscrg" )); + +if (sysreg ==FDT_ADDR_T_NONE ) +return -EINVAL ; + +clk_dm (JH7110_SYSCLK_PLL0_OUT , +starfive_jh7110_pll ("pll0_out" ,"oscillator" , reg, + (void __iomem *)sysreg, &starfive_jh7110_pll0)); +clk_dm (JH7110_SYSCLK_PLL1_OUT , +starfive_jh7110_pll ("pll1_out" ,"oscillator" , reg, + (void __iomem *)sysreg, &starfive_jh7110_pll1)); +clk_dm (JH7110_SYSCLK_PLL2_OUT , +starfive_jh7110_pll ("pll2_out" ,"oscillator" , reg, + (void __iomem *)sysreg, &starfive_jh7110_pll2)); + +return 0 ; +} + +static const struct udevice_id jh7110_pll_clk_of_match[] = { + { .compatible ="starfive,jh7110-pll" , }, + { } +}; + +/* PLL clk device */ +U_BOOT_DRIVER (jh7110_pll_clk) = { + .name ="jh7110_pll_clk" , + .id =UCLASS_CLK , + .of_match = jh7110_pll_clk_of_match, + .probe = jh7110_pll_clk_probe, + .ops = &ccf_clk_ops, };
drivers/clk/starfive/clk-jh7110.c +2 -23
@@ -3,6 +3,7 @@* Copyright (C) 2022-23 StarFive Technology Co., Ltd. * * Author: Yanhong Wang <[email protected]> +* Xingyu Wu <[email protected]> */ #include <common.h>
@@ -16,8 +17,6 @@#include <log.h> #include <linux/clk-provider.h> -#include "clk.h" -#define STARFIVE_CLK_ENABLE_SHIFT 31/* [31] */ #define STARFIVE_CLK_INVERT_SHIFT 30/* [30] */ #define STARFIVE_CLK_MUX_SHIFT 24/* [29:24] */
@@ -230,28 +229,8 @@ static struct clk *starfive_clk_gate_divider(void __iomem *reg,static int jh7110_syscrg_init (struct udevice *dev) {struct jh7110_clk_priv *priv =dev_get_priv (dev); -struct ofnode_phandle_args args; -fdt_addr_t addr;struct clk *pclk; -int ret; - - ret =ofnode_parse_phandle_with_args (dev->node_,"starfive,sys-syscon" ,NULL ,0 ,0 , &args); -if (ret) -return ret; - - addr =ofnode_get_addr (args.node); -if (addr ==FDT_ADDR_T_NONE ) -return -EINVAL ; - -clk_dm (JH7110_SYSCLK_PLL0_OUT , -starfive_jh7110_pll ("pll0_out" ,"oscillator" , (void __iomem *)addr, - priv->reg, &starfive_jh7110_pll0)); -clk_dm (JH7110_SYSCLK_PLL1_OUT , -starfive_jh7110_pll ("pll1_out" ,"oscillator" , (void __iomem *)addr, - priv->reg, &starfive_jh7110_pll1)); -clk_dm (JH7110_SYSCLK_PLL2_OUT , -starfive_jh7110_pll ("pll2_out" ,"oscillator" , (void __iomem *)addr, - priv->reg, &starfive_jh7110_pll2)); + clk_dm(JH7110_SYSCLK_CPU_ROOT, starfive_clk_mux(priv->reg, "cpu_root", OFFSET(JH7110_SYSCLK_CPU_ROOT), 1,
drivers/clk/starfive/clk.h deleted +0 -57
57 lines not on this page · raw message
Signature · 1 line
2.38.1
Hal Feng
maintainerPATCH 2/5 riscv: dts: jh7110: Add PLL clock controller node
In reply to Hal FengFrom: Xingyu Wu <[email protected]>
Add child node about PLL clock controller in sys_syscon node.
--- arch/riscv/dts/jh7110.dtsi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/riscv/dts/jh7110.dtsi +7 -1
@@ -491,8 +491,14 @@ }; sys_syscon: sys_syscon@13030000 { - compatible = "starfive,jh7110-sys-syscon","syscon"; + compatible = "starfive,jh7110-sys-syscon","syscon", "simple-mfd"; reg = <0x0 0x13030000 0x0 0x1000>; + + pllclk: clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + }; }; sysgpio: pinctrl@13040000 {
Signature · 1 line
2.38.1
Quoted 10 lines · On Fri, 7 Jul 2023 18:50:06 +0800 Hal Feng <[email protected]> wrote:
The clock dt-bindings and DT nodes are not consistent with Linux now. Let's sync them with Linux, so the same dtb can work for Linux & U-Boot.
To achieve this goal, the PLL clock driver is separated and some clock IDs conversion is needed in clock drivers.
For the motivation, please see the discussion in the link below.
[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/
Quoted 7 lines
Xingyu Wu (5):
clk: starfive: jh7110: Separate the PLL driver
riscv: dts: jh7110: Add PLL clock controller node
riscv: dts: jh7110: Add clock source from PLL
dt-bindings: clock: jh7110: Modify clock id to be same with Linux
clk: starfive: jh7110: Addof_xlateops and macros for clock id
conversion
For better bisectability, I would have put patch 2 first, then merged 1&3, then merged 4&5. This way U-Boot should compile and boot after each patch (I think, untested ;) But given the rapid development of the platform, I'm fine with inclusion of the series as-is; as it does not affect other targets.
I'm also wondering whether the symbolic clock number constants should be synced, too. But that's also a minor issue, as long as they expand to yield the same numbers.
For the series:
Torsten
Hal Feng
maintainerQuoted 21 lines · Torsten Duwe
Quoted 10 lines · On Fri, 7 Jul 2023 18:50:06 +0800 Hal Feng <[email protected]> wrote:
The clock dt-bindings and DT nodes are not consistent with Linux now. Let's sync them with Linux, so the same dtb can work for Linux & U-Boot.
To achieve this goal, the PLL clock driver is separated and some clock IDs conversion is needed in clock drivers.
For the motivation, please see the discussion in the link below.
[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/
Quoted 7 lines
Xingyu Wu (5):
clk: starfive: jh7110: Separate the PLL driver
riscv: dts: jh7110: Add PLL clock controller node
riscv: dts: jh7110: Add clock source from PLL
dt-bindings: clock: jh7110: Modify clock id to be same with Linux
clk: starfive: jh7110: Addof_xlateops and macros for clock id
conversion
Quoted 3 lines
For better bisectability, I would have put patch 2 first, then merged 1&3, then merged 4&5. This way U-Boot should compile and boot after each patch (I think, untested ;) But given the rapid development of the platform,
Yes, it will get better bisectability if we do so, but it is not a good coding style as we merge the driver changes and the DT changes in one patch.
Does someone else have any suggestions?
Quoted 6 lines
I'm fine with inclusion of the series as-is; as it does not affect other targets.
I'm also wondering whether the symbolic clock number constants should be synced, too. But that's also a minor issue, as long as they expand to yield the same numbers.
Good catch. The main difference is the definitions of PLL and STG. You can simply compare them with the definitions in linux [1] in the link below.
I will sync them in the next version.
Quoted 4 lines
For the series:
Reviewed-by Torsten Duwe <[email protected]>
Thanks for your review.
Best regards,
Hal
Re: [PATCH v1 1/5] clk: starfive: jh7110: Separate the PLL driver
In reply to Hal FengQuoted 5 lines · Hal Feng
From: Xingyu Wu <[email protected]>
Drop the PLL part in SYSCRG driver and separate to be a single PLL driver of which the compatible is "starfive,jh7110-pll".
Quoted 8 lines
Signed-off-by Xingyu Wu <[email protected]>Signed-off-by Hal Feng <[email protected]>--- drivers/clk/starfive/clk-jh7110-pll.c | 86 +++++++++++++++++++++++++-- drivers/clk/starfive/clk-jh7110.c | 25 +------- drivers/clk/starfive/clk.h | 57 ------------------ 3 files changed, 84 insertions(+), 84 deletions(-) delete mode 100644 drivers/clk/starfive/clk.h
Re: [PATCH v1 2/5] riscv: dts: jh7110: Add PLL clock controller node
In reply to Hal FengQuoted 9 lines · Hal Feng
From: Xingyu Wu <[email protected]>
Add child node about PLL clock controller in
sys_sysconnode.Signed-off-by Xingyu Wu <[email protected]>Signed-off-by Hal Feng <[email protected]>--- arch/riscv/dts/jh7110.dtsi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Re: [PATCH v1 3/5] riscv: dts: jh7110: Add clock source from PLL
In reply to Hal FengQuoted 11 lines · Hal Feng
From: Xingyu Wu <[email protected]>
Change the PLL clock source from syscrg to
sys_sysconchild node.Signed-off-by Xingyu Wu <[email protected]>Signed-off-by Hal Feng <[email protected]>--- arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi | 6 +++--- arch/riscv/dts/jh7110-u-boot.dtsi | 1 - arch/riscv/dts/jh7110.dtsi | 8 ++++++-- 3 files changed, 9 insertions(+), 6 deletions(-)
Re: [PATCH v1 4/5] dt-bindings: clock: jh7110: Modify clock id to be same with Linux
In reply to Hal FengQuoted 9 lines · Hal Feng
From: Xingyu Wu <[email protected]>
The clock id needs to be changed to be consistent with Linux.
Signed-off-by Xingyu Wu <[email protected]>Signed-off-by Hal Feng <[email protected]>--- .../dt-bindings/clock/starfive,jh7110-crg.h | 101 +++++++++--------- 1 file changed, 51 insertions(+), 50 deletions(-)
Re: [PATCH v1 5/5] clk: starfive: jh7110: Add of_xlate ops and macros for clock id conversion
In reply to Hal FengQuoted 4 lines · Hal Feng
From: Xingyu Wu <[email protected]>
Modify the drivers to add
of_xlateops and transform clock id.
Quoted 8 lines
Signed-off-by Xingyu Wu <[email protected]>Signed-off-by Hal Feng <[email protected]>--- drivers/clk/starfive/clk-jh7110-pll.c | 29 ++- drivers/clk/starfive/clk-jh7110.c | 287 +++++++++++++++++--------- drivers/clk/starfive/clk.h | 25 +++ 3 files changed, 235 insertions(+), 106 deletions(-) create mode 100644 drivers/clk/starfive/clk.h