CREG clk driver for NXP LPC18xx family
Subsystems (3)
v2 cover CREG clk driver for NXP LPC18xx family
This patch set adds a clk driver for the low power clocks found in the CREG block on lpc18xx. CREG is a collection of miscellaneous configuration registers that can be accessed through a syscon regmap interface. The clk driver makes it possible to setup and enabled these two clocks.
This need to support peripherals like the internal RTC on the lpc18xx platform.
Mike/Stephen is this what you envisioned?
It seems to work, but I currently don't have a setup that requires the 32khz clock early so that part isn't really tested.
The probe deferral seems to work for the RTC:
[ 3.386861] lpc24xx-rtc 40046000.rtc: error getting rtc clock [ 6.737615] lpc24xx-rtc 40046000.rtc: rtc core: registered lpc24xx-rtc as rtc0
Changes since v1:
- Split driver with one early init and one platform driver probe.
Based on v4.5-rc1.
Joachim Eastwood (2):
clk: add lpc18xx creg clk driver
doc: dt: add documentation for lpc1850-creg-clk driver
.../devicetree/bindings/clock/lpc1850-creg-clk.txt | 52 ++++++ drivers/clk/nxp/Makefile | 1 + drivers/clk/nxp/clk-lpc18xx-creg.c | 205 +++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt create mode 100644 drivers/clk/nxp/clk-lpc18xx-creg.c
Signature · 1 line
1.8.0
PATCH v2 1/2 clk: add lpc18xx creg clk driver
The CREG block on lpc18xx contains configuration register for two low power clocks. Support enabling of these two clocks with a clk driver that access CREG trough the syscon regmap interface.
These clocks are needed to support peripherals like the internal RTC on lpc18xx.
--- drivers/clk/nxp/Makefile | 1 + drivers/clk/nxp/clk-lpc18xx-creg.c | 205 +++++++++++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 drivers/clk/nxp/clk-lpc18xx-creg.c
drivers/clk/nxp/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_ARCH_LPC18XX) += clk-lpc18xx-cgu.o obj-$(CONFIG_ARCH_LPC18XX) += clk-lpc18xx-ccu.o +obj-$(CONFIG_ARCH_LPC18XX) += clk-lpc18xx-creg.o obj-$(CONFIG_ARCH_LPC32XX) += clk-lpc32xx.o
drivers/clk/nxp/clk-lpc18xx-creg.c new file +205 -0
205 lines not on this page · raw message
Signature · 1 line
1.8.0
Re: [PATCH v2 1/2] clk: add lpc18xx creg clk driver
Quoted 7 lines · Joachim Eastwood
drivers/clk/nxp/clk-lpc18xx-creg.c new file +7
-0+static int lpc18xx_creg_clk_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct regmap *syscon; + + syscon =syscon_node_to_regmap (np->parent); +if (IS_ERR (syscon)) {
drivers/clk/nxp/clk-lpc18xx-creg.c line 188
Quoted 10 lines
drivers/clk/nxp/clk-lpc18xx-creg.c new file +10
-0+dev_err (&pdev->dev,"syscon lookup failed\n" ); +return PTR_ERR (syscon); + } + + clk_creg[CREG_CLK_1KHZ ] = +clk_register_creg_clk (&clk_creg_clocks[CREG_CLK_1KHZ ], + &clk_creg_clocks[CREG_CLK_32KHZ ].name, + syscon); + +of_clk_add_provider (np, of_clk_src_onecell_get, &clk_base_data);
If we use the same clk_base_data both times then why can't we just insert the 1KHz clk into the clk_creg array when the platform device probes? That would be racy if something was trying to read the array when it's being modified, so the alternative non-racy solution would be to make two clk_base_data structures, one in CLK_OF_DECLARE() and one in platform device probe.
Otherwise this looks like what I was envisioning.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 1/2] clk: add lpc18xx creg clk driver
In reply to Joachim EastwoodQuoting Joachim Eastwood (2016-02-20 10:53:36)
Review
Quoted 3 lines
(quoted diff) +3
-0+static const struct clk_ops clk_creg_32k =3D { + .enable =3D clk_creg_enable, + .disable =3D clk_creg_disable,
There should be a .is_enabled here.
Review
Quoted 8 lines
(quoted diff) +8
-0+ .prepare =3D clk_creg_32k_prepare, + .unprepare =3D clk_creg_32k_unprepare, + .is_prepared =3D clk_creg_32k_is_prepared, +}; + +static const struct clk_ops clk_creg_1k =3D { + .enable =3D clk_creg_enable, + .disable =3D clk_creg_disable,
Ditto.
Otherwise patch looks good to me. Thanks a lot for all of the rework.
Regards,
Mike
PATCH v2 2/2 doc: dt: add documentation for lpc1850-creg-clk driver
In reply to Joachim EastwoodAdd DT binding documentation for lpc1850-creg-clk driver.
--- .../devicetree/bindings/clock/lpc1850-creg-clk.txt | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +52 -0
@@ -0,0 +1,52 @@ +* NXP LPC1850 CREG clocks + +The NXP LPC18xx/43xx CREG (Configuration Registers) block contains +control registers for two low speed clocks. One of the clocks is a +32 kHz oscillator driver with power up/down and clock gating. Next +is a fixed divider that creates a 1 kHz clock from the 32 kHz osc. + +These clocks are used by the RTC and the Event Router peripherials. +The 32 kHz can also be routed to other peripherials to enable low +power modes. + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: + Should be "nxp,lpc1850-creg-clk" +- #clock-cells: + Shall have value <1>. +- clocks: + Shall contain a phandle to the fix 32 kHz crystall. + +The creg-clk node must be a child of the creg syscon node. + +The following clocks are available from the clock node. + +Clock ID Name + 0 1 kHz clock + 1 32 kHz Oscillator + +Example: +soc { + creg: syscon@40043000 { + compatible = "nxp,lpc1850-creg", "syscon", "simple-mfd"; + reg = <0x40043000 0x1000>; + + creg_clk: clock-controller@004 { + compatible = "nxp,lpc1850-creg-clk"; + clocks = <&xtal32>; + #clock-cells = <1>; + }; + + ... + }; + + rtc: rtc@40046000 { + ... + clocks = <&creg_clk 0>, <&ccu1 CLK_CPU_BUS>; + clock-names = "rtc", "reg"; + ... + }; +};
Signature · 1 line
1.8.0
Rob Herring
maintainerRe: [PATCH v2 2/2] doc: dt: add documentation for lpc1850-creg-clk driver
Quoted 41 lines · Joachim Eastwood
Add DT binding documentation for lpc1850-creg-clk driver.
Signed-off-by Joachim Eastwood <[email protected]>--- .../devicetree/bindings/clock/lpc1850-creg-clk.txt | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txtDocumentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +27
-0@@ -0,0 +1,52 @@ +* NXP LPC1850 CREG clocks + +The NXP LPC18xx/43xx CREG (Configuration Registers) block contains +control registers for two low speed clocks. One of the clocks is a +32 kHz oscillator driver with power up/down and clock gating. Next +is a fixed divider that creates a 1 kHz clock from the 32 kHz osc. + +These clocks are used by the RTC and the Event Router peripherials. +The 32 kHz can also be routed to other peripherials to enable low +power modes. + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: + Should be "nxp,lpc1850-creg-clk" +- #clock-cells: + Shall have value <1>. +- clocks: + Shall contain a phandle to the fix 32 kHz crystall. + +The creg-clk node must be a child of the creg syscon node. + +The following clocks are available from the clock node. + +Clock ID Name
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt line 37
Quoted 10 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +10
-0+ 0 1 kHz clock + 1 32 kHz Oscillator + +Example: +soc { + creg: syscon@40043000 { + compatible = "nxp,lpc1850-creg", "syscon", "simple-mfd"; + reg = <0x40043000 0x1000>; + + creg_clk: clock-controller@004 {
What is 4? A unit address should have a corresponding reg prop. and no leading zeros.
Quoted 4 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +4
-0+ compatible = "nxp,lpc1850-creg-clk"; + clocks = <&xtal32>; + #clock-cells = <1>; + };
Re: [PATCH v2 2/2] doc: dt: add documentation for lpc1850-creg-clk driver
Quoted 47 lines · Rob Herring
Quoted 46 lines · Joachim Eastwood
Add DT binding documentation for lpc1850-creg-clk driver.
Signed-off-by Joachim Eastwood <[email protected]>--- .../devicetree/bindings/clock/lpc1850-creg-clk.txt | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txtDocumentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +32
-0@@ -0,0 +1,52 @@ +* NXP LPC1850 CREG clocks + +The NXP LPC18xx/43xx CREG (Configuration Registers) block contains +control registers for two low speed clocks. One of the clocks is a +32 kHz oscillator driver with power up/down and clock gating. Next +is a fixed divider that creates a 1 kHz clock from the 32 kHz osc. + +These clocks are used by the RTC and the Event Router peripherials. +The 32 kHz can also be routed to other peripherials to enable low +power modes. + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: + Should be "nxp,lpc1850-creg-clk" +- #clock-cells: + Shall have value <1>. +- clocks: + Shall contain a phandle to the fix 32 kHz crystall. + +The creg-clk node must be a child of the creg syscon node. + +The following clocks are available from the clock node. + +Clock ID Name + 0 1 kHz clock + 1 32 kHz Oscillator + +Example: +soc {
Quoted 8 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt line 37
Quoted 5 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +5
-0+ creg: syscon@40043000 { + compatible = "nxp,lpc1850-creg", "syscon", "simple-mfd"; + reg = <0x40043000 0x1000>; + + creg_clk: clock-controller@004 {What is 4? A unit address should have a corresponding reg prop. and no leading zeros.
It is the fourth register in the creg syscon block.
Does this look better:
creg_clk: clock-controller@4 {
compatible = "nxp,lpc1850-creg-clk";
reg = <0x4>;
clocks = <&xtal32>;
#clock-cells = <1>;
};Note that the reg property isn't really useful in the driver, but I guess we should have it either way(?).
Alternatively I could drop the unit address and reg property. What do you think?
regards,
Joachim Eastwood
Rob Herring
maintainerRe: [PATCH v2 2/2] doc: dt: add documentation for lpc1850-creg-clk driver
Quoted 57 lines · Joachim Eastwood
Quoted 47 lines · Rob Herring
Quoted 46 lines · Joachim Eastwood
Add DT binding documentation for lpc1850-creg-clk driver.
Signed-off-by Joachim Eastwood <[email protected]>--- .../devicetree/bindings/clock/lpc1850-creg-clk.txt | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txtDocumentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +32
-0@@ -0,0 +1,52 @@ +* NXP LPC1850 CREG clocks + +The NXP LPC18xx/43xx CREG (Configuration Registers) block contains +control registers for two low speed clocks. One of the clocks is a +32 kHz oscillator driver with power up/down and clock gating. Next +is a fixed divider that creates a 1 kHz clock from the 32 kHz osc. + +These clocks are used by the RTC and the Event Router peripherials. +The 32 kHz can also be routed to other peripherials to enable low +power modes. + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: + Should be "nxp,lpc1850-creg-clk" +- #clock-cells: + Shall have value <1>. +- clocks: + Shall contain a phandle to the fix 32 kHz crystall. + +The creg-clk node must be a child of the creg syscon node. + +The following clocks are available from the clock node. + +Clock ID Name + 0 1 kHz clock + 1 32 kHz Oscillator + +Example: +soc {Quoted 8 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt line 37
Quoted 5 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +5
-0+ creg: syscon@40043000 { + compatible = "nxp,lpc1850-creg", "syscon", "simple-mfd"; + reg = <0x40043000 0x1000>; + + creg_clk: clock-controller@004 {What is 4? A unit address should have a corresponding reg prop. and no leading zeros.
Quoted 1 line
It is the fourth register in the creg syscon block.
Probably should be the offset rather than register count.
Quoted 8 lines
Does this look better:
creg_clk: clock-controller@4 { compatible = "nxp,lpc1850-creg-clk"; reg = <0x4>; clocks = <&xtal32>; #clock-cells = <1>; };
Quoted 4 lines
Note that the reg property isn't really useful in the driver, but I guess we should have it either way(?).
Alternatively I could drop the unit address and reg property. What do you think?
Either way is fine. Though I would expect something needs to know the offset.
Rob
Re: [PATCH v2 2/2] doc: dt: add documentation for lpc1850-creg-clk driver
Quoted 70 lines · Rob Herring
Quoted 57 lines · Joachim Eastwood
Quoted 47 lines · Rob Herring
Quoted 46 lines · Joachim Eastwood
Add DT binding documentation for lpc1850-creg-clk driver.
Signed-off-by Joachim Eastwood <[email protected]>--- .../devicetree/bindings/clock/lpc1850-creg-clk.txt | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txtDocumentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +32
-0@@ -0,0 +1,52 @@ +* NXP LPC1850 CREG clocks + +The NXP LPC18xx/43xx CREG (Configuration Registers) block contains +control registers for two low speed clocks. One of the clocks is a +32 kHz oscillator driver with power up/down and clock gating. Next +is a fixed divider that creates a 1 kHz clock from the 32 kHz osc. + +These clocks are used by the RTC and the Event Router peripherials. +The 32 kHz can also be routed to other peripherials to enable low +power modes. + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: + Should be "nxp,lpc1850-creg-clk" +- #clock-cells: + Shall have value <1>. +- clocks: + Shall contain a phandle to the fix 32 kHz crystall. + +The creg-clk node must be a child of the creg syscon node. + +The following clocks are available from the clock node. + +Clock ID Name + 0 1 kHz clock + 1 32 kHz Oscillator + +Example: +soc {Quoted 8 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt line 37
Quoted 5 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +5
-0+ creg: syscon@40043000 { + compatible = "nxp,lpc1850-creg", "syscon", "simple-mfd"; + reg = <0x40043000 0x1000>; + + creg_clk: clock-controller@004 {What is 4? A unit address should have a corresponding reg prop. and no leading zeros.
Quoted 1 line
It is the fourth register in the creg syscon block.
Probably should be the offset rather than register count.
Quoted 8 lines
Does this look better:
creg_clk: clock-controller@4 { compatible = "nxp,lpc1850-creg-clk"; reg = <0x4>; clocks = <&xtal32>; #clock-cells = <1>; };
Quoted 6 lines
Quoted 4 lines
Note that the reg property isn't really useful in the driver, but I guess we should have it either way(?).
Alternatively I could drop the unit address and reg property. What do you think?
Either way is fine. Though I would expect something needs to know the offset.
I have the offset in the driver itself. I don't except the driver to reusable since the CREG block is highly SoC specific. If a new user came along we could also place the register offset in the driver's of_match_data.
I'll remove the unit address in the next version.
I have a couple of other device under the CREG that has unit address already. I'll get them cleaned up as well.
Thanks for looking through the binding, Rob!
regards,
Joachim Eastwood