Add PLL clocks driver and syscon for StarFive JH7110 SoC
Subsystems (8)
Xingyu Wu
maintainerv7 cover Add PLL clocks driver and syscon for StarFive JH7110 SoC
This patch serises are to add PLL clocks driver and providers by writing and reading syscon registers for the StarFive JH7110 RISC-V SoC. And add documentation and nodes to describe StarFive System Controller(syscon) Registers. This patch serises are based on Linux 6.4.
PLLs are high speed, low jitter frequency synthesizers in JH7110. Each PLL clock works in integer mode or fraction mode by some dividers, and the dividers are set in several syscon registers.
The formula for calculating frequency is:
Fvco = Fref * (NI + NF) / M / Q1
The first patch adds docunmentation to describe PLL clock bindings, and the second patch adds documentation to decribe syscon registers. The patch 3 modifies the SYSCRG bindings and adds PLL clock inputs. The patch 4 adds driver to support PLL clocks for JH7110.
The patch 5 modifies the system clock driver and can select the PLL clock source from PLL clocks driver. And the patch 6 adds the stg/sys/aon syscon nodes for JH7110 SoC. The last patch modifies the syscrg node in JH7110 dts file.
Changes since v6:
- Rebased on Linux 6.5-rc2.
- Patch 1 added the 'the' in front of 'JH7110' and changed the PLL clock names from 'JH7110_CLK_PLL?_OUT' to 'JH7110_PLLCLK_PLL?_OUT' in the binding of PLL.
- Patch 2 modified the value of 'reg' in example to fix the error.
- Patch 4 and 7 changed the PLL clock names from 'JH7110_CLK_PLL?_OUT' to 'JH7110_PLLCLK_PLL?_OUT' in the driver and dts.
- Patch 5 added clk_put() and a better way to detect if the pll references are specified in the device tree or not.
v6: https://lore.kernel.org/all/[email protected]/
Changes since v5:
- Rebased on Linux 6.4.
- Patch 1 fixed some grammatical mistake.
- Patch 2 added the selection about properties from different syscon modules and madethe example completed.
- Patch 3 dropped the 'optional' PLL clocks.
v5: https://lore.kernel.org/all/[email protected]/
Changes since v4:
- Rebased on Linux 6.4-rc6.
- Patch 2 dropped the example node about sys-syscon.
- Patch 3 used PLL clocks as one of optional items in SYSCRG bindings.
- Patch 4 used the patch instead about PLL clocks driver from Emil.
- Patch 5 retained the fixed factor PLL clocks as the optional source about PLL clocks in SYSCRG clock driver.
- Patch 6 added the child node clock-controller as the complete sys-syscon node and patch 7 dropped this part.
v4: https://lore.kernel.org/all/[email protected]/
Changes since v3:
- Rebased on Linux 6.4-rc1.
- Dropped the 'power-controller' property and used 'power-domain-cells' instead in syscon binding.
- Used the data by of_device_id to get the syscon registers' configuration include offset, mask and shift.
v3: https://lore.kernel.org/all/[email protected]/
Changes since v2:
- Rebased on latest JH7110 basic clock drivers.
- Added the complete documentation to describe syscon register.
- Added syscon node in JH7110 dts file.
- Modified the clock rate selection to match the closest rate in PLL driver when setting rate.
v2: https://lore.kernel.org/all/[email protected]/
Changes since v1:
- Changed PLL clock node to be child of syscon node in dts.
- Modifed the definitions and names of function in PLL clock driver.
- Added commit to update syscon and syscrg dt-bindings.
v1: https://lore.kernel.org/all/[email protected]/
William Qiu (2):
dt-bindings: soc: starfive: Add StarFive syscon module
riscv: dts: starfive: jh7110: Add syscon nodes
Xingyu Wu (5):
dt-bindings: clock: Add StarFive JH7110 PLL clock generator
dt-bindings: clock: jh7110-syscrg: Add PLL clock inputs
clk: starfive: Add StarFive JH7110 PLL clock driver
clk: starfive: jh7110-sys: Add PLL clocks source from DTS
riscv: dts: starfive: jh7110: Add PLL clocks source in SYSCRG node
.../bindings/clock/starfive,jh7110-pll.yaml | 46 ++ .../clock/starfive,jh7110-syscrg.yaml | 18 +- .../soc/starfive/starfive,jh7110-syscon.yaml | 93 ++++ MAINTAINERS | 13 + arch/riscv/boot/dts/starfive/jh7110.dtsi | 30 +- drivers/clk/starfive/Kconfig | 9 + drivers/clk/starfive/Makefile | 1 + .../clk/starfive/clk-starfive-jh7110-pll.c | 507 ++++++++++++++++++ .../clk/starfive/clk-starfive-jh7110-sys.c | 66 ++- .../dt-bindings/clock/starfive,jh7110-crg.h | 6 + 10 files changed, 763 insertions(+), 26 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml create mode 100644 Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml create mode 100644 drivers/clk/starfive/clk-starfive-jh7110-pll.c
Signature · 1 line
2.25.1
Xingyu Wu
maintainerPATCH v7 1/7 dt-bindings: clock: Add StarFive JH7110 PLL clock generator
Add bindings for the PLL clock generator on the JH7110 RISC-V SoC.
--- .../bindings/clock/starfive,jh7110-pll.yaml | 46 +++++++++++++++++++ .../dt-bindings/clock/starfive,jh7110-crg.h | 6 +++ 2 files changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml
Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml new file +46 -0
@@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/starfive,jh7110-pll.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 PLL Clock Generator + +description: + These PLLs are high speed, low jitter frequency synthesizers in the JH7110. + Each PLL works in integer mode or fraction mode, with configuration + registers in the sys syscon. So the PLLs node should be a child of + SYS-SYSCON node. + The formula for calculating frequency is + Fvco = Fref * (NI + NF) / M / Q1 + +maintainers: + - Xingyu Wu <[email protected]> + +properties: + compatible: + const: starfive,jh7110-pll + + clocks: + maxItems: 1 + description: Main Oscillator (24 MHz) + + '#clock-cells': + const: 1 + description: + See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices. + +required: + - compatible + - clocks + - '#clock-cells' + +additionalProperties: false + +examples: + - | + clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + };
include/dt-bindings/clock/starfive,jh7110-crg.h +6 -0
@@ -6,6 +6,12 @@#ifndef __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__#define __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__ +/* PLL clocks */ +#define JH7110_PLLCLK_PLL0_OUT 0 +#define JH7110_PLLCLK_PLL1_OUT 1 +#define JH7110_PLLCLK_PLL2_OUT 2 +#define JH7110_PLLCLK_END 3 +/* SYSCRG clocks */ #define JH7110_SYSCLK_CPU_ROOT 0#define JH7110_SYSCLK_CPU_CORE 1
Signature · 1 line
2.25.1
Re: [PATCH v7 1/7] dt-bindings: clock: Add StarFive JH7110 PLL clock generator
Quoted 5 lines · Xingyu Wu
Add bindings for the PLL clock generator on the JH7110 RISC-V SoC.
Reviewed-by Conor Dooley <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>
Quoted 77 lines
Signed-off-by Xingyu Wu <[email protected]>--- .../bindings/clock/starfive,jh7110-pll.yaml | 46 +++++++++++++++++++ .../dt-bindings/clock/starfive,jh7110-crg.h | 6 +++ 2 files changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yamlDocumentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml new file +46
-0@@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/starfive,jh7110-pll.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 PLL Clock Generator + +description: + These PLLs are high speed, low jitter frequency synthesizers in the JH7110. + Each PLL works in integer mode or fraction mode, with configuration + registers in the sys syscon. So the PLLs node should be a child of + SYS-SYSCON node. + The formula for calculating frequency is + Fvco = Fref * (NI + NF) / M / Q1 + +maintainers: + - Xingyu Wu <[email protected]> + +properties: + compatible: + const: starfive,jh7110-pll + + clocks: + maxItems: 1 + description: Main Oscillator (24 MHz) + + '#clock-cells': + const: 1 + description: + See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices. + +required: + - compatible + - clocks + - '#clock-cells' + +additionalProperties: false + +examples: + - | + clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + };include/dt-bindings/clock/starfive,jh7110-crg.h +6
-1@@ -6,6 +6,12 @@#ifndef __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__#define __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__ +/* PLL clocks */ +#define JH7110_PLLCLK_PLL0_OUT 0 +#define JH7110_PLLCLK_PLL1_OUT 1 +#define JH7110_PLLCLK_PLL2_OUT 2 +#define JH7110_PLLCLK_END 3 +/* SYSCRG clocks */ #define JH7110_SYSCLK_CPU_ROOT 0#define JH7110_SYSCLK_CPU_CORE 1 --
Quoted 2 lines
2.25.1
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Xingyu Wu
maintainerPATCH v7 2/7 dt-bindings: soc: starfive: Add StarFive syscon module
In reply to Xingyu WuFrom: William Qiu <[email protected]>
Add documentation to describe StarFive System Controller Registers.
--- .../soc/starfive/starfive,jh7110-syscon.yaml | 93 +++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 100 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml
Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml new file +93 -0
@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/starfive/starfive,jh7110-syscon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 SoC system controller + +maintainers: + - William Qiu <[email protected]> + +description: + The StarFive JH7110 SoC system controller provides register information such + as offset, mask and shift to configure related modules such as MMC and PCIe. + +properties: + compatible: + oneOf: + - items: + - const: starfive,jh7110-sys-syscon + - const: syscon + - const: simple-mfd + - items: + - enum: + - starfive,jh7110-aon-syscon + - starfive,jh7110-stg-syscon + - const: syscon + + reg: + maxItems: 1 + + clock-controller: + $ref: /schemas/clock/starfive,jh7110-pll.yaml# + type: object + + "#power-domain-cells": + const: 1 + +required: + - compatible + - reg + +allOf: + - if: + properties: + compatible: + contains: + const: starfive,jh7110-sys-syscon + then: + required: + - clock-controller + else: + properties: + clock-controller: false + - if: + properties: + compatible: + contains: + const: starfive,jh7110-aon-syscon + then: + required: + - "#power-domain-cells" + else: + properties: + "#power-domain-cells": false + +additionalProperties: false + +examples: + - | + syscon@10240000 { + compatible = "starfive,jh7110-stg-syscon", "syscon"; + reg = <0x10240000 0x1000>; + }; + + syscon@13030000 { + compatible = "starfive,jh7110-sys-syscon", "syscon", "simple-mfd"; + reg = <0x13030000 0x1000>; + + clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + }; + }; + + syscon@17010000 { + compatible = "starfive,jh7110-aon-syscon", "syscon"; + reg = <0x17010000 0x1000>; + #power-domain-cells = <1>; + }; + +...
MAINTAINERS +7 -0
@@ -20282,6 +20282,12 @@ S: Supported F: Documentation/devicetree/bindings/mmc/starfive* F: drivers/mmc/host/dw_mmc-starfive.c +STARFIVE JH7110 SYSCON +M: William Qiu <[email protected]> +M: Xingyu Wu <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml + STARFIVE JH7110 TDM DRIVER M: Walker Chen <[email protected]> S: Maintained
@@ -20331,6 +20337,7 @@ STARFIVE SOC DRIVERS M: Conor Dooley <[email protected]> S: Maintained T: git https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/ +F: Documentation/devicetree/bindings/soc/starfive/ F: drivers/soc/starfive/ STARFIVE TRNG DRIVER
Signature · 1 line
2.25.1
Xingyu Wu
maintainerPATCH v7 3/7 dt-bindings: clock: jh7110-syscrg: Add PLL clock inputs
In reply to Xingyu WuAdd PLL clock inputs from PLL clock generator.
--- .../bindings/clock/starfive,jh7110-syscrg.yaml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml +16 -2
@@ -27,6 +27,9 @@ properties: - description: External I2S RX left/right channel clock - description: External TDM clock - description: External audio master clock + - description: PLL0 + - description: PLL1 + - description: PLL2 - items: - description: Main Oscillator (24 MHz)
@@ -38,6 +41,9 @@ properties: - description: External I2S RX left/right channel clock - description: External TDM clock - description: External audio master clock + - description: PLL0 + - description: PLL1 + - description: PLL2 clock-names: oneOf:
@@ -52,6 +58,9 @@ properties: - const: i2srx_lrck_ext - const: tdm_ext - const: mclk_ext + - const: pll0_out + - const: pll1_out + - const: pll2_out - items: - const: osc
@@ -63,6 +72,9 @@ properties: - const: i2srx_lrck_ext - const: tdm_ext - const: mclk_ext + - const: pll0_out + - const: pll1_out + - const: pll2_out '#clock-cells': const: 1
@@ -93,12 +105,14 @@ examples: <&gmac1_rgmii_rxin>, <&i2stx_bclk_ext>, <&i2stx_lrck_ext>, <&i2srx_bclk_ext>, <&i2srx_lrck_ext>, - <&tdm_ext>, <&mclk_ext>; + <&tdm_ext>, <&mclk_ext>, + <&pllclk 0>, <&pllclk 1>, <&pllclk 2>; 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.25.1
Xingyu Wu
maintainerPATCH v7 4/7 clk: starfive: Add StarFive JH7110 PLL clock driver
In reply to Xingyu WuAdd driver for the StarFive JH7110 PLL clock controller and they work by reading and setting syscon registers.
--- MAINTAINERS | 6 + drivers/clk/starfive/Kconfig | 8 + drivers/clk/starfive/Makefile | 1 + .../clk/starfive/clk-starfive-jh7110-pll.c | 507 ++++++++++++++++++ 4 files changed, 522 insertions(+) create mode 100644 drivers/clk/starfive/clk-starfive-jh7110-pll.c
MAINTAINERS +6 -0
@@ -20282,6 +20282,12 @@ S: Supported F: Documentation/devicetree/bindings/mmc/starfive* F: drivers/mmc/host/dw_mmc-starfive.c +STARFIVE JH7110 PLL CLOCK DRIVER +M: Xingyu Wu <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml +F: drivers/clk/starfive/clk-starfive-jh7110-pll.c + STARFIVE JH7110 SYSCON M: William Qiu <[email protected]> M: Xingyu Wu <[email protected]>
drivers/clk/starfive/Kconfig +8 -0
@@ -21,6 +21,14 @@ config CLK_STARFIVE_JH7100_AUDIO Say Y or M here to support the audio clocks on the StarFive JH7100 SoC. +config CLK_STARFIVE_JH7110_PLL + bool "StarFive JH7110 PLL clock support" + depends on ARCH_STARFIVE || COMPILE_TEST + default ARCH_STARFIVE + help + Say yes here to support the PLL clock controller on the + StarFive JH7110 SoC. + config CLK_STARFIVE_JH7110_SYS bool "StarFive JH7110 system clock support" depends on ARCH_STARFIVE || COMPILE_TEST
drivers/clk/starfive/Makefile +1 -0
@@ -4,5 +4,6 @@ obj-$(CONFIG_CLK_STARFIVE_JH71X0) += clk-starfive-jh71x0.o obj-$(CONFIG_CLK_STARFIVE_JH7100) += clk-starfive-jh7100.o obj-$(CONFIG_CLK_STARFIVE_JH7100_AUDIO) += clk-starfive-jh7100-audio.o +obj-$(CONFIG_CLK_STARFIVE_JH7110_PLL) += clk-starfive-jh7110-pll.o obj-$(CONFIG_CLK_STARFIVE_JH7110_SYS) += clk-starfive-jh7110-sys.o obj-$(CONFIG_CLK_STARFIVE_JH7110_AON) += clk-starfive-jh7110-aon.o
drivers/clk/starfive/clk-starfive-jh7110-pll.c new file +507 -0
507 lines not on this page · raw message
Signature · 1 line
2.25.1
Xingyu Wu
maintainerPATCH v7 5/7 clk: starfive: jh7110-sys: Add PLL clocks source from DTS
In reply to Xingyu WuModify PLL clocks source to be got from DTS or
the fixed factor clocks.
--- drivers/clk/starfive/Kconfig | 1 + .../clk/starfive/clk-starfive-jh7110-sys.c | 66 ++++++++++++------- 2 files changed, 45 insertions(+), 22 deletions(-)
drivers/clk/starfive/Kconfig +1 -0
@@ -35,6 +35,7 @@ config CLK_STARFIVE_JH7110_SYS select AUXILIARY_BUS select CLK_STARFIVE_JH71X0 select RESET_STARFIVE_JH7110 if RESET_CONTROLLER + select CLK_STARFIVE_JH7110_PLL default ARCH_STARFIVE help Say yes here to support the system clock controller on the
drivers/clk/starfive/clk-starfive-jh7110-sys.c +44 -22
90 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v7 5/7] clk: starfive: jh7110-sys: Add PLL clocks source from DTS
Quoted 69 lines · Xingyu Wu
Modify PLL clocks source to be got from DTS or
the fixed factor clocks.Signed-off-by Xingyu Wu <[email protected]>--- drivers/clk/starfive/Kconfig | 1 + .../clk/starfive/clk-starfive-jh7110-sys.c | 66 ++++++++++++------- 2 files changed, 45 insertions(+), 22 deletions(-)drivers/clk/starfive/Kconfig +1
-0@@ -35,6 +35,7 @@ config CLK_STARFIVE_JH7110_SYS select AUXILIARY_BUS select CLK_STARFIVE_JH71X0 select RESET_STARFIVE_JH7110 if RESET_CONTROLLER + select CLK_STARFIVE_JH7110_PLL default ARCH_STARFIVE help Say yes here to support the system clock controller on thedrivers/clk/starfive/clk-starfive-jh7110-sys.c +3
-22@@ -7,6 +7,7 @@*/ #include <linux/auxiliary_bus.h> +#include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/init.h> #include <linux/io.h> @@ -389,6 +390,7 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)struct jh71x0_clk_priv *priv;unsigned int idx;int ret; +struct clk *pllclk; priv = devm_kzalloc(&pdev->dev, struct_size(priv, reg, JH7110_SYSCLK_END),@@ -402,28 +404,42 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)if (IS_ERR (priv->base))return PTR_ERR (priv->base); -/* -* These PLL clocks are not actually fixed factor clocks and can be -* controlled by the syscon registers of JH7110. They will be dropped -* and registered in the PLL clock driver instead. -*/ -/* 24MHz -> 1000.0MHz */ - priv->pll[0 ] =devm_clk_hw_register_fixed_factor (priv->dev,"pll0_out" , -"osc" ,0 ,125 ,3 ); -if (IS_ERR (priv->pll[0 ])) -return PTR_ERR (priv->pll[0 ]); - -/* 24MHz -> 1066.0MHz */ - priv->pll[1 ] =devm_clk_hw_register_fixed_factor (priv->dev,"pll1_out" , -"osc" ,0 ,533 ,12 ); -if (IS_ERR (priv->pll[1 ])) -return PTR_ERR (priv->pll[1 ]); - -/* 24MHz -> 1188.0MHz */ - priv->pll[2 ] =devm_clk_hw_register_fixed_factor (priv->dev,"pll2_out" , -"osc" ,0 ,99 ,2 ); -if (IS_ERR (priv->pll[2 ])) -return PTR_ERR (priv->pll[2 ]); +/* Use fixed factor clocks if can not get the PLL clocks from DTS */
drivers/clk/starfive/clk-starfive-jh7110-sys.c static int __init jh7110_syscrg_probe(struct platform_device *pdev) · line 417
Quoted 10 lines
drivers/clk/starfive/clk-starfive-jh7110-sys.c +10
-0+ pllclk =clk_get (priv->dev,"pll0_out" ); +if (IS_ERR (pllclk)) { +/* 24MHz -> 1000.0MHz */ + priv->pll[0 ] =devm_clk_hw_register_fixed_factor (priv->dev,"pll0_out" , +"osc" ,0 ,125 ,3 ); +if (IS_ERR (priv->pll[0 ])) +return PTR_ERR (priv->pll[0 ]); + }else { +clk_put (pllclk); + priv->pll[0 ] =NULL ;
Not really important enough for a respin, but setting these to NULL is not needed as devm_kzalloc() already zeroes the memory allocated.
In any case:
Quoted 42 lines
drivers/clk/starfive/clk-starfive-jh7110-sys.c +31
-1+ } + + pllclk =clk_get (priv->dev,"pll1_out" ); +if (IS_ERR (pllclk)) { +/* 24MHz -> 1066.0MHz */ + priv->pll[1 ] =devm_clk_hw_register_fixed_factor (priv->dev,"pll1_out" , +"osc" ,0 ,533 ,12 ); +if (IS_ERR (priv->pll[1 ])) +return PTR_ERR (priv->pll[1 ]); + }else { +clk_put (pllclk); + priv->pll[1 ] =NULL ; + } + + pllclk =clk_get (priv->dev,"pll2_out" ); +if (IS_ERR (pllclk)) { +/* 24MHz -> 1188.0MHz */ + priv->pll[2 ] =devm_clk_hw_register_fixed_factor (priv->dev,"pll2_out" , +"osc" ,0 ,99 ,2 ); +if (IS_ERR (priv->pll[2 ])) +return PTR_ERR (priv->pll[2 ]); + }else { +clk_put (pllclk); + priv->pll[2 ] =NULL ; + }for (idx =0 ; idx <JH7110_SYSCLK_END ; idx++) {u32 max = jh7110_sysclk_data[idx].max;@@ -462,6 +478,12 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev) parents[i].fw_name ="tdm_ext" ; else if (pidx == JH7110_SYSCLK_MCLK_EXT) parents[i].fw_name = "mclk_ext"; + else if (pidx == JH7110_SYSCLK_PLL0_OUT && !priv->pll[0]) + parents[i].fw_name = "pll0_out"; + else if (pidx == JH7110_SYSCLK_PLL1_OUT && !priv->pll[1]) + parents[i].fw_name = "pll1_out"; + else if (pidx == JH7110_SYSCLK_PLL2_OUT && !priv->pll[2]) + parents[i].fw_name = "pll2_out"; else parents[i].hw = priv->pll[pidx - JH7110_SYSCLK_PLL0_OUT]; } --
Quoted 2 lines
2.25.1
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Xingyu Wu
maintainerPATCH v7 6/7 riscv: dts: starfive: jh7110: Add syscon nodes
In reply to Xingyu WuFrom: William Qiu <[email protected]>
Add stg_syscon/sys_syscon/aon_syscon/PLL nodes for JH7110 SoC.
--- arch/riscv/boot/dts/starfive/jh7110.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/riscv/boot/dts/starfive/jh7110.dtsi +22 -0
@@ -386,6 +386,11 @@ i2c2: i2c@10050000 { status = "disabled"; }; + stg_syscon: syscon@10240000 { + compatible = "starfive,jh7110-stg-syscon", "syscon"; + reg = <0x0 0x10240000 0x0 0x1000>; + }; + uart3: serial@12000000 { compatible = "snps,dw-apb-uart"; reg = <0x0 0x12000000 0x0 0x10000>;
@@ -490,6 +495,17 @@ syscrg: clock-controller@13020000 { #reset-cells = <1>; }; + sys_syscon: syscon@13030000 { + 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 { compatible = "starfive,jh7110-sys-pinctrl"; reg = <0x0 0x13040000 0x0 0x10000>;
@@ -529,6 +545,12 @@ aoncrg: clock-controller@17000000 { #reset-cells = <1>; }; + aon_syscon: syscon@17010000 { + compatible = "starfive,jh7110-aon-syscon", "syscon"; + reg = <0x0 0x17010000 0x0 0x1000>; + #power-domain-cells = <1>; + }; + aongpio: pinctrl@17020000 { compatible = "starfive,jh7110-aon-pinctrl"; reg = <0x0 0x17020000 0x0 0x10000>;
Signature · 1 line
2.25.1
Xingyu Wu
maintainerPATCH v7 7/7 riscv: dts: starfive: jh7110: Add PLL clocks source in SYSCRG node
In reply to Xingyu WuAdd PLL clocks input from PLL clocks driver in SYSCRG node.
--- arch/riscv/boot/dts/starfive/jh7110.dtsi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/riscv/boot/dts/starfive/jh7110.dtsi +6 -2
@@ -485,12 +485,16 @@ syscrg: clock-controller@13020000 { <&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_PLLCLK_PLL0_OUT>, + <&pllclk JH7110_PLLCLK_PLL1_OUT>, + <&pllclk JH7110_PLLCLK_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.25.1
Conor Dooley
maintainerHey Xingyu,
Quoted 11 lines · Xingyu Wu
This patch serises are to add PLL clocks driver and providers by writing and reading syscon registers for the StarFive JH7110 RISC-V SoC. And add documentation and nodes to describe StarFive System Controller(syscon) Registers. This patch serises are based on Linux 6.4.
PLLs are high speed, low jitter frequency synthesizers in JH7110. Each PLL clock works in integer mode or fraction mode by some dividers, and the dividers are set in several syscon registers.
The formula for calculating frequency is:
Fvco = Fref * (NI + NF) / M / Q1
Quoted 8 lines
The first patch adds docunmentation to describe PLL clock bindings, and the second patch adds documentation to decribe syscon registers. The patch 3 modifies the SYSCRG bindings and adds PLL clock inputs. The patch 4 adds driver to support PLL clocks for JH7110.
The patch 5 modifies the system clock driver and can select the PLL clock source from PLL clocks driver. And the patch 6 adds the stg/sys/aon syscon nodes for JH7110 SoC. The last patch modifies the syscrg node in JH7110 dts file.
Just FYI, I have picked up the binding & clock portions of this series and your other one adding the stg syscon. I've pushed them out here for the test robots to have a look:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/log/?h=clk-starfive
If that passes, my plan is to send Stephen a PR for the lot, later this week.
Thanks,
Conor.
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Xingyu Wu
maintainerQuoted 23 lines · Conor Dooley
Hey Xingyu,
Quoted 11 lines · Xingyu Wu
This patch serises are to add PLL clocks driver and providers by writing and reading syscon registers for the StarFive JH7110 RISC-V SoC. And add documentation and nodes to describe StarFive System Controller(syscon) Registers. This patch serises are based on Linux 6.4.
PLLs are high speed, low jitter frequency synthesizers in JH7110. Each PLL clock works in integer mode or fraction mode by some dividers, and the dividers are set in several syscon registers.
The formula for calculating frequency is:
Fvco = Fref * (NI + NF) / M / Q1Quoted 8 lines
The first patch adds docunmentation to describe PLL clock bindings, and the second patch adds documentation to decribe syscon registers. The patch 3 modifies the SYSCRG bindings and adds PLL clock inputs. The patch 4 adds driver to support PLL clocks for JH7110.
The patch 5 modifies the system clock driver and can select the PLL clock source from PLL clocks driver. And the patch 6 adds the stg/sys/aon syscon nodes for JH7110 SoC. The last patch modifies the syscrg node in JH7110 dts file.
Quoted 8 lines
Just FYI, I have picked up the binding & clock portions of this series and your other one adding the stg syscon. I've pushed them out here for the test robots to have a look:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/log/?h=clk-starfiveIf that passes, my plan is to send Stephen a PR for the lot, later this week.
Great. Thank you for everything.
Best regards,
Xingyu Wu
Re: (subset) [PATCH v7 0/7] Add PLL clocks driver and syscon for StarFive JH7110 SoC
In reply to Xingyu WuFrom: Conor Dooley <[email protected]>
Quoted 5 lines · Xingyu Wu
This patch serises are to add PLL clocks driver and providers by writing and reading syscon registers for the StarFive JH7110 RISC-V SoC. And add documentation and nodes to describe StarFive System Controller(syscon) Registers. This patch serises are based on Linux 6.4.
Quoted 7 lines
PLLs are high speed, low jitter frequency synthesizers in JH7110. Each PLL clock works in integer mode or fraction mode by some dividers, and the dividers are set in several syscon registers.
The formula for calculating frequency is:
Fvco = Fref * (NI + NF) / M / Q1[...]
Applied to riscv-dt-for-next, thanks!
[6/7] riscv: dts: starfive: jh7110: Add syscon nodes
https://git.kernel.org/conor/c/3fcbcfc496f0 [7/7] riscv: dts: starfive: jh7110: Add PLL clocks source in SYSCRG node https://git.kernel.org/conor/c/3e6670a28b00
Thanks,
Conor.