Skip to contentSkip to conversation

add hisilicon SoC support

PATCH Superseded Haojian Zhuang 5 participants 44 messages Mar 13, 2013 – Mar 15, 2013

Subsystems (9)

v3 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v3 cover add hisilicon SoC support

Changelog:
v3:
1. Replace to call hs_init_clocks() in hi3xxx.c by of_clk_init().
2. Add CLK_OF_DECLARE() in clk-hi3xxx driver.
3. Add "select USE_OF" for CONFIG_CLKSRC_OF configuration. So drop CONFIG_OF in sp804 driver.
4. Move readme file into driver patch.
5. Append "arm,integrator-timer" for sp804 match table.
v2:
1. Rename mach-hs to mach-hi3xxx.
2. Remove CONFIG_MACH_HS_DT.
3. Move sp804 dual timer driver into drivers/clocksource.
4. Make sp804 driver to support DT. Append CLOCKSOURCE_OF_DECLARE() in sp804 driver.
5. Update hisilicon,hi3620-clkgate & hisilicon,hi3620-clkrst property in clk-hi3xxx driver.

#1 lore raw

PATCH v3 1/11 clocksource: move sp timer driver

All clocksource drivers should be moved into drivers/clocksource directory, since it's necessary for integrating them into clocksource_of infrastructure.

Move ARM SP804 timer driver from arch/arm directory into drivers/clocksource directory.

---
 arch/arm/Kconfig                                                  |    5 -----
 arch/arm/common/Makefile                                          |    1 -
 arch/arm/mach-highbank/highbank.c                                 |    4 ++--
 arch/arm/mach-integrator/integrator_ap.c                          |    2 +-
 arch/arm/mach-integrator/integrator_cp.c                          |    4 ++--
 arch/arm/mach-realview/core.c                                     |    4 ++--
 arch/arm/mach-versatile/core.c                                    |    4 ++--
 arch/arm/mach-vexpress/ct-ca9x4.c                                 |    5 ++---
 arch/arm/mach-vexpress/v2m.c                                      |    4 ++--
 drivers/clocksource/Kconfig                                       |    5 +++++
 drivers/clocksource/Makefile                                      |    1 +
 {arch/arm/common => drivers/clocksource}/timer-sp.c               |    2 +-
 .../arm/include/asm/hardware => include/clocksource}/arm_timer.h  |    4 ++--
 {arch/arm/include/asm/hardware => include/clocksource}/timer-sp.h |    4 ++++
 14 files changed, 26 insertions(+), 23 deletions(-)
 rename {arch/arm/common => drivers/clocksource}/timer-sp.c (99%)
 rename {arch/arm/include/asm/hardware => include/clocksource}/arm_timer.h (93%)
 rename {arch/arm/include/asm/hardware => include/clocksource}/timer-sp.h (87%)
arch/arm/Kconfig +0 -5
index 2363926..10d7e2c 100644
@@ -1177,11 +1177,6 @@ config PLAT_PXA
 config PLAT_VERSATILE
 	bool
 
-config ARM_TIMER_SP804
-	bool
-	select CLKSRC_MMIO
-	select HAVE_SCHED_CLOCK
-
 source arch/arm/mm/Kconfig
 
 config ARM_NR_BANKS
arch/arm/common/Makefile +0 -1
index 45f7eae..a4e49e7 100644
@@ -12,4 +12,3 @@ obj-$(CONFIG_SHARP_LOCOMO)	+= locomo.o
 obj-$(CONFIG_SHARP_PARAM)	+= sharpsl_param.o
 obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_ARM_TIMER_SP804)	+= timer-sp.o
arch/arm/mach-highbank/highbank.c +2 -2
index a4f9f50..cfd843b 100644
@@ -27,14 +27,14 @@
 #include <linux/smp.h>
 #include <linux/amba/bus.h>
 #include <linux/clk-provider.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <asm/arch_timer.h>
 #include <asm/cacheflush.h>
 #include <asm/cputype.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_twd.h>
-#include <asm/hardware/arm_timer.h>
-#include <asm/hardware/timer-sp.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
arch/arm/mach-integrator/integrator_ap.c +1 -1
index ea96144..c2112ff 100644
@@ -41,11 +41,11 @@
 #include <linux/stat.h>
 #include <linux/sys_soc.h>
 #include <linux/termios.h>
+#include <clocksource/arm_timer.h>
 #include <video/vga.h>
 
 #include <mach/hardware.h>
 #include <mach/platform.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/setup.h>
 #include <asm/param.h>		/* HZ */
 #include <asm/mach-types.h>
arch/arm/mach-integrator/integrator_cp.c +2 -2
index 2b0db82..40373ec 100644
@@ -28,12 +28,13 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/sys_soc.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/icst.h>
 
 #include <mach/cm.h>
@@ -45,7 +46,6 @@
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 
-#include <asm/hardware/timer-sp.h>
 
 #include <plat/clcd.h>
 #include <plat/sched_clock.h>
arch/arm/mach-realview/core.c +2 -2
index 1d5ee5c..26a3da38 100644
@@ -31,11 +31,12 @@
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
 #include <linux/mtd/physmap.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
 #include <asm/mach-types.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/icst.h>
 
 #include <asm/mach/arch.h>
@@ -45,7 +46,6 @@
 
 #include <mach/platform.h>
 #include <mach/irqs.h>
-#include <asm/hardware/timer-sp.h>
 
 #include <plat/clcd.h>
 #include <plat/sched_clock.h>
arch/arm/mach-versatile/core.c +2 -2
index 25160ae..e894a1f 100644
@@ -38,9 +38,10 @@
 #include <linux/clkdev.h>
 #include <linux/mtd/physmap.h>
 #include <linux/bitops.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <asm/irq.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/icst.h>
 #include <asm/mach-types.h>
 
@@ -50,7 +51,6 @@
 #include <asm/mach/map.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
-#include <asm/hardware/timer-sp.h>
 
 #include <plat/clcd.h>
 #include <plat/sched_clock.h>
arch/arm/mach-vexpress/ct-ca9x4.c +2 -3
index 6f34497..48f6676 100644
@@ -11,16 +11,15 @@
 #include <linux/clkdev.h>
 #include <linux/vexpress.h>
 #include <linux/irqchip/arm-gic.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/smp_scu.h>
 #include <asm/smp_twd.h>
 
 #include <mach/ct-ca9x4.h>
 
-#include <asm/hardware/timer-sp.h>
-
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 
arch/arm/mach-vexpress/v2m.c +2 -2
index 915683c..51e8701 100644
@@ -21,6 +21,8 @@
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 #include <linux/vexpress.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <asm/arch_timer.h>
 #include <asm/mach-types.h>
@@ -29,9 +31,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
-#include <asm/hardware/timer-sp.h>
 
 #include <mach/ct-ca9x4.h>
 #include <mach/motherboard.h>
drivers/clocksource/Kconfig +5 -0
index e8c4532..4c04d19 100644
@@ -63,6 +63,11 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
 config ARM_ARCH_TIMER
 	bool
 
+config ARM_TIMER_SP804
+	bool
+	select CLKSRC_MMIO
+	select HAVE_SCHED_CLOCK
+
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
 	help
drivers/clocksource/Makefile +1 -0
index 1c1b15d..9d3ad88 100644
@@ -22,4 +22,5 @@ obj-$(CONFIG_VT8500_TIMER)	+= vt8500_timer.o
 obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
 
 obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
+obj-$(CONFIG_ARM_TIMER_SP804)		+= timer-sp.o
 obj-$(CONFIG_CLKSRC_METAG_GENERIC)	+= metag_generic.o
drivers/clocksource/timer-sp.c renamed from arch/arm/common/timer-sp.c +1 -1
similarity index 99%
rename from arch/arm/common/timer-sp.c
rename to drivers/clocksource/timer-sp.c
index 9d2d3ba..a7f2510 100644
@@ -25,9 +25,9 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <clocksource/arm_timer.h>
 
 #include <asm/sched_clock.h>
-#include <asm/hardware/arm_timer.h>
 
 static long __init sp804_get_clock_rate(const char *name)
 {
include/clocksource/arm_timer.h renamed from arch/arm/include/asm/hardware/arm_timer.h +2 -2
similarity index 93%
rename from arch/arm/include/asm/hardware/arm_timer.h
rename to include/clocksource/arm_timer.h
index d6030ff..f4a443a 100644
@@ -1,5 +1,5 @@
-#ifndef __ASM_ARM_HARDWARE_ARM_TIMER_H
-#define __ASM_ARM_HARDWARE_ARM_TIMER_H
+#ifndef __CLOCKSOURCE_ARM_TIMER_H
+#define __CLOCKSOURCE_ARM_TIMER_H
 
 /*
  * ARM timer implementation, found in Integrator, Versatile and Realview
include/clocksource/timer-sp.h renamed from arch/arm/include/asm/hardware/timer-sp.h +4 -0
similarity index 87%
rename from arch/arm/include/asm/hardware/timer-sp.h
rename to include/clocksource/timer-sp.h
index 2dd9d3f..0ad4186 100644
@@ -1,3 +1,6 @@
+#ifndef __TIMER_SP_H
+#define __TIMER_SP_H
+
 void __sp804_clocksource_and_sched_clock_init(void __iomem *,
 					      const char *, int);
 
@@ -13,3 +16,4 @@ static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base,
 }
 
 void sp804_clockevents_init(void __iomem *, unsigned int, const char *);
+#endif	/* __TIMER_SP_H */
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v3 2/11 clocksource: select USE_OF by default

In reply to Haojian Zhuang

Since clksrc_of driver is always used in DT mode, select CONFIG_USE_OF by default. It could avoid build issue.

---
 drivers/clocksource/Kconfig |    1 +
 1 file changed, 1 insertion(+)
drivers/clocksource/Kconfig +1 -0
index 4c04d19..167ed92 100644
@@ -1,4 +1,5 @@
 config CLKSRC_OF
+	select USE_OF
 	bool
 
 config CLKSRC_I8253
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

In reply to Haojian Zhuang

Parse clock & irq from device tree for sp804.

---
 .../devicetree/bindings/timer/arm,sp804.txt        |   27 +++++
 drivers/clocksource/timer-sp.c                     |  105 ++++++++++++++++++++
 2 files changed, 132 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/arm,sp804.txt
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +27 -0
new file mode 100644
index 0000000..ec1ae45
@@ -0,0 +1,27 @@
+ARM sp804 Dual Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "arm,sp804" & "arm,primecell"
+- interrupts: Should contain the list of Dual Timer interrupts
+	interrupts = <0 0 4>, <0 1 4>;
+- reg: Should contain location and length for dual timer register.
+- clocks: clock driving the dual timer hardware
+	clocks = <&timclk0 &timclk1>;
+
+Optional properties:
+- arm,sp804-clocksource: Should contain the register offset of TIMER1 or
+  TIMER2 in Dual Timer Controller.
+	arm,sp804-clocksource = <0x20>;
+
+Example:
+
+	timer0: timer at fc800000 {
+		compatible = "arm,sp804", "arm,primecell";
+		reg = <0xfc800000 0x1000>;
+		/* timer00 & timer01 */
+		interrupts = <0 0 4>, <0 1 4>;
+		clocks = <&timclk0 &timclk1>;
+		clock-names = "apb_pclk";
+		status = "disabled";
+	};
drivers/clocksource/timer-sp.c +105 -0

124 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Documentation/devicetree/bindings/timer/arm,sp804.txt line 7

Quoted 9 lines · Haojian Zhuang

+++ b/Documentation/devicetree/bindings/timer/arm,sp804.txt

Documentation/devicetree/bindings/timer/arm,sp804.txt new file +7 -0
@@ -0,0 +1,27 @@
+ARM sp804 Dual Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "arm,sp804" & "arm,primecell"
+- interrupts: Should contain the list of Dual Timer interrupts
+	interrupts = <0 0 4>, <0 1 4>;

SP804 has three interrupt outputs: TIMINT1 (interrupt generated by the first timer), TIMINT2 (the second timer) and TIMINTC (combined - logical sum of the two former ones). You may want to describe this somehow to make the choice possible later (eg. VE has the combined interrupt wired while - if I understand what Rob is saying correctly - Highbank uses only the TIMINT1).

Documentation/devicetree/bindings/timer/arm,sp804.txt line 10

Quoted 3 lines
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +3 -0
+- reg: Should contain location and length for dual timer register.
+- clocks: clock driving the dual timer hardware
+	clocks = <&timclk0 &timclk1>;

Again, there are three "clock" inputs (even ignoring the APBCLK):
TIMCLK, TIMCLKEN1, TIMCLKEN2. The real clocking rate for the timer depends on the TIMCLK and respective TIMCLKENx - see
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0271d/CJABHCIG.html

The driver than could make educated choice based on this information.

You may choose to ignore this fact (and require only a clock representing the effective rate). I did it for the VE DTS, but it still doesn't seem completely right

Documentation/devicetree/bindings/timer/arm,sp804.txt line 15

Quoted 4 lines
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +4 -0
+Optional properties:
+- arm,sp804-clocksource: Should contain the register offset of TIMER1 or
+  TIMER2 in Dual Timer Controller.
+	arm,sp804-clocksource = <0x20>;

You seem to be missing the "arm,sp804-clockevent" one here.

Regards

Pawe?

#5 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 18 lines · Pawel Moll

Documentation/devicetree/bindings/timer/arm,sp804.txt line 7

Quoted 9 lines · Haojian Zhuang

+++ b/Documentation/devicetree/bindings/timer/arm,sp804.txt

Documentation/devicetree/bindings/timer/arm,sp804.txt new file +7 -0
@@ -0,0 +1,27 @@
+ARM sp804 Dual Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "arm,sp804" & "arm,primecell"
+- interrupts: Should contain the list of Dual Timer interrupts
+     interrupts = <0 0 4>, <0 1 4>;

SP804 has three interrupt outputs: TIMINT1 (interrupt generated by the first timer), TIMINT2 (the second timer) and TIMINTC (combined - logical sum of the two former ones). You may want to describe this somehow to make the choice possible later (eg. VE has the combined interrupt wired while - if I understand what Rob is saying correctly - Highbank uses only the TIMINT1).

I prefer to ignore the TIMINTC. It seems that nobody is using this interrupt.

Quoted 9 lines

Documentation/devicetree/bindings/timer/arm,sp804.txt line 10

Quoted 3 lines
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +3 -0
+- reg: Should contain location and length for dual timer register.
+- clocks: clock driving the dual timer hardware
+     clocks = <&timclk0 &timclk1>;

Again, there are three "clock" inputs (even ignoring the APBCLK):
TIMCLK, TIMCLKEN1, TIMCLKEN2. The real clocking rate for the timer depends on the TIMCLK and respective TIMCLKENx - see
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0271d/CJABHCIG.html

Quoted 6 lines

The driver than could make educated choice based on this information.

You may choose to ignore this fact (and require only a clock representing the effective rate). I did it for the VE DTS, but it still doesn't seem completely right

Sure. I can append it.

Quoted 7 lines

Documentation/devicetree/bindings/timer/arm,sp804.txt line 15

Quoted 4 lines
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +4 -0
+Optional properties:
+- arm,sp804-clocksource: Should contain the register offset of TIMER1 or
+  TIMER2 in Dual Timer Controller.
+     arm,sp804-clocksource = <0x20>;

You seem to be missing the "arm,sp804-clockevent" one here.

Yes, I missed. I'll update the README.

#6 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 19 lines · Haojian Zhuang
Quoted 18 lines · Pawel Moll

Documentation/devicetree/bindings/timer/arm,sp804.txt line 7

Quoted 9 lines · Haojian Zhuang

+++ b/Documentation/devicetree/bindings/timer/arm,sp804.txt

Documentation/devicetree/bindings/timer/arm,sp804.txt new file +7 -0
@@ -0,0 +1,27 @@
+ARM sp804 Dual Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "arm,sp804" & "arm,primecell"
+- interrupts: Should contain the list of Dual Timer interrupts
+     interrupts = <0 0 4>, <0 1 4>;

SP804 has three interrupt outputs: TIMINT1 (interrupt generated by the first timer), TIMINT2 (the second timer) and TIMINTC (combined - logical sum of the two former ones). You may want to describe this somehow to make the choice possible later (eg. VE has the combined interrupt wired while - if I understand what Rob is saying correctly - Highbank uses only the TIMINT1).

Quoted 1 line

I prefer to ignore the TIMINTC. It seems that nobody is using this interrupt.

VE is the nobody then ;-) As I mentioned above - both VE motherboard SP804s have the TIMINTC wired up and TIMINT1/TIMINT2 unused.

Pawe?

#7 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

In reply to Pawel Moll
Quoted 17 lines · Pawel Moll

Documentation/devicetree/bindings/timer/arm,sp804.txt line 7

Quoted 9 lines · Haojian Zhuang

+++ b/Documentation/devicetree/bindings/timer/arm,sp804.txt

Documentation/devicetree/bindings/timer/arm,sp804.txt new file +7 -0
@@ -0,0 +1,27 @@
+ARM sp804 Dual Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "arm,sp804" & "arm,primecell"
+- interrupts: Should contain the list of Dual Timer interrupts
+	interrupts = <0 0 4>, <0 1 4>;

SP804 has three interrupt outputs: TIMINT1 (interrupt generated by the first timer), TIMINT2 (the second timer) and TIMINTC (combined - logical sum of the two former ones). You may want to describe this somehow to make the choice possible later (eg. VE has the combined interrupt wired while - if I understand what Rob is saying correctly - Highbank uses only the TIMINT1).

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

I'm not completely sure if Linux and the irq domain code handles the same interrupt source repeated. It should because that is basically a shared irq line.

If we ever see only TIMINT2 connected we can add a property for that, but I think that case is unlikely.

Quoted 6 lines

Documentation/devicetree/bindings/timer/arm,sp804.txt line 10

Quoted 4 lines
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +3 -0
+- reg: Should contain location and length for dual timer register.
+- clocks: clock driving the dual timer hardware
+	clocks = <&timclk0 &timclk1>;

Again, there are three "clock" inputs (even ignoring the APBCLK):

We should not ignore that clock as we may want this to be a proper amba_device someday.

Quoted 10 lines

TIMCLK, TIMCLKEN1, TIMCLKEN2. The real clocking rate for the timer depends on the TIMCLK and respective TIMCLKENx - see
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0271d/CJABHCIG.html

The driver than could make educated choice based on this information.

You may choose to ignore this fact (and require only a clock representing the effective rate). I did it for the VE DTS, but it still doesn't seem completely right

Quoted 6 lines

Documentation/devicetree/bindings/timer/arm,sp804.txt line 15

Quoted 4 lines
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +4 -0
+Optional properties:
+- arm,sp804-clocksource: Should contain the register offset of TIMER1 or
+  TIMER2 in Dual Timer Controller.
+	arm,sp804-clocksource = <0x20>;

You seem to be missing the "arm,sp804-clockevent" one here.

These should stay as aliases or go away as I suggested.

Rob

#8 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 6 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines

I'm not completely sure if Linux and the irq domain code handles the same interrupt source repeated. It should because that is basically a shared irq line.

If we ever see only TIMINT2 connected we can add a property for that, but I think that case is unlikely.

I was rather thinking about using the "interrupt-names" property and naming them explicitly, eg:

	interrupt-names = "timint1", "timint2";
	interrupts = <1>, <2>;

	interrupt-names = "timint1";
	interrupts = <1>;

	interrupt-names = "timint2";
	interrupts = <2>;

	interrupt-names = "timintc";
	interrupts = <3>;

But now I see that of_amba_device_create() doesn't do anything about it (platform device would use them as resource name so we could use platform_get_resource_byname), so I'm not sure any more...

Quoted 9 lines
Quoted 6 lines

Review

Quoted 4 lines
+- reg: Should contain location and length for dual timer register.
+- clocks: clock driving the dual timer hardware
(quoted diff) +1 -0
+	clocks = <&timclk0 &timclk1>;

Again, there are three "clock" inputs (even ignoring the APBCLK):

We should not ignore that clock as we may want this to be a proper amba_device someday.

Sorry, wrong wording. I meant to say "even not mentioning the APBCLK" (because it's required anyway by the primecell binding). VE SP804 node obviously has it defined:

v2m_timer01: timer at 110000 {                           
	compatible = "arm,sp804", "arm,primecell";    
	reg = <0x110000 0x1000>;
	interrupts = <2>;                
	clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
	clock-names = "timclken1", "timclken2", "apb_pclk";
};                                   
Quoted 10 lines
Quoted 10 lines

TIMCLK, TIMCLKEN1, TIMCLKEN2. The real clocking rate for the timer depends on the TIMCLK and respective TIMCLKENx - see
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0271d/CJABHCIG.html

The driver than could make educated choice based on this information.

You may choose to ignore this fact (and require only a clock representing the effective rate). I did it for the VE DTS, but it still doesn't seem completely right

Quoted 8 lines
Quoted 6 lines

Documentation/devicetree/bindings/timer/arm,sp804.txt line 15

Quoted 4 lines
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +4 -0
+Optional properties:
+- arm,sp804-clocksource: Should contain the register offset of TIMER1 or
+  TIMER2 in Dual Timer Controller.
+	arm,sp804-clocksource = <0x20>;

You seem to be missing the "arm,sp804-clockevent" one here.

These should stay as aliases or go away as I suggested.

I merely pointed out that it's missing from the binding description.

I couldn't agree more that both should not be there in the first place.

Pawe?

#9 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 29 lines · Pawel Moll
Quoted 6 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines

I'm not completely sure if Linux and the irq domain code handles the same interrupt source repeated. It should because that is basically a shared irq line.

If we ever see only TIMINT2 connected we can add a property for that, but I think that case is unlikely.

I was rather thinking about using the "interrupt-names" property and naming them explicitly, eg:

	interrupt-names = "timint1", "timint2";
	interrupts = <1>, <2>;

	interrupt-names = "timint1";
	interrupts = <1>;

	interrupt-names = "timint2";
	interrupts = <2>;

	interrupt-names = "timintc";
	interrupts = <3>;
Quoted 3 lines

But now I see that of_amba_device_create() doesn't do anything about it (platform device would use them as resource name so we could use platform_get_resource_byname), so I'm not sure any more...

The interrupt-names property should not be required and without it here you cannot determine the configuration.

Rob

#10 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 30 lines · Rob Herring
Quoted 29 lines · Pawel Moll
Quoted 6 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines

I'm not completely sure if Linux and the irq domain code handles the same interrupt source repeated. It should because that is basically a shared irq line.

If we ever see only TIMINT2 connected we can add a property for that, but I think that case is unlikely.

I was rather thinking about using the "interrupt-names" property and naming them explicitly, eg:

	interrupt-names = "timint1", "timint2";
	interrupts = <1>, <2>;

	interrupt-names = "timint1";
	interrupts = <1>;

	interrupt-names = "timint2";
	interrupts = <2>;

	interrupt-names = "timintc";
	interrupts = <3>;
Quoted 6 lines
Quoted 3 lines

But now I see that of_amba_device_create() doesn't do anything about it (platform device would use them as resource name so we could use platform_get_resource_byname), so I'm not sure any more...

The interrupt-names property should not be required and without it here you cannot determine the configuration.

It is not required by the standard interrupt bindings. But it could be required by the SP804 binding, couldn't it? (like any other property) "Encoding" the information by specific organization of the field makes it "invisible to the naked eye".

Not that I have any strong feelings about it.

Pawe?

#11 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 38 lines · Pawel Moll
Quoted 30 lines · Rob Herring
Quoted 29 lines · Pawel Moll
Quoted 6 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines

I'm not completely sure if Linux and the irq domain code handles the same interrupt source repeated. It should because that is basically a shared irq line.

If we ever see only TIMINT2 connected we can add a property for that, but I think that case is unlikely.

I was rather thinking about using the "interrupt-names" property and naming them explicitly, eg:

    interrupt-names = "timint1", "timint2";
    interrupts = <1>, <2>;

    interrupt-names = "timint1";
    interrupts = <1>;

    interrupt-names = "timint2";
    interrupts = <2>;

    interrupt-names = "timintc";
    interrupts = <3>;
Quoted 6 lines
Quoted 3 lines

But now I see that of_amba_device_create() doesn't do anything about it (platform device would use them as resource name so we could use platform_get_resource_byname), so I'm not sure any more...

The interrupt-names property should not be required and without it here you cannot determine the configuration.

Quoted 10 lines

It is not required by the standard interrupt bindings. But it could be required by the SP804 binding, couldn't it? (like any other property) "Encoding" the information by specific organization of the field makes it "invisible to the naked eye".

Not that I have any strong feelings about it.

Pawe?

What's the scenario that we must use TIMINTC? TIMINT1 & TIMINT2 are already enough on these two TIMERs. If we really needn't TIMINTC, we need to support it. Since it's over-designed.

If TIMINT1 & TIMINT2 aren't routed, and only TIMINTC is routed. It's another case. We can consider it as replacement of TIMINT1.

Regards
Haojian

#12 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 5 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines · Haojian Zhuang

What's the scenario that we must use TIMINTC? TIMINT1 & TIMINT2 are already enough on these two TIMERs. If we really needn't TIMINTC, we need to support it. Since it's over-designed.

If TIMINT1 & TIMINT2 aren't routed, and only TIMINTC is routed. It's another case. We can consider it as replacement of TIMINT1.

Just a thought... How to describe a SP804 with only TIMINT2 wired up?

Pawe?

#13 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 12 lines · Pawel Moll
Quoted 5 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 4 lines · Haojian Zhuang

What's the scenario that we must use TIMINTC? TIMINT1 & TIMINT2 are already enough on these two TIMERs. If we really needn't TIMINTC, we need to support it. Since it's over-designed.

Quoted 8 lines
Quoted 2 lines

If TIMINT1 & TIMINT2 aren't routed, and only TIMINTC is routed. It's another case. We can consider it as replacement of TIMINT1.

Just a thought... How to describe a SP804 with only TIMINT2 wired up?

Pawe?

There's no difference on TIMINTC is only used to replace TIMINT1 or TIMINT2. We only need to tell sp804 driver which timer is using irq, and the irq number.

#14 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 16 lines · Haojian Zhuang
Quoted 15 lines · Pawel Moll
Quoted 5 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines · Haojian Zhuang

What's the scenario that we must use TIMINTC? TIMINT1 & TIMINT2 are already enough on these two TIMERs. If we really needn't TIMINTC, we need to support it. Since it's over-designed.

If TIMINT1 & TIMINT2 aren't routed, and only TIMINTC is routed. It's another case. We can consider it as replacement of TIMINT1.

Quoted 7 lines
Quoted 5 lines

Just a thought... How to describe a SP804 with only TIMINT2 wired up?

Pawe?

There's no difference on TIMINTC is only used to replace TIMINT1 or TIMINT2. We only need to tell sp804 driver which timer is using irq, and the irq number.

If I understand you well:

* Both TIMINT1 and TIMINT2 wired up - TIMINTC doesn't matter

	interrupts = <1>, <2>;

* TIMINT1 wired up, TIMINT2 not wired up

	interrupts = <1>;

* Only TIMINTC wired up - treat it as TIMINT1

	interrupts = <1>;

So far so good. My question is, how do you describe the following:

* _Only_ TIMINT2 wired up, TIMINT1 and TIMINTC _not_ wired up

interrupts = ???

Pawe?

#15 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 37 lines · Pawel Moll
Quoted 16 lines · Haojian Zhuang
Quoted 15 lines · Pawel Moll
Quoted 5 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines · Haojian Zhuang

What's the scenario that we must use TIMINTC? TIMINT1 & TIMINT2 are already enough on these two TIMERs. If we really needn't TIMINTC, we need to support it. Since it's over-designed.

If TIMINT1 & TIMINT2 aren't routed, and only TIMINTC is routed. It's another case. We can consider it as replacement of TIMINT1.

Quoted 7 lines
Quoted 5 lines

Just a thought... How to describe a SP804 with only TIMINT2 wired up?

Pawe?

There's no difference on TIMINTC is only used to replace TIMINT1 or TIMINT2. We only need to tell sp804 driver which timer is using irq, and the irq number.

If I understand you well:

* Both TIMINT1 and TIMINT2 wired up - TIMINTC doesn't matter

	interrupts = <1>, <2>;

* TIMINT1 wired up, TIMINT2 not wired up

	interrupts = <1>;

* Only TIMINTC wired up - treat it as TIMINT1

Quoted 7 lines
	interrupts = <1>;

So far so good. My question is, how do you describe the following:

* _Only_ TIMINT2 wired up, TIMINT1 and TIMINTC _not_ wired up

interrupts = ???

I previously described that to add a property in that case. That makes INT1 and INT2 only handling asymetric though. An alternative would be an optional property "arm,sp804-has-irq = <#>" in the case of only INT1 or INT2 connected. The combined irq would be a single irq without the "arm,sp804-has-irq" property and both connected would be 2 irqs.

Rob

#16 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 5 lines · Rob Herring

I previously described that to add a property in that case. That makes INT1 and INT2 only handling asymetric though. An alternative would be an optional property "arm,sp804-has-irq = <#>" in the case of only INT1 or INT2 connected. The combined irq would be a single irq without the "arm,sp804-has-irq" property and both connected would be 2 irqs.

Fine with me.

Pawe?

#17 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 7 lines · Pawel Moll
Quoted 5 lines · Rob Herring

I previously described that to add a property in that case. That makes INT1 and INT2 only handling asymetric though. An alternative would be an optional property "arm,sp804-has-irq = <#>" in the case of only INT1 or INT2 connected. The combined irq would be a single irq without the "arm,sp804-has-irq" property and both connected would be 2 irqs.

Quoted 5 lines

Fine with me.

Pawe?

It's OK to me. I can use this property instead.

Regards
Haojian

#18 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

In reply to Pawel Moll
Quoted 39 lines · Pawel Moll
Quoted 16 lines · Haojian Zhuang
Quoted 15 lines · Pawel Moll
Quoted 5 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

Quoted 6 lines · Haojian Zhuang

What's the scenario that we must use TIMINTC? TIMINT1 & TIMINT2 are already enough on these two TIMERs. If we really needn't TIMINTC, we need to support it. Since it's over-designed.

If TIMINT1 & TIMINT2 aren't routed, and only TIMINTC is routed. It's another case. We can consider it as replacement of TIMINT1.

Quoted 7 lines
Quoted 5 lines

Just a thought... How to describe a SP804 with only TIMINT2 wired up?

Pawe?

There's no difference on TIMINTC is only used to replace TIMINT1 or TIMINT2. We only need to tell sp804 driver which timer is using irq, and the irq number.

If I understand you well:

* Both TIMINT1 and TIMINT2 wired up - TIMINTC doesn't matter

        interrupts = <1>, <2>;

* TIMINT1 wired up, TIMINT2 not wired up

        interrupts = <1>;

* Only TIMINTC wired up - treat it as TIMINT1

        interrupts = <1>;
Quoted 10 lines

So far so good. My question is, how do you describe the following:

* _Only_ TIMINT2 wired up, TIMINT1 and TIMINTC _not_ wired up

interrupts = ???

Pawe?

In my current implementation, I need two things to judge whether irq is really necessary.

If the timer contains "arm,sp804-clockevent = <evtoffs>" property, I'll check whether the timer irq is specified at the same time.

TIMINT1 & TIMINTC are not routed. TIMINT2 is used for clock event.

     interrupts = <any number> <1>;

        if (!retevt) {
                if (evtoffs) {
                        /* TIMER2 is clock event */
                        i = 1;
                        evtoffs = TIMER_2_BASE;
                } else {
                        /* TIMER1 is clock event */
                        i = 0;
                        evtoffs = TIMER_1_BASE;
                }
                irq = irq_of_parse_and_map(np, i);
                ...
        }

If the timer contains "arm,sp804-clocksource = <srcoffs>" property, I won't check the timer irq. You even needn't define it.

TIMINT1 & TIMINTC are not routed. TIMER2 is used for clock source.

      interrupts = <any number> <any number>;
or
      don't define interrupts

        if (!retsrc) {
                if (srcoffs) {
                        /* TIMER2 is clock source */
                        i = 1;
                        srcoffs = TIMER_2_BASE;
                } else {
                        /* TIMER1 is clock source */
                        i = 0;
                        srcoffs = TIMER_1_BASE;
                }
                ...
        }
#19 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 7 lines · Haojian Zhuang

In my current implementation, I need two things to judge whether irq is really necessary.

If the timer contains "arm,sp804-clockevent = <evtoffs>" property, I'll check whether the timer irq is specified at the same time.

TIMINT1 & TIMINTC are not routed. TIMINT2 is used for clock event.

Fine, so simply reverse the logic and drop the "arm,sp804-clock*" properties. Something like:

if (has_timint1) {
	evtoffs = TIMER_1_BASE;
	irq = irq_of_parse_and_map(np, 1);
	srcoffs = TIMER_2_BASE;
} else (has_timint2) {
	evtoffs = TIMER_2_BASE;
	irq = irq_of_parse_and_map(np, 2);
	srcoffs = TIMER_1_BASE;
} else {

can't be clockevent, sorry
}

Hope it makes clear what I'd expect from the driver.

Pawe?

maintainer
#20 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 12 lines · Pawel Moll

Fine, so simply reverse the logic and drop the "arm,sp804-clock*" properties. Something like:

if (has_timint1) {
        evtoffs = TIMER_1_BASE;
        irq = irq_of_parse_and_map(np, 1);
        srcoffs = TIMER_2_BASE;
} else (has_timint2) {
        evtoffs = TIMER_2_BASE;
        irq = irq_of_parse_and_map(np, 2);
        srcoffs = TIMER_1_BASE;
} else {
Quoted 4 lines

can't be clockevent, sorry
}

Hope it makes clear what I'd expect from the driver.

Makes sense. I guess you can actually derive "has_timint1" from the presence of the irq and just try to parse it:

	irq = irq_of_parse_and_map(np, 0);
	if (irq) {
		evtoffs = TIMER_1_BASE;
		srcoffs = TIMER_2_BASE;
	} else {
		irq = irq_of_parse_and_map(np, 1);
		if (!irq)
			return -ENODEV;
		srcoffs = TIMER_1_BASE;
		evtoffs = TIMER_2_BASE;
	}

I wonder if we can ever get into the second case though: If the first interrupt in not valid, can there be a second one in the interrupts property? I don't know of a way to put an "invalid" interrupt in there.

Arnd

#21 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

Quoted 16 lines · Arnd Bergmann

Makes sense. I guess you can actually derive "has_timint1" from the presence of the irq and just try to parse it:

	irq = irq_of_parse_and_map(np, 0);
	if (irq) {
		evtoffs = TIMER_1_BASE;
		srcoffs = TIMER_2_BASE;
	} else {
		irq = irq_of_parse_and_map(np, 1);
		if (!irq)
			return -ENODEV;
		srcoffs = TIMER_1_BASE;
		evtoffs = TIMER_2_BASE;
	}
Quoted 4 lines

I wonder if we can ever get into the second case though: If the first interrupt in not valid, can there be a second one in the interrupts property? I don't know of a way to put an "invalid" interrupt in there.

The discussion in the "[PATCH v3 03/11] clocksource: sp804: add device tree support" thread resulted in some ideas how to describe such situation. I suggested using interrupt-names property to explicitly describe the numbers, Rob wanted to simply define one or two interrupts and in the former case have a special property describing which one is it. Either way you can get this information from the tree. The main argument is about the clockevent/source aliases - whether they should be obligatory, optional or banned.

Pawe?

#22 lore raw

PATCH v3 3/11 clocksource: sp804: add device tree support

In reply to Rob Herring
Quoted 9 lines · Rob Herring

How about:

1 irq - TIMINT1
2 irqs w/ same source # - TIMINTC
2 irqs w/ different source # - TIMINT1 and TIMINT2

I'm not completely sure if Linux and the irq domain code handles the same interrupt source repeated. It should because that is basically a shared irq line.

I think you're missing something here. Any particular platform will generally only wire either the common interrupt, or the individual interrupts. Very few, if any, will wire both.

It's just like stuff such as MMCI and the UARTs. They have a combined interrupt out, and individual interrupt outs. However, they're all written for the combined interrupt only, because practically no one uses the individal interrupts.

#23 lore raw

PATCH v3 4/11 ARM: integrator: use clocksource_of_init for sp804

In reply to Haojian Zhuang

Remove all code to parse sp804 in integrator platform driver. Use clocksource_of_init() instead since these code are implemented in sp804 driver already.

---
 arch/arm/boot/dts/integrator.dtsi        |    3 +++
 arch/arm/boot/dts/integratorap.dts       |    9 +++----
 arch/arm/boot/dts/integratorcp.dts       |    9 +++----
 arch/arm/mach-integrator/Kconfig         |    3 +++
 arch/arm/mach-integrator/integrator_ap.c |   41 +-----------------------------
 arch/arm/mach-integrator/integrator_cp.c |   35 ++-----------------------
 drivers/clocksource/timer-sp.c           |    2 ++
 7 files changed, 19 insertions(+), 83 deletions(-)
arch/arm/boot/dts/integrator.dtsi +3 -0
index 813b91d..749ac21 100644
@@ -9,18 +9,21 @@
 		reg = <0x13000000 0x100>;
 		interrupt-parent = <&pic>;
 		interrupts = <5>;
+		status = "disabled";
 	};
 
 	timer at 13000100 {
 		reg = <0x13000100 0x100>;
 		interrupt-parent = <&pic>;
 		interrupts = <6>;
+		status = "disabled";
 	};
 
 	timer at 13000200 {
 		reg = <0x13000200 0x100>;
 		interrupt-parent = <&pic>;
 		interrupts = <7>;
+		status = "disabled";
 	};
 
 	pic at 14000000 {
arch/arm/boot/dts/integratorap.dts +4 -5
index c9c3fa3..112d2e0 100644
@@ -9,11 +9,6 @@
 	model = "ARM Integrator/AP";
 	compatible = "arm,integrator-ap";
 
-	aliases {
-		arm,timer-primary = &timer2;
-		arm,timer-secondary = &timer1;
-	};
-
 	chosen {
 		bootargs = "root=/dev/ram0 console=ttyAM0,38400n8 earlyprintk";
 	};
@@ -29,10 +24,14 @@
 
 	timer1: timer at 13000100 {
 		compatible = "arm,integrator-timer";
+		arm,sp804-clockevent = <0>;
+		status = "ok";
 	};
 
 	timer2: timer at 13000200 {
 		compatible = "arm,integrator-timer";
+		arm,sp804-clocksource = <0>;
+		status = "ok";
 	};
 
 	pic: pic at 14000000 {
arch/arm/boot/dts/integratorcp.dts +4 -5
index 8b11939..19b2e3e 100644
@@ -9,11 +9,6 @@
 	model = "ARM Integrator/CP";
 	compatible = "arm,integrator-cp";
 
-	aliases {
-		arm,timer-primary = &timer2;
-		arm,timer-secondary = &timer1;
-	};
-
 	chosen {
 		bootargs = "root=/dev/ram0 console=ttyAMA0,38400n8 earlyprintk";
 	};
@@ -29,10 +24,14 @@
 
 	timer1: timer at 13000100 {
 		compatible = "arm,sp804", "arm,primecell";
+		arm,sp804-clockevent = <0>;
+		status = "ok";
 	};
 
 	timer2: timer at 13000200 {
 		compatible = "arm,sp804", "arm,primecell";
+		arm,sp804-clocksource = <0>;
+		status = "ok";
 	};
 
 	pic: pic at 14000000 {
arch/arm/mach-integrator/Kconfig +3 -0
index abeff25..031f43a 100644
@@ -5,6 +5,7 @@ menu "Integrator Options"
 config ARCH_INTEGRATOR_AP
 	bool "Support Integrator/AP and Integrator/PP2 platforms"
 	select CLKSRC_MMIO
+	select CLKSRC_OF
 	select MIGHT_HAVE_PCI
 	select SERIAL_AMBA_PL010
 	select SERIAL_AMBA_PL010_CONSOLE
@@ -15,6 +16,8 @@ config ARCH_INTEGRATOR_AP
 
 config ARCH_INTEGRATOR_CP
 	bool "Support Integrator/CP platform"
+	select CLKSRC_MMIO
+	select CLKSRC_OF
 	select ARCH_CINTEGRATOR
 	select ARM_TIMER_SP804
 	select PLAT_VERSATILE_CLCD
arch/arm/mach-integrator/integrator_ap.c +1 -40

53 lines not on this page · raw message

arch/arm/mach-integrator/integrator_cp.c +2 -33
index 40373ec..6e1c340 100644
@@ -28,6 +28,7 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/sys_soc.h>
+#include <linux/clocksource.h>
 #include <clocksource/arm_timer.h>
 #include <clocksource/timer-sp.h>
 
@@ -251,38 +252,6 @@ static void __init intcp_init_early(void)
 
 #ifdef CONFIG_OF
 
-static void __init cp_of_timer_init(void)
-{
-	struct device_node *node;
-	const char *path;
-	void __iomem *base;
-	int err;
-	int irq;
-
-	err = of_property_read_string(of_aliases,
-				"arm,timer-primary", &path);
-	if (WARN_ON(err))
-		return;
-	node = of_find_node_by_path(path);
-	base = of_iomap(node, 0);
-	if (WARN_ON(!base))
-		return;
-	writel(0, base + TIMER_CTRL);
-	sp804_clocksource_init(base, node->name);
-
-	err = of_property_read_string(of_aliases,
-				"arm,timer-secondary", &path);
-	if (WARN_ON(err))
-		return;
-	node = of_find_node_by_path(path);
-	base = of_iomap(node, 0);
-	if (WARN_ON(!base))
-		return;
-	irq = irq_of_parse_and_map(node, 0);
-	writel(0, base + TIMER_CTRL);
-	sp804_clockevents_init(base, irq, node->name);
-}
-
 static const struct of_device_id fpga_irq_of_match[] __initconst = {
 	{ .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, },
 	{ /* Sentinel */ }
@@ -386,7 +355,7 @@ DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)")
 	.init_early	= intcp_init_early,
 	.init_irq	= intcp_init_irq_of,
 	.handle_irq	= fpga_handle_irq,
-	.init_time	= cp_of_timer_init,
+	.init_time	= clocksource_of_init,
 	.init_machine	= intcp_init_of,
 	.restart	= integrator_restart,
 	.dt_compat      = intcp_dt_board_compat,
drivers/clocksource/timer-sp.c +2 -0
index 63f757d..b3d9eba 100644
@@ -201,6 +201,7 @@ static struct device_node *from = NULL;
 
 static struct of_device_id sp804_timer_match[] __initdata = {
 	{ .compatible = "arm,sp804", },
+	{ .compatible = "arm,integrator-timer", },
 	{}
 };
 
@@ -294,3 +295,4 @@ err:
 	iounmap(base);
 }
 CLOCKSOURCE_OF_DECLARE(sp804, "arm,sp804", sp804_dt_init)
+CLOCKSOURCE_OF_DECLARE(integrator, "arm,integrator-timer", sp804_dt_init)
Signature · 1 line
1.7.10.4
#24 lore raw

PATCH v3 5/11 ARM: highbank: use clocksource_of_init for sp804

In reply to Haojian Zhuang

Since sp804 hardware information could be stored in DTS file, remove those ioremap operations. Use clocksource_of_init() instead.

---
 arch/arm/boot/dts/ecx-common.dtsi |    4 +++-
 arch/arm/mach-highbank/highbank.c |   19 +------------------
 2 files changed, 4 insertions(+), 19 deletions(-)
arch/arm/boot/dts/ecx-common.dtsi +3 -1
index d61b535..7ae5b2d 100644
@@ -105,8 +105,10 @@
 			compatible = "arm,sp804", "arm,primecell";
 			reg = <0xfff34000 0x1000>;
 			interrupts = <0 18 4>;
-			clocks = <&pclk>;
+			clocks = <&pclk &pclk>;
 			clock-names = "apb_pclk";
+			arm,sp804-clocksource = <0x20>;
+			arm,sp804-clockevent = <0>;
 		};
 
 		rtc at fff35000 {
arch/arm/mach-highbank/highbank.c +1 -18
index cfd843b..7829c2d 100644
@@ -91,33 +91,16 @@ static void __init highbank_init_irq(void)
 #endif
 }
 
-static struct clk_lookup lookup = {
-	.dev_id = "sp804",
-	.con_id = NULL,
-};
-
 static void __init highbank_timer_init(void)
 {
-	int irq;
 	struct device_node *np;
-	void __iomem *timer_base;
 
 	/* Map system registers */
 	np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
 	sregs_base = of_iomap(np, 0);
 	WARN_ON(!sregs_base);
 
-	np = of_find_compatible_node(NULL, NULL, "arm,sp804");
-	timer_base = of_iomap(np, 0);
-	WARN_ON(!timer_base);
-	irq = irq_of_parse_and_map(np, 0);
-
-	of_clk_init(NULL);
-	lookup.clk = of_clk_get(np, 0);
-	clkdev_add(&lookup);
-
-	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
-	sp804_clockevents_init(timer_base, irq, "timer0");
+	clocksource_of_init();
 
 	twd_local_timer_of_register();
 
Signature · 1 line
1.7.10.4
#25 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

In reply to Haojian Zhuang

Remove all code to parse sp804. Use clocksource_of_init() instead since all these code are implemented in sp804 driver already.

---
 arch/arm/boot/dts/vexpress-v2m-rs1.dtsi |    2 ++
 arch/arm/boot/dts/vexpress-v2m.dtsi     |    2 ++
 arch/arm/boot/dts/vexpress-v2p-ca9.dts  |    2 ++
 arch/arm/mach-vexpress/Kconfig          |    1 +
 arch/arm/mach-vexpress/v2m.c            |   13 ++-----------
 5 files changed, 9 insertions(+), 11 deletions(-)
arch/arm/boot/dts/vexpress-v2m-rs1.dtsi +2 -0
index ac870fb..3fa798f 100644
@@ -183,6 +183,8 @@
 				interrupts = <2>;
 				clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
 				clock-names = "timclken1", "timclken2", "apb_pclk";
+				arm,sp804-clocksource = <0x20>;
+				arm,sp804-clockevent = <0>;
 			};
 
 			v2m_timer23: timer at 120000 {
arch/arm/boot/dts/vexpress-v2m.dtsi +2 -0
index f142036..86e4046 100644
@@ -182,6 +182,8 @@
 				interrupts = <2>;
 				clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
 				clock-names = "timclken1", "timclken2", "apb_pclk";
+				arm,sp804-clocksource = <0x20>;
+				arm,sp804-clockevent = <0>;
 			};
 
 			v2m_timer23: timer at 12000 {
arch/arm/boot/dts/vexpress-v2p-ca9.dts +2 -0
index 1420bb1..a2eba95 100644
@@ -98,6 +98,8 @@
 			     <0 49 4>;
 		clocks = <&oscclk2>, <&oscclk2>;
 		clock-names = "timclk", "apb_pclk";
+		arm,sp804-clocksource = <0x20>;
+		arm,sp804-clockevent = <0>;
 	};
 
 	watchdog at 100e5000 {
arch/arm/mach-vexpress/Kconfig +1 -0
index 52d315b..ff78c15 100644
@@ -5,6 +5,7 @@ config ARCH_VEXPRESS
 	select ARM_GIC
 	select ARM_TIMER_SP804
 	select CLKDEV_LOOKUP
+	select CLKSRC_OF
 	select COMMON_CLK
 	select COMMON_CLK_VERSATILE
 	select CPU_V7
arch/arm/mach-vexpress/v2m.c +2 -11
index 51e8701..bb599d3 100644
@@ -21,6 +21,7 @@
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 #include <linux/vexpress.h>
+#include <linux/clocksource.h>
 #include <clocksource/arm_timer.h>
 #include <clocksource/timer-sp.h>
 
@@ -431,19 +432,9 @@ void __init v2m_dt_init_early(void)
 
 static void __init v2m_dt_timer_init(void)
 {
-	struct device_node *node = NULL;
-
 	vexpress_clk_of_init();
 
-	do {
-		node = of_find_compatible_node(node, NULL, "arm,sp804");
-	} while (node && vexpress_get_site_by_node(node) != VEXPRESS_SITE_MB);
-	if (node) {
-		pr_info("Using SP804 '%s' as a clock & events source\n",
-				node->full_name);
-		v2m_sp804_init(of_iomap(node, 0),
-				irq_of_parse_and_map(node, 0));
-	}
+	clocksource_of_init();
 
 	if (arch_timer_of_register() != 0)
 		twd_local_timer_of_register();
Signature · 1 line
1.7.10.4
#26 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 43 lines · Haojian Zhuang

Remove all code to parse sp804. Use clocksource_of_init() instead since all these code are implemented in sp804 driver already.

---
 arch/arm/boot/dts/vexpress-v2m-rs1.dtsi |    2 ++
 arch/arm/boot/dts/vexpress-v2m.dtsi     |    2 ++
 arch/arm/boot/dts/vexpress-v2p-ca9.dts  |    2 ++
 arch/arm/mach-vexpress/Kconfig          |    1 +
 arch/arm/mach-vexpress/v2m.c            |   13 ++-----------
 5 files changed, 9 insertions(+), 11 deletions(-)
arch/arm/boot/dts/vexpress-v2m-rs1.dtsi +2 -0
index ac870fb..3fa798f 100644
@@ -183,6 +183,8 @@
 				interrupts = <2>;
 				clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
 				clock-names = "timclken1", "timclken2", "apb_pclk";
+				arm,sp804-clocksource = <0x20>;
+				arm,sp804-clockevent = <0>;
 			};
 
 			v2m_timer23: timer at 120000 {
arch/arm/boot/dts/vexpress-v2m.dtsi +2 -0
index f142036..86e4046 100644
@@ -182,6 +182,8 @@
 				interrupts = <2>;
 				clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
 				clock-names = "timclken1", "timclken2", "apb_pclk";
+				arm,sp804-clocksource = <0x20>;
+				arm,sp804-clockevent = <0>;
 			};
 
 			v2m_timer23: timer at 12000 {
arch/arm/boot/dts/vexpress-v2p-ca9.dts +0 -0
index 1420bb1..a2eba95 100644

arch/arm/boot/dts/vexpress-v2p-ca9.dts line 105

Quoted 8 lines
arch/arm/boot/dts/vexpress-v2p-ca9.dts +2 -0
@@ -98,6 +98,8 @@
 			     <0 49 4>;
 		clocks = <&oscclk2>, <&oscclk2>;
 		clock-names = "timclk", "apb_pclk";
+		arm,sp804-clocksource = <0x20>;
+		arm,sp804-clockevent = <0>;
 	};
 
 	watchdog at 100e5000 {

I love the possibility of removing the SP804 code from the VE machine (thanks for your work!), but I'd like to avoid it being replaced by cryptic properties in the tree.

Now, to get this right: I'm not saying that there should be completly no OS-specific (but neutral) properties for the clocking system.

I'm saying that in "my" (the VE) case, there are four, effectively identical timers (each pair sharing an interrupt though). Every single one of them is perfectly capable of serving as clocksource or clockevent. Therefore I believe the driver/framework/OS should make its own decision.

Cheers!

Pawe?

#27 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 57 lines · Pawel Moll
Quoted 43 lines · Haojian Zhuang

Remove all code to parse sp804. Use clocksource_of_init() instead since all these code are implemented in sp804 driver already.

---
 arch/arm/boot/dts/vexpress-v2m-rs1.dtsi |    2 ++
 arch/arm/boot/dts/vexpress-v2m.dtsi     |    2 ++
 arch/arm/boot/dts/vexpress-v2p-ca9.dts  |    2 ++
 arch/arm/mach-vexpress/Kconfig          |    1 +
 arch/arm/mach-vexpress/v2m.c            |   13 ++-----------
 5 files changed, 9 insertions(+), 11 deletions(-)
arch/arm/boot/dts/vexpress-v2m-rs1.dtsi +2 -0
index ac870fb..3fa798f 100644
@@ -183,6 +183,8 @@
                              interrupts = <2>;
                              clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
                              clock-names = "timclken1", "timclken2", "apb_pclk";
+                             arm,sp804-clocksource = <0x20>;
+                             arm,sp804-clockevent = <0>;
                      };
 
                      v2m_timer23: timer at 120000 {
arch/arm/boot/dts/vexpress-v2m.dtsi +2 -0
index f142036..86e4046 100644
@@ -182,6 +182,8 @@
                              interrupts = <2>;
                              clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
                              clock-names = "timclken1", "timclken2", "apb_pclk";
+                             arm,sp804-clocksource = <0x20>;
+                             arm,sp804-clockevent = <0>;
                      };
 
                      v2m_timer23: timer at 12000 {
arch/arm/boot/dts/vexpress-v2p-ca9.dts +0 -0
index 1420bb1..a2eba95 100644

arch/arm/boot/dts/vexpress-v2p-ca9.dts line 105

Quoted 8 lines
arch/arm/boot/dts/vexpress-v2p-ca9.dts +2 -0
@@ -98,6 +98,8 @@
                           <0 49 4>;
              clocks = <&oscclk2>, <&oscclk2>;
              clock-names = "timclk", "apb_pclk";
+             arm,sp804-clocksource = <0x20>;
+             arm,sp804-clockevent = <0>;
      };
 
      watchdog at 100e5000 {

I love the possibility of removing the SP804 code from the VE machine (thanks for your work!), but I'd like to avoid it being replaced by cryptic properties in the tree.

Quoted 9 lines

Now, to get this right: I'm not saying that there should be completly no OS-specific (but neutral) properties for the clocking system.

I'm saying that in "my" (the VE) case, there are four, effectively identical timers (each pair sharing an interrupt though). Every single one of them is perfectly capable of serving as clocksource or clockevent. Therefore I believe the driver/framework/OS should make its own decision.

I can move those properties into dts file instead.

If clocksource uses alias to configure source or event. There's still a lot of work. At least we need to split dual timer into two timer devices in DTS.

#28 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 7 lines · Haojian Zhuang
Quoted 7 lines

I love the possibility of removing the SP804 code from the VE machine (thanks for your work!), but I'd like to avoid it being replaced by cryptic properties in the tree.

Now, to get this right: I'm not saying that there should be completly no OS-specific (but neutral) properties for the clocking system.

Quoted 7 lines
Quoted 6 lines

I'm saying that in "my" (the VE) case, there are four, effectively identical timers (each pair sharing an interrupt though). Every single one of them is perfectly capable of serving as clocksource or clockevent. Therefore I believe the driver/framework/OS should make its own decision.

I can move those properties into dts file instead.

I'm not sure I understand you here...

Quoted 2 lines

If clocksource uses alias to configure source or event. There's still a lot of work. At least we need to split dual timer into two timer devices in DTS.

My point is: at least for VE there is _no need_ for any alias or special property in the tree (DTS). All timers are equal. The system can (and should) pick any one it wants.

Pawe?

#29 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 18 lines · Pawel Moll
Quoted 7 lines · Haojian Zhuang
Quoted 7 lines

I love the possibility of removing the SP804 code from the VE machine (thanks for your work!), but I'd like to avoid it being replaced by cryptic properties in the tree.

Now, to get this right: I'm not saying that there should be completly no OS-specific (but neutral) properties for the clocking system.

Quoted 7 lines
Quoted 6 lines

I'm saying that in "my" (the VE) case, there are four, effectively identical timers (each pair sharing an interrupt though). Every single one of them is perfectly capable of serving as clocksource or clockevent. Therefore I believe the driver/framework/OS should make its own decision.

I can move those properties into dts file instead.

I'm not sure I understand you here...

Quoted 9 lines
Quoted 2 lines

If clocksource uses alias to configure source or event. There's still a lot of work. At least we need to split dual timer into two timer devices in DTS.

My point is: at least for VE there is _no need_ for any alias or special property in the tree (DTS). All timers are equal. The system can (and should) pick any one it wants.

Pawe?

Do you mean that system wants to pick any one randomly? It's impossible. Imagine that only TIMINT1 signal in sp804 is routed to interrupt controller. Could system still pick any one it wants?

I think that clocksource or clockevent must be specified in DTS. Whatever we're using alias or property.

#30 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 1 line · Haojian Zhuang

Do you mean that system wants to pick any one randomly? It's impossible.

It is possible in case of the VE platform. Therefore it is not completely impossible. QED :-)

Quoted 2 lines

Imagine that only TIMINT1 signal in sp804 is routed to interrupt controller. Could system still pick any one it wants?

If you tell the system that only TIMINT1 is wired, it shouldn't even try to use the second timer for anything that would require the interrupt. Therefore, describing the hardware sufficiently, you're giving the system enough information to make the right decisions.

Quoted 2 lines

I think that clocksource or clockevent must be specified in DTS. Whatever we're using alias or property.

I'm convinced it does not *must* be there. I think it *can* be there, for platforms where the available timers are not equal (for whatever reason). My point is: why are you trying to force me to put some information into my hardware description which doesn't have any meaning for me?

Pawe?

#31 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 6 lines · Pawel Moll
Quoted 1 line · Haojian Zhuang

Do you mean that system wants to pick any one randomly? It's impossible.

It is possible in case of the VE platform. Therefore it is not completely impossible. QED :-)

Yes, it's possible. Since only clocksource / clockevent is using SP804 timer on the VE platform. If user app or something else is using other SP804 timer, it would be mess because of resource conflict.

Quoted 3 lines
Quoted 2 lines

Imagine that only TIMINT1 signal in sp804 is routed to interrupt controller. Could system still pick any one it wants?

Then we need another new property. I try to find using minim properties.

Quoted 5 lines

If you tell the system that only TIMINT1 is wired, it shouldn't even try to use the second timer for anything that would require the interrupt. Therefore, describing the hardware sufficiently, you're giving the system enough information to make the right decisions.

Quoted 9 lines
Quoted 2 lines

I think that clocksource or clockevent must be specified in DTS. Whatever we're using alias or property.

I'm convinced it does not *must* be there. I think it *can* be there, for platforms where the available timers are not equal (for whatever reason). My point is: why are you trying to force me to put some information into my hardware description which doesn't have any meaning for me?

As I mentioned above, system must know the behavior first. The upper layer software could know which timer is used in clocksource or clockevent.

For example, your Android system could be shared on multiple platforms. It could parse hardware information from DTS. (Of course, it hasn't this feature yet). Then it could arrange apps to use other timers.

It's like you define console on specified UART even you have multiples UART port.

#32 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 3 lines · Haojian Zhuang

Yes, it's possible. Since only clocksource / clockevent is using SP804 timer on the VE platform. If user app or something else is using other SP804 timer, it would be mess because of resource conflict.

How would you expose this device to the app or something else? It's an amba_bus device, so it must be bound with an amba_driver. Otherwise you're abusing the device model and, well, you're on your own.

The devices are managed by the system. The device tree is merely a description of the available hardware.

Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Imagine that only TIMINT1 signal in sp804 is routed to interrupt controller. Could system still pick any one it wants?

Then we need another new property. I try to find using minim properties.

No, we don't. See the discussion with Rob. He has an idea (using the interrupt property only), I have another one (using already defined interrupt-names property). I see you've just came with another one (TIMINTC treated as TIMINT1), which is fine with me. Either way you've got what you need to make the right decision.

Quoted 2 lines

As I mentioned above, system must know the behavior first. The upper layer software could know which timer is used in clocksource or clockevent.

I claim otherwise. The upper layer software should know what does the hardware offer and based on this knowledge use it in a way it wants to.

Quoted 3 lines

For example, your Android system could be shared on multiple platforms. It could parse hardware information from DTS. (Of course, it hasn't this feature yet). Then it could arrange apps to use other timers.

I honestly don't know what are you suggesting here other than it looks like an abuse to the device model.

Quoted 2 lines

It's like you define console on specified UART even you have multiples UART port.

Where do you do this? In the Device Tree? No. In the kernel command line, which is a runtime argument (the fact it is actually being passed through the tree is irrelevant here) You have the serialX aliases, which
- again - simply describe the hardware ("this node is connected to a connector labeled as serial X"). The tree doesn't tell that the user connected his serial cable to serial1 so it should be used as the console.

Pawe?

#33 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 5 lines · Pawel Moll
Quoted 3 lines · Haojian Zhuang

Yes, it's possible. Since only clocksource / clockevent is using SP804 timer on the VE platform. If user app or something else is using other SP804 timer, it would be mess because of resource conflict.

Quoted 7 lines

How would you expose this device to the app or something else? It's an amba_bus device, so it must be bound with an amba_driver. Otherwise you're abusing the device model and, well, you're on your own.

The devices are managed by the system. The device tree is merely a description of the available hardware.

Maybe I didn't express my idea well. My point is that timer could be clock source
/clock event. It could also just be a timer that user app or other device driver may want to use it directly. There're a lot of reason that user app or some
driver wants to use hardware timer. For example, the specific timer may
keep running even system is in low power mode.

Although there's so much hardware timers available, system must choose one for the usage of clock source / clock event / other hardware timer usage.

Quoted 11 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Imagine that only TIMINT1 signal in sp804 is routed to interrupt controller. Could system still pick any one it wants?

Then we need another new property. I try to find using minim properties.

No, we don't. See the discussion with Rob. He has an idea (using the interrupt property only), I have another one (using already defined interrupt-names property). I see you've just came with another one (TIMINTC treated as TIMINT1), which is fine with me. Either way you've got what you need to make the right decision.

After considered as second time, I think that we still need a property to meet alias usage. Excuse me expand it in this topic.

arm,sp804-has-irq = <offset>;
The offset means TIMER register offset. If it's not zero, TIMER2 is using irq. And it could be configured as clock event. Otherwise, TIMER1 is clock event.
We must make sure that only one of all sp804 timers is using this property.

alias:
linux,clocksource = <&sp804-A>
linux,clockevent = <&sp804-A>

Although both of them points to timerA, only TIMER1 or TIMER2 of sp804 is using irq. So one is clock source, and the other is clock event.

alias:
linux,clocksource = <&sp804-A>
linux,clockevent = <&sp804-B>
The issue comes since system don't know whether TIMER1 or TIMER2 could be configured as clock source.

We still need a new property to claim it. It seems that we can't drop "arm,sp804-clocksource", although everybody don't like it.

What's your opinion?

Quoted 3 lines

Where do you do this? In the Device Tree? No. In the kernel command line

Yes, command line could also be filled in DTS.

#34 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 6 lines · Haojian Zhuang

Maybe I didn't express my idea well. My point is that timer could be clock source
/clock event. It could also just be a timer that user app or other device driver may want to use it directly. There're a lot of reason that user app or some
driver wants to use hardware timer. For example, the specific timer may
keep running even system is in low power mode.

That's all fair enough. My point is in any case the *system* will take care of setting this all up. Therefore it can manage the available resources to avoid the conflict.

Quoted 2 lines

Although there's so much hardware timers available, system must choose one for the usage of clock source / clock event / other hardware timer usage.

By all means. I'm just claiming that in normal situation it can choose on its convenience. In other words - if there are no limitations in hardware, it can pick any of them, being responsible for making the right decision.

Quoted 33 lines
Quoted 11 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Imagine that only TIMINT1 signal in sp804 is routed to interrupt controller. Could system still pick any one it wants?

Then we need another new property. I try to find using minim properties.

No, we don't. See the discussion with Rob. He has an idea (using the interrupt property only), I have another one (using already defined interrupt-names property). I see you've just came with another one (TIMINTC treated as TIMINT1), which is fine with me. Either way you've got what you need to make the right decision.

After considered as second time, I think that we still need a property to meet alias usage. Excuse me expand it in this topic.

arm,sp804-has-irq = <offset>;
The offset means TIMER register offset. If it's not zero, TIMER2 is using irq. And it could be configured as clock event. Otherwise, TIMER1 is clock event.
We must make sure that only one of all sp804 timers is using this property.

alias:
linux,clocksource = <&sp804-A>
linux,clockevent = <&sp804-A>

Although both of them points to timerA, only TIMER1 or TIMER2 of sp804 is using irq. So one is clock source, and the other is clock event.

alias:
linux,clocksource = <&sp804-A>
linux,clockevent = <&sp804-B>
The issue comes since system don't know whether TIMER1 or TIMER2 could be configured as clock source.

Quoted 4 lines

We still need a new property to claim it. It seems that we can't drop "arm,sp804-clocksource", although everybody don't like it.

What's your opinion?

Let me repeat myself - I'm not saying that there must be no such thing like the alias (or your property). I'm sure there will be a use case for them.

What I am saying is that they should not be obligatory. Shortly speaking
- I don't want to have them in VE DTS files. For VE platform the driver should pick one of the timers and use it as clocksource (I don't care which one), another one as clockevent (again, it's up to you) and the rest for whatever it wants.

Could you please provide a solution for such a "generic" case, when there are no aliases defined in the tree? I see no problem with checking if the aliases exist and if they don't picking the first SP804 you can get hold of. Just give me that and you won't hear me complaining further :-)

Quoted 3 lines
Quoted 2 lines

Where do you do this? In the Device Tree? No. In the kernel command line

Yes, command line could also be filled in DTS.

Which is a very bad practice... There's a reason why "chosen" node is named like this ;-)

Pawe?

#35 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

In reply to Haojian Zhuang
Quoted 34 lines · Haojian Zhuang
Quoted 5 lines · Pawel Moll
Quoted 3 lines · Haojian Zhuang

Yes, it's possible. Since only clocksource / clockevent is using SP804 timer on the VE platform. If user app or something else is using other SP804 timer, it would be mess because of resource conflict.

Quoted 7 lines

How would you expose this device to the app or something else? It's an amba_bus device, so it must be bound with an amba_driver. Otherwise you're abusing the device model and, well, you're on your own.

The devices are managed by the system. The device tree is merely a description of the available hardware.

Maybe I didn't express my idea well. My point is that timer could be clock source
/clock event. It could also just be a timer that user app or other device driver may want to use it directly. There're a lot of reason that user app or some
driver wants to use hardware timer. For example, the specific timer may
keep running even system is in low power mode.

Although there's so much hardware timers available, system must choose one for the usage of clock source / clock event / other hardware timer usage.

Quoted 11 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Imagine that only TIMINT1 signal in sp804 is routed to interrupt controller. Could system still pick any one it wants?

Then we need another new property. I try to find using minim properties.

No, we don't. See the discussion with Rob. He has an idea (using the interrupt property only), I have another one (using already defined interrupt-names property). I see you've just came with another one (TIMINTC treated as TIMINT1), which is fine with me. Either way you've got what you need to make the right decision.

Quoted 4 lines

After considered as second time, I think that we still need a property to meet alias usage. Excuse me expand it in this topic.

arm,sp804-has-irq = <offset>;

Interrupt/timer number not offset please. The offset is implied by the fact that the h/w is an sp804. The Integrator AP is not actually an sp804, so it's init should be handled differently with a different compatible property.

Quoted 9 lines

The offset means TIMER register offset. If it's not zero, TIMER2 is using irq. And it could be configured as clock event. Otherwise, TIMER1 is clock event.
We must make sure that only one of all sp804 timers is using this property.

alias:
linux,clocksource = <&sp804-A>
linux,clockevent = <&sp804-A>

Quoted 8 lines

Although both of them points to timerA, only TIMER1 or TIMER2 of sp804 is using irq. So one is clock source, and the other is clock event.

alias:
linux,clocksource = <&sp804-A>
linux,clockevent = <&sp804-B>
The issue comes since system don't know whether TIMER1 or TIMER2 could be configured as clock source.

If you have 2 sp804's, why do you care which one is used by the OS? If they are identical, then it doesn't matter. If they are not, then describe how they are not identical.

The realview and versatile boards currently do this, but there is no good reason that I see and I intend to change this.

Quoted 4 lines

We still need a new property to claim it. It seems that we can't drop "arm,sp804-clocksource", although everybody don't like it.

What's your opinion?

As previously stated, I don't think we need this or the alias based on current in tree users.

There is an issue that you don't know about all available timers so you can select the one with the minimum required features leaving others with more features (i.e. an irq) free. If you need more control like this then you can do custom setup before or instead of calling clocksource_of_init. None of the current platforms have this issue nor do they use sp804 for anything beyond clksrc and clkevt. I would not expect lots of new users of sp804 as I expect most new platforms will use architected timers. So let's not solve imaginary problems now.

Rob

#36 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 6 lines · Rob Herring

If you have 2 sp804's, why do you care which one is used by the OS? If they are identical, then it doesn't matter. If they are not, then describe how they are not identical.

The realview and versatile boards currently do this, but there is no good reason that I see and I intend to change this.

It is highly likely that the timer choice on these boards was made by independent people, who came up with different random choices. Nothing more than that - I believe it to be entirely arbitary. I do think discussion is getting too bogged down on this point.

So, we could make the decision about which timer to use for the clock event based on whether an interrupt is specified, the known clock rate and size of the timer register.

Same can be done for the clock source, but preferring a timer without an interrupt in preference to one with an interrupt.

We do have this nice rating system for clocksources and clockevents - and it could be more flexible if it didn't separate clocksources from clockevents - allowing just a single "timer" and marking it as being suitable as a clocksource or a clockevent, or indeed both.

However, for SP804 selection, there are cases where it matters, such as on Versatile Express where you have to select the right set of SP804 to have a working system (because ARM didn't fully document the SP804 setup there) and we have no way to switch some of those timers from their 32kHz clock source. But then we could just omit the clock source for the "bad" SP804s which would prevent them being used.

#37 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 6 lines · Russell King - ARM Linux

However, for SP804 selection, there are cases where it matters, such as on Versatile Express where you have to select the right set of SP804 to have a working system (because ARM didn't fully document the SP804 setup there) and we have no way to switch some of those timers from their 32kHz clock source. But then we could just omit the clock source for the "bad" SP804s which would prevent them being used.

Both VE motherboard's SP804s TIMCLKENx inputs are fed by the SP810's outputs:

v2m_timer01: timer at 11000 {
	compatible = "arm,sp804", "arm,primecell";
	reg = <0x11000 0x1000>;
	interrupts = <2>;
	clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
	clock-names = "timclken1", "timclken2", "apb_pclk";
};      
v2m_timer23: timer at 12000 {
	compatible = "arm,sp804", "arm,primecell";
	reg = <0x12000 0x1000>;
	interrupts = <3>;
	clocks = <&v2m_sysctl 2>, <&v2m_sysctl 3>, <&smbclk>;
	clock-names = "timclken1", "timclken2", "apb_pclk";
};

TIMCLKs are wired to the SMB_CLK, so the effective rate depends on the TIMCLKENx only.

The SP810 takes the 32kHz and 1MHz reference clocks:

v2m_sysctl: sysctl at 01000 {
	compatible = "arm,sp810", "arm,primecell";
	reg = <0x01000 0x1000>;
	clocks = <&v2m_refclk32khz>, <&v2m_refclk1mhz>, <&smbclk>;
	clock-names = "refclk", "timclk", "apb_pclk";
	#clock-cells = <1>;
	clock-output-names = "timerclken0", "timerclken1", "timerclken2", "timerclken3";
};

and the code in drivers/clk/versatile/clk-vexpress.c picks up the faster one as the parent.

The V2P-CA9 SP804's TIMCLK is wired to one of the main clock generators:

timer at 100e4000 {
	compatible = "arm,sp804", "arm,primecell";
	reg = <0x100e4000 0x1000>;
	interrupts = <0 48 4>,
	             <0 49 4>;
	clocks = <&oscclk2>, <&oscclk2>;
	clock-names = "timclk", "apb_pclk";
};

Both TIMCLKEN0 & 1 are pulled up to 1 so they have no effect on the timer rates.

Overall, the description of the VE clocking in the Device Tree is rather complete.

Pawe?

#38 lore raw

PATCH v3 6/11 ARM: vexpress: use clocksource_of_init for sp804

Quoted 10 lines · Pawel Moll
Quoted 6 lines · Russell King - ARM Linux

However, for SP804 selection, there are cases where it matters, such as on Versatile Express where you have to select the right set of SP804 to have a working system (because ARM didn't fully document the SP804 setup there) and we have no way to switch some of those timers from their 32kHz clock source. But then we could just omit the clock source for the "bad" SP804s which would prevent them being used.

Both VE motherboard's SP804s TIMCLKENx inputs are fed by the SP810's outputs:

Sigh.

You do remember who (re)wrote the Versatile Express support that's in mainline... I know that the motherboard SP804s are clocked from the SP810 (which has no published documentation) and these are selectable between 1MHz and 32kHz.

What I was referring to is the SP804s on the CT9x4 tile, which seem to be clocked at 32kHz with no way to change them, and it's that which has been totally and utterly undocumented (believe me, when I did that work above, I searched the available documentation many times.)

It may be that as a result of my complaints to ARM about that, the documentation has since been fixed. Whether it makes sense to use the CT9x4 SP804s over the motherboards, I've no idea because I've been forced out of the loop on Versatile Express.

#39 lore raw

PATCH v3 7/11 ARM: debug: support debug ll on hisilicon soc

In reply to Haojian Zhuang

Support UART0 debug ll on hisilicon Hi3620 SoC.

---
 arch/arm/Kconfig.debug             |   15 +++++++++++++++
 arch/arm/include/debug/hisilicon.S |   30 ++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 arch/arm/include/debug/hisilicon.S
arch/arm/Kconfig.debug +15 -0
index ecfcdba..fd2a39d 100644
@@ -240,6 +240,20 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on i.MX6Q.
 
+	config DEBUG_HI3620_UART
+		bool "Hisilicon HI3620 Debug UART"
+		depends on ARCH_HI3xxx
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on HI3620 UART.
+
+	config DEBUG_HI3716_UART
+		bool "Hisilicon Hi3716 Debug UART"
+		depends on ARCH_HI3xxx
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on HI3716 UART.
+
 	config DEBUG_MMP_UART2
 		bool "Kernel low-level debugging message via MMP UART2"
 		depends on ARCH_MMP
@@ -589,6 +603,7 @@ config DEBUG_LL_INCLUDE
 				 DEBUG_IMX53_UART ||\
 				 DEBUG_IMX6Q_UART
 	default "debug/highbank.S" if DEBUG_HIGHBANK_UART
+	default "debug/hisilicon.S" if DEBUG_HI3620_UART || DEBUG_HI3716_UART
 	default "debug/mvebu.S" if DEBUG_MVEBU_UART
 	default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
 	default "debug/picoxcell.S" if DEBUG_PICOXCELL_UART
arch/arm/include/debug/hisilicon.S new file +30 -0
new file mode 100644
index 0000000..47ad019
@@ -0,0 +1,30 @@
+/*
+ * Early serial output macro for Hisilicon SoC
+ *
+ * Copyright (C) 2012-2013 Hisilicon Technologies Co., Ltd.
+ * Copyright (C) 2012-2013 Linaro Ltd.
+ *
+ * Author: Haojian Zhuang <[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.
+*/
+
+#if defined(CONFIG_DEBUG_HI3620_UART)
+#define HS_UART_PHYS_BASE	0xfcb00000
+#define HS_UART_VIRT_BASE	0xfeb00000
+#elif defined(CONFIG_DEBUG_HI3716_UART)
+#define HS_UART_PHYS_BASE	0xf8b00000
+#define HS_UART_VIRT_BASE	0xfeb00000
+#endif
+
+#if defined(CONFIG_DEBUG_HI3620_UART) || defined(CONFIG_DEBUG_HI3716_UART)
+		.macro	addruart,rp,rv,tmp
+		ldr	\rp, =HS_UART_PHYS_BASE
+		ldr	\rv, =HS_UART_VIRT_BASE
+		.endm
+
+#include <asm/hardware/debug-pl01x.S>
+
+#endif
Signature · 1 line
1.7.10.4
#40 lore raw

PATCH v3 8/11 clk: hi3xxx: add clock support

In reply to Haojian Zhuang

Add clock support with device tree on Hisilicon SoC.

---
 .../devicetree/bindings/clock/hisilicon.txt        |   73 +++
 drivers/clk/Makefile                               |    1 +
 drivers/clk/clk-hi3xxx.c                           |  643 ++++++++++++++++++++
 3 files changed, 717 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/hisilicon.txt
 create mode 100644 drivers/clk/clk-hi3xxx.c
Documentation/devicetree/bindings/clock/hisilicon.txt new file +73 -0
new file mode 100644
index 0000000..be8db9d
@@ -0,0 +1,73 @@
+Device Tree Clock bindings for arch-vt8500
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties for mux clocks:
+ - compatible : Shall be "hisilicon,hi3620-clk-mux".
+ - clocks : shall be the input parent clock phandle for the clock. This should
+	be the reference clock.
+ - clock-output-names : shall be reference name.
+ - #clock-cells : from common clock binding; shall be set to 0.
+ - hisilicon,hi3620-mux : array of mux register offset & mask bits
+
+Required properties for Hi3620 gate clocks:
+ - compatible : Shall be "hisilicon,hi3620-clk-gate".
+ - clocks : shall be the input parent clock phandle for the clock. This should
+	be the reference clock.
+ - clock-output-names : shall be reference name.
+ - #clock-cells : from common clock binding; shall be set to 0.
+ - hisilicon,hi3620-clkgate : array of enable register offset & enable bits
+ - hisilicon,hi3620-clkreset : array of reset register offset & enable bits
+
+Required properties for clock divider:
+ - compatible : Shall be "hisilicon,hi3620-clk-div".
+ - clocks : shall be the input parent clock phandle for the clock. This should
+	be the reference clock.
+ - clock-output-names : shall be reference name.
+ - #clock-cells : from common clock binding; shall be set to 0.
+ - #hisilicon,clkdiv-table-cells : the number of parameters after phandle in
+   hisilicon,clkdiv-table property.
+ - hisilicon,clkdiv-table : list of value that are used to configure clock
+   divider. They're value of phandle, index & divider value.
+ - hisilicon,clkdiv : array of divider register offset & mask bits.
+
+Required properties for gate clocks:
+ - compatible : Shall be "hisilicon,clk-gate".
+ - clocks : shall be the input parent clock phandle for the clock. This should
+	be the reference clock.
+ - clock-output-names : shall be reference name.
+ - #clock-cells : from common clock binding; shall be set to 0.
+ - hisilicon,clkgate-inverted : bool value. True means that set-to-disable.
+
+Required properties for clock fixed factor divider:
+ - compatible : Shall be "hisilicon,fixed-factor".
+ - clocks : shall be the input parent clock phandle for the clock. This should
+	be the reference clock.
+ - clock-output-names : shall be reference name.
+ - #clock-cells : from common clock binding; shall be set to 0.
+ - hisilicon,fixed-factor : array of multiplier & divider.
+
+For example:
+	timclk1: clkgate at 38 {
+		compatible = "hisilicon,clk-gate";
+		#clock-cells = <0>;
+		clocks = <&refclk_timer1>;
+		clock-output-names = "timclk1";
+		hisilicon,clkgate-inverted;
+		hisilicon,clkgate = <0 18>;
+	};
+
+	dtable: clkdiv at 0 {
+		#hisilicon,clkdiv-table-cells = <2>;
+	};
+
+	div_cfgaxi: clkdiv at 2 {
+		compatible = "hisilicon,hi3620-clk-div";
+		#clock-cells = <0>;
+		clocks = <&div_shareaxi>;
+		clock-output-names = "cfgAXI_div";
+		hisilicon,clkdiv-table = <&dtable 0x01 2>;
+		hisilicon,clkdiv = <0x100 0x60>;
+	};
drivers/clk/Makefile +1 -0
index 0147022..b065e76 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_COMMON_CLK)	+= clk-mux.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835)	+= clk-bcm2835.o
 obj-$(CONFIG_ARCH_NOMADIK)	+= clk-nomadik.o
+obj-$(CONFIG_ARCH_HI3xxx)	+= clk-hi3xxx.o
 obj-$(CONFIG_ARCH_HIGHBANK)	+= clk-highbank.o
 obj-$(CONFIG_ARCH_MXS)		+= mxs/
 obj-$(CONFIG_ARCH_SOCFPGA)	+= socfpga/
drivers/clk/clk-hi3xxx.c new file +643 -0

643 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#41 lore raw

PATCH v3 9/11 ARM: hi3xxx: add board support with device tree

In reply to Haojian Zhuang

Add board support with device tree for Hisilicon Hi36xx/Hi37xx platform.

---
 .../bindings/arm/hisilicon/hisilicon.txt           |   10 +++++
 arch/arm/Kconfig                                   |    2 +
 arch/arm/Makefile                                  |    1 +
 arch/arm/mach-hi3xxx/Kconfig                       |   13 ++++++
 arch/arm/mach-hi3xxx/Makefile                      |    5 +++
 arch/arm/mach-hi3xxx/hi3xxx.c                      |   45 ++++++++++++++++++++
 6 files changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
 create mode 100644 arch/arm/mach-hi3xxx/Kconfig
 create mode 100644 arch/arm/mach-hi3xxx/Makefile
 create mode 100644 arch/arm/mach-hi3xxx/hi3xxx.c
Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt new file +10 -0
new file mode 100644
index 0000000..3be60c8
@@ -0,0 +1,10 @@
+Hisilicon Platforms Device Tree Bindings
+----------------------------------------------------
+
+Hi3716 Development Board
+Required root node properties:
+	- compatible = "hisilicon,hi3716-dkb";
+
+Hi4511 Board
+Required root node properties:
+	- compatible = "hisilicon,hi3620-hi4511";
arch/arm/Kconfig +2 -0
index 10d7e2c..11ef3ea 100644
@@ -1060,6 +1060,8 @@ source "arch/arm/mach-gemini/Kconfig"
 
 source "arch/arm/mach-h720x/Kconfig"
 
+source "arch/arm/mach-hi3xxx/Kconfig"
+
 source "arch/arm/mach-highbank/Kconfig"
 
 source "arch/arm/mach-integrator/Kconfig"
arch/arm/Makefile +1 -0
index ee4605f..4b0de9e 100644
@@ -148,6 +148,7 @@ machine-$(CONFIG_ARCH_EBSA110)		+= ebsa110
 machine-$(CONFIG_ARCH_EP93XX)		+= ep93xx
 machine-$(CONFIG_ARCH_GEMINI)		+= gemini
 machine-$(CONFIG_ARCH_H720X)		+= h720x
+machine-$(CONFIG_ARCH_HI3xxx)		+= hi3xxx
 machine-$(CONFIG_ARCH_HIGHBANK)		+= highbank
 machine-$(CONFIG_ARCH_INTEGRATOR)	+= integrator
 machine-$(CONFIG_ARCH_IOP13XX)		+= iop13xx
arch/arm/mach-hi3xxx/Kconfig new file +13 -0
new file mode 100644
index 0000000..a991dee
@@ -0,0 +1,13 @@
+config ARCH_HI3xxx
+	bool "Hisilicon Hi36xx/Hi37xx family" if ARCH_MULTI_V7
+	select ARM_AMBA
+	select ARM_GIC
+	select CACHE_L2X0
+	select CACHE_PL310
+	select CLKSRC_OF
+	select PINCTRL
+	select PINCTRL_SINGLE
+	select SERIAL_AMBA_PL011
+	select SERIAL_AMBA_PL011_CONSOLE
+	help
+	  Support for Hisilicon Hi36xx/Hi37xx processor family
arch/arm/mach-hi3xxx/Makefile new file +5 -0
new file mode 100644
index 0000000..d68ebb3
@@ -0,0 +1,5 @@
+#
+# Makefile for Hisilicon Hi36xx/Hi37xx processors line
+#
+
+obj-y	+= hi3xxx.o
arch/arm/mach-hi3xxx/hi3xxx.c new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#42 lore raw

PATCH v3 10/11 ARM: hi3xxx: enable hi4511 with device tree

In reply to Haojian Zhuang

Enable Hisilicon Hi4511 development platform with device tree support.

---
 arch/arm/boot/dts/Makefile    |    1 +
 arch/arm/boot/dts/hi3620.dtsi | 1155 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/hi4511.dts  |  743 ++++++++++++++++++++++++++
 3 files changed, 1899 insertions(+)
 create mode 100644 arch/arm/boot/dts/hi3620.dtsi
 create mode 100644 arch/arm/boot/dts/hi4511.dts
arch/arm/boot/dts/Makefile +1 -0
index 1d14ebb..3c0410e 100644
@@ -49,6 +49,7 @@ dtb-$(CONFIG_ARCH_EXYNOS) += exynos4210-origen.dtb \
 	exynos5250-smdk5250.dtb \
 	exynos5250-snow.dtb \
 	exynos5440-ssdk5440.dtb
+dtb-$(CONFIG_ARCH_HI3xxx) += hi4511.dtb
 dtb-$(CONFIG_ARCH_HIGHBANK) += highbank.dtb \
 	ecx-2000.dtb
 dtb-$(CONFIG_ARCH_INTEGRATOR) += integratorap.dtb \
arch/arm/boot/dts/hi3620.dtsi new file +1155 -0

1,155 lines not on this page · raw message

arch/arm/boot/dts/hi4511.dts new file +743 -0

743 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#43 lore raw

PATCH v3 11/11 ARM: config: append arch hi3xxx into multi defconfig

In reply to Haojian Zhuang

Append ARCH_HI3xxx (Hisilicon SoC) into multi_v7_defconfig.

---
 arch/arm/configs/multi_v7_defconfig |    1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
index e31d442..1891611 100644
@@ -5,6 +5,7 @@ CONFIG_ARCH_MVEBU=y
 CONFIG_MACH_ARMADA_370=y
 CONFIG_MACH_ARMADA_XP=y
 CONFIG_ARCH_HIGHBANK=y
+CONFIG_ARCH_HI3xxx=y
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_ARCH_SUNXI=y
 # CONFIG_ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA is not set
Signature · 1 line
1.7.10.4