clk: nomadik: implement the Nomadik clocks properly
Subsystems (3)
PATCH 1/2 clk: nomadik: implement the Nomadik clocks properly
The Nomadik clock implementation was a stub just using fixed clocks.
This implements the clocks properly instead of relying on them all being on at boot and leaving them all on.
The PLLs are on the top locking to the main chrystal oscillator, then the HCLK for the peripherals are below PLL2.
The gated clocks are implemented with zero cells and given the clock ID as a property of each node, so every gate need to have its own node in the device tree. This is because the gate registers contain both HCLK gates and PCLK gates, where the latter has HCLK as parent. As can be seen from the register layout, this is a complete mixup, which means all these gates need their own node to properly model parent/child relations for PCLKs apart from the HCLKs.
This driver also adds a helpful debugfs file to inspect the hardware state of the clock gates.
This is the end result in <debugfs>/clk/clk_summary after applying a proper device tree:
ulpiclk 0 0 60000000
mxtal 3 3 19200000
pll2 1 1 864000000
clk48 3 3 48000000
rngcclk 1 1 48000000
usbmclk 0 0 48000000
mshcclk 0 0 48000000
mspclk3 0 0 48000000
x3dclk 0 0 48000000
skeclk 0 0 48000000
owmclk 0 0 48000000
mspclk2 0 0 48000000
mspclk1 0 0 48000000
uart2clk 0 0 48000000
ipbmcclk 0 0 48000000
ipi2cclk 0 0 48000000
usbclk 0 0 48000000
mspclk0 0 0 48000000
uart1clk 1 2 48000000
i2c1clk 0 0 48000000
i2c0clk 0 0 48000000
sdiclk 1 1 48000000
uart0clk 0 0 48000000
sspiclk 0 0 48000000
irdaclk 0 0 48000000
clk72 0 0 72000000
difclk 0 0 72000000
clcdclk 0 0 72000000
clk216 0 0 216000000
hsiclkrx 0 0 216000000
clk108 0 0 108000000
hsiclktx 0 0 108000000
clk27 0 0 27000000
pll1 1 1 264000000
hclk 3 3 264000000
hclkrng 1 1 264000000
hclkusbm 0 0 264000000
hclkcryp 0 0 264000000
hclkhash 0 0 264000000
hclk3d 0 0 264000000
hclkhpi 0 0 264000000
hclksva 0 0 264000000
hclksaa 0 0 264000000
hclkdif 0 0 264000000
hclkusb 0 0 264000000
hclkclcd 0 0 264000000
hclkdma1 0 0 264000000
hclksdram 0 0 264000000
hclksmc 1 1 264000000
hclkdma0 0 0 264000000
pclk 7 9 264000000
pclkmsp3 0 0 264000000
pclkmshc 0 0 264000000
pclkhsem 0 0 264000000
pclkske 0 0 264000000
pclkowm 0 0 264000000
pclkmsp2 0 0 264000000
pclkmsp1 0 0 264000000
pclkuart2 0 0 264000000
pclkxti 0 0 264000000
pclkhsi 0 0 264000000
pclkmsp0 0 0 264000000
pclkuart1 1 1 264000000
pclki2c1 0 0 264000000
pclki2c0 0 0 264000000
pclksdi 1 1 264000000
pclkuart0 1 1 264000000
pclkssp 0 0 264000000
pclkirda 0 0 264000000
timclk 1 1 2400000---
Hi Mike, I'm seeking an ACK to take this into the ARM SoC tree on top of the other pending Nomadik clock patches there.
--- .../devicetree/bindings/clock/st,nomadik.txt | 104 ++++ drivers/clk/clk-nomadik.c | 553 ++++++++++++++++++++- 2 files changed, 654 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/st,nomadik.txt
Documentation/devicetree/bindings/clock/st,nomadik.txt new file +104 -0
@@ -0,0 +1,104 @@ +ST Microelectronics Nomadik SRC System Reset and Control + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +The Nomadik SRC controller is responsible of controlling chrystals, +PLLs and clock gates. + +Required properties for the SRC node: +- compatible: must be "stericsson,nomadik-src" +- reg: must contain the SRC register base and size + +Optional properties for the SRC node: +- disable-sxtalo: if present this will disable the SXTALO + i.e. the driver output for the slow 32kHz chrystal, if the + board has its own circuitry for providing this oscillator +- disable-mxtal: if present this will disable the MXTALO, + i.e. the driver output for the main (~19.2 MHz) chrystal, + if the board has its own circuitry for providing this + osciallator + + +PLL nodes: these nodes represent the two PLLs on the system, +which should both have the main chrystal, represented as a +fixed frequency clock, as parent. + +Required properties for the two PLL nodes: +- compatible: must be "st,nomadik-pll-clock" +- clock-cells: must be 0 +- clock-id: must be 1 or 2 for PLL1 and PLL2 respectively +- clocks: this clock will have main chrystal as parent + + +HCLK nodes: these represent the clock gates on individual +lines from the HCLK clock tree and the gate for individual +lines from the PCLK clock tree. + +Requires properties for the HCLK nodes: +- compatible: must be "st,nomadik-hclk-clock" +- clock-cells: must be 0 +- clock-id: must be the clock ID from 0 to 63 according to + this table: + + 0: HCLKDMA0 + 1: HCLKSMC + 2: HCLKSDRAM + 3: HCLKDMA1 + 4: HCLKCLCD + 5: PCLKIRDA + 6: PCLKSSP + 7: PCLKUART0 + 8: PCLKSDI + 9: PCLKI2C0 + 10: PCLKI2C1 + 11: PCLKUART1 + 12: PCLMSP0 + 13: HCLKUSB + 14: HCLKDIF + 15: HCLKSAA + 16: HCLKSVA + 17: PCLKHSI + 18: PCLKXTI + 19: PCLKUART2 + 20: PCLKMSP1 + 21: PCLKMSP2 + 22: PCLKOWM + 23: HCLKHPI + 24: PCLKSKE + 25: PCLKHSEM + 26: HCLK3D + 27: HCLKHASH + 28: HCLKCRYP + 29: PCLKMSHC + 30: HCLKUSBM + 31: HCLKRNG + (32, 33, 34, 35 RESERVED) + 36: CLDCLK + 37: IRDACLK + 38: SSPICLK + 39: UART0CLK + 40: SDICLK + 41: I2C0CLK + 42: I2C1CLK + 43: UART1CLK + 44: MSPCLK0 + 45: USBCLK + 46: DIFCLK + 47: IPI2CCLK + 48: IPBMCCLK + 49: HSICLKRX + 50: HSICLKTX + 51: UART2CLK + 52: MSPCLK1 + 53: MSPCLK2 + 54: OWMCLK + (55 RESERVED) + 56: SKECLK + (57 RESERVED) + 58: 3DCLK + 59: PCLKMSP3 + 60: MSPCLK3 + 61: MSHCCLK + 62: USBMCLK + 63: RNGCCLK
drivers/clk/clk-nomadik.c +550 -3
571 lines not on this page · raw message
Signature · 1 line
1.8.1.4
PATCH 1/2 clk: nomadik: implement the Nomadik clocks properly
Quoted 5 lines · Linus Walleij
The Nomadik clock implementation was a stub just using fixed clocks.
This implements the clocks properly instead of relying on them all being on at boot and leaving them all on.
Mike, ping on this.
There was some debate on whether to use 0 or 1 cells for the clocks, but I made some argument that this is how they need to be represented.
As subsystem maintainer I suspect you will need to be the Judge (Dredd) on this. I think I overheard some kind of positive tone to this style of modelling them in some other review but it might've been imagination ...
Yours,
Linus Walleij
PATCH 2/2 ARM: nomadik: add the new clocks to the device tree
In reply to Linus WalleijThis revamps the device tree to fit with the new clock implementation and brings it quite a bit closer to how the hardware actually works.
After this the clock implementation knows about all clock gates and will gate off all unused clocks at boot time and save a bit of power.
--- arch/arm/boot/dts/ste-nomadik-s8815.dts | 6 + arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 501 ++++++++++++++++++++++++++--- 2 files changed, 470 insertions(+), 37 deletions(-)
arch/arm/boot/dts/ste-nomadik-s8815.dts +6 -0
@@ -14,6 +14,12 @@ bootargs = "root=/dev/ram0 console=ttyAMA1,115200n8 earlyprintk"; }; + src at 101e0000 { + /* These chrystal drivers are not used on this board */ + disable-sxtalo; + disable-mxtalo; + }; + pinctrl { /* Hog CD pins */ pinctrl-names = "default";
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +464 -37
543 lines not on this page · raw message
Signature · 1 line
1.8.1.4
PATCH 2/2 ARM: nomadik: add the new clocks to the device tree
Quoted 19 lines · Linus Walleij
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +19
-0+ /* + * IP AMBA bus clocks, driving the bus side of the + * peripheral clocking, clock gates. + */ + + hclkdma0: hclkdma0 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <0>; + clocks = <&hclk>; + }; + hclksmc: hclksmc at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <1>; + clocks = <&hclk>; + }; + hclksdram: hclksdram at 48M { + #clock-cells = <0>;
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi line 301
Quoted 10 lines
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +10
-0+ compatible = "st,nomadik-src-clock"; + clock-id = <2>; + clocks = <&hclk>; + }; + hclkdma1: hclkdma1 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <3>; + clocks = <&hclk>; + };
Sorry if I'm being slow to understand how the clock bindings work, but if you have 63 identical clocks that only differ in ther clock-id, can't you just have a single DT node for them instead with #clock-cells=1 to pass the number from the device using it?
Arnd
A message that is not in the archive (sent off-list or not yet received): CAJAp7OiYZx46aWRsXc+CmS+5F0STz5P+rdYnJEoaRRMUnkD1Cg@mail.gmail.com
PATCH 2/2 ARM: nomadik: add the new clocks to the device tree
While hacking on clock support for msm8960 the other day I did the same thing; I figured that providing clocks with descriptive names would be of great benefit while reading the dts.
I had my uart device setup with:
clocks = <&gsbi8_uart_clk>, <&gsbi8_p_clk>;
However, all currently present clock bindings follow the pattern described by Arnd.
Following this pattern my uart would be setup as:
clocks = <&clks 42>, <&clks 44>;
Needless to say there is no way to make sense of this without consulting the specific binding documentation. So, although your way of setting up the clock binding is not the standard way I do prefer it, but it comes with plenty extra nodes in the tree.
Regards,
Bjorn
Quoted 70 lines · Bjorn Andersson
Linus,
While hacking on clock support for msm8960 the other day I did the same thing; I figured that providing clocks with descriptive names would be of great benefit while reading the dts.
I had my uart device setup with:
clocks = <&gsbi8_uart_clk>, <&gsbi8_p_clk>;However, all currently present clock bindings seem to follow the pattern described by Arnd.
Following this pattern my uart would be setup as:
clocks = <&clks 42>, <&clks 44>;Needless to say there is no way to make sense of this without consulting the specific binding documentation. So, although your way of setting up the clock binding is not the standard way I do prefer it, but it comes with plenty extra nodes in the tree.
Regards,
BjornQuoted 44 lines · Arnd Bergmann
Quoted 19 lines · Linus Walleij
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +19
-0+ /* + * IP AMBA bus clocks, driving the bus side of the + * peripheral clocking, clock gates. + */ + + hclkdma0: hclkdma0 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <0>; + clocks = <&hclk>; + }; + hclksmc: hclksmc at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <1>; + clocks = <&hclk>; + }; + hclksdram: hclksdram at 48M { + #clock-cells = <0>;arch/arm/boot/dts/ste-nomadik-stn8815.dtsi line 301
Quoted 10 lines
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +10
-0+ compatible = "st,nomadik-src-clock"; + clock-id = <2>; + clocks = <&hclk>; + }; + hclkdma1: hclkdma1 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <3>; + clocks = <&hclk>; + };Sorry if I'm being slow to understand how the clock bindings work, but if you have 63 identical clocks that only differ in ther clock-id, can't you just have a single DT node for them instead with #clock-cells=1 to pass the
number from the device using it?Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/2 ARM: nomadik: add the new clocks to the device tree
Quoted 12 lines · Bjorn Andersson
While hacking on clock support for msm8960 the other day I did the same thing; I figured that providing clocks with descriptive names would be of great benefit while reading the dts.
I had my uart device setup with:
clocks = <&gsbi8_uart_clk>, <&gsbi8_p_clk>;However, all currently present clock bindings follow the pattern described by Arnd.
Following this pattern my uart would be setup as:
clocks = <&clks 42>, <&clks 44>;
Quoted 4 lines
Needless to say there is no way to make sense of this without consulting the specific binding documentation. So, although your way of setting up the clock binding is not the standard way I do prefer it, but it comes with plenty extra nodes in the tree.
I agree. In my case this was just a side-effect of the different bits in the register having different parents, so the common pattern could not be used, but when looking at the end result it's strikingly more readable than the cryptic numbers.
However it is possible to mitigate the latter by using the new DTS preprocessor support like so:
#include <dt-bindings/clk/my-clocks.h>:
/* Clock IDs */
#define GSBI8_UART_CLK 42
#define GSBI8_P_CLK 44
(...)
clocks = <&clks GSBI8_UART_CLK>, <&clks GSBI8_P_CLK>;
Yours,
Linus Walleij
PATCH 2/2 ARM: nomadik: add the new clocks to the device tree
In reply to Arnd BergmannQuoted 31 lines · Arnd Bergmann
Quoted 19 lines · Linus Walleij
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +19
-0+ /* + * IP AMBA bus clocks, driving the bus side of the + * peripheral clocking, clock gates. + */ + + hclkdma0: hclkdma0 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <0>; + clocks = <&hclk>; + }; + hclksmc: hclksmc at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <1>; + clocks = <&hclk>; + }; + hclksdram: hclksdram at 48M { + #clock-cells = <0>;arch/arm/boot/dts/ste-nomadik-stn8815.dtsi line 301
Quoted 10 lines
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +10
-0+ compatible = "st,nomadik-src-clock"; + clock-id = <2>; + clocks = <&hclk>; + }; + hclkdma1: hclkdma1 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <3>; + clocks = <&hclk>; + };
Quoted 4 lines
Sorry if I'm being slow to understand how the clock bindings work, but if you have 63 identical clocks that only differ in ther clock-id, can't you just have a single DT node for them instead with #clock-cells=1 to pass the number from the device using it?
I first had exactly that implementation but it didn't work. This is explained in the commit message on patch 1/1:
The gated clocks are implemented with zero cells and given the clock ID as a property of each node, so every gate need to have its own node in the device tree. This is because the gate registers contain both HCLK gates and PCLK gates, where the latter has HCLK as parent. As can be seen from the register layout, this is a complete mixup, which means all these gates need their own node to properly model parent/child relations for PCLKs apart from the HCLKs.
Basically the "shortcoming" in device tree is that modelling this with clock-cells = 1 requires them all to have one and the same parent, but they don't.
Yours,
Linus Walleij
PATCH 2/2 ARM: nomadik: add the new clocks to the device tree
Quoted 50 lines · Linus Walleij
Quoted 31 lines · Arnd Bergmann
Quoted 19 lines · Linus Walleij
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +19
-0+ /* + * IP AMBA bus clocks, driving the bus side of the + * peripheral clocking, clock gates. + */ + + hclkdma0: hclkdma0 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <0>; + clocks = <&hclk>; + }; + hclksmc: hclksmc at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <1>; + clocks = <&hclk>; + }; + hclksdram: hclksdram at 48M { + #clock-cells = <0>;arch/arm/boot/dts/ste-nomadik-stn8815.dtsi line 301
Quoted 10 lines
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +10
-0+ compatible = "st,nomadik-src-clock"; + clock-id = <2>; + clocks = <&hclk>; + }; + hclkdma1: hclkdma1 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <3>; + clocks = <&hclk>; + };Quoted 4 lines
Sorry if I'm being slow to understand how the clock bindings work, but if you have 63 identical clocks that only differ in ther clock-id, can't you just have a single DT node for them instead with #clock-cells=1 to pass the number from the device using it?
I first had exactly that implementation but it didn't work. This is explained in the commit message on patch 1/1:
The gated clocks are implemented with zero cells and given the clock ID as a property of each node, so every gate need to have its own node in the device tree. This is because the gate registers contain both HCLK gates and PCLK gates, where the latter has HCLK as parent. As can be seen from the register layout, this is a complete mixup, which means all these gates need their own node to properly model parent/child relations for PCLKs apart from the HCLKs.
Quoted 3 lines
Basically the "shortcoming" in device tree is that modelling this with clock-cells = 1 requires them all to have one and the same parent, but they don't.
Are you prevented from increasing the number of clock-cells used here?
It is a lot of identical data being added.
g.
PATCH 2/2 ARM: nomadik: add the new clocks to the device tree
Quoted 51 lines · Grant Likely
Quoted 50 lines · Linus Walleij
Quoted 31 lines · Arnd Bergmann
Quoted 19 lines · Linus Walleij
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +19
-0+ /* + * IP AMBA bus clocks, driving the bus side of the + * peripheral clocking, clock gates. + */ + + hclkdma0: hclkdma0 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <0>; + clocks = <&hclk>; + }; + hclksmc: hclksmc at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <1>; + clocks = <&hclk>; + }; + hclksdram: hclksdram at 48M { + #clock-cells = <0>;arch/arm/boot/dts/ste-nomadik-stn8815.dtsi line 301
Quoted 10 lines
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +10
-0+ compatible = "st,nomadik-src-clock"; + clock-id = <2>; + clocks = <&hclk>; + }; + hclkdma1: hclkdma1 at 48M { + #clock-cells = <0>; + compatible = "st,nomadik-src-clock"; + clock-id = <3>; + clocks = <&hclk>; + };Quoted 4 lines
Sorry if I'm being slow to understand how the clock bindings work, but if you have 63 identical clocks that only differ in ther clock-id, can't you just have a single DT node for them instead with #clock-cells=1 to pass the number from the device using it?
I first had exactly that implementation but it didn't work. This is explained in the commit message on patch 1/1:
The gated clocks are implemented with zero cells and given the clock ID as a property of each node, so every gate need to have its own node in the device tree. This is because the gate registers contain both HCLK gates and PCLK gates, where the latter has HCLK as parent. As can be seen from the register layout, this is a complete mixup, which means all these gates need their own node to properly model parent/child relations for PCLKs apart from the HCLKs.
Quoted 5 lines
Quoted 3 lines
Basically the "shortcoming" in device tree is that modelling this with clock-cells = 1 requires them all to have one and the same parent, but they don't.
Are you prevented from increasing the number of clock-cells used here?
No, I can do this, but it involves loosing HW information from the device tree and the debugfs representation of the clocks will not correspond to the actual clock hierarchy.
In short it creates a mess for the understanding of the system for some poor engineer with a datasheet and a device tree.
And AFAIK one of the goals of the device tree is to make things easier to understand, not harder.
Doing this with additional cells would sacrifice readability and HW representation for fewer lines of DTS, basically.
What I wonder is which one is more important for the DT community. We cannot let the kernel community's will to keep down the number of lines in the files (as I'm starting to suspect is behind some of the reasoning here, correct me if wrong) influence everyone else, if we want to keep things reusable for other OS:es.
That said I've recently had the feeling that the majority of the civilized world has started to think of DT as a Linux thing only ... so maybe I'm fighting windmills?
Yours,
Linus Walleij
PATCH 1/2 clk: nomadik: implement the Nomadik clocks properly
In reply to Linus WalleijQuoting Linus Walleij (2013-06-09 03:55:47)
drivers/clk/clk-nomadik.c line 109
Quoted 6 lines
drivers/clk/clk-nomadik.c +6
-0+static void pll_clk_disable (struct clk_hw *hw) +{ +struct clk_pll *pll =to_pll (hw); +u32 val; + +return ;
Is the early return intentional? Everything else looks good.
Quoted 14 lines
drivers/clk/clk-nomadik.c +14
-0+ +spin_lock (&src_lock); + val =readl (src_base +SRC_PLLCR ); +if (pll->id ==1 ) { +if (val &SRC_PLLCR_PLL1OVER ) { + val &= ~SRC_PLLCR_PLL1EN ; +writel (val, src_base +SRC_PLLCR ); + } + }else if (pll->id ==2 ) { + val &= ~SRC_PLLCR_PLL2EN ; +writel (val, src_base +SRC_PLLCR ); + } +spin_unlock (&src_lock); +}
PATCH 1/2 clk: nomadik: implement the Nomadik clocks properly
Quoted 9 lines · Mike Turquette
Quoting Linus Walleij (2013-06-09 03:55:47)
drivers/clk/clk-nomadik.c line 109
Quoted 6 lines
drivers/clk/clk-nomadik.c +6
-0+static void pll_clk_disable (struct clk_hw *hw) +{ +struct clk_pll *pll =to_pll (hw); +u32 val; + +return ;Is the early return intentional? Everything else looks good.
Of course not :-)
At one time it had no proper children registered so would declock the entire system if I didn't have that in... fixed up.
Quoted 1 line
Acked-by Mike Turquette <[email protected]>
Thanks, sending this to ARM SoC now.
Yours,
Linus Walleij