Skip to contentSkip to conversation

ARM: dts: Change dw-apb-timer-osc and dw-apb-timer-sp to just dw-apb-timer

PATCH RESEND Superseded dinguyen at altera.com 3 participants 5 messages Aug 5, 2013 – Aug 8, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/2 ARM: dts: Change dw-apb-timer-osc and dw-apb-timer-sp to just dw-apb-timer

From: Dinh Nguyen <[email protected]>

"dw-apb-timer-osc" and "dw-apb-timer-sp" are the same implementation of the DW APB timer, just fed by different clocks.

CC Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Ian Campbell <[email protected]>
CC Arnd Bergmann <[email protected]>
Cc Olof Johansson <[email protected]>
CC Jamie Iles <[email protected]>
Cc John Stultz <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Pavel Machek <[email protected]>
Cc devicetree-discuss at lists.ozlabs.org
Cc linux-arm-kernel at lists.infradead.org
---
 Documentation/devicetree/bindings/rtc/dw-apb.txt |   21 +++----------------
 arch/arm/boot/dts/rk3066a.dtsi                   |    6 +++---
 arch/arm/boot/dts/socfpga.dtsi                   |   24 +++++++++++-----------
 arch/arm/boot/dts/socfpga_cyclone5.dts           |    8 ++++----
 arch/arm/boot/dts/socfpga_vt.dts                 |    8 ++++----
 5 files changed, 26 insertions(+), 41 deletions(-)
Documentation/devicetree/bindings/rtc/dw-apb.txt +3 -18
index eb2327b..0a1020e 100644
@@ -1,7 +1,7 @@
 * Designware APB timer
 
 Required properties:
-- compatible: "snps,dw-apb-timer-sp" or "snps,dw-apb-timer-osc"
+- compatible: "snps,dw-apb-timer"
 - reg: physical base address of the controller and length of memory mapped
   region.
 - interrupts: IRQ line for the timer.
@@ -20,23 +20,8 @@ systems may use one.
 
 
 Example:
-
-		timer1: timer at ffc09000 {
-				compatible = "snps,dw-apb-timer-sp";
-				interrupts = <0 168 4>;
-				clock-frequency = <200000000>;
-				reg = <0xffc09000 0x1000>;
-			};
-
-		timer2: timer at ffd00000 {
-				compatible = "snps,dw-apb-timer-osc";
-				interrupts = <0 169 4>;
-				clock-frequency = <200000000>;
-				reg = <0xffd00000 0x1000>;
-			};
-
-		timer3: timer at ffe00000 {
-				compatible = "snps,dw-apb-timer-osc";
+		timer1: timer at ffe00000 {
+				compatible = "snps,dw-apb-timer";
 				interrupts = <0 170 4>;
 				reg = <0xffe00000 0x1000>;
 				clocks = <&timer_clk>, <&timer_pclk>;
arch/arm/boot/dts/rk3066a.dtsi +3 -3
index 56bfac9..2dff468 100644
@@ -71,7 +71,7 @@
 		};
 
 		timer at 20038000 {
-			compatible = "snps,dw-apb-timer-osc";
+			compatible = "snps,dw-apb-timer";
 			reg = <0x20038000 0x100>;
 			interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&clk_gates1 0>, <&clk_gates7 7>;
@@ -79,7 +79,7 @@
 		};
 
 		timer at 2003a000 {
-			compatible = "snps,dw-apb-timer-osc";
+			compatible = "snps,dw-apb-timer";
 			reg = <0x2003a000 0x100>;
 			interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&clk_gates1 1>, <&clk_gates7 8>;
@@ -87,7 +87,7 @@
 		};
 
 		timer at 2000e000 {
-			compatible = "snps,dw-apb-timer-osc";
+			compatible = "snps,dw-apb-timer";
 			reg = <0x2000e000 0x100>;
 			interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&clk_gates1 2>, <&clk_gates7 9>;
arch/arm/boot/dts/socfpga.dtsi +12 -12
index 93ee655..4e8291b 100644
@@ -26,10 +26,6 @@
 		ethernet1 = &gmac1;
 		serial0 = &uart0;
 		serial1 = &uart1;
-		timer0 = &timer0;
-		timer1 = &timer1;
-		timer2 = &timer2;
-		timer3 = &timer3;
 	};
 
 	cpus {
@@ -486,28 +482,32 @@
 			interrupts = <1 13 0xf04>;
 		};
 
-		timer0: timer0 at ffc08000 {
-			compatible = "snps,dw-apb-timer-sp";
+		timer0: timer at ffc08000 {
+			compatible = "snps,dw-apb-timer";
 			interrupts = <0 167 4>;
 			reg = <0xffc08000 0x1000>;
+			clocks = <&osc>;
 		};
 
-		timer1: timer1 at ffc09000 {
-			compatible = "snps,dw-apb-timer-sp";
+		timer1: timer at ffc09000 {
+			compatible = "snps,dw-apb-timer";
 			interrupts = <0 168 4>;
 			reg = <0xffc09000 0x1000>;
+			clocks = <&osc>;
 		};
 
-		timer2: timer2 at ffd00000 {
-			compatible = "snps,dw-apb-timer-osc";
+		timer2: timer at ffd00000 {
+			compatible = "snps,dw-apb-timer";
 			interrupts = <0 169 4>;
 			reg = <0xffd00000 0x1000>;
+			clocks = <&l4_sp_clk>;
 		};
 
-		timer3: timer3 at ffd01000 {
-			compatible = "snps,dw-apb-timer-osc";
+		timer3: timer at ffd01000 {
+			compatible = "snps,dw-apb-timer";
 			interrupts = <0 170 4>;
 			reg = <0xffd01000 0x1000>;
+			clocks = <&l4_sp_clk>;
 		};
 
 		uart0: serial0 at ffc02000 {
arch/arm/boot/dts/socfpga_cyclone5.dts +4 -4
index 102c4d8..54b8483 100644
@@ -67,19 +67,19 @@
 			};
 		};
 
-		timer0 at ffc08000 {
+		timer at ffc08000 {
 			clock-frequency = <100000000>;
 		};
 
-		timer1 at ffc09000 {
+		timer at ffc09000 {
 			clock-frequency = <100000000>;
 		};
 
-		timer2 at ffd00000 {
+		timer at ffd00000 {
 			clock-frequency = <25000000>;
 		};
 
-		timer3 at ffd01000 {
+		timer at ffd01000 {
 			clock-frequency = <25000000>;
 		};
 
arch/arm/boot/dts/socfpga_vt.dts +4 -4
index d93deb0..6a1d8b7 100644
@@ -58,19 +58,19 @@
 			};
 		};
 
-		timer0 at ffc08000 {
+		timer at ffc08000 {
 			clock-frequency = <7000000>;
 		};
 
-		timer1 at ffc09000 {
+		timer at ffc09000 {
 			clock-frequency = <7000000>;
 		};
 
-		timer2 at ffd00000 {
+		timer at ffd00000 {
 			clock-frequency = <7000000>;
 		};
 
-		timer3 at ffd01000 {
+		timer at ffd01000 {
 			clock-frequency = <7000000>;
 		};
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH RESEND 2/2 clocksource: dw_apb_timer_of: Fix read_sched_clock

From: Dinh Nguyen <[email protected]>

The read_sched_clock should return the ~value because the clock is a countdown implementation. read_sched_clock() should be the same as __apbt_read_clocksource().

If a separate timer for the sched_clock exist, then read_sched_clock() will return an incorrect value. The (sched_io_base + 0x4) needs to be in the function for both cases.

Also, remove the use of "dw-apb-timer-sp" and "dw-apb-timer-osc" since they are the same DW clock.

CC Rob Herring <[email protected]>
CC Arnd Bergmann <[email protected]>
Cc Olof Johansson <[email protected]>
CC Jamie Iles <[email protected]>
Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/clocksource/dw_apb_timer_of.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/clocksource/dw_apb_timer_of.c +3 -4
index 4cbae4f..8e00929 100644
@@ -102,18 +102,17 @@ static void add_clocksource(struct device_node *source_timer)
 	 * timer is found. sched_io_base then points to the current_value
 	 * register of the clocksource timer.
 	 */
-	sched_io_base = iobase + 0x04;
+	sched_io_base = iobase;
 	sched_rate = rate;
 }
 
 static u32 read_sched_clock(void)
 {
-	return __raw_readl(sched_io_base);
+	return ~__raw_readl(sched_io_base + 0x4);
 }
 
 static const struct of_device_id sptimer_ids[] __initconst = {
 	{ .compatible = "picochip,pc3x2-rtc" },
-	{ .compatible = "snps,dw-apb-timer-sp" },
 	{ /* Sentinel */ },
 };
 
@@ -153,4 +152,4 @@ static void __init dw_apb_timer_init(struct device_node *timer)
 	num_called++;
 }
 CLOCKSOURCE_OF_DECLARE(pc3x2_timer, "picochip,pc3x2-timer", dw_apb_timer_init);
-CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer-osc", dw_apb_timer_init);
+CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer", dw_apb_timer_init);
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH RESEND 1/2 ARM: dts: Change dw-apb-timer-osc and dw-apb-timer-sp to just dw-apb-timer

In reply to dinguyen at altera.com
Quoted 4 lines · dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

"dw-apb-timer-osc" and "dw-apb-timer-sp" are the same implementation of the DW APB timer, just fed by different clocks.

I assume patch 1/1 made similar changes to the driver?

Documentation/devicetree/bindings/rtc/dw-apb.txt line 4

Quoted 5 lines
Documentation/devicetree/bindings/rtc/dw-apb.txt +1 -1
 
 Required properties:
-- compatible: "snps,dw-apb-timer-sp" or "snps,dw-apb-timer-osc"
+- compatible: "snps,dw-apb-timer"

This change is problematic w.r.t device tree as an ABI. any DT that uses the new value "snps,dw-apb-timer" will not work with older software that was written to expect the old values.

Similarly, if the driver was edited to only support the new value listed above, then old DTs will not work with the new driver.

Instead, I think what you need to do is:

a) Update the driver to support all 3 compatible values, so all DTs will work with the new driver.

b) Modify the *.dtsi files to uses one of the old compatible values, so the new DTs will work with the old driver.

c) Modify the binding document to mention all 3 compatible values, but mark the old 2 as deprecated.

#3 lore raw

PATCH RESEND 1/2 ARM: dts: Change dw-apb-timer-osc and dw-apb-timer-sp to just dw-apb-timer

Quoted 10 lines · Stephen Warren
Quoted 4 lines · dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

"dw-apb-timer-osc" and "dw-apb-timer-sp" are the same implementation of the DW APB timer, just fed by different clocks.

I assume patch 1/1 made similar changes to the driver?

Quoted 1 line
Documentation/devicetree/bindings/rtc/dw-apb.txt +0 -0
Quoted 7 lines
Quoted 3 lines

Required properties:
-- compatible: "snps,dw-apb-timer-sp" or "snps,dw-apb-timer-osc" +- compatible: "snps,dw-apb-timer"

This change is problematic w.r.t device tree as an ABI. any DT that uses the new value "snps,dw-apb-timer" will not work with older software that was written to expect the old values.

I'm pretty sure there's no such software out there. Actually, I don't think timers ever worked properly on any mainline kernels.

So I believe we can still fix it the right way... it is same hardware with different labels after all.

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#4 lore raw

PATCH RESEND 1/2 ARM: dts: Change dw-apb-timer-osc and dw-apb-timer-sp to just dw-apb-timer

Quoted 19 lines · Pavel Machek
Quoted 10 lines · Stephen Warren
Quoted 4 lines · dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

"dw-apb-timer-osc" and "dw-apb-timer-sp" are the same implementation of the DW APB timer, just fed by different clocks.

I assume patch 1/1 made similar changes to the driver?

Quoted 1 line
Documentation/devicetree/bindings/rtc/dw-apb.txt +0 -0
Quoted 7 lines
Quoted 3 lines

Required properties:
-- compatible: "snps,dw-apb-timer-sp" or "snps,dw-apb-timer-osc" +- compatible: "snps,dw-apb-timer"

This change is problematic w.r.t device tree as an ABI. any DT that uses the new value "snps,dw-apb-timer" will not work with older software that was written to expect the old values.

Quoted 5 lines

I'm pretty sure there's no such software out there. Actually, I don't think timers ever worked properly on any mainline kernels.

So I believe we can still fix it the right way... it is same hardware with different labels after all.

If even Linux 3.11 isn't going to work properly with the current DT content, then I think breaking ABI compatibility is fine.