clk: palmas: add clock driver for palmas
Subsystems (2)
PATCH 1/1 clk: palmas: add clock driver for palmas
Palmas devices has two clock output CLK32K_KG and CLK32K_KG_AUDIO which can be nebale/disable through software.
Add clock driver support for the Palmas 32k clocks.
--- .../devicetree/bindings/clock/clk-palmas.txt | 45 +++ drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/clk-palmas.c | 306 ++++++++++++++++++++ 4 files changed, 359 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/clk-palmas.txt create mode 100644 drivers/clk/clk-palmas.c
Documentation/devicetree/bindings/clock/clk-palmas.txt new file +45 -0
@@ -0,0 +1,45 @@ +* Palmas 32KHz clocks * + +Palmas device has two clock output pins for 32KHz, KG and KG_AUDIO. + +This binding uses the common clock binding ./clock-bindings.txt. + +Clock 32KHz KG is output 0 of the driver and clock 32KHz is output 1. + +Required properties: +- compatible : shall be "ti,palmas-clk". +- #clock-cells : from common clock binding; shall be set to 1. + +Optional subnode: + The clock node has optional subnode to provide the init configuration of + clocks like boot enable, sleep control. + + The subnode name is fixed and it should be + clk32k_kg for the 32KHz KG clock. + clk32k_kg_audio for the 32KHz KG_AUDIO clock. + + Optional subnode properties: + ti,clock-boot-enable: Enable clock at the time of booting. + ti,external-sleep-control: The clock is enable/disabled by state + of external enable input pins ENABLE, ENABLE2 and NSLEEP. + The valid value for the external pins are: + 1 for ENABLE1 + 2 for ENABLE2 + 3 for NSLEEP. + Option 0 or missing this property means the clock is + enabled/disabled via register access and these pins do + not have any control. + +Example: + clock { + compatible = "ti,palmas-clk"; + #clock-cells = <1>; + clk32k_kg { + ti,clock-boot-enable; + ti,external-sleep-control = <3>; + }; + + clk32k_kg_audio { + ti,clock-boot-enable; + }; + };
drivers/clk/Kconfig +7 -0
@@ -93,6 +93,13 @@ config CLK_PPC_CORENET This adds the clock driver support for Freescale PowerPC corenet platforms using common clock framework. +config COMMON_CLK_PALMAS + tristate "Clock driver for TI Palmas devices" + depends on MFD_PALMAS + ---help--- + This driver supports TI Palmas devices 32KHz output KG and KG_AUDIO + using common clock framework. + endmenu source "drivers/clk/mvebu/Kconfig"
drivers/clk/Makefile +1 -0
@@ -43,3 +43,4 @@ obj-$(CONFIG_COMMON_CLK_SI5351) += clk-si5351.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_CLK_TWL6040) += clk-twl6040.o obj-$(CONFIG_CLK_PPC_CORENET) += clk-ppc-corenet.o +obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o
drivers/clk/clk-palmas.c new file +306 -0
306 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Documentation/devicetree/bindings/clock/clk-palmas.txt line 22
Quoted 2 lines · Laxman Dewangan
Documentation/devicetree/bindings/clock/clk-palmas.txt new file +2
-0+ Optional subnode properties: + ti,clock-boot-enable: Enable clock at the time of booting.
Shouldn't this be a generic clock subsystem thing? It seems like
something that might be desired for nearly any clock.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131004/ea8619ef/attachment.sig>
Quoting Mark Brown (2013-10-04 09:41:39)
Quoted 7 lines · Laxman Dewangan
Documentation/devicetree/bindings/clock/clk-palmas.txt line 22
Quoted 3 lines
Documentation/devicetree/bindings/clock/clk-palmas.txt new file +2
-0+ Optional subnode properties: + ti,clock-boot-enable: Enable clock at the time of booting.Shouldn't this be a generic clock subsystem thing? It seems like something that might be desired for nearly any clock.
The best solution is to have a driver claim the clock with clk_get and enable it with clk_prepare_enable. I gave more detail in my reply to Laxman.
Regards,
Mike
Quoted 3 lines · Mike Turquette
The best solution is to have a driver claim the clock with
clk_getand enable it withclk_prepare_enable. I gave more detail in my reply to Laxman.
Yeah, definitely - though with regulators we did find that there were
some passive things which didn't really warrant a driver for any purpose
other than holding the reference to them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131004/4bf8cf3d/attachment.sig>
PATCH 1/1 clk: palmas: add clock driver for palmas
In reply to Laxman DewanganQuoting Laxman Dewangan (2013-10-03 05:30:07)
drivers/clk/clk-palmas.c line 148
Quoted 4 lines
drivers/clk/clk-palmas.c new file +4
-0+static struct clk_ops palmas_clks_ops = { + .prepare = palmas_clks_prepare, + .unprepare = palmas_clks_unprepare, + .is_enabled = palmas_clks_is_enabled,
Use .is_prepared if a call to clk_prepare for your clock will start generating a signal. No need for .is_enabled since you do not define your own .enable & .disable callbacks.
Quoted 61 lines
drivers/clk/clk-palmas.c new file +61
-0+}; + +static struct clk_init_data palmas_clks_hw_init[PALMAS_CLOCK32K_NR ] = { + [PALMAS_CLOCK32KG ] = { + .name ="clk32k_kg" , + .ops = &palmas_clks_ops, + .flags =CLK_IS_ROOT |CLK_IGNORE_UNUSED , + }, + [PALMAS_CLOCK32KG_AUDIO ] = { + .name ="clk32k_kg_audio" , + .ops = &palmas_clks_ops, + .flags =CLK_IS_ROOT |CLK_IGNORE_UNUSED , + }, +}; + +static int palmas_clks_get_clk_data (struct platform_device *pdev, +struct palmas_clks *palmas_clks) +{ +struct device_node *node = pdev->dev.of_node; +struct device_node *child; +struct palmas_clock_info *cinfo; +unsigned int prop; +int ret; +int i; + +for (i =0 ; i <PALMAS_CLOCK32K_NR ; ++i) { + child =of_get_child_by_name (node, + palmas_clk32k_descs[i].clk_name); +if (!child) +continue ; + + cinfo = &palmas_clks->clk_info[i]; + cinfo->boot_enable =of_property_read_bool (child, +"ti,clock-boot-enable" ); + ret =of_property_read_u32 (child,"ti,external-sleep-control" , + &prop); +if (!ret) { +switch (prop) { +case 1 : + prop =PALMAS_EXT_CONTROL_ENABLE1 ; +break ; +case 2 : + prop =PALMAS_EXT_CONTROL_ENABLE2 ; +break ; +case 3 : + prop =PALMAS_EXT_CONTROL_NSLEEP ; +break ; +default : +WARN_ON (1 ); +dev_warn (&pdev->dev, +"%s: Invalid ext control option: %u\n" , + child->name, prop); + prop =0 ; +break ; + } + cinfo->ext_control_pin = prop; + } + } + +return 0 ; +}
drivers/clk/clk-palmas.c line 219
Quoted 10 lines
drivers/clk/clk-palmas.c new file +10
-0+ +static int palmas_clks_init_configure (struct palmas_clock_info *cinfo) +{ +struct palmas_clks *palmas_clks = cinfo->palmas_clk; +int ret; +unsigned int val =0 ; +unsigned int mask; + +if (cinfo->boot_enable || cinfo->ext_control_pin) + val |= cinfo->clk_desc->enable_mask;
So if the ti,clock-boot-enable property exists then a clock signal will be generated by palmas but the Linux clock tree representation won't know it. This is bad.
Better to call clk_get and clk_prepare_enable here instead of cheating and directly writing to the register.
Regards,
Mike