CREG clk driver for NXP LPC18xx family
Subsystems (3)
v4 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.
The driver has one early init using CLK_OF_DECLARE and a standard platform driver. The early init is used to register the 32KHZ clk which may be needed early on. The other clock (1KHZ) is registered when the platform driver probe runs.
This version splits clk array into clk_creg_early and clk_creg. I think this will work as long as clk_creg_early is _not_ used after the clk_creg is registered.
This 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 v3:
- Add .is_enabled function to both creg clks.
- Remove unit address from bindings as requested by Rob Herring.
Changes since v2:
- Use two clk arrays for registration.
- Couple of minor cleanups.
Changes since v1:
- Split driver with one early init and one platform driver probe.
- Rebase 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 | 222 +++++++++++++++++++++ 3 files changed, 275 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 v4 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 | 222 +++++++++++++++++++++++++++++++++++++ 2 files changed, 223 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 +222 -0
222 lines not on this page · raw message
Signature · 1 line
1.8.0
PATCH v4 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 fixed 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 { + 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
Re: [PATCH v4 2/2] doc: dt: add documentation for lpc1850-creg-clk driver
Quoted 7 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.txt
One typo, otherwise:
Quoted 18 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +11
-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. +
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt line 21
Quoted 10 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +10
-0+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 fixed 32 kHz crystall.
s/crystall/crystal/
Quoted 38 lines
Documentation/devicetree/bindings/clock/lpc1850-creg-clk.txt new file +31
-0+ +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 { + 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 · 6 lines
1.8.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/2] clk: add lpc18xx creg clk driver
In reply to Joachim EastwoodHi Joachim,
Quoting Joachim Eastwood (2016-02-24 14:04:19)
Quoted 5 lines
drivers/clk/nxp/clk-lpc18xx-creg.c new file +5
-0+static struct clk *clk_register_creg_clk (struct clk_creg_data *creg_clk, +const char **parent_name, +struct regmap *syscon) +{ +struct clk_init_data init;
drivers/clk/nxp/clk-lpc18xx-creg.c line 153
Quoted 10 lines
drivers/clk/nxp/clk-lpc18xx-creg.c new file +10
-0+ + init.ops =3D creg_clk->ops; + init.name =3D creg_clk->name; + init.parent_names =3D parent_name; + init.num_parents =3D 1; + + creg_clk->reg =3D syscon; + creg_clk->hw.init =3D &init; + +return clk_register (NULL , &creg_clk->hw);
This should be devm_clk_register with your struct device *dev passed into it.
Otherwise this patch looks good for merge.
Regards,
Mike
Re: [PATCH v4 1/2] clk: add lpc18xx creg clk driver
Quoted 13 lines · Michael Turquette
Hi Joachim,
Quoting Joachim Eastwood (2016-02-24 14:04:19)
Quoted 10 lines
drivers/clk/nxp/clk-lpc18xx-creg.c new file +10
-0+static struct clk *clk_register_creg_clk (struct clk_creg_data *creg_clk, +const char **parent_name, +struct regmap *syscon) +{ +struct clk_init_data init; + + init.ops = creg_clk->ops; + init.name = creg_clk->name; + init.parent_names = parent_name; + init.num_parents =1 ;
Quoted 8 lines
drivers/clk/nxp/clk-lpc18xx-creg.c line 153
Quoted 5 lines
drivers/clk/nxp/clk-lpc18xx-creg.c new file +5
-0+ + creg_clk->reg = syscon; + creg_clk->hw.init = &init; + +return clk_register (NULL , &creg_clk->hw);This should be
devm_clk_registerwith your struct device *dev passed into it.
Since clk_register_creg_clk() is used both from early init and probe I'll need to change the function a bit.
I'll pass dev in as a parameter and either do clk_register() or devm_clk_register() depending on dev being NULL or not.
Doesn't look like devm_clk_register() would like to be passed NULL for dev.
I send out a new version tomorrow.
btw, this driver is a builtin_platform_driver. So is there a point in using devm_clk_register?
regards,
Joachim Eastwood
Re: [PATCH v4 1/2] clk: add lpc18xx creg clk driver
Quoted 13 lines · Joachim Eastwood
Quoted 3 lines · Michael Turquette
This should be
devm_clk_registerwith your struct device *dev passed into it.Since
clk_register_creg_clk()is used both from early init and probe I'll need to change the function a bit.I'll pass dev in as a parameter and either do
clk_register()ordevm_clk_register()depending on dev being NULL or not.
Doesn't look likedevm_clk_register()would like to be passed NULL for dev.
Quoted 5 lines
I send out a new version tomorrow.
btw, this driver is a
builtin_platform_driver. So is there a point in usingdevm_clk_register?
Builtin drivers can still probe defer or fail for other reasons, so just in case that happens it's better to use devm_clk_register() to make sure we cleanup on the error path. It may never actually happen in practice, but it's better to write safe drivers.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project