diff options
author | Dinh Nguyen <dinguyen@altera.com> | 2012-07-11 16:13:16 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-07-12 11:26:09 -0400 |
commit | cfda590178a16e2b5edb09e131460b3e64819807 (patch) | |
tree | 7104a9bb75d101dcdc82c331e9cdd075eab702dc /arch/arm/mach-picoxcell | |
parent | bd0a521e88aa7a06ae7aabaed7ae196ed4ad867a (diff) |
clocksource: dw_apb_timer: Add common DTS glue for dw_apb_timer
Make a common device tree glue for clocksource/dw_apb_timer.
Move mach-picoxcell/time.c to be a generic device tree application
of the dw_apb_timer.
Configure mach-picoxcell to use the dw_apb_timer_of device tree
implementation in drivers/clocksource.
Signed-off-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Dinh Nguyen <dinguyen@altera.com>
Acked-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arm/mach-picoxcell')
-rw-r--r-- | arch/arm/mach-picoxcell/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-picoxcell/common.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-picoxcell/common.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-picoxcell/time.c | 121 |
4 files changed, 3 insertions, 124 deletions
diff --git a/arch/arm/mach-picoxcell/Makefile b/arch/arm/mach-picoxcell/Makefile index e5ec4a8d9bcb..8e39f80fce19 100644 --- a/arch/arm/mach-picoxcell/Makefile +++ b/arch/arm/mach-picoxcell/Makefile | |||
@@ -1,2 +1 @@ | |||
1 | obj-y := common.o | obj-y := common.o | |
2 | obj-y += time.o | ||
diff --git a/arch/arm/mach-picoxcell/common.c b/arch/arm/mach-picoxcell/common.c index a2e8ae8b5821..8f9a0b47a7fa 100644 --- a/arch/arm/mach-picoxcell/common.c +++ b/arch/arm/mach-picoxcell/common.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/of_address.h> | 14 | #include <linux/of_address.h> |
15 | #include <linux/of_irq.h> | 15 | #include <linux/of_irq.h> |
16 | #include <linux/of_platform.h> | 16 | #include <linux/of_platform.h> |
17 | #include <linux/dw_apb_timer.h> | ||
17 | 18 | ||
18 | #include <asm/mach/arch.h> | 19 | #include <asm/mach/arch.h> |
19 | #include <asm/hardware/vic.h> | 20 | #include <asm/hardware/vic.h> |
@@ -97,7 +98,7 @@ DT_MACHINE_START(PICOXCELL, "Picochip picoXcell") | |||
97 | .nr_irqs = NR_IRQS_LEGACY, | 98 | .nr_irqs = NR_IRQS_LEGACY, |
98 | .init_irq = picoxcell_init_irq, | 99 | .init_irq = picoxcell_init_irq, |
99 | .handle_irq = vic_handle_irq, | 100 | .handle_irq = vic_handle_irq, |
100 | .timer = &picoxcell_timer, | 101 | .timer = &dw_apb_timer, |
101 | .init_machine = picoxcell_init_machine, | 102 | .init_machine = picoxcell_init_machine, |
102 | .dt_compat = picoxcell_dt_match, | 103 | .dt_compat = picoxcell_dt_match, |
103 | .restart = picoxcell_wdt_restart, | 104 | .restart = picoxcell_wdt_restart, |
diff --git a/arch/arm/mach-picoxcell/common.h b/arch/arm/mach-picoxcell/common.h index 83d55ab956a4..a65cb02f84c8 100644 --- a/arch/arm/mach-picoxcell/common.h +++ b/arch/arm/mach-picoxcell/common.h | |||
@@ -12,6 +12,6 @@ | |||
12 | 12 | ||
13 | #include <asm/mach/time.h> | 13 | #include <asm/mach/time.h> |
14 | 14 | ||
15 | extern struct sys_timer picoxcell_timer; | 15 | extern struct sys_timer dw_apb_timer; |
16 | 16 | ||
17 | #endif /* __PICOXCELL_COMMON_H__ */ | 17 | #endif /* __PICOXCELL_COMMON_H__ */ |
diff --git a/arch/arm/mach-picoxcell/time.c b/arch/arm/mach-picoxcell/time.c deleted file mode 100644 index 2ecba6743b8e..000000000000 --- a/arch/arm/mach-picoxcell/time.c +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 Picochip Ltd., Jamie Iles | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * All enquiries to support@picochip.com | ||
9 | */ | ||
10 | #include <linux/dw_apb_timer.h> | ||
11 | #include <linux/of.h> | ||
12 | #include <linux/of_address.h> | ||
13 | #include <linux/of_irq.h> | ||
14 | |||
15 | #include <asm/mach/time.h> | ||
16 | #include <asm/sched_clock.h> | ||
17 | |||
18 | #include "common.h" | ||
19 | |||
20 | static void timer_get_base_and_rate(struct device_node *np, | ||
21 | void __iomem **base, u32 *rate) | ||
22 | { | ||
23 | *base = of_iomap(np, 0); | ||
24 | |||
25 | if (!*base) | ||
26 | panic("Unable to map regs for %s", np->name); | ||
27 | |||
28 | if (of_property_read_u32(np, "clock-freq", rate)) | ||
29 | panic("No clock-freq property for %s", np->name); | ||
30 | } | ||
31 | |||
32 | static void picoxcell_add_clockevent(struct device_node *event_timer) | ||
33 | { | ||
34 | void __iomem *iobase; | ||
35 | struct dw_apb_clock_event_device *ced; | ||
36 | u32 irq, rate; | ||
37 | |||
38 | irq = irq_of_parse_and_map(event_timer, 0); | ||
39 | if (irq == NO_IRQ) | ||
40 | panic("No IRQ for clock event timer"); | ||
41 | |||
42 | timer_get_base_and_rate(event_timer, &iobase, &rate); | ||
43 | |||
44 | ced = dw_apb_clockevent_init(0, event_timer->name, 300, iobase, irq, | ||
45 | rate); | ||
46 | if (!ced) | ||
47 | panic("Unable to initialise clockevent device"); | ||
48 | |||
49 | dw_apb_clockevent_register(ced); | ||
50 | } | ||
51 | |||
52 | static void picoxcell_add_clocksource(struct device_node *source_timer) | ||
53 | { | ||
54 | void __iomem *iobase; | ||
55 | struct dw_apb_clocksource *cs; | ||
56 | u32 rate; | ||
57 | |||
58 | timer_get_base_and_rate(source_timer, &iobase, &rate); | ||
59 | |||
60 | cs = dw_apb_clocksource_init(300, source_timer->name, iobase, rate); | ||
61 | if (!cs) | ||
62 | panic("Unable to initialise clocksource device"); | ||
63 | |||
64 | dw_apb_clocksource_start(cs); | ||
65 | dw_apb_clocksource_register(cs); | ||
66 | } | ||
67 | |||
68 | static void __iomem *sched_io_base; | ||
69 | |||
70 | static u32 picoxcell_read_sched_clock(void) | ||
71 | { | ||
72 | return __raw_readl(sched_io_base); | ||
73 | } | ||
74 | |||
75 | static const struct of_device_id picoxcell_rtc_ids[] __initconst = { | ||
76 | { .compatible = "picochip,pc3x2-rtc" }, | ||
77 | { /* Sentinel */ }, | ||
78 | }; | ||
79 | |||
80 | static void picoxcell_init_sched_clock(void) | ||
81 | { | ||
82 | struct device_node *sched_timer; | ||
83 | u32 rate; | ||
84 | |||
85 | sched_timer = of_find_matching_node(NULL, picoxcell_rtc_ids); | ||
86 | if (!sched_timer) | ||
87 | panic("No RTC for sched clock to use"); | ||
88 | |||
89 | timer_get_base_and_rate(sched_timer, &sched_io_base, &rate); | ||
90 | of_node_put(sched_timer); | ||
91 | |||
92 | setup_sched_clock(picoxcell_read_sched_clock, 32, rate); | ||
93 | } | ||
94 | |||
95 | static const struct of_device_id picoxcell_timer_ids[] __initconst = { | ||
96 | { .compatible = "picochip,pc3x2-timer" }, | ||
97 | {}, | ||
98 | }; | ||
99 | |||
100 | static void __init picoxcell_timer_init(void) | ||
101 | { | ||
102 | struct device_node *event_timer, *source_timer; | ||
103 | |||
104 | event_timer = of_find_matching_node(NULL, picoxcell_timer_ids); | ||
105 | if (!event_timer) | ||
106 | panic("No timer for clockevent"); | ||
107 | picoxcell_add_clockevent(event_timer); | ||
108 | |||
109 | source_timer = of_find_matching_node(event_timer, picoxcell_timer_ids); | ||
110 | if (!source_timer) | ||
111 | panic("No timer for clocksource"); | ||
112 | picoxcell_add_clocksource(source_timer); | ||
113 | |||
114 | of_node_put(source_timer); | ||
115 | |||
116 | picoxcell_init_sched_clock(); | ||
117 | } | ||
118 | |||
119 | struct sys_timer picoxcell_timer = { | ||
120 | .init = picoxcell_timer_init, | ||
121 | }; | ||