Add common clock support for Broadcom iProc architecture
Subsystems (3)
Ray Jui
maintainerv6 cover Add common clock support for Broadcom iProc architecture
This patchset contains the initial common clock support for Broadcom's iProc family of SoCs. The iProc clock architecture comprises of various PLLs, e.g., ARMPLL, GENPLL, LCPLL0, MIPIPLL, and etc. An onboard crystal serves as the basic reference clock for these PLLs. Each PLL may have several leaf clocks. One special group of clocks is the ASIU clocks, which are dervied directly from the crystal reference clock.
This patchset also contains the basic clock support for the Broadcom Cygnus SoC, which implements the iProc clock architecture
Changes from v5:
- Rebase to v4.0-rc4
- Drop of_clk_get_parent_rate helper function from the clock framework
- Get rid of custom "clock-frequency" support in iProc PLL code. Instead, add standard clock set_rate and round_rate support and make use of DT properties "assigned-clocks" and "assigned-clock-rates" to initialize PLL to the desired rate when registering to the clock framework
- Add SW workaround for ASIC bug on MIPI PLL to always read back the same register following a write transaction, to ensure value is written to the correct register
Changes from v4:
- Add of_clk_get_parent_rate helper function into the clock framework
- Switch to use of_clk_get_parent_rate in the iProc PLL clock driver
Changes from v3:
- Fix incorrect use of passing in of_clk_src_onecell_get when adding ARM PLL and other iProc PLLs as clock provider. These PLLs have zero cells in DT and thefore of_clk_src_simple_get should be used instead
- Rename Cygnus MIPI PLL Channel 2 clock from BCM_CYGNUS_MIPIPLL_CH2_UNUSED to BCM_CYGNUS_MIPIPLL_CH2_V3D, since a 3D graphic rendering engine has been integrated into Cygnus revision B0 and has its core clock running off MIPI PLL Channel 2
- Changed default MIPI PLL VCO frequency from 1.75 GHz to 2.1 GHz. This allows us to derive 300 MHz V3D clock from channel 2 through the post divisor
Changes from v2:
- Re-arrange Cygnus clock/pll init functions so each init function is right next to its clock table
- Removed #defines for number of clocks in Cygnus. Have the number of clocks automatically determined based on array size of the clock table
Changes from v1:
- Separate drivers/clk/Makefile change for drivers/clk/bcm out to a standalone patch
Ray Jui (6):
clk: iproc: define Broadcom iProc clock binding
clk: iproc: add initial common clock support
clk: Change bcm clocks build dependency
clk: cygnus: add clock support for Broadcom Cygnus
ARM: dts: enable clock support for Broadcom Cygnus
clk: cygnus: remove Cygnus dummy clock binding
.../devicetree/bindings/clock/bcm-cygnus-clock.txt | 34 -- .../bindings/clock/brcm,iproc-clocks.txt | 171 +++++++ arch/arm/boot/dts/bcm-cygnus-clock.dtsi | 112 ++++- arch/arm/boot/dts/bcm-cygnus.dtsi | 2 +- drivers/clk/Makefile | 2 +- drivers/clk/bcm/Kconfig | 9 + drivers/clk/bcm/Makefile | 2 + drivers/clk/bcm/clk-cygnus.c | 284 ++++++++++++ drivers/clk/bcm/clk-iproc-armpll.c | 282 +++++++++++ drivers/clk/bcm/clk-iproc-asiu.c | 275 +++++++++++ drivers/clk/bcm/clk-iproc-clk.c | 244 ++++++++++ drivers/clk/bcm/clk-iproc-pll.c | 490 ++++++++++++++++++++ drivers/clk/bcm/clk-iproc.h | 164 +++++++ include/dt-bindings/clock/bcm-cygnus.h | 65 +++ 14 files changed, 2075 insertions(+), 61 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/bcm-cygnus-clock.txt create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt create mode 100644 drivers/clk/bcm/clk-cygnus.c create mode 100644 drivers/clk/bcm/clk-iproc-armpll.c create mode 100644 drivers/clk/bcm/clk-iproc-asiu.c create mode 100644 drivers/clk/bcm/clk-iproc-clk.c create mode 100644 drivers/clk/bcm/clk-iproc-pll.c create mode 100644 drivers/clk/bcm/clk-iproc.h create mode 100644 include/dt-bindings/clock/bcm-cygnus.h
Signature · 1 line
1.7.9.5
Ray Jui
maintainerPATCH v6 2/6 clk: iproc: add initial common clock support
This adds basic and generic support for various iProc PLLs and clocks including the ARMPLL, GENPLL, LCPLL, MIPIPLL, and ASIU clocks.
SoCs under the iProc architecture can define their specific register offsets and clock parameters for their PLL and clock controllers. These parameters can be passed as arugments into the generic iProc PLL and clock setup functions
Derived from code originally provided by Jonathan Richardson <[email protected]>
--- drivers/clk/bcm/Kconfig | 9 + drivers/clk/bcm/Makefile | 1 + drivers/clk/bcm/clk-iproc-armpll.c | 282 +++++++++++++++++++++ drivers/clk/bcm/clk-iproc-asiu.c | 275 ++++++++++++++++++++ drivers/clk/bcm/clk-iproc-clk.c | 244 ++++++++++++++++++ drivers/clk/bcm/clk-iproc-pll.c | 490 ++++++++++++++++++++++++++++++++++++ drivers/clk/bcm/clk-iproc.h | 164 ++++++++++++ 7 files changed, 1465 insertions(+) create mode 100644 drivers/clk/bcm/clk-iproc-armpll.c create mode 100644 drivers/clk/bcm/clk-iproc-asiu.c create mode 100644 drivers/clk/bcm/clk-iproc-clk.c create mode 100644 drivers/clk/bcm/clk-iproc-pll.c create mode 100644 drivers/clk/bcm/clk-iproc.h
drivers/clk/bcm/Kconfig +9 -0
@@ -7,3 +7,12 @@ config CLK_BCM_KONA Enable common clock framework support for Broadcom SoCs using "Kona" style clock control units, including those in the BCM281xx and BCM21664 families. + +config COMMON_CLK_IPROC + bool "Broadcom iProc clock support" + depends on ARCH_BCM_IPROC + depends on COMMON_CLK + default ARCH_BCM_IPROC + help + Enable common clock framework support for Broadcom SoCs + based on the "iProc" architecture
drivers/clk/bcm/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-kona.o obj-$(CONFIG_CLK_BCM_KONA) += clk-kona-setup.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o +obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-clk.o clk-iproc-asiu.o
drivers/clk/bcm/clk-iproc-armpll.c new file +282 -0
282 lines not on this page · raw message
drivers/clk/bcm/clk-iproc-asiu.c new file +275 -0
275 lines not on this page · raw message
drivers/clk/bcm/clk-iproc-clk.c new file +244 -0
244 lines not on this page · raw message
drivers/clk/bcm/clk-iproc-pll.c new file +490 -0
490 lines not on this page · raw message
drivers/clk/bcm/clk-iproc.h new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Ray Jui
maintainerPATCH v6 3/6 clk: Change bcm clocks build dependency
In reply to Ray JuiThe clock code under drivers/clk/bcm now contains code for both the Broadcom mobile SoCs and the iProc SoCs. Change the the makefile dependency to be under config flag CONFIG_ARCH_BCM that's enabled for both families of SoCs
--- drivers/clk/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/Makefile +1 -1
@@ -43,7 +43,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_AT91) += at91/ -obj-$(CONFIG_ARCH_BCM_MOBILE) += bcm/ +obj-$(CONFIG_ARCH_BCM) += bcm/ obj-$(CONFIG_ARCH_BERLIN) += berlin/ obj-$(CONFIG_ARCH_HI3xxx) += hisilicon/ obj-$(CONFIG_ARCH_HIP04) += hisilicon/
Signature · 1 line
1.7.9.5
Ray Jui
maintainerPATCH v6 4/6 clk: cygnus: add clock support for Broadcom Cygnus
In reply to Ray JuiThe Broadcom Cygnus SoC is architected under the iProc architecture. It has the following PLLs: ARMPLL, GENPLL, LCPLL0, MIPIPLL, all dervied from an onboard crystal. Cygnus also has various ASIU clocks that are derived directly from the onboard crystal.
--- drivers/clk/bcm/Makefile | 1 + drivers/clk/bcm/clk-cygnus.c | 284 ++++++++++++++++++++++++++++++++ include/dt-bindings/clock/bcm-cygnus.h | 65 ++++++++ 3 files changed, 350 insertions(+) create mode 100644 drivers/clk/bcm/clk-cygnus.c create mode 100644 include/dt-bindings/clock/bcm-cygnus.h
drivers/clk/bcm/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-kona-setup.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-clk.o clk-iproc-asiu.o +obj-$(CONFIG_ARCH_BCM_CYGNUS) += clk-cygnus.o
drivers/clk/bcm/clk-cygnus.c new file +284 -0
284 lines not on this page · raw message
include/dt-bindings/clock/bcm-cygnus.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Ray Jui
maintainerPATCH v6 6/6 clk: cygnus: remove Cygnus dummy clock binding
In reply to Ray JuiRemove old Cygnus dummy clock binding document, as it's replaced by Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt
--- .../devicetree/bindings/clock/bcm-cygnus-clock.txt | 34 -------------------- 1 file changed, 34 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/bcm-cygnus-clock.txt
Documentation/devicetree/bindings/clock/bcm-cygnus-clock.txt deleted +0 -34
@@ -1,34 +0,0 @@ -Broadcom Cygnus Clocks - -This binding uses the common clock binding: -Documentation/devicetree/bindings/clock/clock-bindings.txt - -Currently various "fixed" clocks are declared for peripheral drivers that use -the common clock framework to reference their core clocks. Proper support of -these clocks will be added later - -Device tree example: - - clocks { - #address-cells = <1>; - #size-cells = <1>; - ranges; - - osc: oscillator { - compatible = "fixed-clock"; - #clock-cells = <1>; - clock-frequency = <25000000>; - }; - - apb_clk: apb_clk { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <1000000000>; - }; - - periph_clk: periph_clk { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <500000000>; - }; - };
Signature · 1 line
1.7.9.5
Ray Jui
maintainerPATCH v6 5/6 ARM: dts: enable clock support for Broadcom Cygnus
In reply to Ray JuiReplace current device tree dummy clocks with real clock support for Broadcom Cygnus SoC
--- arch/arm/boot/dts/bcm-cygnus-clock.dtsi | 112 ++++++++++++++++++++++++------- arch/arm/boot/dts/bcm-cygnus.dtsi | 2 +- 2 files changed, 88 insertions(+), 26 deletions(-)
arch/arm/boot/dts/bcm-cygnus-clock.dtsi +87 -25
@@ -36,56 +36,118 @@ clocks { ranges; osc: oscillator { + #clock-cells = <0>; compatible = "fixed-clock"; - #clock-cells = <1>; clock-frequency = <25000000>; }; - apb_clk: apb_clk { - compatible = "fixed-clock"; + /* Cygnus ARM PLL */ + armpll: armpll { #clock-cells = <0>; - clock-frequency = <1000000000>; + compatible = "brcm,cygnus-armpll"; + clocks = <&osc>; + reg = <0x19000000 0x1000>; }; - periph_clk: periph_clk { - compatible = "fixed-clock"; + /* peripheral clock for system timer */ + arm_periph_clk: arm_periph_clk { #clock-cells = <0>; - clock-frequency = <500000000>; + compatible = "fixed-factor-clock"; + clocks = <&armpll>; + clock-div = <2>; + clock-mult = <1>; }; - sdio_clk: lcpll_ch2 { - compatible = "fixed-clock"; + /* APB bus clock */ + apb_clk: apb_clk { #clock-cells = <0>; - clock-frequency = <200000000>; + compatible = "fixed-factor-clock"; + clocks = <&armpll>; + clock-div = <4>; + clock-mult = <1>; }; - axi81_clk: axi81_clk { - compatible = "fixed-clock"; + genpll: genpll { #clock-cells = <0>; - clock-frequency = <100000000>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; }; - keypad_clk: keypad_clk { - compatible = "fixed-clock"; + /* various clocks running off the GENPLL */ + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + }; + + /* always 1/2 of the axi21 clock */ + axi41_clk: axi41_clk { #clock-cells = <0>; - clock-frequency = <31806>; + compatible = "fixed-factor-clock"; + clocks = <&genpll_clks 0>; + clock-div = <2>; + clock-mult = <1>; }; - adc_clk: adc_clk { - compatible = "fixed-clock"; + /* always 1/4 of the axi21 clock */ + axi81_clk: axi81_clk { #clock-cells = <0>; - clock-frequency = <1562500>; + compatible = "fixed-factor-clock"; + clocks = <&genpll_clks 0>; + clock-div = <4>; + clock-mult = <1>; }; - pwm_clk: pwm_clk { - compatible = "fixed-clock"; + lcpll0: lcpll0 { #clock-cells = <0>; - clock-frequency = <1000000>; + compatible = "brcm,cygnus-lcpll0"; + reg = <0x0301d02c 0x1c>, + <0x0301c020 0x4>; + clocks = <&osc>; }; - lcd_clk: mipipll_ch1 { - compatible = "fixed-clock"; + /* various clocks running off the LCPLL0 */ + lcpll0_clks: lcpll0_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-lcpll0-clk"; + reg = <0x0301d02c 0x1c>; + clocks = <&lcpll0>; + clock-output-names = "pcie_phy", "ddr_phy", "sdio", + "usb_phy", "smart_card", "ch5"; + }; + + mipipll: mipipll { #clock-cells = <0>; - clock-frequency = <100000000>; + compatible = "brcm,cygnus-mipipll"; + reg = <0x180a9800 0x2c>, + <0x0301c020 0x4>, + <0x180aa024 0x4>; + clocks = <&osc>; + + assigned-clocks = <&mipipll>; + assigned-clock-rates = <2100000000>; + }; + + mipipll_clks: mipipll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-mipipll-clk"; + reg = <0x180a9800 0x2c>; + clocks = <&mipipll>; + clock-output-names = "ch0_unused", "ch1_lcd", "ch2_v3d", + "ch3_unused", "ch4_unused", "ch5_unused"; + }; + + asiu_clks: asiu_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-asiu-clk"; + reg = <0x0301d048 0xc>, + <0x180aa024 0x4>; + clocks = <&osc>; + clock-output-names = "keypad", "adc/touch", "pwm"; }; };
arch/arm/boot/dts/bcm-cygnus.dtsi +1 -1
@@ -154,7 +154,7 @@ compatible = "arm,cortex-a9-global-timer"; reg = <0x19020200 0x100>; interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&periph_clk>; + clocks = <&arm_periph_clk>; }; };
Signature · 1 line
1.7.9.5
Ray Jui
maintainerPATCH v6 1/6 clk: iproc: define Broadcom iProc clock binding
In reply to Ray JuiDocument the device tree binding for Broadcom iProc architecture based clock controller
--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +171 -0
@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + }; + +Required properties for ASIU clocks: + +ASIU clocks are a special case. These clocks are derived directly from the +reference clock of the onboard crystal + +- compatible: + Should have a value of the form "brcm,<soc>-asiu-clk". For example, ASIU +clocks for Cygnus have a compatible string of "brcm,cygnus-asiu-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 ASIU clocks + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for ASIU clocks + +- clocks: + The input parent clock phandle for the ASIU clock, i.e., the onboard +crystal + +- clock-output-names: + An ordered list of strings defining the names of the ASIU clocks + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + asiu_clks: asiu_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-asiu-clk"; + reg = <0x0301d048 0xc>, + <0x180aa024 0x4>; + clocks = <&osc>; + clock-output-names = "keypad", "adc/touch", "pwm"; + }; + +Cygnus +------ +PLL and leaf clock compatible strings for Cygnus are: + "brcm,cygnus-armpll" + "brcm,cygnus-genpll" + "brcm,cygnus-lcpll0" + "brcm,cygnus-mipipll" + "brcm,cygnus-genpll-clk" + "brcm,cygnus-lcpll0-clk" + "brcm,cygnus-mipipll-clk" + "brcm,cygnus-asiu-clk" + +The following table defines the set of PLL/clock index and ID for Cygnus. +These clock IDs are defined in: + "include/dt-bindings/clock/bcm-cygnus.h" + + Clock Source Index ID + --- ----- ----- --------- + crystal N/A N/A N/A + + armpll crystal N/A N/A + genpll crystal N/A N/A + lcpll0 crystal N/A N/A + mipipll crystal N/A N/A + + keypad crystal (ASIU) 0 BCM_CYGNUS_ASIU_KEYPAD_CLK + adc/tsc crystal (ASIU) 1 BCM_CYGNUS_ASIU_ADC_CLK + pwm crystal (ASIU) 2 BCM_CYGNUS_ASIU_PWM_CLK + + axi21 genpll 0 BCM_CYGNUS_GENPLL_AXI21_CLK + 250mhz genpll 1 BCM_CYGNUS_GENPLL_250MHZ_CLK + ihost_sys genpll 2 BCM_CYGNUS_GENPLL_IHOST_SYS_CLK + enet_sw genpll 3 BCM_CYGNUS_GENPLL_ENET_SW_CLK + audio_125 genpll 4 BCM_CYGNUS_GENPLL_AUDIO_125_CLK + can genpll 5 BCM_CYGNUS_GENPLL_CAN_CLK + + pcie_phy lcpll0 0 BCM_CYGNUS_LCPLL0_PCIE_PHY_REF_CLK + ddr_phy lcpll0 1 BCM_CYGNUS_LCPLL0_DDR_PHY_CLK + sdio lcpll0 2 BCM_CYGNUS_LCPLL0_SDIO_CLK + usb_phy lcpll0 3 BCM_CYGNUS_LCPLL0_USB_PHY_REF_CLK + smart_card lcpll0 4 BCM_CYGNUS_LCPLL0_SMART_CARD_CLK + ch5_unused lcpll0 5 BCM_CYGNUS_LCPLL0_CH5_UNUSED + + ch0_unused mipipll 0 BCM_CYGNUS_MIPIPLL_CH0_UNUSED + ch1_lcd mipipll 1 BCM_CYGNUS_MIPIPLL_CH1_LCD + ch2_v3d mipipll 2 BCM_CYGNUS_MIPIPLL_CH2_V3D + ch3_unused mipipll 3 BCM_CYGNUS_MIPIPLL_CH3_UNUSED + ch4_unused mipipll 4 BCM_CYGNUS_MIPIPLL_CH4_UNUSED + ch5_unused mipipll 5 BCM_CYGNUS_MIPIPLL_CH5_UNUSED
Signature · 1 line
1.7.9.5
Scott Branden
maintainerPatchset looks good now.
Scott
Quoted 78 lines · Ray Jui
This patchset contains the initial common clock support for Broadcom's iProc family of SoCs. The iProc clock architecture comprises of various PLLs, e.g., ARMPLL, GENPLL, LCPLL0, MIPIPLL, and etc. An onboard crystal serves as the basic reference clock for these PLLs. Each PLL may have several leaf clocks. One special group of clocks is the ASIU clocks, which are dervied directly from the crystal reference clock.
This patchset also contains the basic clock support for the Broadcom Cygnus SoC, which implements the iProc clock architecture
Changes from v5:
- Rebase to v4.0-rc4
- Dropof_clk_get_parent_ratehelper function from the clock framework
- Get rid of custom "clock-frequency" support in iProc PLL code. Instead, add standard clockset_rateandround_ratesupport and make use of DT properties "assigned-clocks" and "assigned-clock-rates" to initialize PLL to the desired rate when registering to the clock framework
- Add SW workaround for ASIC bug on MIPI PLL to always read back the same register following a write transaction, to ensure value is written to the correct registerChanges from v4:
- Addof_clk_get_parent_ratehelper function into the clock framework
- Switch to useof_clk_get_parent_ratein the iProc PLL clock driverChanges from v3:
- Fix incorrect use of passing inof_clk_src_onecell_getwhen adding ARM PLL and other iProc PLLs as clock provider. These PLLs have zero cells in DT and theforeof_clk_src_simple_getshould be used instead
- Rename Cygnus MIPI PLL Channel 2 clock fromBCM_CYGNUS_MIPIPLL_CH2_UNUSEDtoBCM_CYGNUS_MIPIPLL_CH2_V3D, since a 3D graphic rendering engine has been integrated into Cygnus revision B0 and has its core clock running off MIPI PLL Channel 2
- Changed default MIPI PLL VCO frequency from 1.75 GHz to 2.1 GHz. This allows us to derive 300 MHz V3D clock from channel 2 through the post divisorChanges from v2:
- Re-arrange Cygnus clock/pll init functions so each init function is right next to its clock table
- Removed #defines for number of clocks in Cygnus. Have the number of clocks automatically determined based on array size of the clock tableChanges from v1:
- Separatedrivers/clk/Makefilechange fordrivers/clk/bcmout to a standalone patchRay Jui (6):
clk: iproc: define Broadcom iProc clock binding
clk: iproc: add initial common clock support
clk: Change bcm clocks build dependency
clk: cygnus: add clock support for Broadcom Cygnus
ARM: dts: enable clock support for Broadcom Cygnus
clk: cygnus: remove Cygnus dummy clock binding.../devicetree/bindings/clock/bcm-cygnus-clock.txt | 34 -- .../bindings/clock/brcm,iproc-clocks.txt | 171 +++++++ arch/arm/boot/dts/bcm-cygnus-clock.dtsi | 112 ++++- arch/arm/boot/dts/bcm-cygnus.dtsi | 2 +- drivers/clk/Makefile | 2 +- drivers/clk/bcm/Kconfig | 9 + drivers/clk/bcm/Makefile | 2 + drivers/clk/bcm/clk-cygnus.c | 284 ++++++++++++ drivers/clk/bcm/clk-iproc-armpll.c | 282 +++++++++++ drivers/clk/bcm/clk-iproc-asiu.c | 275 +++++++++++ drivers/clk/bcm/clk-iproc-clk.c | 244 ++++++++++ drivers/clk/bcm/clk-iproc-pll.c | 490 ++++++++++++++++++++ drivers/clk/bcm/clk-iproc.h | 164 +++++++ include/dt-bindings/clock/bcm-cygnus.h | 65 +++ 14 files changed, 2075 insertions(+), 61 deletions(-)delete mode 100644
Documentation/devicetree/bindings/clock/bcm-cygnus-clock.txtcreate mode 100644Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtcreate mode 100644drivers/clk/bcm/clk-cygnus.c
create mode 100644drivers/clk/bcm/clk-iproc-armpll.c
create mode 100644drivers/clk/bcm/clk-iproc-asiu.c
create mode 100644drivers/clk/bcm/clk-iproc-clk.c
create mode 100644drivers/clk/bcm/clk-iproc-pll.c
create mode 100644drivers/clk/bcm/clk-iproc.h
create mode 100644include/dt-bindings/clock/bcm-cygnus.h
Ray Jui
maintainerHi Mike,
This is the latest patch series of the Broadcom iProc clock driver that I was talking about. I believe it has addressed your previous code review comments by switching to use assigned-clocks/assigned-clock-rates for configuring PLL clock at the time of clock registration.
Please have a look and let us know if this can be pulled in.
Thanks,
Ray
Quoted 78 lines · Ray Jui
This patchset contains the initial common clock support for Broadcom's iProc family of SoCs. The iProc clock architecture comprises of various PLLs, e.g., ARMPLL, GENPLL, LCPLL0, MIPIPLL, and etc. An onboard crystal serves as the basic reference clock for these PLLs. Each PLL may have several leaf clocks. One special group of clocks is the ASIU clocks, which are dervied directly from the crystal reference clock.
This patchset also contains the basic clock support for the Broadcom Cygnus SoC, which implements the iProc clock architecture
Changes from v5:
- Rebase to v4.0-rc4
- Dropof_clk_get_parent_ratehelper function from the clock framework
- Get rid of custom "clock-frequency" support in iProc PLL code. Instead, add standard clockset_rateandround_ratesupport and make use of DT properties "assigned-clocks" and "assigned-clock-rates" to initialize PLL to the desired rate when registering to the clock framework
- Add SW workaround for ASIC bug on MIPI PLL to always read back the same register following a write transaction, to ensure value is written to the correct registerChanges from v4:
- Addof_clk_get_parent_ratehelper function into the clock framework
- Switch to useof_clk_get_parent_ratein the iProc PLL clock driverChanges from v3:
- Fix incorrect use of passing inof_clk_src_onecell_getwhen adding ARM PLL and other iProc PLLs as clock provider. These PLLs have zero cells in DT and theforeof_clk_src_simple_getshould be used instead
- Rename Cygnus MIPI PLL Channel 2 clock fromBCM_CYGNUS_MIPIPLL_CH2_UNUSEDtoBCM_CYGNUS_MIPIPLL_CH2_V3D, since a 3D graphic rendering engine has been integrated into Cygnus revision B0 and has its core clock running off MIPI PLL Channel 2
- Changed default MIPI PLL VCO frequency from 1.75 GHz to 2.1 GHz. This allows us to derive 300 MHz V3D clock from channel 2 through the post divisorChanges from v2:
- Re-arrange Cygnus clock/pll init functions so each init function is right next to its clock table
- Removed #defines for number of clocks in Cygnus. Have the number of clocks automatically determined based on array size of the clock tableChanges from v1:
- Separatedrivers/clk/Makefilechange fordrivers/clk/bcmout to a standalone patchRay Jui (6):
clk: iproc: define Broadcom iProc clock binding
clk: iproc: add initial common clock support
clk: Change bcm clocks build dependency
clk: cygnus: add clock support for Broadcom Cygnus
ARM: dts: enable clock support for Broadcom Cygnus
clk: cygnus: remove Cygnus dummy clock binding.../devicetree/bindings/clock/bcm-cygnus-clock.txt | 34 -- .../bindings/clock/brcm,iproc-clocks.txt | 171 +++++++ arch/arm/boot/dts/bcm-cygnus-clock.dtsi | 112 ++++- arch/arm/boot/dts/bcm-cygnus.dtsi | 2 +- drivers/clk/Makefile | 2 +- drivers/clk/bcm/Kconfig | 9 + drivers/clk/bcm/Makefile | 2 + drivers/clk/bcm/clk-cygnus.c | 284 ++++++++++++ drivers/clk/bcm/clk-iproc-armpll.c | 282 +++++++++++ drivers/clk/bcm/clk-iproc-asiu.c | 275 +++++++++++ drivers/clk/bcm/clk-iproc-clk.c | 244 ++++++++++ drivers/clk/bcm/clk-iproc-pll.c | 490 ++++++++++++++++++++ drivers/clk/bcm/clk-iproc.h | 164 +++++++ include/dt-bindings/clock/bcm-cygnus.h | 65 +++ 14 files changed, 2075 insertions(+), 61 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/bcm-cygnus-clock.txt create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt create mode 100644 drivers/clk/bcm/clk-cygnus.c create mode 100644 drivers/clk/bcm/clk-iproc-armpll.c create mode 100644 drivers/clk/bcm/clk-iproc-asiu.c create mode 100644 drivers/clk/bcm/clk-iproc-clk.c create mode 100644 drivers/clk/bcm/clk-iproc-pll.c create mode 100644 drivers/clk/bcm/clk-iproc.h create mode 100644 include/dt-bindings/clock/bcm-cygnus.h
Re: [PATCH v6 1/6] clk: iproc: define Broadcom iProc clock binding
In reply to Ray JuiQuoting Ray Jui (2015-03-17 22:45:17)
Quoted 87 lines
Document the device tree binding for Broadcom iProc architecture based clock controller
Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtDocumentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +71
-0@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>;
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +10
-0+ }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + };
Hi Ray,
Thanks for submitting the patch. It was nice meeting you at ELC as well.
This binding doesn't conform to the norms for clock bindings. It looks like for each type of controllable clock node (e.g. pll, leaf clock, etc) you have a dts node. Looking at the above example it seems that those two nodes (genpll and genpll_clks) share the same register.
/me checks patch #5
Yup, you re-use the same register address for the *pll and *pll_clks nodes. I'm not a DT expert but I think this is considered Wrong.
More generally your clock dt binding should be modeling the hardware in terms of IP blocks. If you have a clock generator IP block it may control many clock bits and output many clock signals. E.g. for your hardware (based only on the addresses in patch #5 and not having seen any data manual) I will hazard a guess that the genpll, lcpll and asiu clocks are all part of the same IP block.
If my guess is correct then these clocks should all be represented by a single node int DT. Lets say that the clock controller IP block that manages the genpll, lcpll and asiu clocks (including their child/leaf clocks) is called "foobar" in your data manual. You should have a dts node with a compatible string such as "brcm,cygnus-foobar" or "brcm,cygnus-foobar-clk".
Your clock driver should be responsible for registering all of the clocks controlled by this IP block, regardless of the "type" of clock node.
I think part of the reason for your approach is that the previous (deprecated) binding/dts had a bunch of fixed-rate clocks in it. This is a hack that we do every now and then to get a new platform up and running with a mainline kernel, but we don't do per-clock nodes in dts any more, we do them by clock controller ip block instead.
There are plenty of good examples of this for Exynos and QCOM SoCs if you want an example.
Regards,
Mike
Ray Jui
maintainerRe: [PATCH v6 1/6] clk: iproc: define Broadcom iProc clock binding
Quoted 113 lines · Michael Turquette
Quoting Ray Jui (2015-03-17 22:45:17)
Quoted 87 lines
Document the device tree binding for Broadcom iProc architecture based clock controller
Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtDocumentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +71
-0@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>;Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +10
-0+ }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + };Hi Ray,
Thanks for submitting the patch. It was nice meeting you at ELC as well.
This binding doesn't conform to the norms for clock bindings. It looks like for each type of controllable clock node (e.g. pll, leaf clock, etc) you have a dts node. Looking at the above example it seems that those two nodes (genpll and
genpll_clks) share the same register./me checks patch #5
Yup, you re-use the same register address for the *pll and
*pll_clksnodes. I'm not a DT expert but I think this is considered Wrong.
Quoted 6 lines
More generally your clock dt binding should be modeling the hardware in terms of IP blocks. If you have a clock generator IP block it may control many clock bits and output many clock signals. E.g. for your hardware (based only on the addresses in patch #5 and not having seen any data manual) I will hazard a guess that the genpll, lcpll and asiu clocks are all part of the same IP block.
Hi Mike,
In fact, lcpll, genpll, mipipll are similar but DIFFERENT IP blocks, and asiu is completely different from any of them. All of these plls are unique and have their own register banks, as you can see from the bcm-cygnus-clock.dtsi file. Therefore, I think it's totally correct and actually necessary to represent each of them with a separate device node.
Regarding the relationship between a PLL clock and its leaf clocks:
Taking the genpll as an example, physically they are connected as:
xtal -> genpll -> axi21, 250mhz, ihost_sys, ...
The 25 MHz crystal feeds to the genpll, and the genpll generates 6 different leaf clocks including axi21, 250mhz, ihost_sys, and etc. One can choose to set the genpll's vco to one frequency, and based on that frequency, different leaf clock frequencies can be generated with their own post divider.
Therefore, I think it makes sense to represent xtal, genpll, genpll_clks (including axi21, 250mhz, ihost_sys, and etc) each with a unique device node, and genpll is the parent of these leaf clocks. Basically the device nodes and the way how the "clocks" phandle is used represent the hierarchy of the clock architecture within Cygnus (and in the future other iProc SoCs). Does that make sense?
Regarding the register address overlapping, again, taking genpll as an example, the genpll and the genpll_clks actually never access the same set of registers, but the registers are sort of scattered within one bank, i.e., on Cygnus, genpll uses registers at offset 0x0, 0x8 ~ 0x1c, and genpll_clks uses registers at offset 0x4, 0x20 - 0x24.
Thanks,
Ray
Quoted 24 lines
If my guess is correct then these clocks should all be represented by a single node int DT. Lets say that the clock controller IP block that manages the genpll, lcpll and asiu clocks (including their child/leaf clocks) is called "foobar" in your data manual. You should have a dts node with a compatible string such as "brcm,cygnus-foobar" or "brcm,cygnus-foobar-clk".
Your clock driver should be responsible for registering all of the clocks controlled by this IP block, regardless of the "type" of clock node.
I think part of the reason for your approach is that the previous (deprecated) binding/dts had a bunch of fixed-rate clocks in it. This is a hack that we do every now and then to get a new platform up and running with a mainline kernel, but we don't do per-clock nodes in dts any more, we do them by clock controller ip block instead.
There are plenty of good examples of this for Exynos and QCOM SoCs if you want an example.
Regards,
Mike
Re: [PATCH v6 1/6] clk: iproc: define Broadcom iProc clock binding
Quoting Ray Jui (2015-04-12 21:08:32)
Quoted 123 lines · Michael Turquette
Quoted 113 lines
Quoting Ray Jui (2015-03-17 22:45:17)
Quoted 87 lines
Document the device tree binding for Broadcom iProc architecture based clock controller
Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtDocumentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +71
-0@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>;Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +10
-0+ }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + };Hi Ray,
Thanks for submitting the patch. It was nice meeting you at ELC as well.
This binding doesn't conform to the norms for clock bindings. It looks like for each type of controllable clock node (e.g. pll, leaf clock, etc) you have a dts node. Looking at the above example it seems that those two nodes (genpll and
genpll_clks) share the same register./me checks patch #5
Yup, you re-use the same register address for the *pll and
*pll_clksnodes. I'm not a DT expert but I think this is considered Wrong.Quoted 6 lines
More generally your clock dt binding should be modeling the hardware in terms of IP blocks. If you have a clock generator IP block it may control many clock bits and output many clock signals. E.g. for your hardware (based only on the addresses in patch #5 and not having seen any data manual) I will hazard a guess that the genpll, lcpll and asiu clocks are all part of the same IP block.
Quoted 7 lines
Hi Mike,
In fact, lcpll, genpll, mipipll are similar but DIFFERENT IP blocks, and asiu is completely different from any of them. All of these plls are unique and have their own register banks, as you can see from the
bcm-cygnus-clock.dtsifile. Therefore, I think it's totally correct and actually necessary to represent each of them with a separate device node.
OK, that makes sense to me, if those registers live in addresses ranges which correspond to different IP blocks.
Quoted 12 lines
Regarding the relationship between a PLL clock and its leaf clocks:
Taking the genpll as an example, physically they are connected as:xtal -> genpll -> axi21, 250mhz,
ihost_sys, ...The 25 MHz crystal feeds to the genpll, and the genpll generates 6 different leaf clocks including axi21, 250mhz,
ihost_sys, and etc. One can choose to set the genpll's vco to one frequency, and based on that frequency, different leaf clock frequencies can be generated with their own post divider.
Quoted 6 lines
Therefore, I think it makes sense to represent xtal, genpll,
genpll_clks(including axi21, 250mhz,ihost_sys, and etc) each with a unique device node, and genpll is the parent of these leaf clocks. Basically the device nodes and the way how the "clocks" phandle is used represent the hierarchy of the clock architecture within Cygnus (and in the future other iProc SoCs). Does that make sense?
This doesn't make sense to me. If I understand correctly, the register range that controls the post-divider clock (e.g. axi21) is the same register range that control's genpll. This is a reasonable indicator to me that the leaf clocks are part of the same clock generator IP block as the PLL controls. As such they should be on node.
Quoted 6 lines
Regarding the register address overlapping, again, taking genpll as an example, the genpll and the
genpll_clksactually never access the same set of registers, but the registers are sort of scattered within one bank, i.e., on Cygnus, genpll uses registers at offset0x0,0x8~0x1c, andgenpll_clksuses registers at offset0x4,0x20-0x24.
Sure, my argument above doesn't hinge on the fact that the pll and child clocks use the exact same register. It still looks to me like *pll and it's child dividers belong in the same IP block. Is there an open data sheet or technical reference manual I can look at for this part? That is the best way to put my concerns at ease ;-)
Looking over your binding again, it looks like your nodes are divided conveniently for the different clock types (e.g. pll versus post-divider), but our goal with DT is to accurately describe the hardware, not the C structures.
Regards,
Mike
Quoted 29 lines
Thanks,
Ray
Quoted 24 lines
If my guess is correct then these clocks should all be represented by a single node int DT. Lets say that the clock controller IP block that manages the genpll, lcpll and asiu clocks (including their child/leaf clocks) is called "foobar" in your data manual. You should have a dts node with a compatible string such as "brcm,cygnus-foobar" or "brcm,cygnus-foobar-clk".
Your clock driver should be responsible for registering all of the clocks controlled by this IP block, regardless of the "type" of clock node.
I think part of the reason for your approach is that the previous (deprecated) binding/dts had a bunch of fixed-rate clocks in it. This is a hack that we do every now and then to get a new platform up and running with a mainline kernel, but we don't do per-clock nodes in dts any more, we do them by clock controller ip block instead.
There are plenty of good examples of this for Exynos and QCOM SoCs if you want an example.
Regards,
Mike
Ray Jui
maintainerRe: [PATCH v6 1/6] clk: iproc: define Broadcom iProc clock binding
Hi Mike,
Quoted 173 lines · Michael Turquette
Quoting Ray Jui (2015-04-12 21:08:32)
Quoted 123 lines · Michael Turquette
Quoted 113 lines
Quoting Ray Jui (2015-03-17 22:45:17)
Quoted 87 lines
Document the device tree binding for Broadcom iProc architecture based clock controller
Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtDocumentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +71
-0@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>;Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +10
-0+ }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + };Hi Ray,
Thanks for submitting the patch. It was nice meeting you at ELC as well.
This binding doesn't conform to the norms for clock bindings. It looks like for each type of controllable clock node (e.g. pll, leaf clock, etc) you have a dts node. Looking at the above example it seems that those two nodes (genpll and
genpll_clks) share the same register./me checks patch #5
Yup, you re-use the same register address for the *pll and
*pll_clksnodes. I'm not a DT expert but I think this is considered Wrong.Quoted 6 lines
More generally your clock dt binding should be modeling the hardware in terms of IP blocks. If you have a clock generator IP block it may control many clock bits and output many clock signals. E.g. for your hardware (based only on the addresses in patch #5 and not having seen any data manual) I will hazard a guess that the genpll, lcpll and asiu clocks are all part of the same IP block.
Quoted 7 lines
Hi Mike,
In fact, lcpll, genpll, mipipll are similar but DIFFERENT IP blocks, and asiu is completely different from any of them. All of these plls are unique and have their own register banks, as you can see from the
bcm-cygnus-clock.dtsifile. Therefore, I think it's totally correct and actually necessary to represent each of them with a separate device node.OK, that makes sense to me, if those registers live in addresses ranges which correspond to different IP blocks.
Quoted 12 lines
Regarding the relationship between a PLL clock and its leaf clocks:
Taking the genpll as an example, physically they are connected as:xtal -> genpll -> axi21, 250mhz,
ihost_sys, ...The 25 MHz crystal feeds to the genpll, and the genpll generates 6 different leaf clocks including axi21, 250mhz,
ihost_sys, and etc. One can choose to set the genpll's vco to one frequency, and based on that frequency, different leaf clock frequencies can be generated with their own post divider.Quoted 6 lines
Therefore, I think it makes sense to represent xtal, genpll,
genpll_clks(including axi21, 250mhz,ihost_sys, and etc) each with a unique device node, and genpll is the parent of these leaf clocks. Basically the device nodes and the way how the "clocks" phandle is used represent the hierarchy of the clock architecture within Cygnus (and in the future other iProc SoCs). Does that make sense?This doesn't make sense to me. If I understand correctly, the register range that controls the post-divider clock (e.g. axi21) is the same register range that control's genpll. This is a reasonable indicator to me that the leaf clocks are part of the same clock generator IP block as the PLL controls. As such they should be on node.
Quoted 6 lines
Regarding the register address overlapping, again, taking genpll as an example, the genpll and the
genpll_clksactually never access the same set of registers, but the registers are sort of scattered within one bank, i.e., on Cygnus, genpll uses registers at offset0x0,0x8~0x1c, andgenpll_clksuses registers at offset0x4,0x20-0x24.Sure, my argument above doesn't hinge on the fact that the pll and child clocks use the exact same register. It still looks to me like *pll and it's child dividers belong in the same IP block. Is there an open data sheet or technical reference manual I can look at for this part? That is the best way to put my concerns at ease ;-)
Quoted 8 lines
Looking over your binding again, it looks like your nodes are divided conveniently for the different clock types (e.g. pll versus post-divider), but our goal with DT is to accurately describe the hardware, not the C structures.
Regards,
Mike
Yes, the genpll and genpll_clks are controlled by the same IP block. I can make the change to combine them to use one DT node. But before doing that, I just need to get one thing clarified with you. In SW, the pll and its leaf clocks will still be registered as separate two clock providers, since we need to be able to configure the PLL vco frequency and its leaf clock frequencies separately. The pll will be the parent of its leaf clocks, and the leaf clocks will be used by various peripherals.
I plan to have the combined DT looks like this:
genpll_clks: genpll_clks {
#clock-cells = <1>;
compatible = "brcm,cygnus-genpll-clk";
reg = <0x0301d000 0x2c>;
assigned-clocks = <&genpll_clks>;
/* this sets the PLL rate at the time when the PLL clock is
registered */
assigned-clock-rates = <4000000000>;
clocks = <&osc>;
clock-output-names = "axi21", "250mhz", "ihost_sys", "enet_sw","audio_125", "can";
};
peripheralA: peripheralA {
/* use the first leaf clock of genpll */
clocks = <&genpll_clks 0>;
clock-frequency = <100000000>;
};If we register both the genpll and its leaf clocks to the clock framework as two separate clock providers, would the above DT entries still work? For example, peripheralA refers to the phandle of genpll_clks, but how does the clock framework know to link it to the pll clock or the leaf clock?
Thanks,
Ray
Ray Jui
maintainerRe: [PATCH v6 1/6] clk: iproc: define Broadcom iProc clock binding
Hi Mike,
Quoted 223 lines · Ray Jui
Hi Mike,
Quoted 173 lines · Michael Turquette
Quoting Ray Jui (2015-04-12 21:08:32)
Quoted 123 lines · Michael Turquette
Quoted 113 lines
Quoting Ray Jui (2015-03-17 22:45:17)
Quoted 87 lines
Document the device tree binding for Broadcom iProc architecture based clock controller
Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtDocumentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +71
-0@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>;Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +10
-0+ }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + };Hi Ray,
Thanks for submitting the patch. It was nice meeting you at ELC as well.
This binding doesn't conform to the norms for clock bindings. It looks like for each type of controllable clock node (e.g. pll, leaf clock, etc) you have a dts node. Looking at the above example it seems that those two nodes (genpll and
genpll_clks) share the same register./me checks patch #5
Yup, you re-use the same register address for the *pll and
*pll_clksnodes. I'm not a DT expert but I think this is considered Wrong.Quoted 6 lines
More generally your clock dt binding should be modeling the hardware in terms of IP blocks. If you have a clock generator IP block it may control many clock bits and output many clock signals. E.g. for your hardware (based only on the addresses in patch #5 and not having seen any data manual) I will hazard a guess that the genpll, lcpll and asiu clocks are all part of the same IP block.
Quoted 7 lines
Hi Mike,
In fact, lcpll, genpll, mipipll are similar but DIFFERENT IP blocks, and asiu is completely different from any of them. All of these plls are unique and have their own register banks, as you can see from the
bcm-cygnus-clock.dtsifile. Therefore, I think it's totally correct and actually necessary to represent each of them with a separate device node.OK, that makes sense to me, if those registers live in addresses ranges which correspond to different IP blocks.
Quoted 12 lines
Regarding the relationship between a PLL clock and its leaf clocks:
Taking the genpll as an example, physically they are connected as:xtal -> genpll -> axi21, 250mhz,
ihost_sys, ...The 25 MHz crystal feeds to the genpll, and the genpll generates 6 different leaf clocks including axi21, 250mhz,
ihost_sys, and etc. One can choose to set the genpll's vco to one frequency, and based on that frequency, different leaf clock frequencies can be generated with their own post divider.Quoted 6 lines
Therefore, I think it makes sense to represent xtal, genpll,
genpll_clks(including axi21, 250mhz,ihost_sys, and etc) each with a unique device node, and genpll is the parent of these leaf clocks. Basically the device nodes and the way how the "clocks" phandle is used represent the hierarchy of the clock architecture within Cygnus (and in the future other iProc SoCs). Does that make sense?This doesn't make sense to me. If I understand correctly, the register range that controls the post-divider clock (e.g. axi21) is the same register range that control's genpll. This is a reasonable indicator to me that the leaf clocks are part of the same clock generator IP block as the PLL controls. As such they should be on node.
Quoted 6 lines
Regarding the register address overlapping, again, taking genpll as an example, the genpll and the
genpll_clksactually never access the same set of registers, but the registers are sort of scattered within one bank, i.e., on Cygnus, genpll uses registers at offset0x0,0x8~0x1c, andgenpll_clksuses registers at offset0x4,0x20-0x24.Sure, my argument above doesn't hinge on the fact that the pll and child clocks use the exact same register. It still looks to me like *pll and it's child dividers belong in the same IP block. Is there an open data sheet or technical reference manual I can look at for this part? That is the best way to put my concerns at ease ;-)
Quoted 8 lines
Looking over your binding again, it looks like your nodes are divided conveniently for the different clock types (e.g. pll versus post-divider), but our goal with DT is to accurately describe the hardware, not the C structures.
Regards,
MikeYes, the genpll and
genpll_clksare controlled by the same IP block. I can make the change to combine them to use one DT node. But before doing that, I just need to get one thing clarified with you. In SW, the pll and its leaf clocks will still be registered as separate two clock providers, since we need to be able to configure the PLL vco frequency and its leaf clock frequencies separately. The pll will be the parent of its leaf clocks, and the leaf clocks will be used by various peripherals.I plan to have the combined DT looks like this:
genpll_clks: genpll_clks { #clock-cells = <1>; compatible = "brcm,cygnus-genpll-clk"; reg = <0x0301d000 0x2c>; assigned-clocks = <&genpll_clks>; /* this sets the PLL rate at the time when the PLL clock is registered */ assigned-clock-rates = <4000000000>; clocks = <&osc>; clock-output-names = "axi21", "250mhz", "ihost_sys", "enet_sw","
audio_125", "can";
};peripheralA: peripheralA { /* use the first leaf clock of genpll */ clocks = <&genpll_clks 0>; clock-frequency = <100000000>; };If we register both the genpll and its leaf clocks to the clock framework as two separate clock providers, would the above DT entries still work? For example, peripheralA refers to the phandle of
genpll_clks, but how does the clock framework know to link it to the pll clock or the leaf clock?
Quoted 4 lines
Thanks,
Ray
So I've changed the code to merge pll and pll_clks nodes and have played around with it a bit. Let me try to explain the issue I'm having here, and see if you can help to shed some light:
As far as I know, the correct way to configure a clock's rate at the time of registering to the clock framework, as you mentioned previously, is to use the "assigned-clock" and "assigned-clock-rates" properties.
Assuming we have a pll clock called "pll", with 6 leaf clocks derived from the pll called "clk-0", "clk-1", etc., and a peripheral using the first leaf clock: "clk-0".
pll: pll {
#clock-cell = <1>;
compatible = "brcm,pll";
clocks = <&osc>;
clock-output-names = "clk-0", "clk-1", ...;
};
peripheral: peripheral {
clocks = <&pll 0>;
};With your proposed way of constructing the above clock device tree, i.e., to combine "pll" and "clk-x" to use the same DT node, now how can one configure the frequency of the "pll" through device tree at the time of clock registration? There's now no access to "pll" through device tree but only access to its leaf clocks, e.g., clocks = <&pll 0>.
The requirement comes from the fact that we need the peripheral to run at a certain clock rate off the leaf clock, and to achieve that we need the pll to run at a specific rate, since we only have an integer based post-divider between the pll and its leaf clocks. I was able to achieve this previously by separating the pll and its leaf clocks into two DT nodes, but I am really not sure how one can do this when merging pll and its leaf clocks into the same node.
Any idea how this can be done cleanly with a single DT node representing the pll and its leaf clocks?
Thanks,
Ray
Re: [PATCH v6 1/6] clk: iproc: define Broadcom iProc clock binding
Quoting Ray Jui (2015-04-14 12:10:35)
Quoted 225 lines
Hi Mike,
Quoted 222 lines · Ray Jui
Hi Mike,
Quoted 173 lines · Michael Turquette
Quoting Ray Jui (2015-04-12 21:08:32)
Quoted 123 lines · Michael Turquette
Quoted 113 lines
Quoting Ray Jui (2015-03-17 22:45:17)
Quoted 87 lines
Document the device tree binding for Broadcom iProc architecture based clock controller
Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtDocumentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +71
-0@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>;Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +10
-0+ }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + };Hi Ray,
Thanks for submitting the patch. It was nice meeting you at ELC as well.
This binding doesn't conform to the norms for clock bindings. It looks like for each type of controllable clock node (e.g. pll, leaf clock, etc) you have a dts node. Looking at the above example it seems that those two nodes (genpll and
genpll_clks) share the same register./me checks patch #5
Yup, you re-use the same register address for the *pll and
*pll_clksnodes. I'm not a DT expert but I think this is considered Wrong.Quoted 6 lines
More generally your clock dt binding should be modeling the hardware in terms of IP blocks. If you have a clock generator IP block it may control many clock bits and output many clock signals. E.g. for your hardware (based only on the addresses in patch #5 and not having seen any data manual) I will hazard a guess that the genpll, lcpll and asiu clocks are all part of the same IP block.
Quoted 7 lines
Hi Mike,
In fact, lcpll, genpll, mipipll are similar but DIFFERENT IP blocks, and asiu is completely different from any of them. All of these plls are unique and have their own register banks, as you can see from the
bcm-cygnus-clock.dtsifile. Therefore, I think it's totally correct and actually necessary to represent each of them with a separate device node.OK, that makes sense to me, if those registers live in addresses ranges which correspond to different IP blocks.
Quoted 12 lines
Regarding the relationship between a PLL clock and its leaf clocks:
Taking the genpll as an example, physically they are connected as:xtal -> genpll -> axi21, 250mhz,
ihost_sys, ...The 25 MHz crystal feeds to the genpll, and the genpll generates 6 different leaf clocks including axi21, 250mhz,
ihost_sys, and etc. One can choose to set the genpll's vco to one frequency, and based on that frequency, different leaf clock frequencies can be generated with their own post divider.Quoted 6 lines
Therefore, I think it makes sense to represent xtal, genpll,
genpll_clks(including axi21, 250mhz,ihost_sys, and etc) each with a unique device node, and genpll is the parent of these leaf clocks. Basically the device nodes and the way how the "clocks" phandle is used represent the hierarchy of the clock architecture within Cygnus (and in the future other iProc SoCs). Does that make sense?This doesn't make sense to me. If I understand correctly, the register range that controls the post-divider clock (e.g. axi21) is the same register range that control's genpll. This is a reasonable indicator to me that the leaf clocks are part of the same clock generator IP block as the PLL controls. As such they should be on node.
Quoted 6 lines
Regarding the register address overlapping, again, taking genpll as an example, the genpll and the
genpll_clksactually never access the same set of registers, but the registers are sort of scattered within one bank, i.e., on Cygnus, genpll uses registers at offset0x0,0x8~0x1c, andgenpll_clksuses registers at offset0x4,0x20-0x24.Sure, my argument above doesn't hinge on the fact that the pll and child clocks use the exact same register. It still looks to me like *pll and it's child dividers belong in the same IP block. Is there an open data sheet or technical reference manual I can look at for this part? That is the best way to put my concerns at ease ;-)
Quoted 8 lines
Looking over your binding again, it looks like your nodes are divided conveniently for the different clock types (e.g. pll versus post-divider), but our goal with DT is to accurately describe the hardware, not the C structures.
Regards,
MikeYes, the genpll and
genpll_clksare controlled by the same IP block. I can make the change to combine them to use one DT node. But before doing that, I just need to get one thing clarified with you. In SW, the pll and its leaf clocks will still be registered as separate two clock providers, since we need to be able to configure the PLL vco frequency and its leaf clock frequencies separately. The pll will be the parent of its leaf clocks, and the leaf clocks will be used by various peripherals.I plan to have the combined DT looks like this:
genpll_clks: genpll_clks { #clock-cells = <1>; compatible = "brcm,cygnus-genpll-clk"; reg = <0x0301d000 0x2c>; assigned-clocks = <&genpll_clks>; /* this sets the PLL rate at the time when the PLL clock is registered */ assigned-clock-rates = <4000000000>; clocks = <&osc>; clock-output-names = "axi21", "250mhz", "ihost_sys", "enet_sw","
audio_125", "can";
};peripheralA: peripheralA { /* use the first leaf clock of genpll */ clocks = <&genpll_clks 0>; clock-frequency = <100000000>; };If we register both the genpll and its leaf clocks to the clock framework as two separate clock providers, would the above DT entries still work? For example, peripheralA refers to the phandle of
genpll_clks, but how does the clock framework know to link it to the pll clock or the leaf clock?
Hi Ray,
There are two options here: using clock-output-names or not using clock-output-names.
I would recommend against using clock-output-names. If both your clock driver and the peripheral devices that consume these clocks are all represented in DT then you can skip clock-output-names and instead create phandle linkage between the clocks inside of your clock provider and the consumer devices. String names are still important here, but now you only need to specify the string name as an *input* to the consumer device, and not as an *output* from the clock provider node. Let's look at how the qcom bindings do it:
gcc is a clock generator ip block.
arch/arm/boot/dts/qcom-apq8084.dtsi:
gcc: clock-controller at fc400000 {
compatible = "qcom,gcc-apq8084";
#clock-cells = <1>;
#reset-cells = <1>;
reg = <0xfc400000 0x4000>;
};This same file includes this header:
#include <dt-bindings/clock/qcom,gcc-apq8084.h>
That header creates a map of clocks by numbers. An example:
#define GCC_BLSP2_UART2_APPS_CLK 142
We can see how it used by the serial controller in arch/arm/boot/dts/qcom-apq8084.dtsi:
serial at f995e000 {
compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
reg = <0xf995e000 0x1000>;
interrupts = <0 114 0x0>;
clocks = <&gcc GCC_BLSP2_UART2_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>;
clock-names = "core", "iface";
status = "disabled";
};Note the 'clock-names' property. This lists a string name which is a property of the *consuming* device (uart controller), not the *providing* device (gcc clock generator).
Finally, it all comes together in the driver simply using clk_get:
msm_port->clk = devm_clk_get(&pdev->dev, "core");
if (IS_ERR(msm_port->clk))
return PTR_ERR(msm_port->clk);
if (msm_port->is_uartdm) {
msm_port->pclk = devm_clk_get(&pdev->dev, "iface");
if (IS_ERR(msm_port->pclk))
return PTR_ERR(msm_port->pclk);
clk_set_rate(msm_port->clk, 1843200);
}This works because we have created linkage between the clock phandle and the consuming device node. The shared header is used by the Linux kernel to look up the clock as well as the consumer node to map the string name onto a clock input.
Back to clock-output-names:
If you decide to keep using clock-output-names you can still represent the pll clock in your "clock-output-names". In a perfect world DT nodes that use clock-output-names would only expose the leaf clocks that your peripheral devices consume, but there is no technical reason why your pll can't be a part of the clock-output-names array. It is simply an array of string names that maps to an index. There is no sense of parent-child hierarchy in the DT binding, so there is no problem adding a parent pll clock to the array of clock-output-names. I think that this will tactically solve your problem in the short term, but I encourage you to inspect the qcom binding example I gave above to see if it a better fit for you long term.
Regards,
Mike
Quoted 49 lines
Quoted 5 lines
Thanks,
Ray
So I've changed the code to merge pll and
pll_clksnodes and have played around with it a bit. Let me try to explain the issue I'm having here, and see if you can help to shed some light:As far as I know, the correct way to configure a clock's rate at the time of registering to the clock framework, as you mentioned previously, is to use the "assigned-clock" and "assigned-clock-rates" properties.
Assuming we have a pll clock called "pll", with 6 leaf clocks derived from the pll called "clk-0", "clk-1", etc., and a peripheral using the first leaf clock: "clk-0".
pll: pll { #clock-cell = <1>; compatible = "brcm,pll"; clocks = <&osc>; clock-output-names = "clk-0", "clk-1", ...; };peripheral: peripheral { clocks = <&pll 0>; };With your proposed way of constructing the above clock device tree, i.e., to combine "pll" and "clk-x" to use the same DT node, now how can one configure the frequency of the "pll" through device tree at the time of clock registration? There's now no access to "pll" through device tree but only access to its leaf clocks, e.g., clocks = <&pll 0>.
The requirement comes from the fact that we need the peripheral to run at a certain clock rate off the leaf clock, and to achieve that we need the pll to run at a specific rate, since we only have an integer based post-divider between the pll and its leaf clocks. I was able to achieve this previously by separating the pll and its leaf clocks into two DT nodes, but I am really not sure how one can do this when merging pll and its leaf clocks into the same node.
Any idea how this can be done cleanly with a single DT node representing the pll and its leaf clocks?
Thanks,
Ray
Ray Jui
maintainerRe: [PATCH v6 1/6] clk: iproc: define Broadcom iProc clock binding
Hi Mike,
Quoted 304 lines · Michael Turquette
Quoting Ray Jui (2015-04-14 12:10:35)
Quoted 225 lines
Hi Mike,
Quoted 222 lines · Ray Jui
Hi Mike,
Quoted 173 lines · Michael Turquette
Quoting Ray Jui (2015-04-12 21:08:32)
Quoted 123 lines · Michael Turquette
Quoted 113 lines
Quoting Ray Jui (2015-03-17 22:45:17)
Quoted 87 lines
Document the device tree binding for Broadcom iProc architecture based clock controller
Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>--- .../bindings/clock/brcm,iproc-clocks.txt | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txtDocumentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +71
-0@@ -0,0 +1,171 @@ +Broadcom iProc Family Clocks + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +The iProc clock controller manages clocks that are common to the iProc family. +An SoC from the iProc family may have several PPLs, e.g., ARMPLL, GENPLL, +LCPLL0, MIPIPLL, and etc., all derived from an onboard crystal. Each PLL +comprises of several leaf clocks + +Required properties for PLLs: +- compatible: + Should have a value of the form "brcm,<soc>-<pll>". For example, GENPLL on +Cygnus has a compatible string of "brcm,cygnus-genpll" + +- #clock-cells: + Must be <0> + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL + +- clocks: + The input parent clock phandle for the PLL. For all iProc PLLs, this is an +onboard crystal with a fixed rate + +Example: + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>; + }; + +Required properties for leaf clocks of a PLL: + +- compatible: + Should have a value of the form "brcm,<soc>-<pll>-clk". For example, leaf +clocks derived from the GENPLL on Cygnus SoC have a compatible string of +"brcm,cygnus-genpll-clk" + +- #clock-cells: + Have a value of <1> since there are more than 1 leaf clock of a +given PLL + +- reg: + Define the base and range of the I/O address space that contain the iProc +clock control registers required for the PLL leaf clocks + +- clocks: + The input parent PLL phandle for the leaf clock + +- clock-output-names: + An ordered list of strings defining the names of the leaf clocks + +Example: + + genpll: genpll { + #clock-cells = <0>; + compatible = "brcm,cygnus-genpll"; + reg = <0x0301d000 0x2c>, + <0x0301c020 0x4>; + clocks = <&osc>;Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt new file +10
-0+ }; + + genpll_clks: genpll_clks { + #clock-cells = <1>; + compatible = "brcm,cygnus-genpll-clk"; + reg = <0x0301d000 0x2c>; + clocks = <&genpll>; + clock-output-names = "axi21", "250mhz", "ihost_sys", + "enet_sw", "audio_125", "can"; + };Hi Ray,
Thanks for submitting the patch. It was nice meeting you at ELC as well.
This binding doesn't conform to the norms for clock bindings. It looks like for each type of controllable clock node (e.g. pll, leaf clock, etc) you have a dts node. Looking at the above example it seems that those two nodes (genpll and
genpll_clks) share the same register./me checks patch #5
Yup, you re-use the same register address for the *pll and
*pll_clksnodes. I'm not a DT expert but I think this is considered Wrong.Quoted 6 lines
More generally your clock dt binding should be modeling the hardware in terms of IP blocks. If you have a clock generator IP block it may control many clock bits and output many clock signals. E.g. for your hardware (based only on the addresses in patch #5 and not having seen any data manual) I will hazard a guess that the genpll, lcpll and asiu clocks are all part of the same IP block.
Quoted 7 lines
Hi Mike,
In fact, lcpll, genpll, mipipll are similar but DIFFERENT IP blocks, and asiu is completely different from any of them. All of these plls are unique and have their own register banks, as you can see from the
bcm-cygnus-clock.dtsifile. Therefore, I think it's totally correct and actually necessary to represent each of them with a separate device node.OK, that makes sense to me, if those registers live in addresses ranges which correspond to different IP blocks.
Quoted 12 lines
Regarding the relationship between a PLL clock and its leaf clocks:
Taking the genpll as an example, physically they are connected as:xtal -> genpll -> axi21, 250mhz,
ihost_sys, ...The 25 MHz crystal feeds to the genpll, and the genpll generates 6 different leaf clocks including axi21, 250mhz,
ihost_sys, and etc. One can choose to set the genpll's vco to one frequency, and based on that frequency, different leaf clock frequencies can be generated with their own post divider.Quoted 6 lines
Therefore, I think it makes sense to represent xtal, genpll,
genpll_clks(including axi21, 250mhz,ihost_sys, and etc) each with a unique device node, and genpll is the parent of these leaf clocks. Basically the device nodes and the way how the "clocks" phandle is used represent the hierarchy of the clock architecture within Cygnus (and in the future other iProc SoCs). Does that make sense?This doesn't make sense to me. If I understand correctly, the register range that controls the post-divider clock (e.g. axi21) is the same register range that control's genpll. This is a reasonable indicator to me that the leaf clocks are part of the same clock generator IP block as the PLL controls. As such they should be on node.
Quoted 6 lines
Regarding the register address overlapping, again, taking genpll as an example, the genpll and the
genpll_clksactually never access the same set of registers, but the registers are sort of scattered within one bank, i.e., on Cygnus, genpll uses registers at offset0x0,0x8~0x1c, andgenpll_clksuses registers at offset0x4,0x20-0x24.Sure, my argument above doesn't hinge on the fact that the pll and child clocks use the exact same register. It still looks to me like *pll and it's child dividers belong in the same IP block. Is there an open data sheet or technical reference manual I can look at for this part? That is the best way to put my concerns at ease ;-)
Quoted 8 lines
Looking over your binding again, it looks like your nodes are divided conveniently for the different clock types (e.g. pll versus post-divider), but our goal with DT is to accurately describe the hardware, not the C structures.
Regards,
MikeYes, the genpll and
genpll_clksare controlled by the same IP block. I can make the change to combine them to use one DT node. But before doing that, I just need to get one thing clarified with you. In SW, the pll and its leaf clocks will still be registered as separate two clock providers, since we need to be able to configure the PLL vco frequency and its leaf clock frequencies separately. The pll will be the parent of its leaf clocks, and the leaf clocks will be used by various peripherals.I plan to have the combined DT looks like this:
genpll_clks: genpll_clks { #clock-cells = <1>; compatible = "brcm,cygnus-genpll-clk"; reg = <0x0301d000 0x2c>; assigned-clocks = <&genpll_clks>; /* this sets the PLL rate at the time when the PLL clock is registered */ assigned-clock-rates = <4000000000>; clocks = <&osc>; clock-output-names = "axi21", "250mhz", "ihost_sys", "enet_sw","
audio_125", "can";
};peripheralA: peripheralA { /* use the first leaf clock of genpll */ clocks = <&genpll_clks 0>; clock-frequency = <100000000>; };If we register both the genpll and its leaf clocks to the clock framework as two separate clock providers, would the above DT entries still work? For example, peripheralA refers to the phandle of
genpll_clks, but how does the clock framework know to link it to the pll clock or the leaf clock?Hi Ray,
There are two options here: using clock-output-names or not using clock-output-names.
I would recommend against using clock-output-names. If both your clock driver and the peripheral devices that consume these clocks are all represented in DT then you can skip clock-output-names and instead create phandle linkage between the clocks inside of your clock provider and the consumer devices. String names are still important here, but now you only need to specify the string name as an *input* to the consumer device, and not as an *output* from the clock provider node. Let's look at how the qcom bindings do it:
gcc is a clock generator ip block.
arch/arm/boot/dts/qcom-apq8084.dtsi:gcc: clock-controller at fc400000 { compatible = "qcom,gcc-apq8084"; #clock-cells = <1>; #reset-cells = <1>; reg = <0xfc400000 0x4000>; };This same file includes this header:
#include <dt-bindings/clock/qcom,gcc-apq8084.h>That header creates a map of clocks by numbers. An example:
#defineGCC_BLSP2_UART2_APPS_CLK142We can see how it used by the serial controller in
arch/arm/boot/dts/qcom-apq8084.dtsi:serial at f995e000 { compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm"; reg = <0xf995e000 0x1000>; interrupts = <0 114 0x0>; clocks = <&gcc GCC_BLSP2_UART2_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>; clock-names = "core", "iface"; status = "disabled"; };Note the 'clock-names' property. This lists a string name which is a property of the *consuming* device (uart controller), not the *providing* device (gcc clock generator).
Finally, it all comes together in the driver simply using
clk_get:msm_port->clk = devm_clk_get(&pdev->dev, "core"); if (IS_ERR(msm_port->clk)) return PTR_ERR(msm_port->clk); if (msm_port->is_uartdm) { msm_port->pclk = devm_clk_get(&pdev->dev, "iface"); if (IS_ERR(msm_port->pclk)) return PTR_ERR(msm_port->pclk); clk_set_rate(msm_port->clk, 1843200); }This works because we have created linkage between the clock phandle and the consuming device node. The shared header is used by the Linux kernel to look up the clock as well as the consumer node to map the string name onto a clock input.
Back to clock-output-names:
If you decide to keep using clock-output-names you can still represent the pll clock in your "clock-output-names". In a perfect world DT nodes that use clock-output-names would only expose the leaf clocks that your peripheral devices consume, but there is no technical reason why your pll can't be a part of the clock-output-names array. It is simply an array of string names that maps to an index. There is no sense of parent-child hierarchy in the DT binding, so there is no problem adding a parent pll clock to the array of clock-output-names. I think that this will tactically solve your problem in the short term, but I encourage you to inspect the qcom binding example I gave above to see if it a better fit for you long term.
Quoted 3 lines
Regards,
Mike
Thanks for your thorough explanation. You clarified that there does not need to be a clock parent-child hierarchy in the DT binding. I think that's where I got really confused at. Yes, by exposing both the pll (parent) and its leaf clocks (children) with individual indices under the same node, that should solve the problem I have.
I will investigate and work out a new patch.
Thanks,
Ray