Skip to contentSkip to conversation

Device tree support for OMAP4 SCRM clocks

RFC PATCH Superseded Roger Quadros 6 participants 42 messages Mar 19, 2013 – Apr 11, 2013

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover Device tree support for OMAP4 SCRM clocks

Hi,

Based on the discussion in [1], I've implemented device tree provider for the AUXCLKs on OMAP4.

Please let me know if there are any issues.

This is important to get USB Host support working on Panda with device tree boot on 3.10.

Roger Quadros (2):
ARM: OMAP4: clock: Add device tree support for AUXCLKs
ARM: dts: omap4-panda: Provide PHY clock information

 .../devicetree/bindings/clock/omap4-clock.txt      |   32 ++++++++++++++++++
 arch/arm/boot/dts/omap4-panda.dts                  |    2 +
 arch/arm/boot/dts/omap4.dtsi                       |    5 +++
 arch/arm/mach-omap2/board-generic.c                |    2 +-
 arch/arm/mach-omap2/cclock44xx_data.c              |   35 ++++++++++++++++++++
 arch/arm/mach-omap2/clock44xx.h                    |    1 +
 arch/arm/mach-omap2/common.h                       |    9 +++++
 arch/arm/mach-omap2/io.c                           |    6 +++
 8 files changed, 91 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Signature · 1 line
1.7.4.1
#1 lore raw

RFC PATCH 1/2 ARM: OMAP4: clock: Add device tree support for AUXCLKs

Register a device tree clock provider for AUX clocks on the OMAP4 SoC. Also provide the binding information.

---
 .../devicetree/bindings/clock/omap4-clock.txt      |   32 ++++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 +++
 arch/arm/mach-omap2/board-generic.c                |    2 +-
 arch/arm/mach-omap2/cclock44xx_data.c              |   35 ++++++++++++++++++++
 arch/arm/mach-omap2/clock44xx.h                    |    1 +
 arch/arm/mach-omap2/common.h                       |    9 +++++
 arch/arm/mach-omap2/io.c                           |    6 +++
 7 files changed, 89 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +32 -0
new file mode 100644
index 0000000..9d5448b
@@ -0,0 +1,32 @@
+* Clock bindings for Texas Instruments OMAP4 SCRM clocks
+
+Required properties:
+- compatible: Should be "ti,omap4-scrm"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell.  The following is a full list of SCRM
+clocks and IDs.
+
+	Clock		ID
+	------------------
+	auxclk0_ck	0
+	auxclk1_ck	1
+	auxclk1_ck	1
+	auxclk1_ck	1
+	auxclk1_ck	1
+
+Example:
+
+aux_clks: scrmclks {
+	compatible = "ti,omap4-scrm";
+	#clock-cells = <1>;
+};
+
+hsusb1_phy: hsusb1_phy {
+	compatible = "usb-nop-xceiv";
+	reset-supply = <&hsusb1_reset>;
+	clocks = <&aux_clks 3>;
+	clock-names = "main_clk";
+	clock-frequency = <19200000>;
+};
arch/arm/boot/dts/omap4.dtsi +5 -0
index b7db1a2..97de56c 100644
@@ -101,6 +101,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		aux_clks: scrmclks {
+			compatible = "ti,omap4-scrm";
+			#clock-cells = <1>;
+		};
+
 		omap4_pmx_core: pinmux at 4a100040 {
 			compatible = "ti,omap4-padconf", "pinctrl-single";
 			reg = <0x4a100040 0x0196>;
arch/arm/mach-omap2/board-generic.c +1 -1
index 0274ff7..23f2064 100644
@@ -158,7 +158,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap4_init_time,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END
arch/arm/mach-omap2/cclock44xx_data.c +35 -0
index 3d58f33..bfc46c1 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};
+
+static struct clk_onecell_data scrm_data;
+
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}
+
+#else
+
+int __init omap4_clk_init_dt(void)
+{
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 int __init omap4xxx_clk_init(void)
 {
 	u32 cpu_clkflg;
arch/arm/mach-omap2/clock44xx.h +1 -0
index 287a46f..6395f63 100644
@@ -16,5 +16,6 @@
 #define OMAP4430_REGM4XEN_MULT	4
 
 int omap4xxx_clk_init(void);
+int omap4_clk_init_dt(void);
 
 #endif
arch/arm/mach-omap2/common.h +9 -0
index 0a6b9c7..1941d1c 100644
@@ -98,6 +98,7 @@ void am35xx_init_early(void);
 void ti81xx_init_early(void);
 void am33xx_init_early(void);
 void omap4430_init_early(void);
+void omap4_init_time(void);
 void omap5_init_early(void);
 void omap3_init_late(void);	/* Do not use this one */
 void omap4430_init_late(void);
@@ -143,6 +144,14 @@ static inline void omap44xx_restart(char mode, const char *cmd)
 }
 #endif
 
+#ifdef CONFIG_ARCH_OMAP4
+void omap4_init_time(void);
+#else
+static inline void omap4_init_time(void)
+{
+}
+#endif
+
 /* This gets called from mach-omap2/io.c, do not call this */
 void __init omap2_set_globals_tap(u32 class, void __iomem *tap);
 
arch/arm/mach-omap2/io.c +6 -0
index 2c3fdd6..c504363 100644
@@ -603,6 +603,12 @@ void __init omap4430_init_late(void)
 	omap4_pm_init();
 	omap2_clk_enable_autoidle_all();
 }
+
+void __init omap4_init_time(void)
+{
+	omap4_clk_init_dt();
+	omap4_local_timer_init();
+}
 #endif
 
 #ifdef CONFIG_SOC_OMAP5
Signature · 1 line
1.7.4.1
#2 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 28 lines · Roger Quadros

Register a device tree clock provider for AUX clocks on the OMAP4 SoC. Also provide the binding information.

---
 .../devicetree/bindings/clock/omap4-clock.txt      |   32 ++++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 +++
 arch/arm/mach-omap2/board-generic.c                |    2 +-
 arch/arm/mach-omap2/cclock44xx_data.c              |   35 ++++++++++++++++++++
 arch/arm/mach-omap2/clock44xx.h                    |    1 +
 arch/arm/mach-omap2/common.h                       |    9 +++++
 arch/arm/mach-omap2/io.c                           |    6 +++
 7 files changed, 89 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +7 -0
new file mode 100644
index 0000000..9d5448b
@@ -0,0 +1,32 @@
+* Clock bindings for Texas Instruments OMAP4 SCRM clocks
+
+Required properties:
+- compatible: Should be "ti,omap4-scrm"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock

Documentation/devicetree/bindings/clock/omap4-clock.txt line 17

Quoted 10 lines
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +10 -0
+ID in its "clocks" phandle cell.  The following is a full list of SCRM
+clocks and IDs.
+
+	Clock		ID
+	------------------
+	auxclk0_ck	0
+	auxclk1_ck	1
+	auxclk1_ck	1
+	auxclk1_ck	1
+	auxclk1_ck	1

Argh! should be 2,3,4,5

Quoted 153 lines
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +15 -0
+
+Example:
+
+aux_clks: scrmclks {
+	compatible = "ti,omap4-scrm";
+	#clock-cells = <1>;
+};
+
+hsusb1_phy: hsusb1_phy {
+	compatible = "usb-nop-xceiv";
+	reset-supply = <&hsusb1_reset>;
+	clocks = <&aux_clks 3>;
+	clock-names = "main_clk";
+	clock-frequency = <19200000>;
+};
arch/arm/boot/dts/omap4.dtsi +5 -0
index b7db1a2..97de56c 100644
@@ -101,6 +101,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		aux_clks: scrmclks {
+			compatible = "ti,omap4-scrm";
+			#clock-cells = <1>;
+		};
+
 		omap4_pmx_core: pinmux at 4a100040 {
 			compatible = "ti,omap4-padconf", "pinctrl-single";
 			reg = <0x4a100040 0x0196>;
arch/arm/mach-omap2/board-generic.c +1 -1
index 0274ff7..23f2064 100644
@@ -158,7 +158,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap4_init_time,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END
arch/arm/mach-omap2/cclock44xx_data.c +35 -0
index 3d58f33..bfc46c1 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};
+
+static struct clk_onecell_data scrm_data;
+
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}
+
+#else
+
+int __init omap4_clk_init_dt(void)
+{
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 int __init omap4xxx_clk_init(void)
 {
 	u32 cpu_clkflg;
arch/arm/mach-omap2/clock44xx.h +1 -0
index 287a46f..6395f63 100644
@@ -16,5 +16,6 @@
 #define OMAP4430_REGM4XEN_MULT	4
 
 int omap4xxx_clk_init(void);
+int omap4_clk_init_dt(void);
 
 #endif
arch/arm/mach-omap2/common.h +9 -0
index 0a6b9c7..1941d1c 100644
@@ -98,6 +98,7 @@ void am35xx_init_early(void);
 void ti81xx_init_early(void);
 void am33xx_init_early(void);
 void omap4430_init_early(void);
+void omap4_init_time(void);
 void omap5_init_early(void);
 void omap3_init_late(void);	/* Do not use this one */
 void omap4430_init_late(void);
@@ -143,6 +144,14 @@ static inline void omap44xx_restart(char mode, const char *cmd)
 }
 #endif
 
+#ifdef CONFIG_ARCH_OMAP4
+void omap4_init_time(void);
+#else
+static inline void omap4_init_time(void)
+{
+}
+#endif
+
 /* This gets called from mach-omap2/io.c, do not call this */
 void __init omap2_set_globals_tap(u32 class, void __iomem *tap);
 
arch/arm/mach-omap2/io.c +6 -0
index 2c3fdd6..c504363 100644
@@ -603,6 +603,12 @@ void __init omap4430_init_late(void)
 	omap4_pm_init();
 	omap2_clk_enable_autoidle_all();
 }
+
+void __init omap4_init_time(void)
+{
+	omap4_clk_init_dt();
+	omap4_local_timer_init();
+}
 #endif
 
 #ifdef CONFIG_SOC_OMAP5
#3 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Roger Quadros

[]..

arch/arm/mach-omap2/board-generic.c DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)") · line 164

Quoted 13 lines
arch/arm/mach-omap2/board-generic.c +1 -1
index 0274ff7..23f2064 100644
@@ -158,7 +158,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap4_init_time,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END

[]..

Quoted 4 lines
arch/arm/mach-omap2/board-generic.c +4 -0
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;

arch/arm/mach-omap2/board-generic.c

Quoted 10 lines
arch/arm/mach-omap2/board-generic.c +10 -0
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}

[]..

arch/arm/mach-omap2/board-generic.c

Quoted 6 lines
arch/arm/mach-omap2/board-generic.c +6 -0
+
+void __init omap4_init_time(void)
+{
+	omap4_clk_init_dt();
+	omap4_local_timer_init();
+}

I guess you did all this because of_clk_add_provider() needs slab to be initialized. With the below patch[1], now clk inits happen within .init_timer already, so none of this would be needed.

[1] http://www.spinics.net/lists/arm-kernel/msg231288.html

#4 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 45 lines · Rajendra Nayak

[]..

arch/arm/mach-omap2/board-generic.c DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)") · line 164

Quoted 13 lines
arch/arm/mach-omap2/board-generic.c +1 -1
index 0274ff7..23f2064 100644
@@ -158,7 +158,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap4_init_time,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END

[]..

Quoted 4 lines
arch/arm/mach-omap2/board-generic.c +4 -0
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;

arch/arm/mach-omap2/board-generic.c

Quoted 10 lines
arch/arm/mach-omap2/board-generic.c +10 -0
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}

[]..

arch/arm/mach-omap2/board-generic.c

Quoted 6 lines
arch/arm/mach-omap2/board-generic.c +6 -0
+
+void __init omap4_init_time(void)
+{
+	omap4_clk_init_dt();
+	omap4_local_timer_init();
+}

I guess you did all this because of_clk_add_provider() needs slab to be initialized. With the below patch[1], now clk inits happen within .init_timer already, so none of this would be needed.

Quoted 2 lines

[1] http://www.spinics.net/lists/arm-kernel/msg231288.html

Right. I can then call omap4_clk_init_dt() from within omap4xxx_clk_init().

Any comments about the main subject? Does the approach look fine?

cheers,
-roger

#5 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 46 lines · Roger Quadros
Quoted 45 lines · Rajendra Nayak

[]..

arch/arm/mach-omap2/board-generic.c DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)") · line 164

Quoted 13 lines
arch/arm/mach-omap2/board-generic.c +1 -1
index 0274ff7..23f2064 100644
@@ -158,7 +158,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap4_init_time,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END

[]..

Quoted 4 lines
arch/arm/mach-omap2/board-generic.c +4 -0
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;

arch/arm/mach-omap2/board-generic.c

Quoted 10 lines
arch/arm/mach-omap2/board-generic.c +10 -0
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}

[]..

arch/arm/mach-omap2/board-generic.c

Quoted 6 lines
arch/arm/mach-omap2/board-generic.c +6 -0
+
+void __init omap4_init_time(void)
+{
+	omap4_clk_init_dt();
+	omap4_local_timer_init();
+}

I guess you did all this because of_clk_add_provider() needs slab to be initialized. With the below patch[1], now clk inits happen within .init_timer already, so none of this would be needed.

Quoted 6 lines
Quoted 2 lines

[1] http://www.spinics.net/lists/arm-kernel/msg231288.html

Right. I can then call omap4_clk_init_dt() from within omap4xxx_clk_init().

Any comments about the main subject? Does the approach look fine?

It looks fine, except for the fact that I was wondering if the clock provider needs to restrict itself to SCRM.
Nishant Menon brought up a need for specifying the mpu clock source from within DT, to be able to use a generic cpufreq driver. It could be a provider (not specific to scrm, but having only scrm clocks for now) which we could add clocks as and when we see a need for them to be specified from DT.

Btw, you need to copy Paul Walmsley for any clock related patches as he is the OMAP clock maintainer.

Quoted 4 lines

cheers,
-roger

#6 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 54 lines · Rajendra Nayak
Quoted 46 lines · Roger Quadros
Quoted 45 lines · Rajendra Nayak

[]..

arch/arm/mach-omap2/board-generic.c DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)") · line 164

Quoted 13 lines
arch/arm/mach-omap2/board-generic.c +1 -1
index 0274ff7..23f2064 100644
@@ -158,7 +158,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap4_init_time,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END

[]..

Quoted 4 lines
arch/arm/mach-omap2/board-generic.c +4 -0
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;

arch/arm/mach-omap2/board-generic.c

Quoted 10 lines
arch/arm/mach-omap2/board-generic.c +10 -0
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}

[]..

arch/arm/mach-omap2/board-generic.c

Quoted 6 lines
arch/arm/mach-omap2/board-generic.c +6 -0
+
+void __init omap4_init_time(void)
+{
+	omap4_clk_init_dt();
+	omap4_local_timer_init();
+}

I guess you did all this because of_clk_add_provider() needs slab to be initialized. With the below patch[1], now clk inits happen within .init_timer already, so none of this would be needed.

Quoted 6 lines
Quoted 2 lines

[1] http://www.spinics.net/lists/arm-kernel/msg231288.html

Right. I can then call omap4_clk_init_dt() from within omap4xxx_clk_init().

Any comments about the main subject? Does the approach look fine?

Quoted 7 lines

It looks fine, except for the fact that I was wondering if the clock provider needs to restrict itself to SCRM.
Nishant Menon brought up a need for specifying the mpu clock source from within DT, to be able to use a generic cpufreq driver. It could be a provider (not specific to scrm, but having only scrm clocks for now) which we could add clocks as and when we see a need for them to be specified from DT.

OK, I will revise the patch to not make it SCRM specific.

Quoted 3 lines

Btw, you need to copy Paul Walmsley for any clock related patches as he is the OMAP clock maintainer.

OK. Thanks for letting know.

cheers,
-roger

#7 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Roger Quadros

+Paul & Nishant

Quoted 191 lines · Roger Quadros

Register a device tree clock provider for AUX clocks on the OMAP4 SoC. Also provide the binding information.

---
 .../devicetree/bindings/clock/omap4-clock.txt      |   32 ++++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 +++
 arch/arm/mach-omap2/board-generic.c                |    2 +-
 arch/arm/mach-omap2/cclock44xx_data.c              |   35 ++++++++++++++++++++
 arch/arm/mach-omap2/clock44xx.h                    |    1 +
 arch/arm/mach-omap2/common.h                       |    9 +++++
 arch/arm/mach-omap2/io.c                           |    6 +++
 7 files changed, 89 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +32 -0
new file mode 100644
index 0000000..9d5448b
@@ -0,0 +1,32 @@
+* Clock bindings for Texas Instruments OMAP4 SCRM clocks
+
+Required properties:
+- compatible: Should be "ti,omap4-scrm"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell.  The following is a full list of SCRM
+clocks and IDs.
+
+	Clock		ID
+	------------------
+	auxclk0_ck	0
+	auxclk1_ck	1
+	auxclk1_ck	1
+	auxclk1_ck	1
+	auxclk1_ck	1
+
+Example:
+
+aux_clks: scrmclks {
+	compatible = "ti,omap4-scrm";
+	#clock-cells = <1>;
+};
+
+hsusb1_phy: hsusb1_phy {
+	compatible = "usb-nop-xceiv";
+	reset-supply = <&hsusb1_reset>;
+	clocks = <&aux_clks 3>;
+	clock-names = "main_clk";
+	clock-frequency = <19200000>;
+};
arch/arm/boot/dts/omap4.dtsi +5 -0
index b7db1a2..97de56c 100644
@@ -101,6 +101,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		aux_clks: scrmclks {
+			compatible = "ti,omap4-scrm";
+			#clock-cells = <1>;
+		};
+
 		omap4_pmx_core: pinmux at 4a100040 {
 			compatible = "ti,omap4-padconf", "pinctrl-single";
 			reg = <0x4a100040 0x0196>;
arch/arm/mach-omap2/board-generic.c +1 -1
index 0274ff7..23f2064 100644
@@ -158,7 +158,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
 	.init_irq	= omap_gic_of_init,
 	.init_machine	= omap_generic_init,
 	.init_late	= omap4430_init_late,
-	.init_time	= omap4_local_timer_init,
+	.init_time	= omap4_init_time,
 	.dt_compat	= omap4_boards_compat,
 	.restart	= omap44xx_restart,
 MACHINE_END
arch/arm/mach-omap2/cclock44xx_data.c +35 -0
index 3d58f33..bfc46c1 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};
+
+static struct clk_onecell_data scrm_data;
+
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}
+
+#else
+
+int __init omap4_clk_init_dt(void)
+{
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 int __init omap4xxx_clk_init(void)
 {
 	u32 cpu_clkflg;
arch/arm/mach-omap2/clock44xx.h +1 -0
index 287a46f..6395f63 100644
@@ -16,5 +16,6 @@
 #define OMAP4430_REGM4XEN_MULT	4
 
 int omap4xxx_clk_init(void);
+int omap4_clk_init_dt(void);
 
 #endif
arch/arm/mach-omap2/common.h +9 -0
index 0a6b9c7..1941d1c 100644
@@ -98,6 +98,7 @@ void am35xx_init_early(void);
 void ti81xx_init_early(void);
 void am33xx_init_early(void);
 void omap4430_init_early(void);
+void omap4_init_time(void);
 void omap5_init_early(void);
 void omap3_init_late(void);	/* Do not use this one */
 void omap4430_init_late(void);
@@ -143,6 +144,14 @@ static inline void omap44xx_restart(char mode, const char *cmd)
 }
 #endif
 
+#ifdef CONFIG_ARCH_OMAP4
+void omap4_init_time(void);
+#else
+static inline void omap4_init_time(void)
+{
+}
+#endif
+
 /* This gets called from mach-omap2/io.c, do not call this */
 void __init omap2_set_globals_tap(u32 class, void __iomem *tap);
 
arch/arm/mach-omap2/io.c +6 -0
index 2c3fdd6..c504363 100644
@@ -603,6 +603,12 @@ void __init omap4430_init_late(void)
 	omap4_pm_init();
 	omap2_clk_enable_autoidle_all();
 }
+
+void __init omap4_init_time(void)
+{
+	omap4_clk_init_dt();
+	omap4_local_timer_init();
+}
 #endif
 
 #ifdef CONFIG_SOC_OMAP5
#8 lore raw

PATCH v2 1/1 ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Roger Quadros

Register a device tree clock provider for the clocks on the OMAP4 SoC. Also provide the binding information.

For now we only provide AUXCLKs.

---
 .../devicetree/bindings/clock/omap4-clock.txt      |   33 ++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 ++
 arch/arm/mach-omap2/cclock44xx_data.c              |   41 ++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +33 -0
new file mode 100644
index 0000000..2845a3f
@@ -0,0 +1,33 @@
+* Clock bindings for Texas Instruments OMAP4 clocks
+
+Required properties:
+- compatible: Should be "ti,omap4-clock"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell.  The following is a list of OMAP4 clocks
+and IDs.
+
+	Clock		ID
+	------------------
+	auxclk0_ck	0
+	auxclk1_ck	1
+	auxclk2_ck	2
+	auxclk3_ck	3
+	auxclk4_ck	4
+	auxclk5_ck	5
+
+Example:
+
+aux_clks: scrmclks {
+	compatible = "ti,omap4-clock";
+	#clock-cells = <1>;
+};
+
+hsusb1_phy: hsusb1_phy {
+	compatible = "usb-nop-xceiv";
+	reset-supply = <&hsusb1_reset>;
+	clocks = <&aux_clks 3>;
+	clock-names = "main_clk";
+	clock-frequency = <19200000>;
+};
arch/arm/boot/dts/omap4.dtsi +5 -0
index 739bb79..f27548a 100644
@@ -101,6 +101,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		clks: clocks {
+			compatible = "ti,omap4-clock";
+			#clock-cells = <1>;
+		};
+
 		omap4_pmx_core: pinmux at 4a100040 {
 			compatible = "ti,omap4-padconf", "pinctrl-single";
 			reg = <0x4a100040 0x0196>;
arch/arm/mach-omap2/cclock44xx_data.c +41 -0

59 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#9 lore raw

Re: [PATCH v2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

+ Paul

Quoted 135 lines · Roger Quadros

Register a device tree clock provider for the clocks on the OMAP4 SoC. Also provide the binding information.

For now we only provide AUXCLKs.

---
 .../devicetree/bindings/clock/omap4-clock.txt      |   33 ++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 ++
 arch/arm/mach-omap2/cclock44xx_data.c              |   41 ++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +33 -0
new file mode 100644
index 0000000..2845a3f
@@ -0,0 +1,33 @@
+* Clock bindings for Texas Instruments OMAP4 clocks
+
+Required properties:
+- compatible: Should be "ti,omap4-clock"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell.  The following is a list of OMAP4 clocks
+and IDs.
+
+	Clock		ID
+	------------------
+	auxclk0_ck	0
+	auxclk1_ck	1
+	auxclk2_ck	2
+	auxclk3_ck	3
+	auxclk4_ck	4
+	auxclk5_ck	5
+
+Example:
+
+aux_clks: scrmclks {
+	compatible = "ti,omap4-clock";
+	#clock-cells = <1>;
+};
+
+hsusb1_phy: hsusb1_phy {
+	compatible = "usb-nop-xceiv";
+	reset-supply = <&hsusb1_reset>;
+	clocks = <&aux_clks 3>;
+	clock-names = "main_clk";
+	clock-frequency = <19200000>;
+};
arch/arm/boot/dts/omap4.dtsi +5 -0
index 739bb79..f27548a 100644
@@ -101,6 +101,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		clks: clocks {
+			compatible = "ti,omap4-clock";
+			#clock-cells = <1>;
+		};
+
 		omap4_pmx_core: pinmux at 4a100040 {
 			compatible = "ti,omap4-padconf", "pinctrl-single";
 			reg = <0x4a100040 0x0196>;
arch/arm/mach-omap2/cclock44xx_data.c +41 -0
index 3d58f33..a93617b 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,44 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
+/*
+ * List of clocks that can be referenced in device tree
+ * Must match with Documentation/devicetree/bindings/clock/omap4-clock.txt
+ */
+static struct clk *dt_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};
+
+static struct clk_onecell_data clock_data;
+
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-clock");
+	if (np) {
+		clock_data.clks = dt_clks;
+		clock_data.clk_num = ARRAY_SIZE(dt_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&clock_data);
+	}
+
+	return 0;
+}
+
+#else
+
+int __init omap4_clk_init_dt(void)
+{
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 int __init omap4xxx_clk_init(void)
 {
 	u32 cpu_clkflg;
@@ -1693,6 +1732,8 @@ int __init omap4xxx_clk_init(void)
 
 	omap2_clk_disable_autoidle_all();
 
+	omap4_clk_init_dt();
+
 	/*
 	 * On OMAP4460 the ABE DPLL fails to turn on if in idle low-power
 	 * state when turning the ABE clock domain. Workaround this by
#10 lore raw

Re: [PATCH v2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 7 lines · Roger Quadros

+ Paul

Quoted 4 lines · Roger Quadros

Register a device tree clock provider for the clocks on the OMAP4 SoC. Also provide the binding information.

For now we only provide AUXCLKs.

NOTE: this patch depends on
https://patchwork.kernel.org/patch/2312211/

Quoted 9 lines
Quoted 9 lines
---
 .../devicetree/bindings/clock/omap4-clock.txt      |   33 ++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 ++
 arch/arm/mach-omap2/cclock44xx_data.c              |   41 ++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt

cheers,
-roger

#11 lore raw

Re: [PATCH v2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 20 lines · Roger Quadros
Quoted 7 lines · Roger Quadros

+ Paul

Quoted 4 lines · Roger Quadros

Register a device tree clock provider for the clocks on the OMAP4 SoC. Also provide the binding information.

For now we only provide AUXCLKs.

NOTE: this patch depends on
https://patchwork.kernel.org/patch/2312211/

Quoted 8 lines
Quoted 8 lines
---
 .../devicetree/bindings/clock/omap4-clock.txt      |   33 ++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 ++
 arch/arm/mach-omap2/cclock44xx_data.c              |   41 ++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt

If we are doing this, we might as well do for all platforms(OMAP3-5, AM..) in an series, no?

Signature · 2 lines
Regards,
Nishanth Menon
#12 lore raw

Re: [PATCH v2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 21 lines · Nishanth Menon
Quoted 20 lines · Roger Quadros
Quoted 7 lines · Roger Quadros

+ Paul

Quoted 4 lines · Roger Quadros

Register a device tree clock provider for the clocks on the OMAP4 SoC. Also provide the binding information.

For now we only provide AUXCLKs.

NOTE: this patch depends on
https://patchwork.kernel.org/patch/2312211/

Quoted 8 lines
Quoted 8 lines
---
 .../devicetree/bindings/clock/omap4-clock.txt      |   33 ++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 ++
 arch/arm/mach-omap2/cclock44xx_data.c              |   41 ++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Quoted 3 lines

If we are doing this, we might as well do for all platforms(OMAP3-5, AM..) in an series, no?

Yes, once we agree on the approach, I can write it for all OMAPs.

cheers,
-roger

maintainer
#13 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Roger Quadros

Hi,

Quoted 15 lines · Roger Quadros

Register a device tree clock provider for AUX clocks on the OMAP4 SoC. Also provide the binding information.

---
 .../devicetree/bindings/clock/omap4-clock.txt      |   32 ++++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 +++
 arch/arm/mach-omap2/board-generic.c                |    2 +-
 arch/arm/mach-omap2/cclock44xx_data.c              |   35 ++++++++++++++++++++
 arch/arm/mach-omap2/clock44xx.h                    |    1 +
 arch/arm/mach-omap2/common.h                       |    9 +++++
 arch/arm/mach-omap2/io.c                           |    6 +++
 7 files changed, 89 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt

...

Documentation/devicetree/bindings/clock/omap4-clock.txt

Quoted 2 lines
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +0 -0

Is this really specific to omap4 and auxclk only?

Shouldn't it be just omap-clock.txt?

Quoted 12 lines
arch/arm/mach-omap2/cclock44xx_data.c +1 -0
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1674

Quoted 10 lines
arch/arm/mach-omap2/cclock44xx_data.c +8 -0
 };
 
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the cclock44xx_data.c and in DT..

Quoted 18 lines
arch/arm/mach-omap2/cclock44xx_data.c +18 -0
+static struct clk_onecell_data scrm_data;
+
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}
+
+#else

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1703

Quoted 10 lines
arch/arm/mach-omap2/cclock44xx_data.c +7 -0
+
+int __init omap4_clk_init_dt(void)
+{
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 int __init omap4xxx_clk_init(void)
 {
 	u32 cpu_clkflg;

.. and I'm not too keen on adding driver specific stuff to this file.

How about just add a minimal drivers/clk/omap/clk-xyz.c that takes the configuration from DT and is based on the binding we already have in Documentation/devicetree/bindings/clock/clock-bindings.txt?

Then as we add new bindings there we can drop them from current cclock44xx_data.c, no? That is after omap4 is DT only..

Regards,

Tony

#14 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Hi Tony,

Quoted 2 lines · Tony Lindgren

Hi,

[]..

Quoted 47 lines

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1674

Quoted 12 lines
arch/arm/mach-omap2/cclock44xx_data.c +8 -0
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the cclock44xx_data.c and in DT..

Quoted 18 lines
arch/arm/mach-omap2/cclock44xx_data.c +18 -0
+static struct clk_onecell_data scrm_data;
+
+#ifdef CONFIG_OF
+int __init omap4_clk_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "ti,omap4-scrm");
+	if (np) {
+		scrm_data.clks = scrm_clks;
+		scrm_data.clk_num = ARRAY_SIZE(scrm_clks);
+		of_clk_add_provider(np, of_clk_src_onecell_get,	&scrm_data);
+	}
+
+	return 0;
+}
+
+#else

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1703

Quoted 10 lines
arch/arm/mach-omap2/cclock44xx_data.c +7 -0
+
+int __init omap4_clk_init_dt(void)
+{
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 int __init omap4xxx_clk_init(void)
 {
 	u32 cpu_clkflg;

.. and I'm not too keen on adding driver specific stuff to this file.

Quoted 6 lines

How about just add a minimal drivers/clk/omap/clk-xyz.c that takes the configuration from DT and is based on the binding we already have in Documentation/devicetree/bindings/clock/clock-bindings.txt?

Then as we add new bindings there we can drop them from current cclock44xx_data.c, no? That is after omap4 is DT only..

The patch just provides an alternative for clkdev mapping in case of DT. Are you suggesting we move all *clock data* related to auxclks (and eventually all clocks) into DT?
We have discussed this multiple times in the past, and moving 250 clock nodes with each needing multiple register offsets, masks, shifts etc into DT makes it completely un-readable. For me, having a way for devices to reference a clock that they use for a device using DT makes sense, but not moving all clock data into dts files.

regards,
Rajendra

Quoted 5 lines

Regards,

Tony

maintainer
#15 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 6 lines · Rajendra Nayak
Quoted 5 lines · Tony Lindgren

How about just add a minimal drivers/clk/omap/clk-xyz.c that takes the configuration from DT and is based on the binding we already have in Documentation/devicetree/bindings/clock/clock-bindings.txt?

Quoted 6 lines
Quoted 2 lines

Then as we add new bindings there we can drop them from current cclock44xx_data.c, no? That is after omap4 is DT only..

The patch just provides an alternative for clkdev mapping in case of DT. Are you suggesting we move all *clock data* related to auxclks (and eventually all clocks) into DT?

Well I think we should have a driver that can take any defined clock binding from DT at least for boottime clocks. We need at least the timer clocks early during the boot, and probably the root device like MMC or possibly Ethernet depending on the board.

The rest of the huge amount of clocks we can just load from /lib/firmware after mounting intramfs or root on MMC. As long as we can define any boottime clock in DT also, loading the rest of the clock data from /lib/firmware should not cause issues with booting.

And as we get the clocks moved, we can drop them from cclock44xx_data.c. AFAIK the new driver can just clk_get the parent clocks so those can stay in cclock44xx_data.c for now?

So basically we can do the same as we are already doing with pinctrl-single.c, but with addition of loading large amounts of data from /lib/firmware. And eventually we can do the same with hwmod too.

Regarding the readability issue, we now have preprocessing support for .dts files merged AFAIK, so they can be as readable as data structures :)

Quoted 4 lines

We have discussed this multiple times in the past, and moving 250 clock nodes with each needing multiple register offsets, masks, shifts etc into DT makes it completely un-readable. For me, having a way for devices to reference a clock that they use for a device using DT makes sense, but not moving all clock data into dts files.

Yes that's why we should also support loading clocks from /lib/firmware. Naturally the parent clocks can be allocated by the clock driver(s) at least initially.

But the main reason I think we should do this is so we get out of the flame path with these huge data files for every new SoC.

Regards,

Tony

#16 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Tony Lindgren

Hi,

Quoted 18 lines · Tony Lindgren

Hi,

Quoted 4 lines · Roger Quadros

Register a device tree clock provider for AUX clocks on the OMAP4 SoC. Also provide the binding information.

Quoted 11 lines
---
 .../devicetree/bindings/clock/omap4-clock.txt      |   32 ++++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi                       |    5 +++
 arch/arm/mach-omap2/board-generic.c                |    2 +-
 arch/arm/mach-omap2/cclock44xx_data.c              |   35 ++++++++++++++++++++
 arch/arm/mach-omap2/clock44xx.h                    |    1 +
 arch/arm/mach-omap2/common.h                       |    9 +++++
 arch/arm/mach-omap2/io.c                           |    6 +++
 7 files changed, 89 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/omap4-clock.txt
Quoted 8 lines

...

Documentation/devicetree/bindings/clock/omap4-clock.txt

Quoted 2 lines
Documentation/devicetree/bindings/clock/omap4-clock.txt new file +0 -0

Is this really specific to omap4 and auxclk only?

Shouldn't it be just omap-clock.txt?

Yes, I've fixed this up in v2 of this patch.

Quoted 15 lines
Quoted 15 lines
arch/arm/mach-omap2/cclock44xx_data.c +1 -0
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
Quoted 11 lines

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1674

Quoted 8 lines
arch/arm/mach-omap2/cclock44xx_data.c +8 -0
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the cclock44xx_data.c and in DT..

Right, but till we have all clocks moved to DT we only need this approach for general purpose clocks that are not mapped to devices by hwmod.

e.g. auxclk are required to be specified in DT nodes for USB PHY. Without this we can't get USB host working on Panda.

As Rajendra points out, it seems moving entire clock data to DT is not going to happen soon. So this is the simplistic way things can work.

cheers,
-roger

maintainer
#17 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 27 lines · Roger Quadros
Quoted 14 lines · Tony Lindgren
Quoted 14 lines
arch/arm/mach-omap2/cclock44xx_data.c +1 -0
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
Quoted 11 lines

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1674

Quoted 8 lines
arch/arm/mach-omap2/cclock44xx_data.c +8 -0
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the cclock44xx_data.c and in DT..

Quoted 3 lines

Right, but till we have all clocks moved to DT we only need this approach for general purpose clocks that are not mapped to devices by hwmod.

For v3.10, let's just make sure that USB works with DT as then after v3.10 we can make omap4 DT only and get rid of estimated 7K lines of code and data. I guess this is the last piece missing for that, or are we also missing something else?

Can't you set up a clock alias for your device so it can find the auxclk when requesting it with the dev entry?

For the DT clock driver if needed for v3.10, how about just do a minimal drivers/clock/omap/ that uses the standard binding? Then that driver can just do clk_get() from cclock44xx_data.c for now? And then later on we'll just move all the clocks to a combination of DT + /lib/firmware.

Quoted 2 lines

e.g. auxclk are required to be specified in DT nodes for USB PHY. Without this we can't get USB host working on Panda.

OK. So if the USB PHY has a dev entry, can't you just set up a clock alias in struct omap_clk omap44xx_clks[] for it?

Quoted 2 lines

As Rajendra points out, it seems moving entire clock data to DT is not going to happen soon. So this is the simplistic way things can work.

Right but seems like we can get started there without moving them all at once.

Regards,

Tony

#18 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 28 lines · Tony Lindgren
Quoted 27 lines · Roger Quadros
Quoted 25 lines · Tony Lindgren
Quoted 12 lines
arch/arm/mach-omap2/cclock44xx_data.c +1 -0
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1674

Quoted 10 lines
arch/arm/mach-omap2/cclock44xx_data.c +8 -0
 };
 
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the cclock44xx_data.c and in DT..

Quoted 8 lines
Quoted 3 lines

Right, but till we have all clocks moved to DT we only need this approach for general purpose clocks that are not mapped to devices by hwmod.

For v3.10, let's just make sure that USB works with DT as then after v3.10 we can make omap4 DT only and get rid of estimated 7K lines of code and data. I guess this is the last piece missing for that, or are we also missing something else?

For panda we just need a way to map the auxclk to the USB PHY device and the relevant dts data to get USB host working with DT. Beagle USB host should work already with DT without any changes.

Quoted 4 lines

Can't you set up a clock alias for your device so it can find the auxclk when requesting it with the dev entry?

which clock is mapped to which PHY device depends on board design and that cannot be per-determined at one place. This information needs to come from the board.dts file.

There was an earlier attempt to provide a way of building clock aliases at runtime from device tree [1], but the current approach is way better

[1]
https://lkml.org/lkml/2013/3/12/241

Quoted 3 lines

For the DT clock driver if needed for v3.10, how about just do a minimal drivers/clock/omap/ that uses the standard binding? Then that driver can just do clk_get() from cclock44xx_data.c

I don't understand how to do it and why it is better than the current approach.

How can that driver do clk_get() from cclock44xx_data.c? from where does it get the clk_id to pass into clk_get()?

Quoted 2 lines

for now? And then later on we'll just move all the clocks to a combination of DT + /lib/firmware.

What is the benefit of moving clock data to /lib/firmware? We could as well just move it to DT only, no?

Quoted 6 lines
Quoted 3 lines

e.g. auxclk are required to be specified in DT nodes for USB PHY. Without this we can't get USB host working on Panda.

OK. So if the USB PHY has a dev entry, can't you just set up a clock alias in struct omap_clk omap44xx_clks[] for it?

I've explained why this can't be done above.

Quoted 7 lines
Quoted 3 lines

As Rajendra points out, it seems moving entire clock data to DT is not going to happen soon. So this is the simplistic way things can work.

Right but seems like we can get started there without moving them all at once.

What if we provide a complete clock list instead of only auxclks in dt_clks[]?

This approach is similar to arch/arm/mach-imx/clk-imx35.c

Device drivers can then use them as they migrate to DT. Then later we could migrate clock data to DT, without impacting device drivers.

cheers,
-roger

maintainer
#19 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 13 lines · Roger Quadros
Quoted 6 lines · Tony Lindgren
Quoted 1 line · Roger Quadros

On 04/04/2013 02:42 AM, Tony Lindgren wrote:

For v3.10, let's just make sure that USB works with DT as then after v3.10 we can make omap4 DT only and get rid of estimated 7K lines of code and data. I guess this is the last piece missing for that, or are we also missing something else?

For panda we just need a way to map the auxclk to the USB PHY device and the relevant dts data to get USB host working with DT. Beagle USB host should work already with DT without any changes.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

Can't you set up a clock alias for your device so it can find the auxclk when requesting it with the dev entry?

which clock is mapped to which PHY device depends on board design and that cannot be per-determined at one place. This information needs to come from the board.dts file.

OK that makes sense.

Quoted 6 lines

There was an earlier attempt to provide a way of building clock aliases at runtime from device tree [1], but the current approach is way better

[1]
https://lkml.org/lkml/2013/3/12/241

Quoted 6 lines
Quoted 3 lines

For the DT clock driver if needed for v3.10, how about just do a minimal drivers/clock/omap/ that uses the standard binding? Then that driver can just do clk_get() from cclock44xx_data.c

I don't understand how to do it and why it is better than the current approach.

Well your approach is fine as a first step moving all the clock code, but it needs to be a real driver under drivers/clock/omap. And the DT binding needs to stay the same for the driver(s) in the long term as we start moving clocks to DT + /lib/firmware.

If this all is too late for v3.10, I suggest you just set up the right clock alias for panda with machine_is_compatible flag in board-generic.c so we get EHCI working with DT for v3.10. Then it's easy to to deal with it properly for v3.11.

Quoted 2 lines

How can that driver do clk_get() from cclock44xx_data.c? from where does it get the clk_id to pass into clk_get()?

Can't you just use the clock name there to get it?

Quoted 5 lines
Quoted 2 lines

for now? And then later on we'll just move all the clocks to a combination of DT + /lib/firmware.

What is the benefit of moving clock data to /lib/firmware? We could as well just move it to DT only, no?

DT only clocks option is naturally available with this too. It just gets easily inefficient with such a huge number of clocks.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

e.g. auxclk are required to be specified in DT nodes for USB PHY. Without this we can't get USB host working on Panda.

OK. So if the USB PHY has a dev entry, can't you just set up a clock alias in struct omap_clk omap44xx_clks[] for it?

I've explained why this can't be done above.

Yes I understand now, the clock is board specific.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

As Rajendra points out, it seems moving entire clock data to DT is not going to happen soon. So this is the simplistic way things can work.

Right but seems like we can get started there without moving them all at once.

Quoted 7 lines

What if we provide a complete clock list instead of only auxclks in dt_clks[]?

This approach is similar to arch/arm/mach-imx/clk-imx35.c

Device drivers can then use them as they migrate to DT. Then later we could migrate clock data to DT, without impacting device drivers.

As long as the binding stays the same in the long run too, this clock remapping approach is just fine as a starting point. And the driver needs to go to drivers/clock/omap. But in the long run we just want to get the huge amounts static data out of the kernel for clocks and hwmod data to fix things for good.

Regards,

Tony

#20 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 34 lines · Tony Lindgren
Quoted 13 lines · Roger Quadros
Quoted 6 lines · Tony Lindgren
Quoted 1 line · Roger Quadros

On 04/04/2013 02:42 AM, Tony Lindgren wrote:

For v3.10, let's just make sure that USB works with DT as then after v3.10 we can make omap4 DT only and get rid of estimated 7K lines of code and data. I guess this is the last piece missing for that, or are we also missing something else?

For panda we just need a way to map the auxclk to the USB PHY device and the relevant dts data to get USB host working with DT. Beagle USB host should work already with DT without any changes.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

Can't you set up a clock alias for your device so it can find the auxclk when requesting it with the dev entry?

which clock is mapped to which PHY device depends on board design and that cannot be per-determined at one place. This information needs to come from the board.dts file.

OK that makes sense.

Quoted 10 lines

There was an earlier attempt to provide a way of building clock aliases at runtime from device tree [1], but the current approach is way better

[1]
https://lkml.org/lkml/2013/3/12/241

Quoted 3 lines

For the DT clock driver if needed for v3.10, how about just do a minimal drivers/clock/omap/ that uses the standard binding? Then that driver can just do clk_get() from cclock44xx_data.c

Quoted 7 lines
Quoted 2 lines

I don't understand how to do it and why it is better than the current approach.

Well your approach is fine as a first step moving all the clock code, but it needs to be a real driver under drivers/clock/omap. And the DT binding needs to stay the same for the driver(s) in the long term as we start moving clocks to DT + /lib/firmware.

The code needs to be there were the clock structs are defined. Currently they are in arch/arm/mach-omap2/cclock44xx_data.c for OMAP4.

Quoted 5 lines

If this all is too late for v3.10, I suggest you just set up the right clock alias for panda with machine_is_compatible flag in board-generic.c so we get EHCI working with DT for v3.10. Then it's easy to to deal with it properly for v3.11.

OK, let's do it this way for Panda for 3.10.

Quoted 5 lines
Quoted 3 lines

How can that driver do clk_get() from cclock44xx_data.c? from where does it get the clk_id to pass into clk_get()?

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

for now? And then later on we'll just move all the clocks to a combination of DT + /lib/firmware.

What is the benefit of moving clock data to /lib/firmware? We could as well just move it to DT only, no?

DT only clocks option is naturally available with this too. It just gets easily inefficient with such a huge number of clocks.

OK.

Quoted 21 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

e.g. auxclk are required to be specified in DT nodes for USB PHY. Without this we can't get USB host working on Panda.

OK. So if the USB PHY has a dev entry, can't you just set up a clock alias in struct omap_clk omap44xx_clks[] for it?

I've explained why this can't be done above.

Yes I understand now, the clock is board specific.

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

As Rajendra points out, it seems moving entire clock data to DT is not going to happen soon. So this is the simplistic way things can work.

Right but seems like we can get started there without moving them all at once.

What if we provide a complete clock list instead of only auxclks in dt_clks[]?

This approach is similar to arch/arm/mach-imx/clk-imx35.c

Quoted 8 lines
Quoted 2 lines

Device drivers can then use them as they migrate to DT. Then later we could migrate clock data to DT, without impacting device drivers.

As long as the binding stays the same in the long run too, this clock remapping approach is just fine as a starting point. And the driver needs to go to drivers/clock/omap. But in the long run we just want to get the huge amounts static data out of the kernel for clocks and hwmod data to fix things for good.

In that case we need to identify what clocks need to be supported. If it is all (~200) of them, is this method good enough?

cheers,
-roger

maintainer
#21 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 9 lines · Roger Quadros
Quoted 5 lines · Tony Lindgren

Well your approach is fine as a first step moving all the clock code, but it needs to be a real driver under drivers/clock/omap. And the DT binding needs to stay the same for the driver(s) in the long term as we start moving clocks to DT + /lib/firmware.

The code needs to be there were the clock structs are defined. Currently they are in arch/arm/mach-omap2/cclock44xx_data.c for OMAP4.

But if you do just a passthrough driver then that should not be needed.

Quoted 6 lines
Quoted 4 lines

If this all is too late for v3.10, I suggest you just set up the right clock alias for panda with machine_is_compatible flag in board-generic.c so we get EHCI working with DT for v3.10. Then it's easy to to deal with it properly for v3.11.

OK, let's do it this way for Panda for 3.10.

Yes otherwise we'll be delaying omap4 DT conversion again.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

How can that driver do clk_get() from cclock44xx_data.c? from where does it get the clk_id to pass into clk_get()?

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Quoted 8 lines
Quoted 5 lines

As long as the binding stays the same in the long run too, this clock remapping approach is just fine as a starting point. And the driver needs to go to drivers/clock/omap. But in the long run we just want to get the huge amounts static data out of the kernel for clocks and hwmod data to fix things for good.

In that case we need to identify what clocks need to be supported. If it is all (~200) of them, is this method good enough?

We should support any clock we need for booting the device with just DT bindings to get timers, console and rootfs working. Then we just need to load the complete set from /lib/firmware.

It seems that the binding can be the same for all the clocks. For now, we can just use the standard clock binding and do the remapping in the clock driver.

Regards,

Tony

maintainer
#22 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 8 lines · Tony Lindgren
Quoted 7 lines · Roger Quadros
Quoted 2 lines · Tony Lindgren

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

Regards,

Tony

#23 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 20 lines · Tony Lindgren
Quoted 8 lines · Tony Lindgren
Quoted 7 lines · Roger Quadros
Quoted 2 lines · Tony Lindgren

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

Quoted 6 lines

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

Here is an attempt on beagleXM - adds every clock node to the list. Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr

Would an cleaned up version be good enough as a step #1 of transition?

Quoted 1 line

From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001

From: Nishanth Menon <[email protected]>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [PATCH] OMAP: add devicetree support for clock nodes.

Dummy patch based on Roger's original idea

---
 arch/arm/boot/dts/omap3.dtsi          |    5 ++
 arch/arm/boot/dts/omap34xx.dtsi       |    2 +
 arch/arm/mach-omap2/cclock3xxx_data.c |    3 +-
 arch/arm/mach-omap2/cclock44xx_data.c |    3 +-
 arch/arm/mach-omap2/pm.c              |   11 +++-
 drivers/clk/Kconfig                   |    6 ++
 drivers/clk/Makefile                  |    2 +
 drivers/clk/ti.c                      |  100 +++++++++++++++++++++++++++++++++
 include/linux/clk/ti.h                |   30 ++++++++++
 9 files changed, 157 insertions(+), 5 deletions(-)
 create mode 100644 drivers/clk/ti.c
 create mode 100644 include/linux/clk/ti.h
arch/arm/boot/dts/omap3.dtsi +5 -0
index 3344f05..a08990d 100644
@@ -73,6 +73,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		clks: clocks {
+			compatible = "ti,clock";
+			#clock-cells = <1>;
+		};
+
 		intc: interrupt-controller at 48200000 {
 			compatible = "ti,omap2-intc";
 			interrupt-controller;
arch/arm/boot/dts/omap34xx.dtsi +2 -0
index 75ed4ae..93c2621 100644
@@ -23,6 +23,8 @@
 				600000  1350000
 			>;
 			clock-latency = <300000>; /* From legacy driver */
+			clocks = <&clks 249>; /* index to cpufreq_ck */
+			clock-names = "cpu";
 		};
 	};
 };
arch/arm/mach-omap2/cclock3xxx_data.c +2 -1
index 4579c3c..d5d5ef5 100644
@@ -22,6 +22,7 @@
 #include <linux/clk-private.h>
 #include <linux/list.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
 	for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
 	     c++)
 		if (c->cpu & cpu_clkflg) {
-			clkdev_add(&c->lk);
+			ti_clk_node_add(&c->lk);
 			if (!__clk_init(NULL, c->lk.clk))
 				omap2_init_clk_hw_omap_clocks(c->lk.clk);
 		}
arch/arm/mach-omap2/cclock44xx_data.c +2 -1
index 0c6834a..338ef64 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
 	for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
 									c++) {
 		if (c->cpu & cpu_clkflg) {
-			clkdev_add(&c->lk);
+			ti_clk_node_add(&c->lk);
 			if (!__clk_init(NULL, c->lk.clk))
 				omap2_init_clk_hw_omap_clocks(c->lk.clk);
 		}
arch/arm/mach-omap2/pm.c +8 -3
index 8d15f9a..6cf95160 100644
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
 
 static inline void omap_init_cpufreq(void)
 {
-	struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+	struct platform_device_info devinfo = { };
+
+	if (!of_have_populated_dt())
+		devinfo.name = "omap-cpufreq";
+	else
+		devinfo.name = "cpufreq-cpu0";
 	platform_device_register_full(&devinfo);
 }
 
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
 		/* Smartreflex device init */
 		omap_devinit_smartreflex();
 
-		/* cpufreq dummy device instantiation */
-		omap_init_cpufreq();
 	}
+	/* cpufreq dummy device instantiation */
+	omap_init_cpufreq();
 
 #ifdef CONFIG_SUSPEND
 	suspend_set_ops(&omap_pm_ops);
drivers/clk/Kconfig +6 -0
index a47e6ee..03c6e48 100644
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
 	---help---
 	  This driver supports Maxim 77686 crystal oscillator clock. 
 
+config COMMON_CLK_TI
+	tristate "Clock driver for TI SoCs"
+	depends on ARCH_OMAP && OF
+	---help---
+	  Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
 config CLK_TWL6040
 	tristate "External McPDM functional clock from twl6040"
 	depends on TWL6040_CORE
drivers/clk/Makefile +2 -0
index 300d477..9621815 100644
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 
 obj-$(CONFIG_X86)		+= x86/
 
+obj-$(CONFIG_COMMON_CLK_TI)	+= ti.o
+
 # Chip specific
 obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
drivers/clk/ti.c new file +100 -0

100 lines not on this page · raw message

include/linux/clk/ti.h new file +30 -0
new file mode 100644
index 0000000..eb502a8
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *	Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk)
+{
+	clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif	/* __TI_CLK_H */
Signature · 6 lines
1.7.9.5


-- 
Regards,
Nishanth Menon
#24 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 32 lines · Nishanth Menon
Quoted 20 lines · Tony Lindgren
Quoted 8 lines · Tony Lindgren
Quoted 7 lines · Roger Quadros
Quoted 2 lines · Tony Lindgren

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

Quoted 6 lines

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

Quoted 6 lines

Here is an attempt on beagleXM - adds every clock node to the list. Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr

Would an cleaned up version be good enough as a step #1 of transition?

Approach #2:
Here is yet another revision -> here I am trying to avoid the risk of folks messing up indexing. for example: using an older DTB with newer kernel, clocks being inserted into existing list etc. to prevent these, we add an "DT_ID" for omap clock nodes, and use it to uniquely identify the clock node. We try to minimize(not avoidable with integer indexing) mistakes during development/productization.

Quoted 1 line

From 2b576affdc6f6bf0b51ebf9b85ef4319357a7994 Mon Sep 17 00:00:00 2001

From: Nishanth Menon <[email protected]>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [RFC PATCH V2] OMAP: add devicetree support for clock nodes.(rev 2)

Dummy patch based on Roger's original idea
this time have lesser possibiltiy of screwing up indices. instead use a specific integer ID to uniquely (TI SoC wide) identify an clock. on the flip side, we do not all make clock nodes to be accesible from DT clock indexing.

---
 .../devicetree/bindings/clock/ti,clock.txt         |   48 +++++++++++
 arch/arm/boot/dts/omap3.dtsi                       |    5 ++
 arch/arm/boot/dts/omap34xx.dtsi                    |    2 +
 arch/arm/boot/dts/omap4.dtsi                       |    5 ++
 arch/arm/boot/dts/omap443x.dtsi                    |    2 +
 arch/arm/mach-omap2/cclock3xxx_data.c              |    5 +-
 arch/arm/mach-omap2/cclock44xx_data.c              |    5 +-
 arch/arm/mach-omap2/clock.h                        |   12 +++
 arch/arm/mach-omap2/pm.c                           |   11 ++-
 drivers/clk/Kconfig                                |    6 ++
 drivers/clk/Makefile                               |    2 +
 drivers/clk/ti.c                                   |   85 ++++++++++++++++++++
 include/linux/clk/ti.h                             |   30 +++++++
 13 files changed, 211 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti,clock.txt
 create mode 100644 drivers/clk/ti.c
 create mode 100644 include/linux/clk/ti.h
Documentation/devicetree/bindings/clock/ti,clock.txt new file +48 -0
new file mode 100644
index 0000000..53c947c
@@ -0,0 +1,48 @@
+* Clock bindings for Texas Instruments clocks
+
+Required properties:
+- compatible: Should be "ti,clock"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell.  The following is a list of ID reservations
+across TI SoCs
+
+       Clock           ID
+       ------------------
+       cpu clock	1
+
+The definition is used by SoC clock data using CLKDT() macro
+(example of OMAP2+).
+
+Example Steps:
+/* step 1: definiting an SoC nodes compatible with ti clocks -skip if already done */
+clks: clocks {
+	compatible = "ti,clock";
+	#clock-cells = <1>;
+};
+
+/* step 2: Modify the bindings documentation to reserve an ID */
+	auxclk0_ck      2
+	auxclk1_ck      3
+	auxclk2_ck      4
+	auxclk3_ck      5
+	auxclk4_ck      6
+	auxclk5_ck      7
+etc. use an unique number not conflicting with previous reservations.
+WARNING: DONOT insert values - this breaks backward compatibility.
+/* Step 3: replace in clock data file */
+	CLK(NULL,	"auxclk0_ck",			&auxclk0_ck,	CK_443X),
+with
+	CLKDT(2, NULL,	"auxclk0_ck",			&auxclk0_ck,	CK_443X),
+
+/* step 4: in device tree entry, now we can use index 2 to uniquely identify auxclk0 clock */
+
+hsusb1_phy: hsusb1_phy {
+	compatible = "usb-nop-xceiv";
+	reset-supply = <&hsusb1_reset>;
+	clocks = <&aux_clks 2>;
+	clock-names = "main_clk";
+	clock-frequency = <19200000>;
+};
+
arch/arm/boot/dts/omap3.dtsi +5 -0
index 3344f05..a08990d 100644
@@ -73,6 +73,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		clks: clocks {
+			compatible = "ti,clock";
+			#clock-cells = <1>;
+		};
+
 		intc: interrupt-controller at 48200000 {
 			compatible = "ti,omap2-intc";
 			interrupt-controller;
arch/arm/boot/dts/omap34xx.dtsi +2 -0
index 75ed4ae..de59fb8 100644
@@ -23,6 +23,8 @@
 				600000  1350000
 			>;
 			clock-latency = <300000>; /* From legacy driver */
+			clocks = <&clks 1>;
+			clock-names = "cpu";
 		};
 	};
 };
arch/arm/boot/dts/omap4.dtsi +5 -0
index 3329140..ad18d6a 100644
@@ -106,6 +106,11 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		clks: clocks {
+			compatible = "ti,clock";
+			#clock-cells = <1>;
+		};
+
 		omap4_pmx_core: pinmux at 4a100040 {
 			compatible = "ti,omap4-padconf", "pinctrl-single";
 			reg = <0x4a100040 0x0196>;
arch/arm/boot/dts/omap443x.dtsi +2 -0
index cccf39a..5bfc02b 100644
@@ -22,6 +22,8 @@
 				1008000 1375000
 			>;
 			clock-latency = <300000>; /* From legacy driver */
+			clocks = <&clks 1>;
+			clock-names = "cpu";
 		};
 	};
 };
arch/arm/mach-omap2/cclock3xxx_data.c +3 -2
index 4579c3c..2f2932b 100644
@@ -22,6 +22,7 @@
 #include <linux/clk-private.h>
 #include <linux/list.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -3501,7 +3502,7 @@ static struct omap_clk omap3xxx_clks[] = {
 	CLK(NULL,	"uart4_ick",	&uart4_ick_am35xx,	CK_AM35XX),
 	CLK(NULL,	"timer_32k_ck",	&omap_32k_fck,  CK_3XXX),
 	CLK(NULL,	"timer_sys_ck",	&sys_ck,	CK_3XXX),
-	CLK(NULL,	"cpufreq_ck",	&dpll1_ck,	CK_3XXX),
+	CLKDT(1, NULL,	"cpufreq_ck",	&dpll1_ck,	CK_3XXX),
 };
 
 static const char *enable_init_clks[] = {
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
 	for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
 	     c++)
 		if (c->cpu & cpu_clkflg) {
-			clkdev_add(&c->lk);
+			ti_clk_node_add(&c->lk, c->dt_clkid);
 			if (!__clk_init(NULL, c->lk.clk))
 				omap2_init_clk_hw_omap_clocks(c->lk.clk);
 		}
arch/arm/mach-omap2/cclock44xx_data.c +3 -2
index 0c6834a..74d4e8c 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1672,7 +1673,7 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK("4013a000.timer",	"timer_sys_ck",	&syc_clk_div_ck,	CK_443X),
 	CLK("4013c000.timer",	"timer_sys_ck",	&syc_clk_div_ck,	CK_443X),
 	CLK("4013e000.timer",	"timer_sys_ck",	&syc_clk_div_ck,	CK_443X),
-	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
+	CLKDT(1, NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
 };
 
 int __init omap4xxx_clk_init(void)
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
 	for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
 									c++) {
 		if (c->cpu & cpu_clkflg) {
-			clkdev_add(&c->lk);
+			ti_clk_node_add(&c->lk, c->dt_clkid);
 			if (!__clk_init(NULL, c->lk.clk))
 				omap2_init_clk_hw_omap_clocks(c->lk.clk);
 		}
arch/arm/mach-omap2/clock.h +12 -0
index 60ddd86..9a7c95b 100644
@@ -23,10 +23,22 @@
 #include <linux/clk-provider.h>
 
 struct omap_clk {
+	u16				dt_clkid;
 	u16				cpu;
 	struct clk_lookup		lk;
 };
 
+#define CLKDT(id, dev, con, ck, cp)	\
+	{				\
+		.dt_clkid = id,		\
+		.cpu = cp,		\
+		.lk = {			\
+			.dev_id = dev,	\
+			.con_id = con,	\
+			.clk = ck,	\
+		},			\
+	}
+
 #define CLK(dev, con, ck, cp)		\
 	{				\
 		 .cpu = cp,		\
drivers/clk/Kconfig +6 -0
index a47e6ee..03c6e48 100644
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
 	---help---
 	  This driver supports Maxim 77686 crystal oscillator clock. 
 
+config COMMON_CLK_TI
+	tristate "Clock driver for TI SoCs"
+	depends on ARCH_OMAP && OF
+	---help---
+	  Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
 config CLK_TWL6040
 	tristate "External McPDM functional clock from twl6040"
 	depends on TWL6040_CORE
drivers/clk/Makefile +2 -0
index 300d477..9621815 100644
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 
 obj-$(CONFIG_X86)		+= x86/
 
+obj-$(CONFIG_COMMON_CLK_TI)	+= ti.o
+
 # Chip specific
 obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
drivers/clk/ti.c new file +85 -0

85 lines not on this page · raw message

include/linux/clk/ti.h new file +30 -0
new file mode 100644
index 0000000..ebed98a
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *	Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk, u16 id);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk, u16 id)
+{
+	clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif	/* __TI_CLK_H */
arch/arm/mach-omap2/pm.c +8 -3
index 8d15f9a..6cf95160 100644
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
 
 static inline void omap_init_cpufreq(void)
 {
-	struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+	struct platform_device_info devinfo = { };
+
+	if (!of_have_populated_dt())
+		devinfo.name = "omap-cpufreq";
+	else
+		devinfo.name = "cpufreq-cpu0";
 	platform_device_register_full(&devinfo);
 }
 
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
 		/* Smartreflex device init */
 		omap_devinit_smartreflex();
 
-		/* cpufreq dummy device instantiation */
-		omap_init_cpufreq();
 	}
+	/* cpufreq dummy device instantiation */
+	omap_init_cpufreq();
 
 #ifdef CONFIG_SUSPEND
 	suspend_set_ops(&omap_pm_ops);
Signature · 5 lines
1.7.9.5

-- 
Regards,
Nishanth Menon
#25 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 37 lines · Nishanth Menon
Quoted 36 lines · Nishanth Menon
Quoted 20 lines · Tony Lindgren
Quoted 8 lines · Tony Lindgren
Quoted 7 lines · Roger Quadros
Quoted 2 lines · Tony Lindgren

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

Quoted 6 lines

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

Here is an attempt on beagleXM - adds every clock node to the list. Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr

Quoted 6 lines
Quoted 2 lines

Would an cleaned up version be good enough as a step #1 of transition?

Approach #2:
Here is yet another revision -> here I am trying to avoid the risk of folks messing up indexing. for example: using an older DTB with newer kernel, clocks being inserted into existing list etc. to prevent these,

Why do you need to worry about users using old DTB with new kernel. That is entirely the user's fault no?

Quoted 3 lines

we add an "DT_ID" for omap clock nodes, and use it to uniquely identify the clock node. We try to minimize(not avoidable with integer indexing) mistakes during development/productization.

cheers,
-roger

maintainer
#26 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Nishanth Menon
Quoted 4 lines · Nishanth Menon

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

It seems that you should have a separate clock defines for each clock instead. That way we can later on populate that with the clock specific data.

Quoted 5 lines

Here is an attempt on beagleXM - adds every clock node to the list. Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr

Would an cleaned up version be good enough as a step #1 of transition?

Well I would make it even simpler initially. Just a standard .dts clock defined that gets parsed by drivers/clock/ driver that just calls clk_add_alias(). Then the consumer driver can just do clk_get() and and the right clock is found, see below.

Quoted 4 lines
arch/arm/boot/dts/omap3.dtsi +0 -0
@@ -73,6 +73,11 @@
 			ti,hwmods = "counter_32k";

arch/arm/boot/dts/omap3.dtsi line 83

Quoted 10 lines
arch/arm/boot/dts/omap3.dtsi +5 -0
 		};
 
+		clks: clocks {
+			compatible = "ti,clock";
+			#clock-cells = <1>;
+		};
+
 		intc: interrupt-controller at 48200000 {
 			compatible = "ti,omap2-intc";
 			interrupt-controller;

There should be a separate entry for each clock defined, like auxclk1 in the USB case assuming the clock being used is aux clock #1. I doubt that we want to map all the auxclks as a single clock as they are separate clocks AFAIK.

arch/arm/boot/dts/omap34xx.dtsi line 30

Quoted 11 lines
arch/arm/boot/dts/omap34xx.dtsi +2 -0
@@ -23,6 +23,8 @@
 				600000  1350000
 			>;
 			clock-latency = <300000>; /* From legacy driver */
+			clocks = <&clks 249>; /* index to cpufreq_ck */
+			clock-names = "cpu";
 		};
 	};
 };

Then in the consumer driver you would just have:

			clocks = <&auxclk1 0>;

for the USB case, then something else for the cpufreq driver.

Quoted 11 lines
arch/arm/mach-omap2/cclock3xxx_data.c +1 -0
@@ -22,6 +22,7 @@
 #include <linux/clk-private.h>
 #include <linux/list.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"

arch/arm/mach-omap2/cclock3xxx_data.c int __init omap3xxx_clk_init(void) · line 3581

Quoted 8 lines
arch/arm/mach-omap2/cclock3xxx_data.c +1 -1
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
 	for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
 	     c++)
 		if (c->cpu & cpu_clkflg) {
-			clkdev_add(&c->lk);
+			ti_clk_node_add(&c->lk);
 			if (!__clk_init(NULL, c->lk.clk))
 				omap2_init_clk_hw_omap_clocks(c->lk.clk);
 		}

AFAIK no need to tinkering with the clockxxxx_data.c files.

Quoted 15 lines
drivers/clk/ti.c new file +12 -0
@@ -0,0 +1,100 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *	Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty

drivers/clk/ti.c line 22

Quoted 10 lines
drivers/clk/ti.c new file +10 -0
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>

Then this can be just a minimal DT device driver that initially just calls clk_add_alias() so the right clock is found when the driver does clk_get(). Probably should be drivers/clock/omap/clk.c.

Regards,

Tony

#27 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Nishanth Menon

Quoting Nishanth Menon (2013-04-09 13:49:00)

Quoted 25 lines · Tony Lindgren
Quoted 24 lines · Tony Lindgren
Quoted 8 lines · Roger Quadros
Quoted 7 lines · Tony Lindgren
Quoted 2 lines

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Quoted 7 lines
Quoted 2 lines

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034

Regards,
Mike

Quoted 312 lines

Here is an attempt on beagleXM - adds every clock node to the list. Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr

Would an cleaned up version be good enough as a step #1 of transition?

From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [PATCH] OMAP: add devicetree support for clock nodes.

Dummy patch based on Roger's original idea

---
 arch/arm/boot/dts/omap3.dtsi          |    5 ++
 arch/arm/boot/dts/omap34xx.dtsi       |    2 +
 arch/arm/mach-omap2/cclock3xxx_data.c |    3 +-
 arch/arm/mach-omap2/cclock44xx_data.c |    3 +-
 arch/arm/mach-omap2/pm.c              |   11 +++-
 drivers/clk/Kconfig                   |    6 ++
 drivers/clk/Makefile                  |    2 +
 drivers/clk/ti.c                      |  100 +++++++++++++++++++++++++++++++++
 include/linux/clk/ti.h                |   30 ++++++++++
 9 files changed, 157 insertions(+), 5 deletions(-)
 create mode 100644 drivers/clk/ti.c
 create mode 100644 include/linux/clk/ti.h
arch/arm/boot/dts/omap3.dtsi +5 -0
index 3344f05..a08990d 100644
@@ -73,6 +73,11 @@
                        ti,hwmods = "counter_32k";
                };
 
+               clks: clocks {
+                       compatible = "ti,clock";
+                       #clock-cells = <1>;
+               };
+
                intc: interrupt-controller at 48200000 {
                        compatible = "ti,omap2-intc";
                        interrupt-controller;
arch/arm/boot/dts/omap34xx.dtsi +2 -0
index 75ed4ae..93c2621 100644
@@ -23,6 +23,8 @@
                                600000  1350000
                        >;
                        clock-latency = <300000>; /* From legacy driver */
+                       clocks = <&clks 249>; /* index to cpufreq_ck */
+                       clock-names = "cpu";
                };
        };
 };
arch/arm/mach-omap2/cclock3xxx_data.c +2 -1
index 4579c3c..d5d5ef5 100644
@@ -22,6 +22,7 @@
 #include <linux/clk-private.h>
 #include <linux/list.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
        for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
             c++)
                if (c->cpu & cpu_clkflg) {
-                       clkdev_add(&c->lk);
+                       ti_clk_node_add(&c->lk);
                        if (!__clk_init(NULL, c->lk.clk))
                                omap2_init_clk_hw_omap_clocks(c->lk.clk);
                }
arch/arm/mach-omap2/cclock44xx_data.c +2 -1
index 0c6834a..338ef64 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
        for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
                                                                        c++) {
                if (c->cpu & cpu_clkflg) {
-                       clkdev_add(&c->lk);
+                       ti_clk_node_add(&c->lk);
                        if (!__clk_init(NULL, c->lk.clk))
                                omap2_init_clk_hw_omap_clocks(c->lk.clk);
                }
arch/arm/mach-omap2/pm.c +8 -3
index 8d15f9a..6cf95160 100644
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
 
 static inline void omap_init_cpufreq(void)
 {
-       struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+       struct platform_device_info devinfo = { };
+
+       if (!of_have_populated_dt())
+               devinfo.name = "omap-cpufreq";
+       else
+               devinfo.name = "cpufreq-cpu0";
        platform_device_register_full(&devinfo);
 }
 
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
                /* Smartreflex device init */
                omap_devinit_smartreflex();
 
-               /* cpufreq dummy device instantiation */
-               omap_init_cpufreq();
        }
+       /* cpufreq dummy device instantiation */
+       omap_init_cpufreq();
 
 #ifdef CONFIG_SUSPEND
        suspend_set_ops(&omap_pm_ops);
drivers/clk/Kconfig +6 -0
index a47e6ee..03c6e48 100644
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
        ---help---
          This driver supports Maxim 77686 crystal oscillator clock. 
 
+config COMMON_CLK_TI
+       tristate "Clock driver for TI SoCs"
+       depends on ARCH_OMAP && OF
+       ---help---
+         Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
 config CLK_TWL6040
        tristate "External McPDM functional clock from twl6040"
        depends on TWL6040_CORE
drivers/clk/Makefile +2 -0
index 300d477..9621815 100644
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA)      += tegra/
 
 obj-$(CONFIG_X86)              += x86/
 
+obj-$(CONFIG_COMMON_CLK_TI)    += ti.o
+
 # Chip specific
 obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
drivers/clk/ti.c new file +100 -0
new file mode 100644
index 0000000..c747381
@@ -0,0 +1,100 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *     Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>
+
+struct ti_clk {
+       struct clk_lookup *lk;
+       struct list_head node;
+};
+
+static LIST_HEAD(ti_clk_list);
+
+static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
+                                            void *data)
+{
+       struct ti_clk *c;
+#if 0
+       /* Eww.. IF ONLY phandle arguments could be string */
+       char clk_name[32]; /* 32 is max size of property name */
+
+       char *name = clkspec->args[0];
+
+       snprintf(clk_name, 32, "%s_ck", name);
+       list_for_each_entry(c, &ti_clk_list, node) {
+               int r = strncmp(c->lk->conn_id, clk_name, 32);
+               pr_err("%s: searching %s in %s - %d\n",
+                       __func__, clk_name, c->lk->con_id, r);
+               if (!r) {
+                       pr_err("%s: found it!\n", __func__);
+                       return c->lk.clk;
+               }
+       }
+#else
+       /* Use integer indexing into clkdev list! Sigh.. */
+       int idx = clkspec->args[0];
+       int cindex = 1;
+
+       list_for_each_entry(c, &ti_clk_list, node) {
+               int r = (idx == cindex) ? 0 :  1;
+               pr_err("%s: searching index search = %d in %d in %s - %d\n",
+                       __func__, idx, cindex, c->lk->con_id, r);
+               if (!r) {
+                       pr_err("%s: found it!\n", __func__);
+                       return c->lk->clk;
+               }
+               cindex++;
+       }
+#endif
+
+       pr_err("%s: ran out of options\n", __func__);
+       return ERR_PTR(-ENODEV);
+}
+
+static void __init ti_clock_init(struct device_node *node)
+{
+
+       pr_err("%s: START\n", __func__);
+       of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
+       pr_err("%s: END\n", __func__);
+}
+CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
+
+void __init ti_clk_node_add(struct clk_lookup *lk)
+{
+       struct ti_clk *c;
+       static bool of_added;
+
+       c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
+       if (!c) {
+               pr_err("%s: No memory!! cannot add clk node!\n", __func__);
+               return;
+       }
+       clkdev_add(lk);
+       c->lk = lk;
+       list_add_tail(&c->node, &ti_clk_list);
+       pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
+       if (!of_added) {
+               of_clk_init(NULL);
+               of_added =  true;
+       }
+};
+
include/linux/clk/ti.h new file +30 -0
new file mode 100644
index 0000000..eb502a8
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *     Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk)
+{
+       clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif /* __TI_CLK_H */
Signature · 10 lines
1.7.9.5


-- 
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#28 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 28 lines · Mike Turquette

Quoting Nishanth Menon (2013-04-09 13:49:00)

Quoted 27 lines · Tony Lindgren
Quoted 26 lines · Tony Lindgren
Quoted 8 lines · Roger Quadros
Quoted 7 lines · Tony Lindgren
Quoted 2 lines

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

Quoted 8 lines
Quoted 5 lines

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034

Awesome. Thanks for pointing this out Mike.

Now all we need to do is create a named define for each clock index in the header file.

cheers,
-roger

Quoted 313 lines
Quoted 313 lines

Here is an attempt on beagleXM - adds every clock node to the list. Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr

Would an cleaned up version be good enough as a step #1 of transition?

From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [PATCH] OMAP: add devicetree support for clock nodes.

Dummy patch based on Roger's original idea

---
 arch/arm/boot/dts/omap3.dtsi          |    5 ++
 arch/arm/boot/dts/omap34xx.dtsi       |    2 +
 arch/arm/mach-omap2/cclock3xxx_data.c |    3 +-
 arch/arm/mach-omap2/cclock44xx_data.c |    3 +-
 arch/arm/mach-omap2/pm.c              |   11 +++-
 drivers/clk/Kconfig                   |    6 ++
 drivers/clk/Makefile                  |    2 +
 drivers/clk/ti.c                      |  100 +++++++++++++++++++++++++++++++++
 include/linux/clk/ti.h                |   30 ++++++++++
 9 files changed, 157 insertions(+), 5 deletions(-)
 create mode 100644 drivers/clk/ti.c
 create mode 100644 include/linux/clk/ti.h
arch/arm/boot/dts/omap3.dtsi +5 -0
index 3344f05..a08990d 100644
@@ -73,6 +73,11 @@
                        ti,hwmods = "counter_32k";
                };
 
+               clks: clocks {
+                       compatible = "ti,clock";
+                       #clock-cells = <1>;
+               };
+
                intc: interrupt-controller at 48200000 {
                        compatible = "ti,omap2-intc";
                        interrupt-controller;
arch/arm/boot/dts/omap34xx.dtsi +2 -0
index 75ed4ae..93c2621 100644
@@ -23,6 +23,8 @@
                                600000  1350000
                        >;
                        clock-latency = <300000>; /* From legacy driver */
+                       clocks = <&clks 249>; /* index to cpufreq_ck */
+                       clock-names = "cpu";
                };
        };
 };
arch/arm/mach-omap2/cclock3xxx_data.c +2 -1
index 4579c3c..d5d5ef5 100644
@@ -22,6 +22,7 @@
 #include <linux/clk-private.h>
 #include <linux/list.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
        for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
             c++)
                if (c->cpu & cpu_clkflg) {
-                       clkdev_add(&c->lk);
+                       ti_clk_node_add(&c->lk);
                        if (!__clk_init(NULL, c->lk.clk))
                                omap2_init_clk_hw_omap_clocks(c->lk.clk);
                }
arch/arm/mach-omap2/cclock44xx_data.c +2 -1
index 0c6834a..338ef64 100644
@@ -27,6 +27,7 @@
 #include <linux/clk-private.h>
 #include <linux/clkdev.h>
 #include <linux/io.h>
+#include <linux/clk/ti.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
        for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
                                                                        c++) {
                if (c->cpu & cpu_clkflg) {
-                       clkdev_add(&c->lk);
+                       ti_clk_node_add(&c->lk);
                        if (!__clk_init(NULL, c->lk.clk))
                                omap2_init_clk_hw_omap_clocks(c->lk.clk);
                }
arch/arm/mach-omap2/pm.c +8 -3
index 8d15f9a..6cf95160 100644
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
 
 static inline void omap_init_cpufreq(void)
 {
-       struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+       struct platform_device_info devinfo = { };
+
+       if (!of_have_populated_dt())
+               devinfo.name = "omap-cpufreq";
+       else
+               devinfo.name = "cpufreq-cpu0";
        platform_device_register_full(&devinfo);
 }
 
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
                /* Smartreflex device init */
                omap_devinit_smartreflex();
 
-               /* cpufreq dummy device instantiation */
-               omap_init_cpufreq();
        }
+       /* cpufreq dummy device instantiation */
+       omap_init_cpufreq();
 
 #ifdef CONFIG_SUSPEND
        suspend_set_ops(&omap_pm_ops);
drivers/clk/Kconfig +6 -0
index a47e6ee..03c6e48 100644
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
        ---help---
          This driver supports Maxim 77686 crystal oscillator clock. 
 
+config COMMON_CLK_TI
+       tristate "Clock driver for TI SoCs"
+       depends on ARCH_OMAP && OF
+       ---help---
+         Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
 config CLK_TWL6040
        tristate "External McPDM functional clock from twl6040"
        depends on TWL6040_CORE
drivers/clk/Makefile +2 -0
index 300d477..9621815 100644
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA)      += tegra/
 
 obj-$(CONFIG_X86)              += x86/
 
+obj-$(CONFIG_COMMON_CLK_TI)    += ti.o
+
 # Chip specific
 obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
drivers/clk/ti.c new file +100 -0
new file mode 100644
index 0000000..c747381
@@ -0,0 +1,100 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *     Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>
+
+struct ti_clk {
+       struct clk_lookup *lk;
+       struct list_head node;
+};
+
+static LIST_HEAD(ti_clk_list);
+
+static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
+                                            void *data)
+{
+       struct ti_clk *c;
+#if 0
+       /* Eww.. IF ONLY phandle arguments could be string */
+       char clk_name[32]; /* 32 is max size of property name */
+
+       char *name = clkspec->args[0];
+
+       snprintf(clk_name, 32, "%s_ck", name);
+       list_for_each_entry(c, &ti_clk_list, node) {
+               int r = strncmp(c->lk->conn_id, clk_name, 32);
+               pr_err("%s: searching %s in %s - %d\n",
+                       __func__, clk_name, c->lk->con_id, r);
+               if (!r) {
+                       pr_err("%s: found it!\n", __func__);
+                       return c->lk.clk;
+               }
+       }
+#else
+       /* Use integer indexing into clkdev list! Sigh.. */
+       int idx = clkspec->args[0];
+       int cindex = 1;
+
+       list_for_each_entry(c, &ti_clk_list, node) {
+               int r = (idx == cindex) ? 0 :  1;
+               pr_err("%s: searching index search = %d in %d in %s - %d\n",
+                       __func__, idx, cindex, c->lk->con_id, r);
+               if (!r) {
+                       pr_err("%s: found it!\n", __func__);
+                       return c->lk->clk;
+               }
+               cindex++;
+       }
+#endif
+
+       pr_err("%s: ran out of options\n", __func__);
+       return ERR_PTR(-ENODEV);
+}
+
+static void __init ti_clock_init(struct device_node *node)
+{
+
+       pr_err("%s: START\n", __func__);
+       of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
+       pr_err("%s: END\n", __func__);
+}
+CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
+
+void __init ti_clk_node_add(struct clk_lookup *lk)
+{
+       struct ti_clk *c;
+       static bool of_added;
+
+       c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
+       if (!c) {
+               pr_err("%s: No memory!! cannot add clk node!\n", __func__);
+               return;
+       }
+       clkdev_add(lk);
+       c->lk = lk;
+       list_add_tail(&c->node, &ti_clk_list);
+       pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
+       if (!of_added) {
+               of_clk_init(NULL);
+               of_added =  true;
+       }
+};
+
include/linux/clk/ti.h new file +30 -0
new file mode 100644
index 0000000..eb502a8
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *     Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk)
+{
+       clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif /* __TI_CLK_H */
Signature · 10 lines
1.7.9.5


-- 
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#29 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 35 lines · Roger Quadros
Quoted 34 lines · Mike Turquette

Quoting Nishanth Menon (2013-04-09 13:49:00)

Quoted 32 lines · Tony Lindgren
Quoted 20 lines · Tony Lindgren
Quoted 8 lines · Roger Quadros
Quoted 7 lines · Tony Lindgren
Quoted 2 lines

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

Quoted 6 lines

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

Quoted 7 lines
Quoted 2 lines

See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034

Awesome. Thanks for pointing this out Mike.

Now all we need to do is create a named define for each clock index in the header file.

Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing this.
Details in the patch below (Tony, I have added you as collaborator for helping in getting this working-clk_add_alias was'nt needed in the internal patch discussion we had - I have taken a bit of freedom in adding your contributions to the patch below)

Folks, this does seem to be the best compromise we can achieve at this point in time. feedback on this approach is much appreciated - if folks are ok, I can post this as an formal patch series.

Quoted 1 line

From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001

From: Nishanth Menon <[email protected]>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data

OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c. However, this presents an obstacle for using these clock nodes in Device Tree definitions. There are many possible approaches to this problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required. This is similar in approach taken by tegra and few other platforms. example clock = <&clk 5>;
cons: potential to have mismatches in indexed table and associated dtb data. In addition, managing continued documentation in bindings as clock indexing increases. Even though readability angle could be improved by using preprocessing of DT using macros, indexed approach is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses <&clk 2>, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has updated indices will result in per_dpll now controlled for peripheral X without warning or any potential error detection and warning.

Even though we can claim this is user error, such errors are hard to track down and fix.

An alternate approach introduced here is to introduce device tree bindings corresponding to the clock nodes required in DT definition for SoC which automatically maps back to the definitions in cclockXYZ_data.c.

The driver introduced here to do this mapping will eventually be the place where the clock handling will migrate to. We need to consider this angle as well so that the solution will be an valid transition point for moving the clock data out of kernel image (into device tree or firmware load etc..).

Overall strategy introduced here is simple: an clock node described in device tree blob is used to identify the exact clock provided in the SoC specific data. This is then linked back using of_clk_add_provider to the device node to be accessible by of_clk_get.

Based on discussion contributions from Roger Quadros, Grygorii Strashko and others.

[tony at atomide.com: co-developed]
---
 .../devicetree/bindings/clock/omap-clock.txt       |   40 +++++++++
 drivers/clk/Makefile                               |    1 +
 drivers/clk/omap/Makefile                          |    1 +
 drivers/clk/omap/clk.c                             |   94 ++++++++++++++++++++
 4 files changed, 136 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
 create mode 100644 drivers/clk/omap/Makefile
 create mode 100644 drivers/clk/omap/clk.c
Documentation/devicetree/bindings/clock/omap-clock.txt new file +40 -0
new file mode 100644
index 0000000..07e3ff8
@@ -0,0 +1,40 @@
+Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
+
+This binding is a work-in-progress, and meant to be stage #1 of transitioning
+OMAP clock data out of kernel image.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be "ti,omap-clock"
+- #clock-cells : from common clock binding; shall be set to 0.
+NOTE:
+node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
+Since all clocks are described with _ck, the node name is optimized to drop the
+usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
+
+Example #1: describing clock node for CPU on OMAP34xx platform:
+Ref: arch/arm/mach-omap2/cclock3xxx_data.c
+describes the CPU clock to be as follows
+	CLK(NULL,	"dpll1_ck",	&dpll1_ck,	CK_3XXX),
+Corresponding binding will be:
+	dpll1: dpll1 {
+		#clock-cells = <0>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+		clocks = <&dpll1>;
+
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+	CLK(NULL,	"auxclk3_ck",	&auxclk3_ck,	CK_443X),
+Corresponding binding will be:
+	auxclk3: auxclk3 {
+		#clock-cells = <1>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+	clocks = <&auxclk3>;
drivers/clk/Makefile +1 -0
index 300d477..a0209d7 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500)	+= ux500/
 obj-$(CONFIG_ARCH_VT8500)	+= clk-vt8500.o
 obj-$(CONFIG_ARCH_ZYNQ)		+= clk-zynq.o
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
+obj-$(CONFIG_ARCH_OMAP)		+= omap/
 
 obj-$(CONFIG_X86)		+= x86/
 
drivers/clk/omap/Makefile new file +1 -0
new file mode 100644
index 0000000..8195931
@@ -0,0 +1 @@
+obj-y					+= clk.o
drivers/clk/omap/clk.c new file +94 -0

94 lines not on this page · raw message

Signature · 5 lines
1.7.9.5

-- 
Regards,
Nishanth Menon
maintainer
#30 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 4 lines · Nishanth Menon

Details in the patch below (Tony, I have added you as collaborator for helping in getting this working-clk_add_alias was'nt needed in the internal patch discussion we had - I have taken a bit of freedom in adding your contributions to the patch below)

OK thanks. Noticed few minor things, see below.

Quoted 10 lines

Folks, this does seem to be the best compromise we can achieve at this point in time. feedback on this approach is much appreciated - if folks are ok, I can post this as an formal patch series.

From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data

Quoted 5 lines

OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c. However, this presents an obstacle for using these clock nodes in Device Tree definitions. There are many possible approaches to this problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2

It might be worth clarifying that this is especially for the board specific clocks initially. The fixed clocks are currently found via the clock aliases table.

Quoted 64 lines

Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required. This is similar in approach taken by tegra and few other platforms. example clock = <&clk 5>;
cons: potential to have mismatches in indexed table and associated dtb data. In addition, managing continued documentation in bindings as clock indexing increases. Even though readability angle could be improved by using preprocessing of DT using macros, indexed approach is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses <&clk 2>, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has updated indices will result in per_dpll now controlled for peripheral X without warning or any potential error detection and warning.

Even though we can claim this is user error, such errors are hard to track down and fix.

An alternate approach introduced here is to introduce device tree bindings corresponding to the clock nodes required in DT definition for SoC which automatically maps back to the definitions in cclockXYZ_data.c.

The driver introduced here to do this mapping will eventually be the place where the clock handling will migrate to. We need to consider this angle as well so that the solution will be an valid transition point for moving the clock data out of kernel image (into device tree or firmware load etc..).

Overall strategy introduced here is simple: an clock node described in device tree blob is used to identify the exact clock provided in the SoC specific data. This is then linked back using of_clk_add_provider to the device node to be accessible by of_clk_get.

Based on discussion contributions from Roger Quadros, Grygorii Strashko and others.

[tony at atomide.com: co-developed]
---
 .../devicetree/bindings/clock/omap-clock.txt       |   40 +++++++++
 drivers/clk/Makefile                               |    1 +
 drivers/clk/omap/Makefile                          |    1 +
 drivers/clk/omap/clk.c                             |   94 ++++++++++++++++++++
 4 files changed, 136 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
 create mode 100644 drivers/clk/omap/Makefile
 create mode 100644 drivers/clk/omap/clk.c
Documentation/devicetree/bindings/clock/omap-clock.txt new file +0 -0
new file mode 100644
index 0000000..07e3ff8

Documentation/devicetree/bindings/clock/omap-clock.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/clock/omap-clock.txt new file +4 -0
@@ -0,0 +1,40 @@
+Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
+
+This binding is a work-in-progress, and meant to be stage #1 of transitioning
+OMAP clock data out of kernel image.

As it's using the common clock binding, this will be supported in the long run too. So maybe replace work-in-progress with initial minimal binding that can be enhanced later on.

Quoted 25 lines
Documentation/devicetree/bindings/clock/omap-clock.txt new file +25 -0
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be "ti,omap-clock"
+- #clock-cells : from common clock binding; shall be set to 0.
+NOTE:
+node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
+Since all clocks are described with _ck, the node name is optimized to drop the
+usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
+
+Example #1: describing clock node for CPU on OMAP34xx platform:
+Ref: arch/arm/mach-omap2/cclock3xxx_data.c
+describes the CPU clock to be as follows
+	CLK(NULL,	"dpll1_ck",	&dpll1_ck,	CK_3XXX),
+Corresponding binding will be:
+	dpll1: dpll1 {
+		#clock-cells = <0>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+		clocks = <&dpll1>;
+
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:

Documentation/devicetree/bindings/clock/omap-clock.txt line 40

Quoted 10 lines
Documentation/devicetree/bindings/clock/omap-clock.txt new file +10 -0
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+	CLK(NULL,	"auxclk3_ck",	&auxclk3_ck,	CK_443X),
+Corresponding binding will be:
+	auxclk3: auxclk3 {
+		#clock-cells = <1>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+	clocks = <&auxclk3>;

The #clock-cells in the auxclk3 example should also be 0 instead of 1 AFAIK. We should only use #clock-cells = <1> when the same physical clock provides multiple outputs. I believe the auxclocks are all separate, but that needs to be verified.

Quoted 75 lines
drivers/clk/Makefile +1 -0
index 300d477..a0209d7 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500)	+= ux500/
 obj-$(CONFIG_ARCH_VT8500)	+= clk-vt8500.o
 obj-$(CONFIG_ARCH_ZYNQ)		+= clk-zynq.o
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
+obj-$(CONFIG_ARCH_OMAP)		+= omap/
 
 obj-$(CONFIG_X86)		+= x86/
 
drivers/clk/omap/Makefile new file +1 -0
new file mode 100644
index 0000000..8195931
@@ -0,0 +1 @@
+obj-y					+= clk.o
drivers/clk/omap/clk.c new file +50 -0
new file mode 100644
index 0000000..63a4cce
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *	Nishanth Menon
+ *	Tony Lindgren <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clkdev.h>
+#include <linux/clk-private.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
+
+static const struct of_device_id omap_clk_of_match[] = {
+	{.compatible = "ti,omap-clock",},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, omap_clk_of_match);
+
+/**
+ * omap_clk_probe() - create link from DT definition to clock data
+ * @pdev:	device node
+ *
+ * REVISIT: We are now assuming the following:
+ * 1. omap clock names end with _ck
+ * 2. omap clocks don't get removed
+ */
+static int omap_clk_probe(struct platform_device *pdev)
+{
+	struct clk *clk;
+	int res;
+
+	const struct of_device_id *match;
+	struct device_node *np = pdev->dev.of_node;
+	char clk_name[32];
+
+	match = of_match_device(omap_clk_of_match, &pdev->dev);

drivers/clk/omap/clk.c line 60

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+
+	/* Set up things so consumer can call clk_get() with name */
+	snprintf(clk_name, 32, "%s_ck", np->name);
+	clk = clk_get(NULL, clk_name);
+	if (IS_ERR(clk)) {
+		res = PTR_ERR(clk);
+		dev_err(&pdev->dev, "could not get clock %s (%d)\n",
+			clk_name, res);
+		goto out;
+	}

It seems that at least for now we can assume the naming will stay that way, then if we need other rules for finding clocks, we can add omap_match_clock() function or something.

drivers/clk/omap/clk.c line 71

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+	/* This allows the driver to of_clk_get() */
+	res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
+	if (res)
+		dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
+			clk_name, res);
+
+	clk_put(clk);
+out:
+	return res;
+}

We can avoid the concern of storing the struct clk * and do the look up lazily on consumer driver probe by setting a dummy struct clk * here. Then replace of_clk_src_simple_get() with a custom omap_clk_src_get() that does the lookup and replaces the struct clk * with the real one.

Quoted 12 lines
drivers/clk/omap/clk.c new file +12 -0
+MODULE_ALIAS("platform:omap_clk");
+
+/* We assume here that OMAP clocks will not be removed */
+static struct platform_driver omap_clk_driver = {
+	.probe = omap_clk_probe,
+	.driver = {
+		   .name = "omap_clk",
+		   .owner = THIS_MODULE,
+		   .of_match_table = of_match_ptr(omap_clk_of_match),
+		   },
+};
+

drivers/clk/omap/clk.c line 94

Quoted 10 lines
drivers/clk/omap/clk.c new file +9 -0
+static int __init omap_clk_init(void)
+{
+	return platform_driver_register(&omap_clk_driver);
+}
+
+arch_initcall(omap_clk_init);
 
+MODULE_DESCRIPTION("OMAP Clock driver");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_LICENSE("GPL v2");

Regards,

Tony

#31 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Hi Tony,

Quoted 7 lines · Tony Lindgren
Quoted 4 lines · Nishanth Menon

Details in the patch below (Tony, I have added you as collaborator for helping in getting this working-clk_add_alias was'nt needed in the internal patch discussion we had - I have taken a bit of freedom in adding your contributions to the patch below)

OK thanks. Noticed few minor things, see below.

Thanks on the checkup

Quoted 17 lines
Quoted 11 lines

Folks, this does seem to be the best compromise we can achieve at this point in time. feedback on this approach is much appreciated - if folks are ok, I can post this as an formal patch series.

From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data

Quoted 5 lines

OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c. However, this presents an obstacle for using these clock nodes in Device Tree definitions. There are many possible approaches to this problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2

Quoted 3 lines

It might be worth clarifying that this is especially for the board specific clocks initially. The fixed clocks are currently found via the clock aliases table.

Ack.
[...]

Quoted 17 lines

Documentation/devicetree/bindings/clock/omap-clock.txt line 40

Quoted 12 lines
Documentation/devicetree/bindings/clock/omap-clock.txt new file +11 -0
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+     CLK(NULL,       "auxclk3_ck",   &auxclk3_ck,    CK_443X),
+Corresponding binding will be:
+     auxclk3: auxclk3 {
+             #clock-cells = <1>;
+             compatible = "ti,omap-clock";
+     };
+And it's usage will be:
+     clocks = <&auxclk3>;

The #clock-cells in the auxclk3 example should also be 0 instead of 1 AFAIK. We should only use #clock-cells = <1> when the same physical clock provides multiple outputs. I believe the auxclocks are all separate, but that needs to be verified.

Oops.. my bad. you are correct here - auxclk is single output. all of them. will fix.
[...]

Quoted 16 lines
Quoted 16 lines
drivers/clk/omap/clk.c new file +16 -0
+static int omap_clk_probe(struct platform_device *pdev)
+{
+     struct clk *clk;
+     int res;
+
+     const struct of_device_id *match;
+     struct device_node *np = pdev->dev.of_node;
+     char clk_name[32];
+
+     match = of_match_device(omap_clk_of_match, &pdev->dev);
+
+     /* Set up things so consumer can call clk_get() with name */
+     snprintf(clk_name, 32, "%s_ck", np->name);
+     clk = clk_get(NULL, clk_name);
+     if (IS_ERR(clk)) {
+             res = PTR_ERR(clk);
Quoted 8 lines

drivers/clk/omap/clk.c line 60

Quoted 4 lines
drivers/clk/omap/clk.c new file +4 -0
+             dev_err(&pdev->dev, "could not get clock %s (%d)\n",
+                     clk_name, res);
+             goto out;
+     }

It seems that at least for now we can assume the naming will stay that way, then if we need other rules for finding clocks, we can add omap_match_clock() function or something.

ack.

Quoted 17 lines

drivers/clk/omap/clk.c line 71

Quoted 11 lines
drivers/clk/omap/clk.c new file +10 -0
+     /* This allows the driver to of_clk_get() */
+     res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
+     if (res)
+             dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
+                     clk_name, res);
+
+     clk_put(clk);
+out:
+     return res;
+}

We can avoid the concern of storing the struct clk * and do the look up lazily on consumer driver probe by setting a dummy struct clk * here. Then replace of_clk_src_simple_get() with a custom omap_clk_src_get() that does the lookup and replaces the struct clk * with the real one.

Hmm.. this is interesting. will give it a try. Thanks on the suggestion.

Regards,
Nishanth Menon

maintainer
#32 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 8 lines · Nishanth Menon
Quoted 6 lines · Tony Lindgren

We can avoid the concern of storing the struct clk * and do the look up lazily on consumer driver probe by setting a dummy struct clk * here. Then replace of_clk_src_simple_get() with a custom omap_clk_src_get() that does the lookup and replaces the struct clk * with the real one.

Hmm.. this is interesting. will give it a try. Thanks on the suggestion.

Setting the struct clk * to NULL initially might work too, but that needs to be checked.

Regards,

Tony

#33 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Nishanth Menon
Quoted 54 lines · Nishanth Menon
Quoted 35 lines · Roger Quadros
Quoted 34 lines · Mike Turquette

Quoting Nishanth Menon (2013-04-09 13:49:00)

Quoted 32 lines · Tony Lindgren
Quoted 20 lines · Tony Lindgren
Quoted 8 lines · Roger Quadros
Quoted 7 lines · Tony Lindgren
Quoted 2 lines

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 7 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

Quoted 6 lines

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

Quoted 7 lines
Quoted 2 lines

See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034

Awesome. Thanks for pointing this out Mike.

Now all we need to do is create a named define for each clock index in the header file.

Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing this.
Details in the patch below (Tony, I have added you as collaborator for helping in getting this working-clk_add_alias was'nt needed in the internal patch discussion we had - I have taken a bit of freedom in adding your contributions to the patch below)

Quoted 3 lines

Folks, this does seem to be the best compromise we can achieve at this point in time. feedback on this approach is much appreciated - if folks are ok, I can post this as an formal patch series.

This looks fine to me. Minor comments below.

Quoted 43 lines

From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data

OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c. However, this presents an obstacle for using these clock nodes in Device Tree definitions. There are many possible approaches to this problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required. This is similar in approach taken by tegra and few other platforms. example clock = <&clk 5>;
cons: potential to have mismatches in indexed table and associated dtb data. In addition, managing continued documentation in bindings as clock indexing increases. Even though readability angle could be improved by using preprocessing of DT using macros, indexed approach is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses <&clk 2>, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has updated indices will result in per_dpll now controlled for peripheral X without warning or any potential error detection and warning.

Even though we can claim this is user error, such errors are hard to track down and fix.

An alternate approach introduced here is to introduce device tree bindings corresponding to the clock nodes required in DT definition for SoC which automatically maps back to the definitions in cclockXYZ_data.c.

Quoted 7 lines

The driver introduced here to do this mapping will eventually be the place where the clock handling will migrate to. We need to consider this angle as well so that the solution will be an valid transition point for moving the clock data out of kernel image (into device tree or firmware load etc..).

Overall strategy introduced here is simple: an clock node described in

typo: "an"->"a"

Quoted 91 lines

device tree blob is used to identify the exact clock provided in the SoC specific data. This is then linked back using of_clk_add_provider to the device node to be accessible by of_clk_get.

Based on discussion contributions from Roger Quadros, Grygorii Strashko and others.

[tony at atomide.com: co-developed]
---
 .../devicetree/bindings/clock/omap-clock.txt       |   40 +++++++++
 drivers/clk/Makefile                               |    1 +
 drivers/clk/omap/Makefile                          |    1 +
 drivers/clk/omap/clk.c                             |   94 ++++++++++++++++++++
 4 files changed, 136 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
 create mode 100644 drivers/clk/omap/Makefile
 create mode 100644 drivers/clk/omap/clk.c
Documentation/devicetree/bindings/clock/omap-clock.txt new file +40 -0
new file mode 100644
index 0000000..07e3ff8
@@ -0,0 +1,40 @@
+Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
+
+This binding is a work-in-progress, and meant to be stage #1 of transitioning
+OMAP clock data out of kernel image.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be "ti,omap-clock"
+- #clock-cells : from common clock binding; shall be set to 0.
+NOTE:
+node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
+Since all clocks are described with _ck, the node name is optimized to drop the
+usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
+
+Example #1: describing clock node for CPU on OMAP34xx platform:
+Ref: arch/arm/mach-omap2/cclock3xxx_data.c
+describes the CPU clock to be as follows
+	CLK(NULL,	"dpll1_ck",	&dpll1_ck,	CK_3XXX),
+Corresponding binding will be:
+	dpll1: dpll1 {
+		#clock-cells = <0>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+		clocks = <&dpll1>;
+
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+	CLK(NULL,	"auxclk3_ck",	&auxclk3_ck,	CK_443X),
+Corresponding binding will be:
+	auxclk3: auxclk3 {
+		#clock-cells = <1>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+	clocks = <&auxclk3>;
drivers/clk/Makefile +1 -0
index 300d477..a0209d7 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500)	+= ux500/
 obj-$(CONFIG_ARCH_VT8500)	+= clk-vt8500.o
 obj-$(CONFIG_ARCH_ZYNQ)		+= clk-zynq.o
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
+obj-$(CONFIG_ARCH_OMAP)		+= omap/
 
 obj-$(CONFIG_X86)		+= x86/
 
drivers/clk/omap/Makefile new file +1 -0
new file mode 100644
index 0000000..8195931
@@ -0,0 +1 @@
+obj-y					+= clk.o
drivers/clk/omap/clk.c new file +0 -0
new file mode 100644
index 0000000..63a4cce

drivers/clk/omap/clk.c line 5

Quoted 5 lines
drivers/clk/omap/clk.c new file +5 -0
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *	Nishanth Menon

missing e-mail id.

Quoted 17 lines
drivers/clk/omap/clk.c new file +17 -0
+ *	Tony Lindgren <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clkdev.h>
+#include <linux/clk-private.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_device.h>

drivers/clk/omap/clk.c line 32

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+#include <linux/platform_device.h>
+#include <linux/string.h>
+
+static const struct of_device_id omap_clk_of_match[] = {
+	{.compatible = "ti,omap-clock",},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, omap_clk_of_match);
+

Is this driver ever going to be a loadable module? If not then you don't need this.

Quoted 31 lines
drivers/clk/omap/clk.c new file +31 -0
+/**
+ * omap_clk_probe() - create link from DT definition to clock data
+ * @pdev:	device node
+ *
+ * REVISIT: We are now assuming the following:
+ * 1. omap clock names end with _ck
+ * 2. omap clocks don't get removed
+ */
+static int omap_clk_probe(struct platform_device *pdev)
+{
+	struct clk *clk;
+	int res;
+
+	const struct of_device_id *match;
+	struct device_node *np = pdev->dev.of_node;
+	char clk_name[32];
+
+	match = of_match_device(omap_clk_of_match, &pdev->dev);
+
+	/* Set up things so consumer can call clk_get() with name */
+	snprintf(clk_name, 32, "%s_ck", np->name);
+	clk = clk_get(NULL, clk_name);
+	if (IS_ERR(clk)) {
+		res = PTR_ERR(clk);
+		dev_err(&pdev->dev, "could not get clock %s (%d)\n",
+			clk_name, res);
+		goto out;
+	}
+
+	/* This allows the driver to of_clk_get() */
+	res = of_clk_add_provider(np, of_clk_src_simple_get, clk);

drivers/clk/omap/clk.c line 73

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+	if (res)
+		dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
+			clk_name, res);
+
+	clk_put(clk);
+out:
+	return res;
+}
+
+MODULE_ALIAS("platform:omap_clk");

ditto.

drivers/clk/omap/clk.c line 80

Quoted 7 lines
drivers/clk/omap/clk.c new file +7 -0
+
+/* We assume here that OMAP clocks will not be removed */
+static struct platform_driver omap_clk_driver = {
+	.probe = omap_clk_probe,
+	.driver = {
+		   .name = "omap_clk",
+		   .owner = THIS_MODULE,

same here.

Quoted 5 lines
drivers/clk/omap/clk.c new file +4 -0
+		   .of_match_table = of_match_ptr(omap_clk_of_match),
+		   },
+};
+

drivers/clk/omap/clk.c line 94

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+static int __init omap_clk_init(void)
+{
+	return platform_driver_register(&omap_clk_driver);
+}
+
+arch_initcall(omap_clk_init);
+
+MODULE_DESCRIPTION("OMAP Clock driver");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_LICENSE("GPL v2");

cheers,
-roger

#34 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 49 lines · Roger Quadros
Quoted 48 lines · Nishanth Menon
Quoted 30 lines · Roger Quadros
Quoted 29 lines · Mike Turquette

Quoting Nishanth Menon (2013-04-09 13:49:00)

Quoted 28 lines · Tony Lindgren
Quoted 16 lines · Tony Lindgren
Quoted 6 lines · Roger Quadros
Quoted 5 lines · Tony Lindgren
Quoted 1 line

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get a phandle or an index to the clock.

Quoted 6 lines
Quoted 1 line

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just remap the DT device initially so the board specific clock is found from the clock alias table. Basically initially a passthrough driver that can be enhanced to parse DT clock bindings and load data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less initially. There probably even no need to remap clocks there.

Quoted 6 lines

As long as the DT clock driver understands that a board specific auxclk is specified in the DT it can just call clk_add_alias() so the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes. unfortunately, device tree wont let me have arguments of strings :( So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;

Quoted 6 lines
Quoted 2 lines

See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034

Awesome. Thanks for pointing this out Mike.

Now all we need to do is create a named define for each clock index in the header file.

Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing this.
Details in the patch below (Tony, I have added you as collaborator for helping in getting this working-clk_add_alias was'nt needed in the internal patch discussion we had - I have taken a bit of freedom in adding your contributions to the patch below)

Quoted 4 lines
Quoted 3 lines

Folks, this does seem to be the best compromise we can achieve at this point in time. feedback on this approach is much appreciated - if folks are ok, I can post this as an formal patch series.

This looks fine to me. Minor comments below.

I like it. No IDs and can add clocks support in DT as needed.

Quoted 240 lines
Quoted 43 lines

From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <[email protected]>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data

OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c. However, this presents an obstacle for using these clock nodes in Device Tree definitions. There are many possible approaches to this problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required. This is similar in approach taken by tegra and few other platforms. example clock = <&clk 5>;
cons: potential to have mismatches in indexed table and associated dtb data. In addition, managing continued documentation in bindings as clock indexing increases. Even though readability angle could be improved by using preprocessing of DT using macros, indexed approach is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses <&clk 2>, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has updated indices will result in per_dpll now controlled for peripheral X without warning or any potential error detection and warning.

Even though we can claim this is user error, such errors are hard to track down and fix.

An alternate approach introduced here is to introduce device tree bindings corresponding to the clock nodes required in DT definition for SoC which automatically maps back to the definitions in cclockXYZ_data.c.

Quoted 7 lines

The driver introduced here to do this mapping will eventually be the place where the clock handling will migrate to. We need to consider this angle as well so that the solution will be an valid transition point for moving the clock data out of kernel image (into device tree or firmware load etc..).

Overall strategy introduced here is simple: an clock node described in

typo: "an"->"a"

Quoted 91 lines

device tree blob is used to identify the exact clock provided in the SoC specific data. This is then linked back using of_clk_add_provider to the device node to be accessible by of_clk_get.

Based on discussion contributions from Roger Quadros, Grygorii Strashko and others.

[tony at atomide.com: co-developed]
---
  .../devicetree/bindings/clock/omap-clock.txt       |   40 +++++++++
  drivers/clk/Makefile                               |    1 +
  drivers/clk/omap/Makefile                          |    1 +
  drivers/clk/omap/clk.c                             |   94 ++++++++++++++++++++
  4 files changed, 136 insertions(+)

create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt create mode 100644 drivers/clk/omap/Makefile
create mode 100644 drivers/clk/omap/clk.c

Documentation/devicetree/bindings/clock/omap-clock.txt new file +40 -0
new file mode 100644
index 0000000..07e3ff8
@@ -0,0 +1,40 @@
+Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
+
+This binding is a work-in-progress, and meant to be stage #1 of transitioning
+OMAP clock data out of kernel image.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be "ti,omap-clock"
+- #clock-cells : from common clock binding; shall be set to 0.
+NOTE:
+node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
+Since all clocks are described with _ck, the node name is optimized to drop the
+usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
+
+Example #1: describing clock node for CPU on OMAP34xx platform:
+Ref: arch/arm/mach-omap2/cclock3xxx_data.c
+describes the CPU clock to be as follows
+	CLK(NULL,	"dpll1_ck",	&dpll1_ck,	CK_3XXX),
+Corresponding binding will be:
+	dpll1: dpll1 {
+		#clock-cells = <0>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+		clocks = <&dpll1>;
+
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+	CLK(NULL,	"auxclk3_ck",	&auxclk3_ck,	CK_443X),
+Corresponding binding will be:
+	auxclk3: auxclk3 {
+		#clock-cells = <1>;
+		compatible = "ti,omap-clock";
+	};
+And it's usage will be:
+	clocks = <&auxclk3>;
drivers/clk/Makefile +1 -0
index 300d477..a0209d7 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500)	+= ux500/
  obj-$(CONFIG_ARCH_VT8500)	+= clk-vt8500.o
  obj-$(CONFIG_ARCH_ZYNQ)		+= clk-zynq.o
  obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
+obj-$(CONFIG_ARCH_OMAP)		+= omap/
 
  obj-$(CONFIG_X86)		+= x86/
 
drivers/clk/omap/Makefile new file +1 -0
new file mode 100644
index 0000000..8195931
@@ -0,0 +1 @@
+obj-y					+= clk.o
drivers/clk/omap/clk.c new file +0 -0
new file mode 100644
index 0000000..63a4cce

drivers/clk/omap/clk.c line 5

Quoted 5 lines
drivers/clk/omap/clk.c new file +5 -0
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *	Nishanth Menon

missing e-mail id.

Quoted 17 lines
drivers/clk/omap/clk.c new file +17 -0
+ *	Tony Lindgren <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clkdev.h>
+#include <linux/clk-private.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_device.h>

drivers/clk/omap/clk.c line 32

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+#include <linux/platform_device.h>
+#include <linux/string.h>
+
+static const struct of_device_id omap_clk_of_match[] = {
+	{.compatible = "ti,omap-clock",},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, omap_clk_of_match);
+

Is this driver ever going to be a loadable module? If not then you don't need this.

Quoted 31 lines
drivers/clk/omap/clk.c new file +31 -0
+/**
+ * omap_clk_probe() - create link from DT definition to clock data
+ * @pdev:	device node
+ *
+ * REVISIT: We are now assuming the following:
+ * 1. omap clock names end with _ck
+ * 2. omap clocks don't get removed
+ */
+static int omap_clk_probe(struct platform_device *pdev)
+{
+	struct clk *clk;
+	int res;
+
+	const struct of_device_id *match;
+	struct device_node *np = pdev->dev.of_node;
+	char clk_name[32];
+
+	match = of_match_device(omap_clk_of_match, &pdev->dev);
+
+	/* Set up things so consumer can call clk_get() with name */
+	snprintf(clk_name, 32, "%s_ck", np->name);
+	clk = clk_get(NULL, clk_name);
+	if (IS_ERR(clk)) {
+		res = PTR_ERR(clk);
+		dev_err(&pdev->dev, "could not get clock %s (%d)\n",
+			clk_name, res);
+		goto out;
+	}
+
+	/* This allows the driver to of_clk_get() */
+	res = of_clk_add_provider(np, of_clk_src_simple_get, clk);

drivers/clk/omap/clk.c line 73

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+	if (res)
+		dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
+			clk_name, res);
+
+	clk_put(clk);
+out:
+	return res;
+}
+
+MODULE_ALIAS("platform:omap_clk");

ditto.

drivers/clk/omap/clk.c line 80

Quoted 7 lines
drivers/clk/omap/clk.c new file +7 -0
+
+/* We assume here that OMAP clocks will not be removed */
+static struct platform_driver omap_clk_driver = {
+	.probe = omap_clk_probe,
+	.driver = {
+		   .name = "omap_clk",
+		   .owner = THIS_MODULE,

same here.

Quoted 9 lines
drivers/clk/omap/clk.c new file +9 -0
+		   .of_match_table = of_match_ptr(omap_clk_of_match),
+		   },
+};
+
+static int __init omap_clk_init(void)
+{
+	return platform_driver_register(&omap_clk_driver);
+}
+
Quoted 8 lines

drivers/clk/omap/clk.c line 94

Quoted 6 lines
drivers/clk/omap/clk.c new file +5 -0
+arch_initcall(omap_clk_init);
+
+MODULE_DESCRIPTION("OMAP Clock driver");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_LICENSE("GPL v2");

cheers,
-roger

-grygorii

#35 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Roger Quadros
Quoted 9 lines · Roger Quadros
Quoted 6 lines · Nishanth Menon
Quoted 2 lines · Roger Quadros
Quoted 1 line · Mike Turquette

Quoting Nishanth Menon (2013-04-09 13:49:00)

Folks, this does seem to be the best compromise we can achieve at this point in time. feedback on this approach is much appreciated - if folks are ok, I can post this as an formal patch series.

This looks fine to me. Minor comments below.

Thanks on the review. will fix in my next post
Regards,
Nishanth Menon

#36 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Nishanth Menon

Quoting Nishanth Menon (2013-04-10 10:39:21)

Quoted 15 lines
drivers/clk/omap/clk.c new file +9 -0
new file mode 100644
index 0000000..63a4cce
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *     Nishanth Menon
+ *     Tony Lindgren <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as

drivers/clk/omap/clk.c line 19

Quoted 10 lines
drivers/clk/omap/clk.c new file +10 -0
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clkdev.h>
+#include <linux/clk-private.h>

Please use clk-provider.h. Otherwise this looks like an OK transitional solution. Hopefully this will be replaced with a more legitimate clock driver for 3.11.

Regards,
Mike

#37 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 20 lines · Mike Turquette

Quoting Nishanth Menon (2013-04-10 10:39:21)

Quoted 19 lines
drivers/clk/omap/clk.c new file +13 -0
new file mode 100644
index 0000000..63a4cce
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *     Nishanth Menon
+ *     Tony Lindgren <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
Quoted 8 lines

drivers/clk/omap/clk.c line 19

Quoted 6 lines
drivers/clk/omap/clk.c new file +6 -0
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clkdev.h>
+#include <linux/clk-private.h>

Please use clk-provider.h. Otherwise this looks like an OK transitional

k. thanks for checking up on this. will update.

Quoted 2 lines

solution. Hopefully this will be replaced with a more legitimate clock driver for 3.11.

I hope so too. At least we should start debate with the direction we'd like to take and start migrating towards that purpose.

Regards,
Nishanth Menon

#38 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

In reply to Tony Lindgren
Quoted 34 lines · Tony Lindgren
Quoted 25 lines · Roger Quadros
Quoted 14 lines · Tony Lindgren
Quoted 14 lines
arch/arm/mach-omap2/cclock44xx_data.c +1 -0
@@ -27,6 +27,7 @@
  #include <linux/clk-private.h>
  #include <linux/clkdev.h>
  #include <linux/io.h>
+#include <linux/of.h>
 
  #include "soc.h"
  #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
  	CLK(NULL,	"cpufreq_ck",	&dpll_mpu_ck,	CK_443X),
  };
 
Quoted 10 lines

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1674

Quoted 8 lines
arch/arm/mach-omap2/cclock44xx_data.c +8 -0
+static struct clk *scrm_clks[] = {
+	&auxclk0_ck,
+	&auxclk1_ck,
+	&auxclk2_ck,
+	&auxclk3_ck,
+	&auxclk4_ck,
+	&auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the cclock44xx_data.c and in DT..

Quoted 3 lines

Right, but till we have all clocks moved to DT we only need this approach for general purpose clocks that are not mapped to devices by hwmod.

For v3.10, let's just make sure that USB works with DT as then after v3.10 we can make omap4 DT only and get rid of estimated 7K lines of code and data. I guess this is the last piece missing for that, or are we also missing something else?

Quoted 9 lines

Can't you set up a clock alias for your device so it can find the auxclk when requesting it with the dev entry?

For the DT clock driver if needed for v3.10, how about just do a minimal drivers/clock/omap/ that uses the standard binding? Then that driver can just do clk_get() from cclock44xx_data.c for now? And then later on we'll just move all the clocks to a combination of DT + /lib/firmware.

Hi Roger, Rajendra, All

Sorry that disturbing you.

I'm supporting Android OMAP4 kernels (K3.0/K3.4) and like to clarify few points regarding this approach (having into account possible future migrations
on newer Kernels and OMAP5).
If I understand everything right, this patch series allows to create clock binding
in DT using following syntax: clocks = <&aux_clks 3>
- does it means that in worst case there will be ~200 clock IDs defined?
- does it means that clock nodes binding using phandles
(human-friendly notation)
isn't going to be supported?
for example:
clocks = <&sys_clkin_ck>
clocks = <&dss_sys_clk &dss_tv_clk &dss_dss_clk>)

I was horrified to think about the problems of this approach support (in case if there would be more then ~30 IDs) - just miss with on digit and weeks of debugging would be guaranteed.

Please, say me that i'm wrong.
And why clock DT data can't be auto-generated like all other OMAP data to close this questions?

Thanks.

Quoted 17 lines
Quoted 2 lines

e.g. auxclk are required to be specified in DT nodes for USB PHY. Without this we can't get USB host working on Panda.

OK. So if the USB PHY has a dev entry, can't you just set up a clock alias in struct omap_clk omap44xx_clks[] for it?

Quoted 2 lines

As Rajendra points out, it seems moving entire clock data to DT is not going to happen soon. So this is the simplistic way things can work.

Right but seems like we can get started there without moving them all at once.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#39 lore raw

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

Quoted 42 lines · Grygorii Strashko
Quoted 32 lines · Tony Lindgren
Quoted 23 lines · Roger Quadros
Quoted 14 lines · Tony Lindgren
Quoted 14 lines
arch/arm/mach-omap2/cclock44xx_data.c +2 -0
@@ -27,6 +27,7 @@
  #include <linux/clk-private.h>
  #include <linux/clkdev.h>
  #include <linux/io.h>
+#include <linux/of.h>
    #include "soc.h"
  #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
      CLK(NULL,    "cpufreq_ck",    &dpll_mpu_ck,    CK_443X),
  };
  +static struct clk *scrm_clks[] = {
+    &auxclk0_ck,
Quoted 8 lines

arch/arm/mach-omap2/cclock44xx_data.c static struct omap_clk omap44xx_clks[] = { · line 1674

Quoted 6 lines
arch/arm/mach-omap2/cclock44xx_data.c +6 -0
+    &auxclk1_ck,
+    &auxclk2_ck,
+    &auxclk3_ck,
+    &auxclk4_ck,
+    &auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the cclock44xx_data.c and in DT..

Quoted 3 lines

Right, but till we have all clocks moved to DT we only need this approach for general purpose clocks that are not mapped to devices by hwmod.

For v3.10, let's just make sure that USB works with DT as then after v3.10 we can make omap4 DT only and get rid of estimated 7K lines of code and data. I guess this is the last piece missing for that, or are we also missing something else?

Quoted 9 lines

Can't you set up a clock alias for your device so it can find the auxclk when requesting it with the dev entry?

For the DT clock driver if needed for v3.10, how about just do a minimal drivers/clock/omap/ that uses the standard binding? Then that driver can just do clk_get() from cclock44xx_data.c for now? And then later on we'll just move all the clocks to a combination of DT + /lib/firmware.

Quoted 3 lines

Hi Roger, Rajendra, All

Sorry that disturbing you.

Hi Grygorri,

Nothing to disturb at all ;).

Quoted 6 lines

I'm supporting Android OMAP4 kernels (K3.0/K3.4) and like to clarify few points regarding this approach (having into account possible future migrations on newer Kernels and OMAP5).
If I understand everything right, this patch series allows to create clock binding in DT using following syntax: clocks = <&aux_clks 3>

Actually in v2 of the patch this would be clocks = <&clks 3>

Quoted 1 line

- does it means that in worst case there will be ~200 clock IDs defined?

I'm afraid so yes. But when I wrote this I was only thinking of generic clocks, i.e. AUXCLKS. So when we start talking of all clocks we might need to reconsider the approach.

Quoted 5 lines

- does it means that clock nodes binding using phandles (human-friendly notation)
isn't going to be supported?
for example:
clocks = <&sys_clkin_ck>
clocks = <&dss_sys_clk &dss_tv_clk &dss_dss_clk>)

This would depend if we define the clock nodes within DT or not. From what Tony mentioned (i.e. inefficiency) it seems that the clock nodes won't be defined in the device tree. Then we are left with using an index.

Quoted 6 lines

I was horrified to think about the problems of this approach support (in case if there would be more then ~30 IDs) - just miss with on digit and weeks of debugging would be guaranteed.

Please, say me that i'm wrong.

It is still not written in stone so if you have a better idea we could go that route.

cheers,
-roger

Quoted 23 lines

And why clock DT data can't be auto-generated like all other OMAP data to close this questions?

Thanks.

Quoted 17 lines
Quoted 2 lines

e.g. auxclk are required to be specified in DT nodes for USB PHY. Without this we can't get USB host working on Panda.

OK. So if the USB PHY has a dev entry, can't you just set up a clock alias in struct omap_clk omap44xx_clks[] for it?

Quoted 2 lines

As Rajendra points out, it seems moving entire clock data to DT is not going to happen soon. So this is the simplistic way things can work.

Right but seems like we can get started there without moving them all at once.

Regards,

Tony

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#40 lore raw

PATCH 2/2 ARM: dts: omap4-panda: Provide PHY clock information

In reply to Roger Quadros

The USB PHY needs AUXCLK3 to operate. Provide this information in the device tree.

---
 arch/arm/boot/dts/omap4-panda.dts |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/boot/dts/omap4-panda.dts +2 -0
index cfc7683..2cd369b 100644
@@ -85,6 +85,8 @@
 		compatible = "usb-nop-xceiv";
 		reset-supply = <&hsusb1_reset>;
 		vcc-supply = <&hsusb1_power>;
+		clocks = <&aux_clks 3>;
+		clock-names = "main_clk";
 		clock-frequency = <19200000>;
 	};
 };
Signature · 1 line
1.7.4.1