aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-03-16 15:51:30 -0400
committerArnd Bergmann <arnd@arndb.de>2012-03-16 15:51:30 -0400
commitd4ef467aea0fdcd5e75a4bbfaf97e579bbe532f3 (patch)
tree5b91923fb5031c6963a60ee33ee7671d178f26b2 /arch/arm
parent4acf18232f80c29906356f0f35b2d5f800b5953d (diff)
parent71de5c46e0600b72df58269e80da343e354ddbd7 (diff)
Merge branch 'ux500/dt' into next/dt2
* ux500/dt: ARM: ux500: Provide local timer support for Device Tree ARM: ux500: Enable PL022 SSP Controller in Device Tree ARM: ux500: Enable PL310 Level 2 Cache Controller in Device Tree ARM: ux500: Enable PL011 AMBA UART Controller for Device Tree ARM: ux500: Enable Cortex-A9 GIC (Generic Interrupt Controller) in Device Tree ARM: ux500: db8500: list most devices in the snowball device tree ARM: ux500: split dts file for snowball into generic part ARM: ux500: combine the board init functions for DT boot ARM: ux500: Initial Device Tree support for Snowball ARM: ux500: CONFIG: Enable Device Tree support for future endeavours ARM: ux500: fix compilation after local timer rework (adds dependency on localtimer branch, irqdomain branch and ux500/soc branch) Conflicts: arch/arm/mach-ux500/devices-common.c This adds patches from Lee Jones, Niklas Hernaeus and myself to provide initial device tree support on the ux500 platform. The pull request from Lee contained some other changes, so I rebased the patches on top of the branches that are actually dependencies for this. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/boot/dts/db8500.dtsi275
-rw-r--r--arch/arm/boot/dts/highbank.dts8
-rw-r--r--arch/arm/boot/dts/imx6q.dtsi6
-rw-r--r--arch/arm/boot/dts/snowball.dts139
-rw-r--r--arch/arm/configs/u8500_defconfig1
-rw-r--r--arch/arm/include/asm/localtimer.h37
-rw-r--r--arch/arm/include/asm/smp_twd.h25
-rw-r--r--arch/arm/kernel/smp.c22
-rw-r--r--arch/arm/kernel/smp_twd.c123
-rw-r--r--arch/arm/mach-exynos/mct.c18
-rw-r--r--arch/arm/mach-highbank/Makefile1
-rw-r--r--arch/arm/mach-highbank/highbank.c3
-rw-r--r--arch/arm/mach-highbank/localtimer.c40
-rw-r--r--arch/arm/mach-imx/Makefile1
-rw-r--r--arch/arm/mach-imx/localtimer.c35
-rw-r--r--arch/arm/mach-imx/mach-imx6q.c2
-rw-r--r--arch/arm/mach-msm/timer.c79
-rw-r--r--arch/arm/mach-nomadik/board-nhk8815.c7
-rw-r--r--arch/arm/mach-nomadik/include/mach/setup.h19
-rw-r--r--arch/arm/mach-omap2/Makefile1
-rw-r--r--arch/arm/mach-omap2/timer-mpu.c39
-rw-r--r--arch/arm/mach-omap2/timer.c22
-rw-r--r--arch/arm/mach-realview/realview_eb.c27
-rw-r--r--arch/arm/mach-realview/realview_pb11mp.c21
-rw-r--r--arch/arm/mach-realview/realview_pbx.c20
-rw-r--r--arch/arm/mach-shmobile/Makefile1
-rw-r--r--arch/arm/mach-shmobile/include/mach/common.h2
-rw-r--r--arch/arm/mach-shmobile/localtimer.c26
-rw-r--r--arch/arm/mach-shmobile/platsmp.c1
-rw-r--r--arch/arm/mach-shmobile/smp-r8a7779.c8
-rw-r--r--arch/arm/mach-shmobile/smp-sh73a0.c8
-rw-r--r--arch/arm/mach-shmobile/timer.c10
-rw-r--r--arch/arm/mach-tegra/Makefile2
-rw-r--r--arch/arm/mach-tegra/localtimer.c26
-rw-r--r--arch/arm/mach-tegra/timer.c22
-rw-r--r--arch/arm/mach-ux500/Kconfig7
-rw-r--r--arch/arm/mach-ux500/Makefile1
-rw-r--r--arch/arm/mach-ux500/Makefile.boot1
-rw-r--r--arch/arm/mach-ux500/board-mop500-sdi.c31
-rw-r--r--arch/arm/mach-ux500/board-mop500.c171
-rw-r--r--arch/arm/mach-ux500/board-mop500.h8
-rw-r--r--arch/arm/mach-ux500/board-u5500-sdi.c4
-rw-r--r--arch/arm/mach-ux500/board-u5500.c27
-rw-r--r--arch/arm/mach-ux500/cache-l2x0.c7
-rw-r--r--arch/arm/mach-ux500/cpu-db5500.c36
-rw-r--r--arch/arm/mach-ux500/cpu-db8500.c44
-rw-r--r--arch/arm/mach-ux500/cpu.c90
-rw-r--r--arch/arm/mach-ux500/devices-common.c79
-rw-r--r--arch/arm/mach-ux500/devices-common.h83
-rw-r--r--arch/arm/mach-ux500/devices-db5500.h116
-rw-r--r--arch/arm/mach-ux500/devices-db8500.h176
-rw-r--r--arch/arm/mach-ux500/dma-db5500.c3
-rw-r--r--arch/arm/mach-ux500/include/mach/db8500-regs.h3
-rw-r--r--arch/arm/mach-ux500/include/mach/setup.h11
-rw-r--r--arch/arm/mach-ux500/include/mach/usb.h4
-rw-r--r--arch/arm/mach-ux500/localtimer.c29
-rw-r--r--arch/arm/mach-ux500/timer.c44
-rw-r--r--arch/arm/mach-ux500/usb.c7
-rw-r--r--arch/arm/mach-vexpress/ct-ca9x4.c17
-rw-r--r--arch/arm/plat-nomadik/include/plat/mtu.h4
-rw-r--r--arch/arm/plat-nomadik/timer.c33
-rw-r--r--arch/arm/plat-versatile/Makefile1
-rw-r--r--arch/arm/plat-versatile/localtimer.c53
63 files changed, 1392 insertions, 775 deletions
diff --git a/arch/arm/boot/dts/db8500.dtsi b/arch/arm/boot/dts/db8500.dtsi
new file mode 100644
index 000000000000..d73dce645667
--- /dev/null
+++ b/arch/arm/boot/dts/db8500.dtsi
@@ -0,0 +1,275 @@
1/*
2 * Copyright 2012 Linaro Ltd
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/include/ "skeleton.dtsi"
13
14/ {
15 soc-u9500 {
16 #address-cells = <1>;
17 #size-cells = <1>;
18 compatible = "stericsson,db8500";
19 interrupt-parent = <&intc>;
20 ranges;
21
22 intc: interrupt-controller@a0411000 {
23 compatible = "arm,cortex-a9-gic";
24 #interrupt-cells = <3>;
25 #address-cells = <1>;
26 interrupt-controller;
27 interrupt-parent;
28 reg = <0xa0411000 0x1000>,
29 <0xa0410100 0x100>;
30 };
31
32 L2: l2-cache {
33 compatible = "arm,pl310-cache";
34 reg = <0xa0412000 0x1000>;
35 interrupts = <0 13 4>;
36 cache-unified;
37 cache-level = <2>;
38 };
39
40 pmu {
41 compatible = "arm,cortex-a9-pmu";
42 interrupts = <0 7 0x4>;
43 };
44
45 timer@a0410600 {
46 compatible = "arm,cortex-a9-twd-timer";
47 reg = <0xa0410600 0x20>;
48 interrupts = <1 13 0x304>;
49 };
50
51 rtc@80154000 {
52 compatible = "stericsson,db8500-rtc";
53 reg = <0x80154000 0x1000>;
54 interrupts = <0 18 0x4>;
55 };
56
57 gpio0: gpio@8012e000 {
58 compatible = "stericsson,db8500-gpio",
59 "stmicroelectronics,nomadik-gpio";
60 reg = <0x8012e000 0x80>;
61 interrupts = <0 119 0x4>;
62 supports-sleepmode;
63 gpio-controller;
64 };
65
66 gpio1: gpio@8012e080 {
67 compatible = "stericsson,db8500-gpio",
68 "stmicroelectronics,nomadik-gpio";
69 reg = <0x8012e080 0x80>;
70 interrupts = <0 120 0x4>;
71 supports-sleepmode;
72 gpio-controller;
73 };
74
75 gpio2: gpio@8000e000 {
76 compatible = "stericsson,db8500-gpio",
77 "stmicroelectronics,nomadik-gpio";
78 reg = <0x8000e000 0x80>;
79 interrupts = <0 121 0x4>;
80 supports-sleepmode;
81 gpio-controller;
82 };
83
84 gpio3: gpio@8000e080 {
85 compatible = "stericsson,db8500-gpio",
86 "stmicroelectronics,nomadik-gpio";
87 reg = <0x8000e080 0x80>;
88 interrupts = <0 122 0x4>;
89 supports-sleepmode;
90 gpio-controller;
91 };
92
93 gpio4: gpio@8000e100 {
94 compatible = "stericsson,db8500-gpio",
95 "stmicroelectronics,nomadik-gpio";
96 reg = <0x8000e100 0x80>;
97 interrupts = <0 123 0x4>;
98 supports-sleepmode;
99 gpio-controller;
100 };
101
102 gpio5: gpio@8000e180 {
103 compatible = "stericsson,db8500-gpio",
104 "stmicroelectronics,nomadik-gpio";
105 reg = <0x8000e180 0x80>;
106 interrupts = <0 124 0x4>;
107 supports-sleepmode;
108 gpio-controller;
109 };
110
111 gpio6: gpio@8011e000 {
112 compatible = "stericsson,db8500-gpio",
113 "stmicroelectronics,nomadik-gpio";
114 reg = <0x8011e000 0x80>;
115 interrupts = <0 125 0x4>;
116 supports-sleepmode;
117 gpio-controller;
118 };
119
120 gpio7: gpio@8011e080 {
121 compatible = "stericsson,db8500-gpio",
122 "stmicroelectronics,nomadik-gpio";
123 reg = <0x8011e080 0x80>;
124 interrupts = <0 126 0x4>;
125 supports-sleepmode;
126 gpio-controller;
127 };
128
129 gpio8: gpio@a03fe000 {
130 compatible = "stericsson,db8500-gpio",
131 "stmicroelectronics,nomadik-gpio";
132 reg = <0xa03fe000 0x80>;
133 interrupts = <0 127 0x4>;
134 supports-sleepmode;
135 gpio-controller;
136 };
137
138 usb@a03e0000 {
139 compatible = "stericsson,db8500-musb",
140 "mentor,musb";
141 reg = <0xa03e0000 0x10000>;
142 interrupts = <0 23 0x4>;
143 };
144
145 dma-controller@801C0000 {
146 compatible = "stericsson,db8500-dma40",
147 "stericsson,dma40";
148 reg = <0x801C0000 0x1000 0x40010000 0x800>;
149 interrupts = <0 25 0x4>;
150 };
151
152 prcmu@80157000 {
153 compatible = "stericsson,db8500-prcmu";
154 reg = <0x80157000 0x1000>;
155 interrupts = <46 47>;
156 #address-cells = <1>;
157 #size-cells = <0>;
158
159 ab8500@5 {
160 compatible = "stericsson,ab8500";
161 reg = <5>; /* mailbox 5 is i2c */
162 interrupts = <0 40 0x4>;
163 };
164 };
165
166 i2c@80004000 {
167 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
168 reg = <0x80004000 0x1000>;
169 interrupts = <0 21 0x4>;
170 #address-cells = <1>;
171 #size-cells = <0>;
172 };
173
174 i2c@80122000 {
175 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
176 reg = <0x80122000 0x1000>;
177 interrupts = <0 22 0x4>;
178 #address-cells = <1>;
179 #size-cells = <0>;
180 };
181
182 i2c@80128000 {
183 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
184 reg = <0x80128000 0x1000>;
185 interrupts = <0 55 0x4>;
186 #address-cells = <1>;
187 #size-cells = <0>;
188 };
189
190 i2c@80110000 {
191 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
192 reg = <0x80110000 0x1000>;
193 interrupts = <0 12 0x4>;
194 #address-cells = <1>;
195 #size-cells = <0>;
196 };
197
198 i2c@8012a000 {
199 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
200 reg = <0x8012a000 0x1000>;
201 interrupts = <0 51 0x4>;
202 #address-cells = <1>;
203 #size-cells = <0>;
204 };
205
206 ssp@80002000 {
207 compatible = "arm,pl022", "arm,primecell";
208 reg = <80002000 0x1000>;
209 interrupts = <0 14 0x4>;
210 #address-cells = <1>;
211 #size-cells = <0>;
212 status = "disabled";
213
214 // Add one of these for each child device
215 cs-gpios = <&gpio0 31 &gpio4 14 &gpio4 16 &gpio6 22 &gpio7 0>;
216
217 };
218
219 uart@80120000 {
220 compatible = "arm,pl011", "arm,primecell";
221 reg = <0x80120000 0x1000>;
222 interrupts = <0 11 0x4>;
223 status = "disabled";
224 };
225 uart@80121000 {
226 compatible = "arm,pl011", "arm,primecell";
227 reg = <0x80121000 0x1000>;
228 interrupts = <0 19 0x4>;
229 status = "disabled";
230 };
231 uart@80007000 {
232 compatible = "arm,pl011", "arm,primecell";
233 reg = <0x80007000 0x1000>;
234 interrupts = <0 26 0x4>;
235 status = "disabled";
236 };
237
238 sdi@80126000 {
239 compatible = "arm,pl18x", "arm,primecell";
240 reg = <0x80126000 0x1000>;
241 interrupts = <0 60 0x4>;
242 status = "disabled";
243 };
244 sdi@80118000 {
245 compatible = "arm,pl18x", "arm,primecell";
246 reg = <0x80118000 0x1000>;
247 interrupts = <0 50 0x4>;
248 status = "disabled";
249 };
250 sdi@80005000 {
251 compatible = "arm,pl18x", "arm,primecell";
252 reg = <0x80005000 0x1000>;
253 interrupts = <0 41 0x4>;
254 status = "disabled";
255 };
256 sdi@80119000 {
257 compatible = "arm,pl18x", "arm,primecell";
258 reg = <0x80119000 0x1000>;
259 interrupts = <0 59 0x4>;
260 status = "disabled";
261 };
262 sdi@80114000 {
263 compatible = "arm,pl18x", "arm,primecell";
264 reg = <0x80114000 0x1000>;
265 interrupts = <0 99 0x4>;
266 status = "disabled";
267 };
268 sdi@80008000 {
269 compatible = "arm,pl18x", "arm,primecell";
270 reg = <0x80114000 0x1000>;
271 interrupts = <0 100 0x4>;
272 status = "disabled";
273 };
274 };
275};
diff --git a/arch/arm/boot/dts/highbank.dts b/arch/arm/boot/dts/highbank.dts
index 305635bd45c0..37c0ff9c8b90 100644
--- a/arch/arm/boot/dts/highbank.dts
+++ b/arch/arm/boot/dts/highbank.dts
@@ -72,15 +72,15 @@
72 ranges; 72 ranges;
73 73
74 timer@fff10600 { 74 timer@fff10600 {
75 compatible = "arm,smp-twd"; 75 compatible = "arm,cortex-a9-twd-timer";
76 reg = <0xfff10600 0x20>; 76 reg = <0xfff10600 0x20>;
77 interrupts = <1 13 0xf04>; 77 interrupts = <1 13 0xf01>;
78 }; 78 };
79 79
80 watchdog@fff10620 { 80 watchdog@fff10620 {
81 compatible = "arm,cortex-a9-wdt"; 81 compatible = "arm,cortex-a9-twd-wdt";
82 reg = <0xfff10620 0x20>; 82 reg = <0xfff10620 0x20>;
83 interrupts = <1 14 0xf04>; 83 interrupts = <1 14 0xf01>;
84 }; 84 };
85 85
86 intc: interrupt-controller@fff11000 { 86 intc: interrupt-controller@fff11000 {
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 263e8f3664b5..4905f51a106f 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -88,9 +88,9 @@
88 ranges; 88 ranges;
89 89
90 timer@00a00600 { 90 timer@00a00600 {
91 compatible = "arm,smp-twd"; 91 compatible = "arm,cortex-a9-twd-timer";
92 reg = <0x00a00600 0x100>; 92 reg = <0x00a00600 0x20>;
93 interrupts = <1 13 0xf4>; 93 interrupts = <1 13 0xf01>;
94 }; 94 };
95 95
96 L2: l2-cache@00a02000 { 96 L2: l2-cache@00a02000 {
diff --git a/arch/arm/boot/dts/snowball.dts b/arch/arm/boot/dts/snowball.dts
new file mode 100644
index 000000000000..359c6d679156
--- /dev/null
+++ b/arch/arm/boot/dts/snowball.dts
@@ -0,0 +1,139 @@
1/*
2 * Copyright 2011 ST-Ericsson AB
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/dts-v1/;
13/include/ "db8500.dtsi"
14
15/ {
16 model = "Calao Systems Snowball platform with device tree";
17 compatible = "calaosystems,snowball-a9500";
18
19 memory {
20 reg = <0x00000000 0x20000000>;
21 };
22
23 gpio_keys {
24 compatible = "gpio-keys";
25 #address-cells = <1>;
26 #size-cells = <0>;
27
28 button@1 {
29 debounce_interval = <50>;
30 wakeup = <1>;
31 linux,code = <2>;
32 label = "userpb";
33 gpios = <&gpio1 0>;
34 };
35 button@2 {
36 debounce_interval = <50>;
37 wakeup = <1>;
38 linux,code = <3>;
39 label = "userpb";
40 gpios = <&gpio4 23>;
41 };
42 button@3 {
43 debounce_interval = <50>;
44 wakeup = <1>;
45 linux,code = <4>;
46 label = "userpb";
47 gpios = <&gpio4 23>;
48 };
49 button@4 {
50 debounce_interval = <50>;
51 wakeup = <1>;
52 linux,code = <5>;
53 label = "userpb";
54 gpios = <&gpio5 1>;
55 };
56 button@5 {
57 debounce_interval = <50>;
58 wakeup = <1>;
59 linux,code = <6>;
60 label = "userpb";
61 gpios = <&gpio5 2>;
62 };
63 };
64
65 leds {
66 compatible = "gpio-leds";
67 used-led {
68 label = "user_led";
69 gpios = <&gpio4 14>;
70 };
71 };
72
73 soc-u9500 {
74
75 external-bus@50000000 {
76 compatible = "simple-bus";
77 reg = <0x50000000 0x10000000>;
78 #address-cells = <1>;
79 #size-cells = <1>;
80 ranges;
81
82 ethernet@50000000 {
83 compatible = "smsc,9111";
84 reg = <0x50000000 0x10000>;
85 interrupts = <12>;
86 interrupt-parent = <&gpio4>;
87 };
88 };
89
90 sdi@80126000 {
91 status = "enabled";
92 cd-gpios = <&gpio6 26>;
93 };
94
95 sdi@80114000 {
96 status = "enabled";
97 };
98
99 uart@80120000 {
100 status = "okay";
101 };
102
103 uart@80121000 {
104 status = "okay";
105 };
106
107 uart@80007000 {
108 status = "okay";
109 };
110
111 i2c@80004000 {
112 tc3589x@42 {
113 //compatible = "tc3589x";
114 reg = <0x42>;
115 interrupts = <25>;
116 interrupt-parent = <&gpio6>;
117 };
118 tps61052@33 {
119 //compatible = "tps61052";
120 reg = <0x33>;
121 };
122 };
123
124 i2c@80128000 {
125 lp5521@0x33 {
126 // compatible = "lp5521";
127 reg = <0x33>;
128 };
129 lp5521@0x34 {
130 // compatible = "lp5521";
131 reg = <0x34>;
132 };
133 bh1780@0x29 {
134 // compatible = "rohm,bh1780gli";
135 reg = <0x33>;
136 };
137 };
138 };
139};
diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig
index 2d7b6e7b7271..889d73ac1ae1 100644
--- a/arch/arm/configs/u8500_defconfig
+++ b/arch/arm/configs/u8500_defconfig
@@ -13,6 +13,7 @@ CONFIG_UX500_SOC_DB8500=y
13CONFIG_MACH_HREFV60=y 13CONFIG_MACH_HREFV60=y
14CONFIG_MACH_SNOWBALL=y 14CONFIG_MACH_SNOWBALL=y
15CONFIG_MACH_U5500=y 15CONFIG_MACH_U5500=y
16CONFIG_MACH_UX500_DT=y
16CONFIG_NO_HZ=y 17CONFIG_NO_HZ=y
17CONFIG_HIGH_RES_TIMERS=y 18CONFIG_HIGH_RES_TIMERS=y
18CONFIG_SMP=y 19CONFIG_SMP=y
diff --git a/arch/arm/include/asm/localtimer.h b/arch/arm/include/asm/localtimer.h
index c6a18424888e..f77ffc1eb0c2 100644
--- a/arch/arm/include/asm/localtimer.h
+++ b/arch/arm/include/asm/localtimer.h
@@ -11,47 +11,24 @@
11#define __ASM_ARM_LOCALTIMER_H 11#define __ASM_ARM_LOCALTIMER_H
12 12
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/interrupt.h>
15 14
16struct clock_event_device; 15struct clock_event_device;
17 16
18/* 17struct local_timer_ops {
19 * Setup a per-cpu timer, whether it be a local timer or dummy broadcast 18 int (*setup)(struct clock_event_device *);
20 */ 19 void (*stop)(struct clock_event_device *);
21void percpu_timer_setup(void); 20};
22 21
23#ifdef CONFIG_LOCAL_TIMERS 22#ifdef CONFIG_LOCAL_TIMERS
24
25#ifdef CONFIG_HAVE_ARM_TWD
26
27#include "smp_twd.h"
28
29#define local_timer_stop(c) twd_timer_stop((c))
30
31#else
32
33/*
34 * Stop the local timer
35 */
36void local_timer_stop(struct clock_event_device *);
37
38#endif
39
40/* 23/*
41 * Setup a local timer interrupt for a CPU. 24 * Register a local timer driver
42 */ 25 */
43int local_timer_setup(struct clock_event_device *); 26int local_timer_register(struct local_timer_ops *);
44
45#else 27#else
46 28static inline int local_timer_register(struct local_timer_ops *ops)
47static inline int local_timer_setup(struct clock_event_device *evt)
48{ 29{
49 return -ENXIO; 30 return -ENXIO;
50} 31}
51
52static inline void local_timer_stop(struct clock_event_device *evt)
53{
54}
55#endif 32#endif
56 33
57#endif 34#endif
diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h
index ef9ffba97ad8..0f01f4677bd2 100644
--- a/arch/arm/include/asm/smp_twd.h
+++ b/arch/arm/include/asm/smp_twd.h
@@ -18,11 +18,28 @@
18#define TWD_TIMER_CONTROL_PERIODIC (1 << 1) 18#define TWD_TIMER_CONTROL_PERIODIC (1 << 1)
19#define TWD_TIMER_CONTROL_IT_ENABLE (1 << 2) 19#define TWD_TIMER_CONTROL_IT_ENABLE (1 << 2)
20 20
21struct clock_event_device; 21#include <linux/ioport.h>
22 22
23extern void __iomem *twd_base; 23struct twd_local_timer {
24 struct resource res[2];
25};
24 26
25void twd_timer_setup(struct clock_event_device *); 27#define DEFINE_TWD_LOCAL_TIMER(name,base,irq) \
26void twd_timer_stop(struct clock_event_device *); 28struct twd_local_timer name __initdata = { \
29 .res = { \
30 DEFINE_RES_MEM(base, 0x10), \
31 DEFINE_RES_IRQ(irq), \
32 }, \
33};
34
35int twd_local_timer_register(struct twd_local_timer *);
36
37#ifdef CONFIG_HAVE_ARM_TWD
38void twd_local_timer_of_register(void);
39#else
40static inline void twd_local_timer_of_register(void)
41{
42}
43#endif
27 44
28#endif 45#endif
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index cdeb727527d3..1ad84a6c9bfb 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -246,6 +246,8 @@ static void __cpuinit smp_store_cpu_info(unsigned int cpuid)
246 store_cpu_topology(cpuid); 246 store_cpu_topology(cpuid);
247} 247}
248 248
249static void percpu_timer_setup(void);
250
249/* 251/*
250 * This is the secondary CPU boot entry. We're using this CPUs 252 * This is the secondary CPU boot entry. We're using this CPUs
251 * idle thread stack, but a set of temporary page tables. 253 * idle thread stack, but a set of temporary page tables.
@@ -459,7 +461,20 @@ static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt)
459 clockevents_register_device(evt); 461 clockevents_register_device(evt);
460} 462}
461 463
462void __cpuinit percpu_timer_setup(void) 464static struct local_timer_ops *lt_ops;
465
466#ifdef CONFIG_LOCAL_TIMERS
467int local_timer_register(struct local_timer_ops *ops)
468{
469 if (lt_ops)
470 return -EBUSY;
471
472 lt_ops = ops;
473 return 0;
474}
475#endif
476
477static void __cpuinit percpu_timer_setup(void)
463{ 478{
464 unsigned int cpu = smp_processor_id(); 479 unsigned int cpu = smp_processor_id();
465 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu); 480 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
@@ -467,7 +482,7 @@ void __cpuinit percpu_timer_setup(void)
467 evt->cpumask = cpumask_of(cpu); 482 evt->cpumask = cpumask_of(cpu);
468 evt->broadcast = smp_timer_broadcast; 483 evt->broadcast = smp_timer_broadcast;
469 484
470 if (local_timer_setup(evt)) 485 if (!lt_ops || lt_ops->setup(evt))
471 broadcast_timer_setup(evt); 486 broadcast_timer_setup(evt);
472} 487}
473 488
@@ -482,7 +497,8 @@ static void percpu_timer_stop(void)
482 unsigned int cpu = smp_processor_id(); 497 unsigned int cpu = smp_processor_id();
483 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu); 498 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
484 499
485 local_timer_stop(evt); 500 if (lt_ops)
501 lt_ops->stop(evt);
486} 502}
487#endif 503#endif
488 504
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 7a79b24597b2..fef42b21cecb 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -18,20 +18,23 @@
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/jiffies.h> 19#include <linux/jiffies.h>
20#include <linux/clockchips.h> 20#include <linux/clockchips.h>
21#include <linux/irq.h> 21#include <linux/interrupt.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/of_irq.h>
24#include <linux/of_address.h>
23 25
24#include <asm/smp_twd.h> 26#include <asm/smp_twd.h>
25#include <asm/localtimer.h> 27#include <asm/localtimer.h>
26#include <asm/hardware/gic.h> 28#include <asm/hardware/gic.h>
27 29
28/* set up by the platform code */ 30/* set up by the platform code */
29void __iomem *twd_base; 31static void __iomem *twd_base;
30 32
31static struct clk *twd_clk; 33static struct clk *twd_clk;
32static unsigned long twd_timer_rate; 34static unsigned long twd_timer_rate;
33 35
34static struct clock_event_device __percpu **twd_evt; 36static struct clock_event_device __percpu **twd_evt;
37static int twd_ppi;
35 38
36static void twd_set_mode(enum clock_event_mode mode, 39static void twd_set_mode(enum clock_event_mode mode,
37 struct clock_event_device *clk) 40 struct clock_event_device *clk)
@@ -77,7 +80,7 @@ static int twd_set_next_event(unsigned long evt,
77 * If a local timer interrupt has occurred, acknowledge and return 1. 80 * If a local timer interrupt has occurred, acknowledge and return 1.
78 * Otherwise, return 0. 81 * Otherwise, return 0.
79 */ 82 */
80int twd_timer_ack(void) 83static int twd_timer_ack(void)
81{ 84{
82 if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) { 85 if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) {
83 __raw_writel(1, twd_base + TWD_TIMER_INTSTAT); 86 __raw_writel(1, twd_base + TWD_TIMER_INTSTAT);
@@ -87,7 +90,7 @@ int twd_timer_ack(void)
87 return 0; 90 return 0;
88} 91}
89 92
90void twd_timer_stop(struct clock_event_device *clk) 93static void twd_timer_stop(struct clock_event_device *clk)
91{ 94{
92 twd_set_mode(CLOCK_EVT_MODE_UNUSED, clk); 95 twd_set_mode(CLOCK_EVT_MODE_UNUSED, clk);
93 disable_percpu_irq(clk->irq); 96 disable_percpu_irq(clk->irq);
@@ -222,28 +225,10 @@ static struct clk *twd_get_clock(void)
222/* 225/*
223 * Setup the local clock events for a CPU. 226 * Setup the local clock events for a CPU.
224 */ 227 */
225void __cpuinit twd_timer_setup(struct clock_event_device *clk) 228static int __cpuinit twd_timer_setup(struct clock_event_device *clk)
226{ 229{
227 struct clock_event_device **this_cpu_clk; 230 struct clock_event_device **this_cpu_clk;
228 231
229 if (!twd_evt) {
230 int err;
231
232 twd_evt = alloc_percpu(struct clock_event_device *);
233 if (!twd_evt) {
234 pr_err("twd: can't allocate memory\n");
235 return;
236 }
237
238 err = request_percpu_irq(clk->irq, twd_handler,
239 "twd", twd_evt);
240 if (err) {
241 pr_err("twd: can't register interrupt %d (%d)\n",
242 clk->irq, err);
243 return;
244 }
245 }
246
247 if (!twd_clk) 232 if (!twd_clk)
248 twd_clk = twd_get_clock(); 233 twd_clk = twd_get_clock();
249 234
@@ -260,6 +245,7 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
260 clk->rating = 350; 245 clk->rating = 350;
261 clk->set_mode = twd_set_mode; 246 clk->set_mode = twd_set_mode;
262 clk->set_next_event = twd_set_next_event; 247 clk->set_next_event = twd_set_next_event;
248 clk->irq = twd_ppi;
263 249
264 this_cpu_clk = __this_cpu_ptr(twd_evt); 250 this_cpu_clk = __this_cpu_ptr(twd_evt);
265 *this_cpu_clk = clk; 251 *this_cpu_clk = clk;
@@ -267,4 +253,95 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
267 clockevents_config_and_register(clk, twd_timer_rate, 253 clockevents_config_and_register(clk, twd_timer_rate,
268 0xf, 0xffffffff); 254 0xf, 0xffffffff);
269 enable_percpu_irq(clk->irq, 0); 255 enable_percpu_irq(clk->irq, 0);
256
257 return 0;
258}
259
260static struct local_timer_ops twd_lt_ops __cpuinitdata = {
261 .setup = twd_timer_setup,
262 .stop = twd_timer_stop,
263};
264
265static int __init twd_local_timer_common_register(void)
266{
267 int err;
268
269 twd_evt = alloc_percpu(struct clock_event_device *);
270 if (!twd_evt) {
271 err = -ENOMEM;
272 goto out_free;
273 }
274
275 err = request_percpu_irq(twd_ppi, twd_handler, "twd", twd_evt);
276 if (err) {
277 pr_err("twd: can't register interrupt %d (%d)\n", twd_ppi, err);
278 goto out_free;
279 }
280
281 err = local_timer_register(&twd_lt_ops);
282 if (err)
283 goto out_irq;
284
285 return 0;
286
287out_irq:
288 free_percpu_irq(twd_ppi, twd_evt);
289out_free:
290 iounmap(twd_base);
291 twd_base = NULL;
292 free_percpu(twd_evt);
293
294 return err;
270} 295}
296
297int __init twd_local_timer_register(struct twd_local_timer *tlt)
298{
299 if (twd_base || twd_evt)
300 return -EBUSY;
301
302 twd_ppi = tlt->res[1].start;
303
304 twd_base = ioremap(tlt->res[0].start, resource_size(&tlt->res[0]));
305 if (!twd_base)
306 return -ENOMEM;
307
308 return twd_local_timer_common_register();
309}
310
311#ifdef CONFIG_OF
312const static struct of_device_id twd_of_match[] __initconst = {
313 { .compatible = "arm,cortex-a9-twd-timer", },
314 { .compatible = "arm,cortex-a5-twd-timer", },
315 { .compatible = "arm,arm11mp-twd-timer", },
316 { },
317};
318
319void __init twd_local_timer_of_register(void)
320{
321 struct device_node *np;
322 int err;
323
324 np = of_find_matching_node(NULL, twd_of_match);
325 if (!np) {
326 err = -ENODEV;
327 goto out;
328 }
329
330 twd_ppi = irq_of_parse_and_map(np, 0);
331 if (!twd_ppi) {
332 err = -EINVAL;
333 goto out;
334 }
335
336 twd_base = of_iomap(np, 0);
337 if (!twd_base) {
338 err = -ENOMEM;
339 goto out;
340 }
341
342 err = twd_local_timer_common_register();
343
344out:
345 WARN(err, "twd_local_timer_of_register failed (%d)\n", err);
346}
347#endif
diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
index 85b5527d0918..edc4b9488f2f 100644
--- a/arch/arm/mach-exynos/mct.c
+++ b/arch/arm/mach-exynos/mct.c
@@ -21,6 +21,7 @@
21#include <linux/percpu.h> 21#include <linux/percpu.h>
22 22
23#include <asm/hardware/gic.h> 23#include <asm/hardware/gic.h>
24#include <asm/localtimer.h>
24 25
25#include <plat/cpu.h> 26#include <plat/cpu.h>
26 27
@@ -375,7 +376,7 @@ static struct irqaction mct_tick1_event_irq = {
375 .handler = exynos4_mct_tick_isr, 376 .handler = exynos4_mct_tick_isr,
376}; 377};
377 378
378static void exynos4_mct_tick_init(struct clock_event_device *evt) 379static int __cpuinit exynos4_local_timer_setup(struct clock_event_device *evt)
379{ 380{
380 struct mct_clock_event_device *mevt; 381 struct mct_clock_event_device *mevt;
381 unsigned int cpu = smp_processor_id(); 382 unsigned int cpu = smp_processor_id();
@@ -417,17 +418,11 @@ static void exynos4_mct_tick_init(struct clock_event_device *evt)
417 } else { 418 } else {
418 enable_percpu_irq(IRQ_MCT_LOCALTIMER, 0); 419 enable_percpu_irq(IRQ_MCT_LOCALTIMER, 0);
419 } 420 }
420}
421
422/* Setup the local clock events for a CPU */
423int __cpuinit local_timer_setup(struct clock_event_device *evt)
424{
425 exynos4_mct_tick_init(evt);
426 421
427 return 0; 422 return 0;
428} 423}
429 424
430void local_timer_stop(struct clock_event_device *evt) 425static void exynos4_local_timer_stop(struct clock_event_device *evt)
431{ 426{
432 unsigned int cpu = smp_processor_id(); 427 unsigned int cpu = smp_processor_id();
433 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt); 428 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
@@ -439,6 +434,11 @@ void local_timer_stop(struct clock_event_device *evt)
439 else 434 else
440 disable_percpu_irq(IRQ_MCT_LOCALTIMER); 435 disable_percpu_irq(IRQ_MCT_LOCALTIMER);
441} 436}
437
438static struct local_timer_ops exynos4_mct_tick_ops __cpuinitdata = {
439 .setup = exynos4_local_timer_setup,
440 .stop = exynos4_local_timer_stop,
441};
442#endif /* CONFIG_LOCAL_TIMERS */ 442#endif /* CONFIG_LOCAL_TIMERS */
443 443
444static void __init exynos4_timer_resources(void) 444static void __init exynos4_timer_resources(void)
@@ -458,6 +458,8 @@ static void __init exynos4_timer_resources(void)
458 WARN(err, "MCT: can't request IRQ %d (%d)\n", 458 WARN(err, "MCT: can't request IRQ %d (%d)\n",
459 IRQ_MCT_LOCALTIMER, err); 459 IRQ_MCT_LOCALTIMER, err);
460 } 460 }
461
462 local_timer_register(&exynos4_mct_tick_ops);
461#endif /* CONFIG_LOCAL_TIMERS */ 463#endif /* CONFIG_LOCAL_TIMERS */
462} 464}
463 465
diff --git a/arch/arm/mach-highbank/Makefile b/arch/arm/mach-highbank/Makefile
index 986958a5a720..f8437dd238c2 100644
--- a/arch/arm/mach-highbank/Makefile
+++ b/arch/arm/mach-highbank/Makefile
@@ -1,6 +1,5 @@
1obj-y := clock.o highbank.o system.o 1obj-y := clock.o highbank.o system.o
2obj-$(CONFIG_DEBUG_HIGHBANK_UART) += lluart.o 2obj-$(CONFIG_DEBUG_HIGHBANK_UART) += lluart.o
3obj-$(CONFIG_SMP) += platsmp.o 3obj-$(CONFIG_SMP) += platsmp.o
4obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
5obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 4obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
6obj-$(CONFIG_PM_SLEEP) += pm.o 5obj-$(CONFIG_PM_SLEEP) += pm.o
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 8394d512a402..bb1684f9b68b 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -27,6 +27,7 @@
27#include <asm/cacheflush.h> 27#include <asm/cacheflush.h>
28#include <asm/smp_plat.h> 28#include <asm/smp_plat.h>
29#include <asm/smp_scu.h> 29#include <asm/smp_scu.h>
30#include <asm/smp_twd.h>
30#include <asm/hardware/arm_timer.h> 31#include <asm/hardware/arm_timer.h>
31#include <asm/hardware/timer-sp.h> 32#include <asm/hardware/timer-sp.h>
32#include <asm/hardware/gic.h> 33#include <asm/hardware/gic.h>
@@ -111,6 +112,8 @@ static void __init highbank_timer_init(void)
111 112
112 sp804_clocksource_init(timer_base + 0x20, "timer1"); 113 sp804_clocksource_init(timer_base + 0x20, "timer1");
113 sp804_clockevents_init(timer_base, irq, "timer0"); 114 sp804_clockevents_init(timer_base, irq, "timer0");
115
116 twd_local_timer_of_register();
114} 117}
115 118
116static struct sys_timer highbank_timer = { 119static struct sys_timer highbank_timer = {
diff --git a/arch/arm/mach-highbank/localtimer.c b/arch/arm/mach-highbank/localtimer.c
deleted file mode 100644
index 5a00e7945fdf..000000000000
--- a/arch/arm/mach-highbank/localtimer.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * Copyright 2010-2011 Calxeda, Inc.
3 * Based on localtimer.c, Copyright (C) 2002 ARM Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#include <linux/init.h>
18#include <linux/clockchips.h>
19#include <linux/of.h>
20#include <linux/of_address.h>
21#include <linux/of_irq.h>
22
23#include <asm/smp_twd.h>
24
25/*
26 * Setup the local clock events for a CPU.
27 */
28int __cpuinit local_timer_setup(struct clock_event_device *evt)
29{
30 struct device_node *np;
31
32 np = of_find_compatible_node(NULL, NULL, "arm,smp-twd");
33 if (!twd_base) {
34 twd_base = of_iomap(np, 0);
35 WARN_ON(!twd_base);
36 }
37 evt->irq = irq_of_parse_and_map(np, 0);
38 twd_timer_setup(evt);
39 return 0;
40}
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 4ffeca7ee25e..8f57daf5e798 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -72,7 +72,6 @@ obj-$(CONFIG_CPU_V7) += head-v7.o
72AFLAGS_head-v7.o :=-Wa,-march=armv7-a 72AFLAGS_head-v7.o :=-Wa,-march=armv7-a
73obj-$(CONFIG_SMP) += platsmp.o 73obj-$(CONFIG_SMP) += platsmp.o
74obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 74obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
75obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
76obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o mach-imx6q.o 75obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o mach-imx6q.o
77 76
78ifeq ($(CONFIG_PM),y) 77ifeq ($(CONFIG_PM),y)
diff --git a/arch/arm/mach-imx/localtimer.c b/arch/arm/mach-imx/localtimer.c
deleted file mode 100644
index 3a163515d41f..000000000000
--- a/arch/arm/mach-imx/localtimer.c
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright 2011 Freescale Semiconductor, Inc.
3 * Copyright 2011 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/init.h>
14#include <linux/clockchips.h>
15#include <linux/of_address.h>
16#include <linux/of_irq.h>
17#include <asm/smp_twd.h>
18
19/*
20 * Setup the local clock events for a CPU.
21 */
22int __cpuinit local_timer_setup(struct clock_event_device *evt)
23{
24 struct device_node *np;
25
26 np = of_find_compatible_node(NULL, NULL, "arm,smp-twd");
27 if (!twd_base) {
28 twd_base = of_iomap(np, 0);
29 WARN_ON(!twd_base);
30 }
31 evt->irq = irq_of_parse_and_map(np, 0);
32 twd_timer_setup(evt);
33
34 return 0;
35}
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 379b1a9cd22b..7696dfa2bdba 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -21,6 +21,7 @@
21#include <linux/of_platform.h> 21#include <linux/of_platform.h>
22#include <linux/phy.h> 22#include <linux/phy.h>
23#include <linux/micrel_phy.h> 23#include <linux/micrel_phy.h>
24#include <asm/smp_twd.h>
24#include <asm/hardware/cache-l2x0.h> 25#include <asm/hardware/cache-l2x0.h>
25#include <asm/hardware/gic.h> 26#include <asm/hardware/gic.h>
26#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
@@ -120,6 +121,7 @@ static void __init imx6q_init_irq(void)
120static void __init imx6q_timer_init(void) 121static void __init imx6q_timer_init(void)
121{ 122{
122 mx6q_clocks_init(); 123 mx6q_clocks_init();
124 twd_local_timer_of_register();
123} 125}
124 126
125static struct sys_timer imx6q_timer = { 127static struct sys_timer imx6q_timer = {
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index 11d0d8f2656c..75f4be40b3e5 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -127,6 +127,45 @@ static struct clocksource msm_clocksource = {
127 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 127 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
128}; 128};
129 129
130#ifdef CONFIG_LOCAL_TIMERS
131static int __cpuinit msm_local_timer_setup(struct clock_event_device *evt)
132{
133 /* Use existing clock_event for cpu 0 */
134 if (!smp_processor_id())
135 return 0;
136
137 writel_relaxed(0, event_base + TIMER_ENABLE);
138 writel_relaxed(0, event_base + TIMER_CLEAR);
139 writel_relaxed(~0, event_base + TIMER_MATCH_VAL);
140 evt->irq = msm_clockevent.irq;
141 evt->name = "local_timer";
142 evt->features = msm_clockevent.features;
143 evt->rating = msm_clockevent.rating;
144 evt->set_mode = msm_timer_set_mode;
145 evt->set_next_event = msm_timer_set_next_event;
146 evt->shift = msm_clockevent.shift;
147 evt->mult = div_sc(GPT_HZ, NSEC_PER_SEC, evt->shift);
148 evt->max_delta_ns = clockevent_delta2ns(0xf0000000, evt);
149 evt->min_delta_ns = clockevent_delta2ns(4, evt);
150
151 *__this_cpu_ptr(msm_evt.percpu_evt) = evt;
152 clockevents_register_device(evt);
153 enable_percpu_irq(evt->irq, 0);
154 return 0;
155}
156
157static void msm_local_timer_stop(struct clock_event_device *evt)
158{
159 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
160 disable_percpu_irq(evt->irq);
161}
162
163static struct local_timer_ops msm_local_timer_ops __cpuinitdata = {
164 .setup = msm_local_timer_setup,
165 .stop = msm_local_timer_stop,
166};
167#endif /* CONFIG_LOCAL_TIMERS */
168
130static void __init msm_timer_init(void) 169static void __init msm_timer_init(void)
131{ 170{
132 struct clock_event_device *ce = &msm_clockevent; 171 struct clock_event_device *ce = &msm_clockevent;
@@ -173,8 +212,12 @@ static void __init msm_timer_init(void)
173 *__this_cpu_ptr(msm_evt.percpu_evt) = ce; 212 *__this_cpu_ptr(msm_evt.percpu_evt) = ce;
174 res = request_percpu_irq(ce->irq, msm_timer_interrupt, 213 res = request_percpu_irq(ce->irq, msm_timer_interrupt,
175 ce->name, msm_evt.percpu_evt); 214 ce->name, msm_evt.percpu_evt);
176 if (!res) 215 if (!res) {
177 enable_percpu_irq(ce->irq, 0); 216 enable_percpu_irq(ce->irq, 0);
217#ifdef CONFIG_LOCAL_TIMERS
218 local_timer_register(&msm_local_timer_ops);
219#endif
220 }
178 } else { 221 } else {
179 msm_evt.evt = ce; 222 msm_evt.evt = ce;
180 res = request_irq(ce->irq, msm_timer_interrupt, 223 res = request_irq(ce->irq, msm_timer_interrupt,
@@ -191,40 +234,6 @@ err:
191 pr_err("clocksource_register failed\n"); 234 pr_err("clocksource_register failed\n");
192} 235}
193 236
194#ifdef CONFIG_LOCAL_TIMERS
195int __cpuinit local_timer_setup(struct clock_event_device *evt)
196{
197 /* Use existing clock_event for cpu 0 */
198 if (!smp_processor_id())
199 return 0;
200
201 writel_relaxed(0, event_base + TIMER_ENABLE);
202 writel_relaxed(0, event_base + TIMER_CLEAR);
203 writel_relaxed(~0, event_base + TIMER_MATCH_VAL);
204 evt->irq = msm_clockevent.irq;
205 evt->name = "local_timer";
206 evt->features = msm_clockevent.features;
207 evt->rating = msm_clockevent.rating;
208 evt->set_mode = msm_timer_set_mode;
209 evt->set_next_event = msm_timer_set_next_event;
210 evt->shift = msm_clockevent.shift;
211 evt->mult = div_sc(GPT_HZ, NSEC_PER_SEC, evt->shift);
212 evt->max_delta_ns = clockevent_delta2ns(0xf0000000, evt);
213 evt->min_delta_ns = clockevent_delta2ns(4, evt);
214
215 *__this_cpu_ptr(msm_evt.percpu_evt) = evt;
216 clockevents_register_device(evt);
217 enable_percpu_irq(evt->irq, 0);
218 return 0;
219}
220
221void local_timer_stop(struct clock_event_device *evt)
222{
223 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
224 disable_percpu_irq(evt->irq);
225}
226#endif /* CONFIG_LOCAL_TIMERS */
227
228struct sys_timer msm_timer = { 237struct sys_timer msm_timer = {
229 .init = msm_timer_init 238 .init = msm_timer_init
230}; 239};
diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c
index f6f74adbe8c4..58cacafcf662 100644
--- a/arch/arm/mach-nomadik/board-nhk8815.c
+++ b/arch/arm/mach-nomadik/board-nhk8815.c
@@ -27,11 +27,11 @@
27#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
28#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
29#include <asm/mach/flash.h> 29#include <asm/mach/flash.h>
30#include <asm/mach/time.h>
30 31
31#include <plat/gpio-nomadik.h> 32#include <plat/gpio-nomadik.h>
32#include <plat/mtu.h> 33#include <plat/mtu.h>
33 34
34#include <mach/setup.h>
35#include <mach/nand.h> 35#include <mach/nand.h>
36#include <mach/fsmc.h> 36#include <mach/fsmc.h>
37 37
@@ -246,10 +246,7 @@ static void __init nomadik_timer_init(void)
246 src_cr |= SRC_CR_INIT_VAL; 246 src_cr |= SRC_CR_INIT_VAL;
247 writel(src_cr, io_p2v(NOMADIK_SRC_BASE)); 247 writel(src_cr, io_p2v(NOMADIK_SRC_BASE));
248 248
249 /* Save global pointer to mtu, used by platform timer code */ 249 nmdk_timer_init(io_p2v(NOMADIK_MTU0_BASE));
250 mtu_base = io_p2v(NOMADIK_MTU0_BASE);
251
252 nmdk_timer_init();
253} 250}
254 251
255static struct sys_timer nomadik_timer = { 252static struct sys_timer nomadik_timer = {
diff --git a/arch/arm/mach-nomadik/include/mach/setup.h b/arch/arm/mach-nomadik/include/mach/setup.h
deleted file mode 100644
index bcaeaf41c053..000000000000
--- a/arch/arm/mach-nomadik/include/mach/setup.h
+++ /dev/null
@@ -1,19 +0,0 @@
1
2/*
3 * These symbols are needed for board-specific files to call their
4 * own cpu-specific files
5 */
6
7#ifndef __ASM_ARCH_SETUP_H
8#define __ASM_ARCH_SETUP_H
9
10#include <asm/mach/time.h>
11#include <linux/init.h>
12
13#ifdef CONFIG_NOMADIK_8815
14
15extern void nmdk_timer_init(void);
16
17#endif /* NOMADIK_8815 */
18
19#endif /* __ASM_ARCH_SETUP_H */
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index bd76394ccaf8..05c2ffc1030a 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -23,7 +23,6 @@ obj-$(CONFIG_TWL4030_CORE) += omap_twl.o
23 23
24# SMP support ONLY available for OMAP4 24# SMP support ONLY available for OMAP4
25obj-$(CONFIG_SMP) += omap-smp.o omap-headsmp.o 25obj-$(CONFIG_SMP) += omap-smp.o omap-headsmp.o
26obj-$(CONFIG_LOCAL_TIMERS) += timer-mpu.o
27obj-$(CONFIG_HOTPLUG_CPU) += omap-hotplug.o 26obj-$(CONFIG_HOTPLUG_CPU) += omap-hotplug.o
28obj-$(CONFIG_ARCH_OMAP4) += omap4-common.o omap-wakeupgen.o \ 27obj-$(CONFIG_ARCH_OMAP4) += omap4-common.o omap-wakeupgen.o \
29 sleep44xx.o 28 sleep44xx.o
diff --git a/arch/arm/mach-omap2/timer-mpu.c b/arch/arm/mach-omap2/timer-mpu.c
deleted file mode 100644
index 31c0ac4cd66a..000000000000
--- a/arch/arm/mach-omap2/timer-mpu.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * The MPU local timer source file. In OMAP4, both cortex-a9 cores have
3 * own timer in it's MPU domain. These timers will be driving the
4 * linux kernel SMP tick framework when active. These timers are not
5 * part of the wake up domain.
6 *
7 * Copyright (C) 2009 Texas Instruments, Inc.
8 *
9 * Author:
10 * Santosh Shilimkar <santosh.shilimkar@ti.com>
11 *
12 * This file is based on arm realview smp platform file.
13 * Copyright (C) 2002 ARM Ltd.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as
17 * published by the Free Software Foundation.
18 */
19#include <linux/init.h>
20#include <linux/smp.h>
21#include <linux/clockchips.h>
22#include <asm/irq.h>
23#include <asm/smp_twd.h>
24#include <asm/localtimer.h>
25
26/*
27 * Setup the local clock events for a CPU.
28 */
29int __cpuinit local_timer_setup(struct clock_event_device *evt)
30{
31 /* Local timers are not supprted on OMAP4430 ES1.0 */
32 if (omap_rev() == OMAP4430_REV_ES1_0)
33 return -ENXIO;
34
35 evt->irq = OMAP44XX_IRQ_LOCALTIMER;
36 twd_timer_setup(evt);
37 return 0;
38}
39
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 5c9acea95761..c512bac69ec5 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -39,7 +39,7 @@
39 39
40#include <asm/mach/time.h> 40#include <asm/mach/time.h>
41#include <plat/dmtimer.h> 41#include <plat/dmtimer.h>
42#include <asm/localtimer.h> 42#include <asm/smp_twd.h>
43#include <asm/sched_clock.h> 43#include <asm/sched_clock.h>
44#include "common.h" 44#include "common.h"
45#include <plat/omap_hwmod.h> 45#include <plat/omap_hwmod.h>
@@ -324,14 +324,26 @@ OMAP_SYS_TIMER(3_secure)
324#endif 324#endif
325 325
326#ifdef CONFIG_ARCH_OMAP4 326#ifdef CONFIG_ARCH_OMAP4
327static void __init omap4_timer_init(void)
328{
329#ifdef CONFIG_LOCAL_TIMERS 327#ifdef CONFIG_LOCAL_TIMERS
330 twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256); 328static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
331 BUG_ON(!twd_base); 329 OMAP44XX_LOCAL_TWD_BASE,
330 OMAP44XX_IRQ_LOCALTIMER);
332#endif 331#endif
332
333static void __init omap4_timer_init(void)
334{
333 omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE); 335 omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE);
334 omap2_gp_clocksource_init(2, OMAP4_MPU_SOURCE); 336 omap2_gp_clocksource_init(2, OMAP4_MPU_SOURCE);
337#ifdef CONFIG_LOCAL_TIMERS
338 /* Local timers are not supprted on OMAP4430 ES1.0 */
339 if (omap_rev() != OMAP4430_REV_ES1_0) {
340 int err;
341
342 err = twd_local_timer_register(&twd_local_timer);
343 if (err)
344 pr_err("twd_local_timer_register failed %d\n", err);
345 }
346#endif
335} 347}
336OMAP_SYS_TIMER(4) 348OMAP_SYS_TIMER(4)
337#endif 349#endif
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 157e1bc6e83c..baf382c5e776 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -36,7 +36,7 @@
36#include <asm/pgtable.h> 36#include <asm/pgtable.h>
37#include <asm/hardware/gic.h> 37#include <asm/hardware/gic.h>
38#include <asm/hardware/cache-l2x0.h> 38#include <asm/hardware/cache-l2x0.h>
39#include <asm/localtimer.h> 39#include <asm/smp_twd.h>
40 40
41#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
42#include <asm/mach/map.h> 42#include <asm/mach/map.h>
@@ -383,6 +383,23 @@ static void realview_eb11mp_fixup(void)
383 realview_eb_isp1761_resources[1].end = IRQ_EB11MP_USB; 383 realview_eb_isp1761_resources[1].end = IRQ_EB11MP_USB;
384} 384}
385 385
386#ifdef CONFIG_HAVE_ARM_TWD
387static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
388 REALVIEW_EB11MP_TWD_BASE,
389 IRQ_LOCALTIMER);
390
391static void __init realview_eb_twd_init(void)
392{
393 if (core_tile_eb11mp() || core_tile_a9mp()) {
394 int err = twd_local_timer_register(&twd_local_timer);
395 if (err)
396 pr_err("twd_local_timer_register failed %d\n", err);
397 }
398}
399#else
400#define realview_eb_twd_init() do { } while(0)
401#endif
402
386static void __init realview_eb_timer_init(void) 403static void __init realview_eb_timer_init(void)
387{ 404{
388 unsigned int timer_irq; 405 unsigned int timer_irq;
@@ -392,15 +409,13 @@ static void __init realview_eb_timer_init(void)
392 timer2_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE); 409 timer2_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE);
393 timer3_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE) + 0x20; 410 timer3_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE) + 0x20;
394 411
395 if (core_tile_eb11mp() || core_tile_a9mp()) { 412 if (core_tile_eb11mp() || core_tile_a9mp())
396#ifdef CONFIG_LOCAL_TIMERS
397 twd_base = __io_address(REALVIEW_EB11MP_TWD_BASE);
398#endif
399 timer_irq = IRQ_EB11MP_TIMER0_1; 413 timer_irq = IRQ_EB11MP_TIMER0_1;
400 } else 414 else
401 timer_irq = IRQ_EB_TIMER0_1; 415 timer_irq = IRQ_EB_TIMER0_1;
402 416
403 realview_timer_init(timer_irq); 417 realview_timer_init(timer_irq);
418 realview_eb_twd_init();
404} 419}
405 420
406static struct sys_timer realview_eb_timer = { 421static struct sys_timer realview_eb_timer = {
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index ae7fe54f6eb6..a98c536e3327 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -36,7 +36,7 @@
36#include <asm/pgtable.h> 36#include <asm/pgtable.h>
37#include <asm/hardware/gic.h> 37#include <asm/hardware/gic.h>
38#include <asm/hardware/cache-l2x0.h> 38#include <asm/hardware/cache-l2x0.h>
39#include <asm/localtimer.h> 39#include <asm/smp_twd.h>
40 40
41#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
42#include <asm/mach/flash.h> 42#include <asm/mach/flash.h>
@@ -290,6 +290,21 @@ static void __init gic_init_irq(void)
290 gic_cascade_irq(1, IRQ_TC11MP_PB_IRQ1); 290 gic_cascade_irq(1, IRQ_TC11MP_PB_IRQ1);
291} 291}
292 292
293#ifdef CONFIG_HAVE_ARM_TWD
294static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
295 REALVIEW_TC11MP_TWD_BASE,
296 IRQ_LOCALTIMER);
297
298static void __init realview_pb11mp_twd_init(void)
299{
300 int err = twd_local_timer_register(&twd_local_timer);
301 if (err)
302 pr_err("twd_local_timer_register failed %d\n", err);
303}
304#else
305#define realview_pb11mp_twd_init() do {} while(0)
306#endif
307
293static void __init realview_pb11mp_timer_init(void) 308static void __init realview_pb11mp_timer_init(void)
294{ 309{
295 timer0_va_base = __io_address(REALVIEW_PB11MP_TIMER0_1_BASE); 310 timer0_va_base = __io_address(REALVIEW_PB11MP_TIMER0_1_BASE);
@@ -297,10 +312,8 @@ static void __init realview_pb11mp_timer_init(void)
297 timer2_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE); 312 timer2_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE);
298 timer3_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE) + 0x20; 313 timer3_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE) + 0x20;
299 314
300#ifdef CONFIG_LOCAL_TIMERS
301 twd_base = __io_address(REALVIEW_TC11MP_TWD_BASE);
302#endif
303 realview_timer_init(IRQ_TC11MP_TIMER0_1); 315 realview_timer_init(IRQ_TC11MP_TIMER0_1);
316 realview_pb11mp_twd_init();
304} 317}
305 318
306static struct sys_timer realview_pb11mp_timer = { 319static struct sys_timer realview_pb11mp_timer = {
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 1cd9956f5875..3f2f605624e9 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -298,6 +298,21 @@ static void __init gic_init_irq(void)
298 } 298 }
299} 299}
300 300
301#ifdef CONFIG_HAVE_ARM_TWD
302static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
303 REALVIEW_PBX_TILE_TWD_BASE,
304 IRQ_LOCALTIMER);
305
306static void __init realview_pbx_twd_init(void)
307{
308 int err = twd_local_timer_register(&twd_local_timer);
309 if (err)
310 pr_err("twd_local_timer_register failed %d\n", err);
311}
312#else
313#define realview_pbx_twd_init() do { } while(0)
314#endif
315
301static void __init realview_pbx_timer_init(void) 316static void __init realview_pbx_timer_init(void)
302{ 317{
303 timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE); 318 timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE);
@@ -305,11 +320,8 @@ static void __init realview_pbx_timer_init(void)
305 timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE); 320 timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE);
306 timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20; 321 timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20;
307 322
308#ifdef CONFIG_LOCAL_TIMERS
309 if (core_tile_pbx11mp() || core_tile_pbxa9mp())
310 twd_base = __io_address(REALVIEW_PBX_TILE_TWD_BASE);
311#endif
312 realview_timer_init(IRQ_PBX_TIMER0_1); 323 realview_timer_init(IRQ_PBX_TIMER0_1);
324 realview_pbx_twd_init();
313} 325}
314 326
315static struct sys_timer realview_pbx_timer = { 327static struct sys_timer realview_pbx_timer = {
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 7ad6954c46cd..e7c2590b75d9 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -16,7 +16,6 @@ obj-$(CONFIG_ARCH_R8A7779) += setup-r8a7779.o clock-r8a7779.o intc-r8a7779.o
16# SMP objects 16# SMP objects
17smp-y := platsmp.o headsmp.o 17smp-y := platsmp.o headsmp.o
18smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o 18smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o
19smp-$(CONFIG_LOCAL_TIMERS) += localtimer.o
20smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o 19smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o
21smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o 20smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o
22 21
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index e4b945e271e7..9fde3eb686a6 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -2,6 +2,8 @@
2#define __ARCH_MACH_COMMON_H 2#define __ARCH_MACH_COMMON_H
3 3
4extern struct sys_timer shmobile_timer; 4extern struct sys_timer shmobile_timer;
5struct twd_local_timer;
6void shmobile_twd_init(struct twd_local_timer *twd_local_timer);
5extern void shmobile_setup_console(void); 7extern void shmobile_setup_console(void);
6extern void shmobile_secondary_vector(void); 8extern void shmobile_secondary_vector(void);
7extern int shmobile_platform_cpu_kill(unsigned int cpu); 9extern int shmobile_platform_cpu_kill(unsigned int cpu);
diff --git a/arch/arm/mach-shmobile/localtimer.c b/arch/arm/mach-shmobile/localtimer.c
deleted file mode 100644
index ad9ccc9900c8..000000000000
--- a/arch/arm/mach-shmobile/localtimer.c
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * SMP support for R-Mobile / SH-Mobile - local timer portion
3 *
4 * Copyright (C) 2010 Magnus Damm
5 *
6 * Based on vexpress, Copyright (C) 2002 ARM Ltd, All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/init.h>
13#include <linux/smp.h>
14#include <linux/clockchips.h>
15#include <asm/smp_twd.h>
16#include <asm/localtimer.h>
17
18/*
19 * Setup the local clock events for a CPU.
20 */
21int __cpuinit local_timer_setup(struct clock_event_device *evt)
22{
23 evt->irq = 29;
24 twd_timer_setup(evt);
25 return 0;
26}
diff --git a/arch/arm/mach-shmobile/platsmp.c b/arch/arm/mach-shmobile/platsmp.c
index 993381257f69..45fa3924c6a1 100644
--- a/arch/arm/mach-shmobile/platsmp.c
+++ b/arch/arm/mach-shmobile/platsmp.c
@@ -17,7 +17,6 @@
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <asm/hardware/gic.h> 19#include <asm/hardware/gic.h>
20#include <asm/localtimer.h>
21#include <asm/mach-types.h> 20#include <asm/mach-types.h>
22#include <mach/common.h> 21#include <mach/common.h>
23 22
diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c
index 4fe2e9eaf501..9bb7b8575a1f 100644
--- a/arch/arm/mach-shmobile/smp-r8a7779.c
+++ b/arch/arm/mach-shmobile/smp-r8a7779.c
@@ -64,6 +64,8 @@ static void __iomem *scu_base_addr(void)
64static DEFINE_SPINLOCK(scu_lock); 64static DEFINE_SPINLOCK(scu_lock);
65static unsigned long tmp; 65static unsigned long tmp;
66 66
67static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
68
67static void modify_scu_cpu_psr(unsigned long set, unsigned long clr) 69static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
68{ 70{
69 void __iomem *scu_base = scu_base_addr(); 71 void __iomem *scu_base = scu_base_addr();
@@ -82,11 +84,7 @@ unsigned int __init r8a7779_get_core_count(void)
82{ 84{
83 void __iomem *scu_base = scu_base_addr(); 85 void __iomem *scu_base = scu_base_addr();
84 86
85#ifdef CONFIG_HAVE_ARM_TWD 87 shmobile_twd_init(&twd_local_timer);
86 /* twd_base needs to be initialized before percpu_timer_setup() */
87 twd_base = (void __iomem *)0xf0000600;
88#endif
89
90 return scu_get_core_count(scu_base); 88 return scu_get_core_count(scu_base);
91} 89}
92 90
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index 2d0d4212be41..c0a9093ba3a8 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -42,6 +42,8 @@ static void __iomem *scu_base_addr(void)
42static DEFINE_SPINLOCK(scu_lock); 42static DEFINE_SPINLOCK(scu_lock);
43static unsigned long tmp; 43static unsigned long tmp;
44 44
45static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
46
45static void modify_scu_cpu_psr(unsigned long set, unsigned long clr) 47static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
46{ 48{
47 void __iomem *scu_base = scu_base_addr(); 49 void __iomem *scu_base = scu_base_addr();
@@ -60,11 +62,7 @@ unsigned int __init sh73a0_get_core_count(void)
60{ 62{
61 void __iomem *scu_base = scu_base_addr(); 63 void __iomem *scu_base = scu_base_addr();
62 64
63#ifdef CONFIG_HAVE_ARM_TWD 65 shmobile_twd_init(&twd_local_timer);
64 /* twd_base needs to be initialized before percpu_timer_setup() */
65 twd_base = (void __iomem *)0xf0000600;
66#endif
67
68 return scu_get_core_count(scu_base); 66 return scu_get_core_count(scu_base);
69} 67}
70 68
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index 895794b543cd..be16231e86fc 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <asm/mach/time.h> 22#include <asm/mach/time.h>
23#include <asm/smp_twd.h>
23 24
24static void __init shmobile_late_time_init(void) 25static void __init shmobile_late_time_init(void)
25{ 26{
@@ -41,6 +42,15 @@ static void __init shmobile_timer_init(void)
41 late_time_init = shmobile_late_time_init; 42 late_time_init = shmobile_late_time_init;
42} 43}
43 44
45void __init shmobile_twd_init(struct twd_local_timer *twd_local_timer)
46{
47#ifdef CONFIG_HAVE_ARM_TWD
48 int err = twd_local_timer_register(twd_local_timer);
49 if (err)
50 pr_err("twd_local_timer_register failed %d\n", err);
51#endif
52}
53
44struct sys_timer shmobile_timer = { 54struct sys_timer shmobile_timer = {
45 .init = shmobile_timer_init, 55 .init = shmobile_timer_init,
46}; 56};
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index e120ff54f663..f7d044369ed5 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o
13obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pinmux-tegra20-tables.o 13obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pinmux-tegra20-tables.o
14obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pinmux-tegra30-tables.o 14obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pinmux-tegra30-tables.o
15obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o 15obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o
16obj-$(CONFIG_SMP) += platsmp.o localtimer.o headsmp.o 16obj-$(CONFIG_SMP) += platsmp.o headsmp.o
17obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 17obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
18obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o 18obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o
19obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o 19obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o
diff --git a/arch/arm/mach-tegra/localtimer.c b/arch/arm/mach-tegra/localtimer.c
deleted file mode 100644
index e91d681d45a2..000000000000
--- a/arch/arm/mach-tegra/localtimer.c
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * arch/arm/mach-tegra/localtimer.c
3 *
4 * Copyright (C) 2002 ARM Ltd.
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/init.h>
12#include <linux/smp.h>
13#include <linux/clockchips.h>
14#include <asm/irq.h>
15#include <asm/smp_twd.h>
16#include <asm/localtimer.h>
17
18/*
19 * Setup the local clock events for a CPU.
20 */
21int __cpuinit local_timer_setup(struct clock_event_device *evt)
22{
23 evt->irq = IRQ_LOCALTIMER;
24 twd_timer_setup(evt);
25 return 0;
26}
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c
index 1d1acda4f3e0..1eed8d4a80ef 100644
--- a/arch/arm/mach-tegra/timer.c
+++ b/arch/arm/mach-tegra/timer.c
@@ -28,7 +28,7 @@
28#include <linux/io.h> 28#include <linux/io.h>
29 29
30#include <asm/mach/time.h> 30#include <asm/mach/time.h>
31#include <asm/localtimer.h> 31#include <asm/smp_twd.h>
32#include <asm/sched_clock.h> 32#include <asm/sched_clock.h>
33 33
34#include <mach/iomap.h> 34#include <mach/iomap.h>
@@ -162,6 +162,21 @@ static struct irqaction tegra_timer_irq = {
162 .irq = INT_TMR3, 162 .irq = INT_TMR3,
163}; 163};
164 164
165#ifdef CONFIG_HAVE_ARM_TWD
166static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
167 TEGRA_ARM_PERIF_BASE + 0x600,
168 IRQ_LOCALTIMER);
169
170static void __init tegra_twd_init(void)
171{
172 int err = twd_local_timer_register(&twd_local_timer);
173 if (err)
174 pr_err("twd_local_timer_register failed %d\n", err);
175}
176#else
177#define tegra_twd_init() do {} while(0)
178#endif
179
165static void __init tegra_init_timer(void) 180static void __init tegra_init_timer(void)
166{ 181{
167 struct clk *clk; 182 struct clk *clk;
@@ -188,10 +203,6 @@ static void __init tegra_init_timer(void)
188 else 203 else
189 clk_enable(clk); 204 clk_enable(clk);
190 205
191#ifdef CONFIG_HAVE_ARM_TWD
192 twd_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x600);
193#endif
194
195 switch (rate) { 206 switch (rate) {
196 case 12000000: 207 case 12000000:
197 timer_writel(0x000b, TIMERUS_USEC_CFG); 208 timer_writel(0x000b, TIMERUS_USEC_CFG);
@@ -231,6 +242,7 @@ static void __init tegra_init_timer(void)
231 tegra_clockevent.cpumask = cpu_all_mask; 242 tegra_clockevent.cpumask = cpu_all_mask;
232 tegra_clockevent.irq = tegra_timer_irq.irq; 243 tegra_clockevent.irq = tegra_timer_irq.irq;
233 clockevents_register_device(&tegra_clockevent); 244 clockevents_register_device(&tegra_clockevent);
245 tegra_twd_init();
234} 246}
235 247
236struct sys_timer tegra_timer = { 248struct sys_timer tegra_timer = {
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index 52af00446a63..afb3706bab2a 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -28,6 +28,7 @@ config MACH_U8500
28 bool "U8500 Development platform" 28 bool "U8500 Development platform"
29 depends on UX500_SOC_DB8500 29 depends on UX500_SOC_DB8500
30 select TPS6105X 30 select TPS6105X
31 select SOC_BUS
31 help 32 help
32 Include support for the mop500 development platform. 33 Include support for the mop500 development platform.
33 34
@@ -49,6 +50,12 @@ config MACH_U5500
49 depends on UX500_SOC_DB5500 50 depends on UX500_SOC_DB5500
50 help 51 help
51 Include support for the U5500 development platform. 52 Include support for the U5500 development platform.
53
54config MACH_UX500_DT
55 bool "Generic U8500 support using device tree"
56 depends on MACH_U8500
57 select USE_OF
58
52endmenu 59endmenu
53 60
54config UX500_DEBUG_UART 61config UX500_DEBUG_UART
diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
index 6bd2f451c185..35b389442afe 100644
--- a/arch/arm/mach-ux500/Makefile
+++ b/arch/arm/mach-ux500/Makefile
@@ -15,7 +15,6 @@ obj-$(CONFIG_MACH_U8500) += board-mop500.o board-mop500-sdi.o \
15obj-$(CONFIG_MACH_U5500) += board-u5500.o board-u5500-sdi.o 15obj-$(CONFIG_MACH_U5500) += board-u5500.o board-u5500-sdi.o
16obj-$(CONFIG_SMP) += platsmp.o headsmp.o 16obj-$(CONFIG_SMP) += platsmp.o headsmp.o
17obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 17obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
18obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
19obj-$(CONFIG_U5500_MODEM_IRQ) += modem-irq-db5500.o 18obj-$(CONFIG_U5500_MODEM_IRQ) += modem-irq-db5500.o
20obj-$(CONFIG_U5500_MBOX) += mbox-db5500.o 19obj-$(CONFIG_U5500_MBOX) += mbox-db5500.o
21 20
diff --git a/arch/arm/mach-ux500/Makefile.boot b/arch/arm/mach-ux500/Makefile.boot
index ff0a4b5b0a82..dd5cd00e2554 100644
--- a/arch/arm/mach-ux500/Makefile.boot
+++ b/arch/arm/mach-ux500/Makefile.boot
@@ -2,3 +2,4 @@
2params_phys-y := 0x00000100 2params_phys-y := 0x00000100
3initrd_phys-y := 0x00800000 3initrd_phys-y := 0x00800000
4 4
5dtb-$(CONFIG_MACH_SNOWBALL) += snowball.dtb
diff --git a/arch/arm/mach-ux500/board-mop500-sdi.c b/arch/arm/mach-ux500/board-mop500-sdi.c
index 5dde4d4ebe88..479ebe04cf9c 100644
--- a/arch/arm/mach-ux500/board-mop500-sdi.c
+++ b/arch/arm/mach-ux500/board-mop500-sdi.c
@@ -104,7 +104,7 @@ static struct mmci_platform_data mop500_sdi0_data = {
104#endif 104#endif
105}; 105};
106 106
107static void sdi0_configure(void) 107static void sdi0_configure(struct device *parent)
108{ 108{
109 int ret; 109 int ret;
110 110
@@ -123,15 +123,15 @@ static void sdi0_configure(void)
123 gpio_direction_output(sdi0_en, 1); 123 gpio_direction_output(sdi0_en, 1);
124 124
125 /* Add the device, force v2 to subrevision 1 */ 125 /* Add the device, force v2 to subrevision 1 */
126 db8500_add_sdi0(&mop500_sdi0_data, U8500_SDI_V2_PERIPHID); 126 db8500_add_sdi0(parent, &mop500_sdi0_data, U8500_SDI_V2_PERIPHID);
127} 127}
128 128
129void mop500_sdi_tc35892_init(void) 129void mop500_sdi_tc35892_init(struct device *parent)
130{ 130{
131 mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD; 131 mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD;
132 sdi0_en = GPIO_SDMMC_EN; 132 sdi0_en = GPIO_SDMMC_EN;
133 sdi0_vsel = GPIO_SDMMC_1V8_3V_SEL; 133 sdi0_vsel = GPIO_SDMMC_1V8_3V_SEL;
134 sdi0_configure(); 134 sdi0_configure(parent);
135} 135}
136 136
137/* 137/*
@@ -246,12 +246,13 @@ static struct mmci_platform_data mop500_sdi4_data = {
246#endif 246#endif
247}; 247};
248 248
249void __init mop500_sdi_init(void) 249void __init mop500_sdi_init(struct device *parent)
250{ 250{
251 /* PoP:ed eMMC */ 251 /* PoP:ed eMMC */
252 db8500_add_sdi2(&mop500_sdi2_data, U8500_SDI_V2_PERIPHID); 252 db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
253 /* On-board eMMC */ 253 /* On-board eMMC */
254 db8500_add_sdi4(&mop500_sdi4_data, U8500_SDI_V2_PERIPHID); 254 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
255
255 /* 256 /*
256 * On boards with the TC35892 GPIO expander, sdi0 will finally 257 * On boards with the TC35892 GPIO expander, sdi0 will finally
257 * be added when the TC35892 initializes and calls 258 * be added when the TC35892 initializes and calls
@@ -259,31 +260,31 @@ void __init mop500_sdi_init(void)
259 */ 260 */
260} 261}
261 262
262void __init snowball_sdi_init(void) 263void __init snowball_sdi_init(struct device *parent)
263{ 264{
264 /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */ 265 /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */
265 mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED; 266 mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED;
266 /* On-board eMMC */ 267 /* On-board eMMC */
267 db8500_add_sdi4(&mop500_sdi4_data, U8500_SDI_V2_PERIPHID); 268 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
268 /* External Micro SD slot */ 269 /* External Micro SD slot */
269 mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO; 270 mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO;
270 mop500_sdi0_data.cd_invert = true; 271 mop500_sdi0_data.cd_invert = true;
271 sdi0_en = SNOWBALL_SDMMC_EN_GPIO; 272 sdi0_en = SNOWBALL_SDMMC_EN_GPIO;
272 sdi0_vsel = SNOWBALL_SDMMC_1V8_3V_GPIO; 273 sdi0_vsel = SNOWBALL_SDMMC_1V8_3V_GPIO;
273 sdi0_configure(); 274 sdi0_configure(parent);
274} 275}
275 276
276void __init hrefv60_sdi_init(void) 277void __init hrefv60_sdi_init(struct device *parent)
277{ 278{
278 /* PoP:ed eMMC */ 279 /* PoP:ed eMMC */
279 db8500_add_sdi2(&mop500_sdi2_data, U8500_SDI_V2_PERIPHID); 280 db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
280 /* On-board eMMC */ 281 /* On-board eMMC */
281 db8500_add_sdi4(&mop500_sdi4_data, U8500_SDI_V2_PERIPHID); 282 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
282 /* External Micro SD slot */ 283 /* External Micro SD slot */
283 mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO; 284 mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO;
284 sdi0_en = HREFV60_SDMMC_EN_GPIO; 285 sdi0_en = HREFV60_SDMMC_EN_GPIO;
285 sdi0_vsel = HREFV60_SDMMC_1V8_3V_GPIO; 286 sdi0_vsel = HREFV60_SDMMC_1V8_3V_GPIO;
286 sdi0_configure(); 287 sdi0_configure(parent);
287 /* WLAN SDIO channel */ 288 /* WLAN SDIO channel */
288 db8500_add_sdi1(&mop500_sdi1_data, U8500_SDI_V2_PERIPHID); 289 db8500_add_sdi1(parent, &mop500_sdi1_data, U8500_SDI_V2_PERIPHID);
289} 290}
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 5c00712907d1..d0799d592218 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -30,6 +30,9 @@
30#include <linux/gpio_keys.h> 30#include <linux/gpio_keys.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32 32
33#include <linux/of.h>
34#include <linux/of_platform.h>
35
33#include <linux/leds.h> 36#include <linux/leds.h>
34#include <asm/mach-types.h> 37#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
@@ -226,7 +229,12 @@ static struct tps6105x_platform_data mop500_tps61052_data = {
226 229
227static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base) 230static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
228{ 231{
229 mop500_sdi_tc35892_init(); 232 struct device *parent = NULL;
233#if 0
234 /* FIXME: Is the sdi actually part of tc3589x? */
235 parent = tc3589x->dev;
236#endif
237 mop500_sdi_tc35892_init(parent);
230} 238}
231 239
232static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = { 240static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
@@ -353,12 +361,12 @@ U8500_I2C_CONTROLLER(1, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
353U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); 361U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
354U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); 362U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
355 363
356static void __init mop500_i2c_init(void) 364static void __init mop500_i2c_init(struct device *parent)
357{ 365{
358 db8500_add_i2c0(&u8500_i2c0_data); 366 db8500_add_i2c0(parent, &u8500_i2c0_data);
359 db8500_add_i2c1(&u8500_i2c1_data); 367 db8500_add_i2c1(parent, &u8500_i2c1_data);
360 db8500_add_i2c2(&u8500_i2c2_data); 368 db8500_add_i2c2(parent, &u8500_i2c2_data);
361 db8500_add_i2c3(&u8500_i2c3_data); 369 db8500_add_i2c3(parent, &u8500_i2c3_data);
362} 370}
363 371
364static struct gpio_keys_button mop500_gpio_keys[] = { 372static struct gpio_keys_button mop500_gpio_keys[] = {
@@ -435,7 +443,7 @@ static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
435}; 443};
436#endif 444#endif
437 445
438static struct pl022_ssp_controller ssp0_platform_data = { 446static struct pl022_ssp_controller ssp0_plat = {
439 .bus_id = 0, 447 .bus_id = 0,
440#ifdef CONFIG_STE_DMA40 448#ifdef CONFIG_STE_DMA40
441 .enable_dma = 1, 449 .enable_dma = 1,
@@ -451,9 +459,9 @@ static struct pl022_ssp_controller ssp0_platform_data = {
451 .num_chipselect = 5, 459 .num_chipselect = 5,
452}; 460};
453 461
454static void __init mop500_spi_init(void) 462static void __init mop500_spi_init(struct device *parent)
455{ 463{
456 db8500_add_ssp0(&ssp0_platform_data); 464 db8500_add_ssp0(parent, &ssp0_plat);
457} 465}
458 466
459#ifdef CONFIG_STE_DMA40 467#ifdef CONFIG_STE_DMA40
@@ -587,11 +595,11 @@ static struct amba_pl011_data uart2_plat = {
587#endif 595#endif
588}; 596};
589 597
590static void __init mop500_uart_init(void) 598static void __init mop500_uart_init(struct device *parent)
591{ 599{
592 db8500_add_uart0(&uart0_plat); 600 db8500_add_uart0(parent, &uart0_plat);
593 db8500_add_uart1(&uart1_plat); 601 db8500_add_uart1(parent, &uart1_plat);
594 db8500_add_uart2(&uart2_plat); 602 db8500_add_uart2(parent, &uart2_plat);
595} 603}
596 604
597static struct platform_device *snowball_platform_devs[] __initdata = { 605static struct platform_device *snowball_platform_devs[] __initdata = {
@@ -603,21 +611,27 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
603 611
604static void __init mop500_init_machine(void) 612static void __init mop500_init_machine(void)
605{ 613{
614 struct device *parent = NULL;
606 int i2c0_devs; 615 int i2c0_devs;
616 int i;
607 617
608 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR; 618 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
609 619
610 u8500_init_devices(); 620 parent = u8500_init_devices();
611 621
612 mop500_pins_init(); 622 mop500_pins_init();
613 623
624 /* FIXME: parent of ab8500 should be prcmu */
625 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
626 mop500_platform_devs[i]->dev.parent = parent;
627
614 platform_add_devices(mop500_platform_devs, 628 platform_add_devices(mop500_platform_devs,
615 ARRAY_SIZE(mop500_platform_devs)); 629 ARRAY_SIZE(mop500_platform_devs));
616 630
617 mop500_i2c_init(); 631 mop500_i2c_init(parent);
618 mop500_sdi_init(); 632 mop500_sdi_init(parent);
619 mop500_spi_init(); 633 mop500_spi_init(parent);
620 mop500_uart_init(); 634 mop500_uart_init(parent);
621 635
622 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 636 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
623 637
@@ -631,19 +645,24 @@ static void __init mop500_init_machine(void)
631 645
632static void __init snowball_init_machine(void) 646static void __init snowball_init_machine(void)
633{ 647{
648 struct device *parent = NULL;
634 int i2c0_devs; 649 int i2c0_devs;
650 int i;
635 651
636 u8500_init_devices(); 652 parent = u8500_init_devices();
637 653
638 snowball_pins_init(); 654 snowball_pins_init();
639 655
656 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
657 snowball_platform_devs[i]->dev.parent = parent;
658
640 platform_add_devices(snowball_platform_devs, 659 platform_add_devices(snowball_platform_devs,
641 ARRAY_SIZE(snowball_platform_devs)); 660 ARRAY_SIZE(snowball_platform_devs));
642 661
643 mop500_i2c_init(); 662 mop500_i2c_init(parent);
644 snowball_sdi_init(); 663 snowball_sdi_init(parent);
645 mop500_spi_init(); 664 mop500_spi_init(parent);
646 mop500_uart_init(); 665 mop500_uart_init(parent);
647 666
648 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 667 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
649 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs); 668 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
@@ -656,7 +675,9 @@ static void __init snowball_init_machine(void)
656 675
657static void __init hrefv60_init_machine(void) 676static void __init hrefv60_init_machine(void)
658{ 677{
678 struct device *parent = NULL;
659 int i2c0_devs; 679 int i2c0_devs;
680 int i;
660 681
661 /* 682 /*
662 * The HREFv60 board removed a GPIO expander and routed 683 * The HREFv60 board removed a GPIO expander and routed
@@ -665,17 +686,20 @@ static void __init hrefv60_init_machine(void)
665 */ 686 */
666 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO; 687 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
667 688
668 u8500_init_devices(); 689 parent = u8500_init_devices();
669 690
670 hrefv60_pins_init(); 691 hrefv60_pins_init();
671 692
693 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
694 mop500_platform_devs[i]->dev.parent = parent;
695
672 platform_add_devices(mop500_platform_devs, 696 platform_add_devices(mop500_platform_devs,
673 ARRAY_SIZE(mop500_platform_devs)); 697 ARRAY_SIZE(mop500_platform_devs));
674 698
675 mop500_i2c_init(); 699 mop500_i2c_init(parent);
676 hrefv60_sdi_init(); 700 hrefv60_sdi_init(parent);
677 mop500_spi_init(); 701 mop500_spi_init(parent);
678 mop500_uart_init(); 702 mop500_uart_init(parent);
679 703
680 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 704 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
681 705
@@ -718,3 +742,94 @@ MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
718 .handle_irq = gic_handle_irq, 742 .handle_irq = gic_handle_irq,
719 .init_machine = snowball_init_machine, 743 .init_machine = snowball_init_machine,
720MACHINE_END 744MACHINE_END
745
746#ifdef CONFIG_MACH_UX500_DT
747
748struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
749 OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat),
750 OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat),
751 OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
752 OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat),
753 {},
754};
755
756static const struct of_device_id u8500_soc_node[] = {
757 /* only create devices below soc node */
758 { .compatible = "stericsson,db8500", },
759 { },
760};
761
762static void __init u8500_init_machine(void)
763{
764 struct device *parent = NULL;
765 int i2c0_devs;
766 int i;
767
768 parent = u8500_init_devices();
769 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
770
771 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
772 mop500_platform_devs[i]->dev.parent = parent;
773 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
774 snowball_platform_devs[i]->dev.parent = parent;
775
776 /* automatically probe child nodes of db8500 device */
777 of_platform_populate(NULL, u8500_soc_node, u8500_auxdata_lookup, parent);
778
779 if (of_machine_is_compatible("st-ericsson,mop500")) {
780 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
781 mop500_pins_init();
782
783 platform_add_devices(mop500_platform_devs,
784 ARRAY_SIZE(mop500_platform_devs));
785
786 mop500_sdi_init(parent);
787 } else if (of_machine_is_compatible("calaosystems,snowball-a9500")) {
788 snowball_pins_init();
789 platform_add_devices(snowball_platform_devs,
790 ARRAY_SIZE(snowball_platform_devs));
791
792 snowball_sdi_init(parent);
793 } else if (of_machine_is_compatible("st-ericsson,hrefv60+")) {
794 /*
795 * The HREFv60 board removed a GPIO expander and routed
796 * all these GPIO pins to the internal GPIO controller
797 * instead.
798 */
799 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
800 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
801 hrefv60_pins_init();
802 platform_add_devices(mop500_platform_devs,
803 ARRAY_SIZE(mop500_platform_devs));
804
805 hrefv60_sdi_init(parent);
806 }
807 mop500_i2c_init(parent);
808
809 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
810 i2c_register_board_info(2, mop500_i2c2_devices,
811 ARRAY_SIZE(mop500_i2c2_devices));
812
813 /* This board has full regulator constraints */
814 regulator_has_full_constraints();
815}
816
817static const char * u8500_dt_board_compat[] = {
818 "calaosystems,snowball-a9500",
819 "st-ericsson,hrefv60+",
820 "st-ericsson,u8500",
821 "st-ericsson,mop500",
822 NULL,
823};
824
825
826DT_MACHINE_START(U8500_DT, "ST-Ericsson U8500 platform (Device Tree Support)")
827 .map_io = u8500_map_io,
828 .init_irq = ux500_init_irq,
829 /* we re-use nomadik timer here */
830 .timer = &ux500_timer,
831 .handle_irq = gic_handle_irq,
832 .init_machine = u8500_init_machine,
833 .dt_compat = u8500_dt_board_compat,
834MACHINE_END
835#endif
diff --git a/arch/arm/mach-ux500/board-mop500.h b/arch/arm/mach-ux500/board-mop500.h
index f926d3db6207..3d594c24bfee 100644
--- a/arch/arm/mach-ux500/board-mop500.h
+++ b/arch/arm/mach-ux500/board-mop500.h
@@ -75,10 +75,10 @@
75 75
76struct i2c_board_info; 76struct i2c_board_info;
77 77
78extern void mop500_sdi_init(void); 78extern void mop500_sdi_init(struct device *parent);
79extern void snowball_sdi_init(void); 79extern void snowball_sdi_init(struct device *parent);
80extern void hrefv60_sdi_init(void); 80extern void hrefv60_sdi_init(struct device *parent);
81extern void mop500_sdi_tc35892_init(void); 81extern void mop500_sdi_tc35892_init(struct device *parent);
82void __init mop500_u8500uib_init(void); 82void __init mop500_u8500uib_init(void);
83void __init mop500_stuib_init(void); 83void __init mop500_stuib_init(void);
84void __init mop500_pins_init(void); 84void __init mop500_pins_init(void);
diff --git a/arch/arm/mach-ux500/board-u5500-sdi.c b/arch/arm/mach-ux500/board-u5500-sdi.c
index 63c3f8058ffc..836112eedde7 100644
--- a/arch/arm/mach-ux500/board-u5500-sdi.c
+++ b/arch/arm/mach-ux500/board-u5500-sdi.c
@@ -66,9 +66,9 @@ static struct mmci_platform_data u5500_sdi0_data = {
66#endif 66#endif
67}; 67};
68 68
69void __init u5500_sdi_init(void) 69void __init u5500_sdi_init(struct device *parent)
70{ 70{
71 nmk_config_pins(u5500_sdi_pins, ARRAY_SIZE(u5500_sdi_pins)); 71 nmk_config_pins(u5500_sdi_pins, ARRAY_SIZE(u5500_sdi_pins));
72 72
73 db5500_add_sdi0(&u5500_sdi0_data); 73 db5500_add_sdi0(parent, &u5500_sdi0_data);
74} 74}
diff --git a/arch/arm/mach-ux500/board-u5500.c b/arch/arm/mach-ux500/board-u5500.c
index 9de9e9c4dbbb..0ff4be72a809 100644
--- a/arch/arm/mach-ux500/board-u5500.c
+++ b/arch/arm/mach-ux500/board-u5500.c
@@ -97,9 +97,9 @@ static struct i2c_board_info __initdata u5500_i2c2_devices[] = {
97 }, 97 },
98}; 98};
99 99
100static void __init u5500_i2c_init(void) 100static void __init u5500_i2c_init(struct device *parent)
101{ 101{
102 db5500_add_i2c2(&u5500_i2c2_data); 102 db5500_add_i2c2(parent, &u5500_i2c2_data);
103 i2c_register_board_info(2, ARRAY_AND_SIZE(u5500_i2c2_devices)); 103 i2c_register_board_info(2, ARRAY_AND_SIZE(u5500_i2c2_devices));
104} 104}
105 105
@@ -126,20 +126,27 @@ static struct platform_device *u5500_platform_devices[] __initdata = {
126 &ab5500_device, 126 &ab5500_device,
127}; 127};
128 128
129static void __init u5500_uart_init(void) 129static void __init u5500_uart_init(struct device *parent)
130{ 130{
131 db5500_add_uart0(NULL); 131 db5500_add_uart0(parent, NULL);
132 db5500_add_uart1(NULL); 132 db5500_add_uart1(parent, NULL);
133 db5500_add_uart2(NULL); 133 db5500_add_uart2(parent, NULL);
134} 134}
135 135
136static void __init u5500_init_machine(void) 136static void __init u5500_init_machine(void)
137{ 137{
138 u5500_init_devices(); 138 struct device *parent = NULL;
139 int i;
140
141 parent = u5500_init_devices();
139 nmk_config_pins(u5500_pins, ARRAY_SIZE(u5500_pins)); 142 nmk_config_pins(u5500_pins, ARRAY_SIZE(u5500_pins));
140 u5500_i2c_init(); 143
141 u5500_sdi_init(); 144 u5500_i2c_init(parent);
142 u5500_uart_init(); 145 u5500_sdi_init(parent);
146 u5500_uart_init(parent);
147
148 for (i = 0; i < ARRAY_SIZE(u5500_platform_devices); i++)
149 u5500_platform_devices[i]->dev.parent = parent;
143 150
144 platform_add_devices(u5500_platform_devices, 151 platform_add_devices(u5500_platform_devices,
145 ARRAY_SIZE(u5500_platform_devices)); 152 ARRAY_SIZE(u5500_platform_devices));
diff --git a/arch/arm/mach-ux500/cache-l2x0.c b/arch/arm/mach-ux500/cache-l2x0.c
index da5569d83d58..77a75ed0df67 100644
--- a/arch/arm/mach-ux500/cache-l2x0.c
+++ b/arch/arm/mach-ux500/cache-l2x0.c
@@ -5,6 +5,8 @@
5 */ 5 */
6 6
7#include <linux/io.h> 7#include <linux/io.h>
8#include <linux/of.h>
9
8#include <asm/cacheflush.h> 10#include <asm/cacheflush.h>
9#include <asm/hardware/cache-l2x0.h> 11#include <asm/hardware/cache-l2x0.h>
10#include <mach/hardware.h> 12#include <mach/hardware.h>
@@ -45,7 +47,10 @@ static int __init ux500_l2x0_init(void)
45 ux500_l2x0_unlock(); 47 ux500_l2x0_unlock();
46 48
47 /* 64KB way size, 8 way associativity, force WA */ 49 /* 64KB way size, 8 way associativity, force WA */
48 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff); 50 if (of_have_populated_dt())
51 l2x0_of_init(0x3e060000, 0xc0000fff);
52 else
53 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
49 54
50 /* 55 /*
51 * We can't disable l2 as we are in non secure mode, currently 56 * We can't disable l2 as we are in non secure mode, currently
diff --git a/arch/arm/mach-ux500/cpu-db5500.c b/arch/arm/mach-ux500/cpu-db5500.c
index 18aa5c05c69e..bca47f32082f 100644
--- a/arch/arm/mach-ux500/cpu-db5500.c
+++ b/arch/arm/mach-ux500/cpu-db5500.c
@@ -147,13 +147,13 @@ static resource_size_t __initdata db5500_gpio_base[] = {
147 U5500_GPIOBANK7_BASE, 147 U5500_GPIOBANK7_BASE,
148}; 148};
149 149
150static void __init db5500_add_gpios(void) 150static void __init db5500_add_gpios(struct device *parent)
151{ 151{
152 struct nmk_gpio_platform_data pdata = { 152 struct nmk_gpio_platform_data pdata = {
153 /* No custom data yet */ 153 /* No custom data yet */
154 }; 154 };
155 155
156 dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base), 156 dbx500_add_gpios(parent, ARRAY_AND_SIZE(db5500_gpio_base),
157 IRQ_DB5500_GPIO0, &pdata); 157 IRQ_DB5500_GPIO0, &pdata);
158} 158}
159 159
@@ -212,14 +212,36 @@ static int usb_db5500_tx_dma_cfg[] = {
212 DB5500_DMA_DEV38_USB_OTG_OEP_8 212 DB5500_DMA_DEV38_USB_OTG_OEP_8
213}; 213};
214 214
215void __init u5500_init_devices(void) 215static const char *db5500_read_soc_id(void)
216{ 216{
217 db5500_add_gpios(); 217 return kasprintf(GFP_KERNEL, "u5500 currently unsupported\n");
218}
219
220static struct device * __init db5500_soc_device_init(void)
221{
222 const char *soc_id = db5500_read_soc_id();
223
224 return ux500_soc_device_init(soc_id);
225}
226
227struct device * __init u5500_init_devices(void)
228{
229 struct device *parent;
230 int i;
231
232 parent = db5500_soc_device_init();
233
234 db5500_add_gpios(parent);
218 db5500_pmu_init(); 235 db5500_pmu_init();
219 db5500_dma_init(); 236 db5500_dma_init(parent);
220 db5500_add_rtc(); 237 db5500_add_rtc(parent);
221 db5500_add_usb(usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); 238 db5500_add_usb(parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
239
240 for (i = 0; i < ARRAY_SIZE(db5500_platform_devs); i++)
241 db5500_platform_devs[i]->dev.parent = parent;
222 242
223 platform_add_devices(db5500_platform_devs, 243 platform_add_devices(db5500_platform_devs,
224 ARRAY_SIZE(db5500_platform_devs)); 244 ARRAY_SIZE(db5500_platform_devs));
245
246 return parent;
225} 247}
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 7176ee7491ab..9bd8163896cf 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -24,6 +24,7 @@
24#include <mach/setup.h> 24#include <mach/setup.h>
25#include <mach/devices.h> 25#include <mach/devices.h>
26#include <mach/usb.h> 26#include <mach/usb.h>
27#include <mach/db8500-regs.h>
27 28
28#include "devices-db8500.h" 29#include "devices-db8500.h"
29#include "ste-dma40-db8500.h" 30#include "ste-dma40-db8500.h"
@@ -132,13 +133,13 @@ static resource_size_t __initdata db8500_gpio_base[] = {
132 U8500_GPIOBANK8_BASE, 133 U8500_GPIOBANK8_BASE,
133}; 134};
134 135
135static void __init db8500_add_gpios(void) 136static void __init db8500_add_gpios(struct device *parent)
136{ 137{
137 struct nmk_gpio_platform_data pdata = { 138 struct nmk_gpio_platform_data pdata = {
138 .supports_sleepmode = true, 139 .supports_sleepmode = true,
139 }; 140 };
140 141
141 dbx500_add_gpios(ARRAY_AND_SIZE(db8500_gpio_base), 142 dbx500_add_gpios(parent, ARRAY_AND_SIZE(db8500_gpio_base),
142 IRQ_DB8500_GPIO0, &pdata); 143 IRQ_DB8500_GPIO0, &pdata);
143} 144}
144 145
@@ -164,17 +165,44 @@ static int usb_db8500_tx_dma_cfg[] = {
164 DB8500_DMA_DEV39_USB_OTG_OEP_8 165 DB8500_DMA_DEV39_USB_OTG_OEP_8
165}; 166};
166 167
168static const char *db8500_read_soc_id(void)
169{
170 void __iomem *uid = __io_address(U8500_BB_UID_BASE);
171
172 return kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x",
173 readl((u32 *)uid+1),
174 readl((u32 *)uid+1), readl((u32 *)uid+2),
175 readl((u32 *)uid+3), readl((u32 *)uid+4));
176}
177
178static struct device * __init db8500_soc_device_init(void)
179{
180 const char *soc_id = db8500_read_soc_id();
181
182 return ux500_soc_device_init(soc_id);
183}
184
167/* 185/*
168 * This function is called from the board init 186 * This function is called from the board init
169 */ 187 */
170void __init u8500_init_devices(void) 188struct device * __init u8500_init_devices(void)
171{ 189{
172 db8500_add_rtc(); 190 struct device *parent;
173 db8500_add_gpios(); 191 int i;
174 db8500_add_usb(usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); 192
193 parent = db8500_soc_device_init();
194
195 db8500_add_rtc(parent);
196 db8500_add_gpios(parent);
197 db8500_add_usb(parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg);
198
199 platform_device_register_data(parent,
200 "cpufreq-u8500", -1, NULL, 0);
201
202 for (i = 0; i < ARRAY_SIZE(platform_devs); i++)
203 platform_devs[i]->dev.parent = parent;
175 204
176 platform_device_register_simple("cpufreq-u8500", -1, NULL, 0);
177 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); 205 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
178 206
179 return ; 207 return parent;
180} 208}
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index f41857494375..d11f3892a27d 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -2,6 +2,7 @@
2 * Copyright (C) ST-Ericsson SA 2010 2 * Copyright (C) ST-Ericsson SA 2010
3 * 3 *
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson
5 * License terms: GNU General Public License (GPL) version 2 6 * License terms: GNU General Public License (GPL) version 2
6 */ 7 */
7 8
@@ -11,10 +12,15 @@
11#include <linux/mfd/db8500-prcmu.h> 12#include <linux/mfd/db8500-prcmu.h>
12#include <linux/mfd/db5500-prcmu.h> 13#include <linux/mfd/db5500-prcmu.h>
13#include <linux/clksrc-dbx500-prcmu.h> 14#include <linux/clksrc-dbx500-prcmu.h>
15#include <linux/sys_soc.h>
16#include <linux/err.h>
17#include <linux/slab.h>
18#include <linux/stat.h>
19#include <linux/of.h>
20#include <linux/of_irq.h>
14 21
15#include <asm/hardware/gic.h> 22#include <asm/hardware/gic.h>
16#include <asm/mach/map.h> 23#include <asm/mach/map.h>
17#include <asm/localtimer.h>
18 24
19#include <mach/hardware.h> 25#include <mach/hardware.h>
20#include <mach/setup.h> 26#include <mach/setup.h>
@@ -24,6 +30,11 @@
24 30
25void __iomem *_PRCMU_BASE; 31void __iomem *_PRCMU_BASE;
26 32
33static const struct of_device_id ux500_dt_irq_match[] = {
34 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
35 {},
36};
37
27void __init ux500_init_irq(void) 38void __init ux500_init_irq(void)
28{ 39{
29 void __iomem *dist_base; 40 void __iomem *dist_base;
@@ -38,7 +49,12 @@ void __init ux500_init_irq(void)
38 } else 49 } else
39 ux500_unknown_soc(); 50 ux500_unknown_soc();
40 51
41 gic_init(0, 29, dist_base, cpu_base); 52#ifdef CONFIG_OF
53 if (of_have_populated_dt())
54 of_irq_init(ux500_dt_irq_match);
55 else
56#endif
57 gic_init(0, 29, dist_base, cpu_base);
42 58
43 /* 59 /*
44 * Init clocks here so that they are available for system timer 60 * Init clocks here so that they are available for system timer
@@ -50,3 +66,73 @@ void __init ux500_init_irq(void)
50 db8500_prcmu_early_init(); 66 db8500_prcmu_early_init();
51 clk_init(); 67 clk_init();
52} 68}
69
70static const char * __init ux500_get_machine(void)
71{
72 return kasprintf(GFP_KERNEL, "DB%4x", dbx500_partnumber());
73}
74
75static const char * __init ux500_get_family(void)
76{
77 return kasprintf(GFP_KERNEL, "ux500");
78}
79
80static const char * __init ux500_get_revision(void)
81{
82 unsigned int rev = dbx500_revision();
83
84 if (rev == 0x01)
85 return kasprintf(GFP_KERNEL, "%s", "ED");
86 else if (rev >= 0xA0)
87 return kasprintf(GFP_KERNEL, "%d.%d",
88 (rev >> 4) - 0xA + 1, rev & 0xf);
89
90 return kasprintf(GFP_KERNEL, "%s", "Unknown");
91}
92
93static ssize_t ux500_get_process(struct device *dev,
94 struct device_attribute *attr,
95 char *buf)
96{
97 if (dbx500_id.process == 0x00)
98 return sprintf(buf, "Standard\n");
99
100 return sprintf(buf, "%02xnm\n", dbx500_id.process);
101}
102
103static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr,
104 const char *soc_id)
105{
106 soc_dev_attr->soc_id = soc_id;
107 soc_dev_attr->machine = ux500_get_machine();
108 soc_dev_attr->family = ux500_get_family();
109 soc_dev_attr->revision = ux500_get_revision();
110}
111
112struct device_attribute ux500_soc_attr =
113 __ATTR(process, S_IRUGO, ux500_get_process, NULL);
114
115struct device * __init ux500_soc_device_init(const char *soc_id)
116{
117 struct device *parent;
118 struct soc_device *soc_dev;
119 struct soc_device_attribute *soc_dev_attr;
120
121 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
122 if (!soc_dev_attr)
123 return ERR_PTR(-ENOMEM);
124
125 soc_info_populate(soc_dev_attr, soc_id);
126
127 soc_dev = soc_device_register(soc_dev_attr);
128 if (IS_ERR_OR_NULL(soc_dev)) {
129 kfree(soc_dev_attr);
130 return NULL;
131 }
132
133 parent = soc_device_to_device(soc_dev);
134 if (!IS_ERR_OR_NULL(parent))
135 device_create_file(parent, &ux500_soc_attr);
136
137 return parent;
138}
diff --git a/arch/arm/mach-ux500/devices-common.c b/arch/arm/mach-ux500/devices-common.c
index 898a64517b09..c5312a4b49f5 100644
--- a/arch/arm/mach-ux500/devices-common.c
+++ b/arch/arm/mach-ux500/devices-common.c
@@ -20,8 +20,9 @@
20#include "devices-common.h" 20#include "devices-common.h"
21 21
22struct amba_device * 22struct amba_device *
23dbx500_add_amba_device(const char *name, resource_size_t base, 23dbx500_add_amba_device(struct device *parent, const char *name,
24 int irq, void *pdata, unsigned int periphid) 24 resource_size_t base, int irq, void *pdata,
25 unsigned int periphid)
25{ 26{
26 struct amba_device *dev; 27 struct amba_device *dev;
27 int ret; 28 int ret;
@@ -39,6 +40,8 @@ dbx500_add_amba_device(const char *name, resource_size_t base,
39 40
40 dev->dev.platform_data = pdata; 41 dev->dev.platform_data = pdata;
41 42
43 dev->dev.parent = parent;
44
42 ret = amba_device_add(dev, &iomem_resource); 45 ret = amba_device_add(dev, &iomem_resource);
43 if (ret) { 46 if (ret) {
44 amba_device_put(dev); 47 amba_device_put(dev);
@@ -49,60 +52,7 @@ dbx500_add_amba_device(const char *name, resource_size_t base,
49} 52}
50 53
51static struct platform_device * 54static struct platform_device *
52dbx500_add_platform_device(const char *name, int id, void *pdata, 55dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq,
53 struct resource *res, int resnum)
54{
55 struct platform_device *dev;
56 int ret;
57
58 dev = platform_device_alloc(name, id);
59 if (!dev)
60 return ERR_PTR(-ENOMEM);
61
62 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
63 dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
64
65 ret = platform_device_add_resources(dev, res, resnum);
66 if (ret)
67 goto out_free;
68
69 dev->dev.platform_data = pdata;
70
71 ret = platform_device_add(dev);
72 if (ret)
73 goto out_free;
74
75 return dev;
76
77out_free:
78 platform_device_put(dev);
79 return ERR_PTR(ret);
80}
81
82struct platform_device *
83dbx500_add_platform_device_4k1irq(const char *name, int id,
84 resource_size_t base,
85 int irq, void *pdata)
86{
87 struct resource resources[] = {
88 [0] = {
89 .start = base,
90 .end = base + SZ_4K - 1,
91 .flags = IORESOURCE_MEM,
92 },
93 [1] = {
94 .start = irq,
95 .end = irq,
96 .flags = IORESOURCE_IRQ,
97 }
98 };
99
100 return dbx500_add_platform_device(name, id, pdata, resources,
101 ARRAY_SIZE(resources));
102}
103
104static struct platform_device *
105dbx500_add_gpio(int id, resource_size_t addr, int irq,
106 struct nmk_gpio_platform_data *pdata) 56 struct nmk_gpio_platform_data *pdata)
107{ 57{
108 struct resource resources[] = { 58 struct resource resources[] = {
@@ -118,13 +68,18 @@ dbx500_add_gpio(int id, resource_size_t addr, int irq,
118 } 68 }
119 }; 69 };
120 70
121 return platform_device_register_resndata(NULL, "gpio", id, 71 return platform_device_register_resndata(
122 resources, ARRAY_SIZE(resources), 72 parent,
123 pdata, sizeof(*pdata)); 73 "gpio",
74 id,
75 resources,
76 ARRAY_SIZE(resources),
77 pdata,
78 sizeof(*pdata));
124} 79}
125 80
126void dbx500_add_gpios(resource_size_t *base, int num, int irq, 81void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
127 struct nmk_gpio_platform_data *pdata) 82 int irq, struct nmk_gpio_platform_data *pdata)
128{ 83{
129 int first = 0; 84 int first = 0;
130 int i; 85 int i;
@@ -134,6 +89,6 @@ void dbx500_add_gpios(resource_size_t *base, int num, int irq,
134 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); 89 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
135 pdata->num_gpio = 32; 90 pdata->num_gpio = 32;
136 91
137 dbx500_add_gpio(i, base[i], irq, pdata); 92 dbx500_add_gpio(parent, i, base[i], irq, pdata);
138 } 93 }
139} 94}
diff --git a/arch/arm/mach-ux500/devices-common.h b/arch/arm/mach-ux500/devices-common.h
index 7825705033bf..39c74ec82add 100644
--- a/arch/arm/mach-ux500/devices-common.h
+++ b/arch/arm/mach-ux500/devices-common.h
@@ -8,80 +8,89 @@
8#ifndef __DEVICES_COMMON_H 8#ifndef __DEVICES_COMMON_H
9#define __DEVICES_COMMON_H 9#define __DEVICES_COMMON_H
10 10
11extern struct amba_device * 11#include <linux/platform_device.h>
12dbx500_add_amba_device(const char *name, resource_size_t base, 12#include <linux/dma-mapping.h>
13 int irq, void *pdata, unsigned int periphid); 13#include <linux/sys_soc.h>
14#include <plat/i2c.h>
14 15
15extern struct platform_device * 16extern struct amba_device *
16dbx500_add_platform_device_4k1irq(const char *name, int id, 17dbx500_add_amba_device(struct device *parent, const char *name,
17 resource_size_t base, 18 resource_size_t base, int irq, void *pdata,
18 int irq, void *pdata); 19 unsigned int periphid);
19 20
20struct spi_master_cntlr; 21struct spi_master_cntlr;
21 22
22static inline struct amba_device * 23static inline struct amba_device *
23dbx500_add_msp_spi(const char *name, resource_size_t base, int irq, 24dbx500_add_msp_spi(struct device *parent, const char *name,
25 resource_size_t base, int irq,
24 struct spi_master_cntlr *pdata) 26 struct spi_master_cntlr *pdata)
25{ 27{
26 return dbx500_add_amba_device(name, base, irq, pdata, 0); 28 return dbx500_add_amba_device(parent, name, base, irq,
29 pdata, 0);
27} 30}
28 31
29static inline struct amba_device * 32static inline struct amba_device *
30dbx500_add_spi(const char *name, resource_size_t base, int irq, 33dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
31 struct spi_master_cntlr *pdata, 34 int irq, struct spi_master_cntlr *pdata,
32 u32 periphid) 35 u32 periphid)
33{ 36{
34 return dbx500_add_amba_device(name, base, irq, pdata, periphid); 37 return dbx500_add_amba_device(parent, name, base, irq,
38 pdata, periphid);
35} 39}
36 40
37struct mmci_platform_data; 41struct mmci_platform_data;
38 42
39static inline struct amba_device * 43static inline struct amba_device *
40dbx500_add_sdi(const char *name, resource_size_t base, int irq, 44dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
41 struct mmci_platform_data *pdata, 45 int irq, struct mmci_platform_data *pdata, u32 periphid)
42 u32 periphid)
43{ 46{
44 return dbx500_add_amba_device(name, base, irq, pdata, periphid); 47 return dbx500_add_amba_device(parent, name, base, irq,
48 pdata, periphid);
45} 49}
46 50
47struct amba_pl011_data; 51struct amba_pl011_data;
48 52
49static inline struct amba_device * 53static inline struct amba_device *
50dbx500_add_uart(const char *name, resource_size_t base, int irq, 54dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
51 struct amba_pl011_data *pdata) 55 int irq, struct amba_pl011_data *pdata)
52{ 56{
53 return dbx500_add_amba_device(name, base, irq, pdata, 0); 57 return dbx500_add_amba_device(parent, name, base, irq, pdata, 0);
54} 58}
55 59
56struct nmk_i2c_controller; 60struct nmk_i2c_controller;
57 61
58static inline struct platform_device * 62static inline struct platform_device *
59dbx500_add_i2c(int id, resource_size_t base, int irq, 63dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
60 struct nmk_i2c_controller *pdata) 64 struct nmk_i2c_controller *data)
61{
62 return dbx500_add_platform_device_4k1irq("nmk-i2c", id, base, irq,
63 pdata);
64}
65
66struct msp_i2s_platform_data;
67
68static inline struct platform_device *
69dbx500_add_msp_i2s(int id, resource_size_t base, int irq,
70 struct msp_i2s_platform_data *pdata)
71{ 65{
72 return dbx500_add_platform_device_4k1irq("MSP_I2S", id, base, irq, 66 struct resource res[] = {
73 pdata); 67 DEFINE_RES_MEM(base, SZ_4K),
68 DEFINE_RES_IRQ(irq),
69 };
70
71 struct platform_device_info pdevinfo = {
72 .parent = parent,
73 .name = "nmk-i2c",
74 .id = id,
75 .res = res,
76 .num_res = ARRAY_SIZE(res),
77 .data = data,
78 .size_data = sizeof(*data),
79 .dma_mask = DMA_BIT_MASK(32),
80 };
81
82 return platform_device_register_full(&pdevinfo);
74} 83}
75 84
76static inline struct amba_device * 85static inline struct amba_device *
77dbx500_add_rtc(resource_size_t base, int irq) 86dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
78{ 87{
79 return dbx500_add_amba_device("rtc-pl031", base, irq, NULL, 0); 88 return dbx500_add_amba_device(parent, "rtc-pl031", base, irq, NULL, 0);
80} 89}
81 90
82struct nmk_gpio_platform_data; 91struct nmk_gpio_platform_data;
83 92
84void dbx500_add_gpios(resource_size_t *base, int num, int irq, 93void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
85 struct nmk_gpio_platform_data *pdata); 94 int irq, struct nmk_gpio_platform_data *pdata);
86 95
87#endif 96#endif
diff --git a/arch/arm/mach-ux500/devices-db5500.h b/arch/arm/mach-ux500/devices-db5500.h
index 0c4bccd02b90..e70955502c35 100644
--- a/arch/arm/mach-ux500/devices-db5500.h
+++ b/arch/arm/mach-ux500/devices-db5500.h
@@ -10,70 +10,90 @@
10 10
11#include "devices-common.h" 11#include "devices-common.h"
12 12
13#define db5500_add_i2c1(pdata) \ 13#define db5500_add_i2c1(parent, pdata) \
14 dbx500_add_i2c(1, U5500_I2C1_BASE, IRQ_DB5500_I2C1, pdata) 14 dbx500_add_i2c(parent, 1, U5500_I2C1_BASE, IRQ_DB5500_I2C1, pdata)
15#define db5500_add_i2c2(pdata) \ 15#define db5500_add_i2c2(parent, pdata) \
16 dbx500_add_i2c(2, U5500_I2C2_BASE, IRQ_DB5500_I2C2, pdata) 16 dbx500_add_i2c(parent, 2, U5500_I2C2_BASE, IRQ_DB5500_I2C2, pdata)
17#define db5500_add_i2c3(pdata) \ 17#define db5500_add_i2c3(parent, pdata) \
18 dbx500_add_i2c(3, U5500_I2C3_BASE, IRQ_DB5500_I2C3, pdata) 18 dbx500_add_i2c(parent, 3, U5500_I2C3_BASE, IRQ_DB5500_I2C3, pdata)
19 19
20#define db5500_add_msp0_i2s(pdata) \ 20#define db5500_add_msp0_spi(parent, pdata) \
21 dbx500_add_msp_i2s(0, U5500_MSP0_BASE, IRQ_DB5500_MSP0, pdata) 21 dbx500_add_msp_spi(parent, "msp0", U5500_MSP0_BASE, \
22#define db5500_add_msp1_i2s(pdata) \ 22 IRQ_DB5500_MSP0, pdata)
23 dbx500_add_msp_i2s(1, U5500_MSP1_BASE, IRQ_DB5500_MSP1, pdata) 23#define db5500_add_msp1_spi(parent, pdata) \
24#define db5500_add_msp2_i2s(pdata) \ 24 dbx500_add_msp_spi(parent, "msp1", U5500_MSP1_BASE, \
25 dbx500_add_msp_i2s(2, U5500_MSP2_BASE, IRQ_DB5500_MSP2, pdata) 25 IRQ_DB5500_MSP1, pdata)
26#define db5500_add_msp2_spi(parent, pdata) \
27 dbx500_add_msp_spi(parent, "msp2", U5500_MSP2_BASE, \
28 IRQ_DB5500_MSP2, pdata)
26 29
27#define db5500_add_msp0_spi(pdata) \ 30#define db5500_add_msp0_spi(parent, pdata) \
28 dbx500_add_msp_spi("msp0", U5500_MSP0_BASE, IRQ_DB5500_MSP0, pdata) 31 dbx500_add_msp_spi(parent, "msp0", U5500_MSP0_BASE, \
29#define db5500_add_msp1_spi(pdata) \ 32 IRQ_DB5500_MSP0, pdata)
30 dbx500_add_msp_spi("msp1", U5500_MSP1_BASE, IRQ_DB5500_MSP1, pdata) 33#define db5500_add_msp1_spi(parent, pdata) \
31#define db5500_add_msp2_spi(pdata) \ 34 dbx500_add_msp_spi(parent, "msp1", U5500_MSP1_BASE, \
32 dbx500_add_msp_spi("msp2", U5500_MSP2_BASE, IRQ_DB5500_MSP2, pdata) 35 IRQ_DB5500_MSP1, pdata)
36#define db5500_add_msp2_spi(parent, pdata) \
37 dbx500_add_msp_spi(parent, "msp2", U5500_MSP2_BASE, \
38 IRQ_DB5500_MSP2, pdata)
33 39
34#define db5500_add_rtc() \ 40#define db5500_add_rtc(parent) \
35 dbx500_add_rtc(U5500_RTC_BASE, IRQ_DB5500_RTC); 41 dbx500_add_rtc(parent, U5500_RTC_BASE, IRQ_DB5500_RTC);
36 42
37#define db5500_add_usb(rx_cfg, tx_cfg) \ 43#define db5500_add_usb(parent, rx_cfg, tx_cfg) \
38 ux500_add_usb(U5500_USBOTG_BASE, IRQ_DB5500_USBOTG, rx_cfg, tx_cfg) 44 ux500_add_usb(parent, U5500_USBOTG_BASE, \
45 IRQ_DB5500_USBOTG, rx_cfg, tx_cfg)
39 46
40#define db5500_add_sdi0(pdata) \ 47#define db5500_add_sdi0(parent, pdata) \
41 dbx500_add_sdi("sdi0", U5500_SDI0_BASE, IRQ_DB5500_SDMMC0, pdata, \ 48 dbx500_add_sdi(parent, "sdi0", U5500_SDI0_BASE, \
49 IRQ_DB5500_SDMMC0, pdata, \
42 0x10480180) 50 0x10480180)
43#define db5500_add_sdi1(pdata) \ 51#define db5500_add_sdi1(parent, pdata) \
44 dbx500_add_sdi("sdi1", U5500_SDI1_BASE, IRQ_DB5500_SDMMC1, pdata, \ 52 dbx500_add_sdi(parent, "sdi1", U5500_SDI1_BASE, \
53 IRQ_DB5500_SDMMC1, pdata, \
45 0x10480180) 54 0x10480180)
46#define db5500_add_sdi2(pdata) \ 55#define db5500_add_sdi2(parent, pdata) \
47 dbx500_add_sdi("sdi2", U5500_SDI2_BASE, IRQ_DB5500_SDMMC2, pdata \ 56 dbx500_add_sdi(parent, "sdi2", U5500_SDI2_BASE, \
57 IRQ_DB5500_SDMMC2, pdata \
48 0x10480180) 58 0x10480180)
49#define db5500_add_sdi3(pdata) \ 59#define db5500_add_sdi3(parent, pdata) \
50 dbx500_add_sdi("sdi3", U5500_SDI3_BASE, IRQ_DB5500_SDMMC3, pdata \ 60 dbx500_add_sdi(parent, "sdi3", U5500_SDI3_BASE, \
61 IRQ_DB5500_SDMMC3, pdata \
51 0x10480180) 62 0x10480180)
52#define db5500_add_sdi4(pdata) \ 63#define db5500_add_sdi4(parent, pdata) \
53 dbx500_add_sdi("sdi4", U5500_SDI4_BASE, IRQ_DB5500_SDMMC4, pdata \ 64 dbx500_add_sdi(parent, "sdi4", U5500_SDI4_BASE, \
65 IRQ_DB5500_SDMMC4, pdata \
54 0x10480180) 66 0x10480180)
55 67
56/* This one has a bad peripheral ID in the U5500 silicon */ 68/* This one has a bad peripheral ID in the U5500 silicon */
57#define db5500_add_spi0(pdata) \ 69#define db5500_add_spi0(parent, pdata) \
58 dbx500_add_spi("spi0", U5500_SPI0_BASE, IRQ_DB5500_SPI0, pdata, \ 70 dbx500_add_spi(parent, "spi0", U5500_SPI0_BASE, \
71 IRQ_DB5500_SPI0, pdata, \
59 0x10080023) 72 0x10080023)
60#define db5500_add_spi1(pdata) \ 73#define db5500_add_spi1(parent, pdata) \
61 dbx500_add_spi("spi1", U5500_SPI1_BASE, IRQ_DB5500_SPI1, pdata, \ 74 dbx500_add_spi(parent, "spi1", U5500_SPI1_BASE, \
75 IRQ_DB5500_SPI1, pdata, \
62 0x10080023) 76 0x10080023)
63#define db5500_add_spi2(pdata) \ 77#define db5500_add_spi2(parent, pdata) \
64 dbx500_add_spi("spi2", U5500_SPI2_BASE, IRQ_DB5500_SPI2, pdata \ 78 dbx500_add_spi(parent, "spi2", U5500_SPI2_BASE, \
79 IRQ_DB5500_SPI2, pdata \
65 0x10080023) 80 0x10080023)
66#define db5500_add_spi3(pdata) \ 81#define db5500_add_spi3(parent, pdata) \
67 dbx500_add_spi("spi3", U5500_SPI3_BASE, IRQ_DB5500_SPI3, pdata \ 82 dbx500_add_spi(parent, "spi3", U5500_SPI3_BASE, \
83 IRQ_DB5500_SPI3, pdata \
68 0x10080023) 84 0x10080023)
69 85
70#define db5500_add_uart0(plat) \ 86#define db5500_add_uart0(parent, plat) \
71 dbx500_add_uart("uart0", U5500_UART0_BASE, IRQ_DB5500_UART0, plat) 87 dbx500_add_uart(parent, "uart0", U5500_UART0_BASE, \
72#define db5500_add_uart1(plat) \ 88 IRQ_DB5500_UART0, plat)
73 dbx500_add_uart("uart1", U5500_UART1_BASE, IRQ_DB5500_UART1, plat) 89#define db5500_add_uart1(parent, plat) \
74#define db5500_add_uart2(plat) \ 90 dbx500_add_uart(parent, "uart1", U5500_UART1_BASE, \
75 dbx500_add_uart("uart2", U5500_UART2_BASE, IRQ_DB5500_UART2, plat) 91 IRQ_DB5500_UART1, plat)
76#define db5500_add_uart3(plat) \ 92#define db5500_add_uart2(parent, plat) \
77 dbx500_add_uart("uart3", U5500_UART3_BASE, IRQ_DB5500_UART3, plat) 93 dbx500_add_uart(parent, "uart2", U5500_UART2_BASE, \
94 IRQ_DB5500_UART2, plat)
95#define db5500_add_uart3(parent, plat) \
96 dbx500_add_uart(parent, "uart3", U5500_UART3_BASE, \
97 IRQ_DB5500_UART3, plat)
78 98
79#endif 99#endif
diff --git a/arch/arm/mach-ux500/devices-db8500.h b/arch/arm/mach-ux500/devices-db8500.h
index cbd4a9ae8109..9fd93e9da529 100644
--- a/arch/arm/mach-ux500/devices-db8500.h
+++ b/arch/arm/mach-ux500/devices-db8500.h
@@ -14,88 +14,114 @@ struct ske_keypad_platform_data;
14struct pl022_ssp_controller; 14struct pl022_ssp_controller;
15 15
16static inline struct platform_device * 16static inline struct platform_device *
17db8500_add_ske_keypad(struct ske_keypad_platform_data *pdata) 17db8500_add_ske_keypad(struct device *parent,
18 struct ske_keypad_platform_data *pdata,
19 size_t size)
18{ 20{
19 return dbx500_add_platform_device_4k1irq("nmk-ske-keypad", -1, 21 struct resource resources[] = {
20 U8500_SKE_BASE, 22 DEFINE_RES_MEM(U8500_SKE_BASE, SZ_4K),
21 IRQ_DB8500_KB, pdata); 23 DEFINE_RES_IRQ(IRQ_DB8500_KB),
24 };
25
26 return platform_device_register_resndata(parent, "nmk-ske-keypad", -1,
27 resources, 2, pdata, size);
22} 28}
23 29
24static inline struct amba_device * 30static inline struct amba_device *
25db8500_add_ssp(const char *name, resource_size_t base, int irq, 31db8500_add_ssp(struct device *parent, const char *name, resource_size_t base,
26 struct pl022_ssp_controller *pdata) 32 int irq, struct pl022_ssp_controller *pdata)
27{ 33{
28 return dbx500_add_amba_device(name, base, irq, pdata, 0); 34 return dbx500_add_amba_device(parent, name, base, irq, pdata, 0);
29} 35}
30 36
31 37
32#define db8500_add_i2c0(pdata) \ 38#define db8500_add_i2c0(parent, pdata) \
33 dbx500_add_i2c(0, U8500_I2C0_BASE, IRQ_DB8500_I2C0, pdata) 39 dbx500_add_i2c(parent, 0, U8500_I2C0_BASE, IRQ_DB8500_I2C0, pdata)
34#define db8500_add_i2c1(pdata) \ 40#define db8500_add_i2c1(parent, pdata) \
35 dbx500_add_i2c(1, U8500_I2C1_BASE, IRQ_DB8500_I2C1, pdata) 41 dbx500_add_i2c(parent, 1, U8500_I2C1_BASE, IRQ_DB8500_I2C1, pdata)
36#define db8500_add_i2c2(pdata) \ 42#define db8500_add_i2c2(parent, pdata) \
37 dbx500_add_i2c(2, U8500_I2C2_BASE, IRQ_DB8500_I2C2, pdata) 43 dbx500_add_i2c(parent, 2, U8500_I2C2_BASE, IRQ_DB8500_I2C2, pdata)
38#define db8500_add_i2c3(pdata) \ 44#define db8500_add_i2c3(parent, pdata) \
39 dbx500_add_i2c(3, U8500_I2C3_BASE, IRQ_DB8500_I2C3, pdata) 45 dbx500_add_i2c(parent, 3, U8500_I2C3_BASE, IRQ_DB8500_I2C3, pdata)
40#define db8500_add_i2c4(pdata) \ 46#define db8500_add_i2c4(parent, pdata) \
41 dbx500_add_i2c(4, U8500_I2C4_BASE, IRQ_DB8500_I2C4, pdata) 47 dbx500_add_i2c(parent, 4, U8500_I2C4_BASE, IRQ_DB8500_I2C4, pdata)
42 48
43#define db8500_add_msp0_i2s(pdata) \ 49#define db8500_add_msp0_i2s(parent, pdata) \
44 dbx500_add_msp_i2s(0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, pdata) 50 dbx500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, pdata)
45#define db8500_add_msp1_i2s(pdata) \ 51#define db8500_add_msp1_i2s(parent, pdata) \
46 dbx500_add_msp_i2s(1, U8500_MSP1_BASE, IRQ_DB8500_MSP1, pdata) 52 dbx500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1, pdata)
47#define db8500_add_msp2_i2s(pdata) \ 53#define db8500_add_msp2_i2s(parent, pdata) \
48 dbx500_add_msp_i2s(2, U8500_MSP2_BASE, IRQ_DB8500_MSP2, pdata) 54 dbx500_add_msp_i2s(parent, 2, U8500_MSP2_BASE, IRQ_DB8500_MSP2, pdata)
49#define db8500_add_msp3_i2s(pdata) \ 55#define db8500_add_msp3_i2s(parent, pdata) \
50 dbx500_add_msp_i2s(3, U8500_MSP3_BASE, IRQ_DB8500_MSP1, pdata) 56 dbx500_add_msp_i2s(parent, 3, U8500_MSP3_BASE, IRQ_DB8500_MSP1, pdata)
51 57
52#define db8500_add_msp0_spi(pdata) \ 58#define db8500_add_msp0_spi(parent, pdata) \
53 dbx500_add_msp_spi("msp0", U8500_MSP0_BASE, IRQ_DB8500_MSP0, pdata) 59 dbx500_add_msp_spi(parent, "msp0", U8500_MSP0_BASE, \
54#define db8500_add_msp1_spi(pdata) \ 60 IRQ_DB8500_MSP0, pdata)
55 dbx500_add_msp_spi("msp1", U8500_MSP1_BASE, IRQ_DB8500_MSP1, pdata) 61#define db8500_add_msp1_spi(parent, pdata) \
56#define db8500_add_msp2_spi(pdata) \ 62 dbx500_add_msp_spi(parent, "msp1", U8500_MSP1_BASE, \
57 dbx500_add_msp_spi("msp2", U8500_MSP2_BASE, IRQ_DB8500_MSP2, pdata) 63 IRQ_DB8500_MSP1, pdata)
58#define db8500_add_msp3_spi(pdata) \ 64#define db8500_add_msp2_spi(parent, pdata) \
59 dbx500_add_msp_spi("msp3", U8500_MSP3_BASE, IRQ_DB8500_MSP1, pdata) 65 dbx500_add_msp_spi(parent, "msp2", U8500_MSP2_BASE, \
60 66 IRQ_DB8500_MSP2, pdata)
61#define db8500_add_rtc() \ 67#define db8500_add_msp3_spi(parent, pdata) \
62 dbx500_add_rtc(U8500_RTC_BASE, IRQ_DB8500_RTC); 68 dbx500_add_msp_spi(parent, "msp3", U8500_MSP3_BASE, \
63 69 IRQ_DB8500_MSP1, pdata)
64#define db8500_add_usb(rx_cfg, tx_cfg) \ 70
65 ux500_add_usb(U8500_USBOTG_BASE, IRQ_DB8500_USBOTG, rx_cfg, tx_cfg) 71#define db8500_add_rtc(parent) \
66 72 dbx500_add_rtc(parent, U8500_RTC_BASE, IRQ_DB8500_RTC);
67#define db8500_add_sdi0(pdata, pid) \ 73
68 dbx500_add_sdi("sdi0", U8500_SDI0_BASE, IRQ_DB8500_SDMMC0, pdata, pid) 74#define db8500_add_usb(parent, rx_cfg, tx_cfg) \
69#define db8500_add_sdi1(pdata, pid) \ 75 ux500_add_usb(parent, U8500_USBOTG_BASE, \
70 dbx500_add_sdi("sdi1", U8500_SDI1_BASE, IRQ_DB8500_SDMMC1, pdata, pid) 76 IRQ_DB8500_USBOTG, rx_cfg, tx_cfg)
71#define db8500_add_sdi2(pdata, pid) \ 77
72 dbx500_add_sdi("sdi2", U8500_SDI2_BASE, IRQ_DB8500_SDMMC2, pdata, pid) 78#define db8500_add_sdi0(parent, pdata, pid) \
73#define db8500_add_sdi3(pdata, pid) \ 79 dbx500_add_sdi(parent, "sdi0", U8500_SDI0_BASE, \
74 dbx500_add_sdi("sdi3", U8500_SDI3_BASE, IRQ_DB8500_SDMMC3, pdata, pid) 80 IRQ_DB8500_SDMMC0, pdata, pid)
75#define db8500_add_sdi4(pdata, pid) \ 81#define db8500_add_sdi1(parent, pdata, pid) \
76 dbx500_add_sdi("sdi4", U8500_SDI4_BASE, IRQ_DB8500_SDMMC4, pdata, pid) 82 dbx500_add_sdi(parent, "sdi1", U8500_SDI1_BASE, \
77#define db8500_add_sdi5(pdata, pid) \ 83 IRQ_DB8500_SDMMC1, pdata, pid)
78 dbx500_add_sdi("sdi5", U8500_SDI5_BASE, IRQ_DB8500_SDMMC5, pdata, pid) 84#define db8500_add_sdi2(parent, pdata, pid) \
79 85 dbx500_add_sdi(parent, "sdi2", U8500_SDI2_BASE, \
80#define db8500_add_ssp0(pdata) \ 86 IRQ_DB8500_SDMMC2, pdata, pid)
81 db8500_add_ssp("ssp0", U8500_SSP0_BASE, IRQ_DB8500_SSP0, pdata) 87#define db8500_add_sdi3(parent, pdata, pid) \
82#define db8500_add_ssp1(pdata) \ 88 dbx500_add_sdi(parent, "sdi3", U8500_SDI3_BASE, \
83 db8500_add_ssp("ssp1", U8500_SSP1_BASE, IRQ_DB8500_SSP1, pdata) 89 IRQ_DB8500_SDMMC3, pdata, pid)
84 90#define db8500_add_sdi4(parent, pdata, pid) \
85#define db8500_add_spi0(pdata) \ 91 dbx500_add_sdi(parent, "sdi4", U8500_SDI4_BASE, \
86 dbx500_add_spi("spi0", U8500_SPI0_BASE, IRQ_DB8500_SPI0, pdata, 0) 92 IRQ_DB8500_SDMMC4, pdata, pid)
87#define db8500_add_spi1(pdata) \ 93#define db8500_add_sdi5(parent, pdata, pid) \
88 dbx500_add_spi("spi1", U8500_SPI1_BASE, IRQ_DB8500_SPI1, pdata, 0) 94 dbx500_add_sdi(parent, "sdi5", U8500_SDI5_BASE, \
89#define db8500_add_spi2(pdata) \ 95 IRQ_DB8500_SDMMC5, pdata, pid)
90 dbx500_add_spi("spi2", U8500_SPI2_BASE, IRQ_DB8500_SPI2, pdata, 0) 96
91#define db8500_add_spi3(pdata) \ 97#define db8500_add_ssp0(parent, pdata) \
92 dbx500_add_spi("spi3", U8500_SPI3_BASE, IRQ_DB8500_SPI3, pdata, 0) 98 db8500_add_ssp(parent, "ssp0", U8500_SSP0_BASE, \
93 99 IRQ_DB8500_SSP0, pdata)
94#define db8500_add_uart0(pdata) \ 100#define db8500_add_ssp1(parent, pdata) \
95 dbx500_add_uart("uart0", U8500_UART0_BASE, IRQ_DB8500_UART0, pdata) 101 db8500_add_ssp(parent, "ssp1", U8500_SSP1_BASE, \
96#define db8500_add_uart1(pdata) \ 102 IRQ_DB8500_SSP1, pdata)
97 dbx500_add_uart("uart1", U8500_UART1_BASE, IRQ_DB8500_UART1, pdata) 103
98#define db8500_add_uart2(pdata) \ 104#define db8500_add_spi0(parent, pdata) \
99 dbx500_add_uart("uart2", U8500_UART2_BASE, IRQ_DB8500_UART2, pdata) 105 dbx500_add_spi(parent, "spi0", U8500_SPI0_BASE, \
106 IRQ_DB8500_SPI0, pdata, 0)
107#define db8500_add_spi1(parent, pdata) \
108 dbx500_add_spi(parent, "spi1", U8500_SPI1_BASE, \
109 IRQ_DB8500_SPI1, pdata, 0)
110#define db8500_add_spi2(parent, pdata) \
111 dbx500_add_spi(parent, "spi2", U8500_SPI2_BASE, \
112 IRQ_DB8500_SPI2, pdata, 0)
113#define db8500_add_spi3(parent, pdata) \
114 dbx500_add_spi(parent, "spi3", U8500_SPI3_BASE, \
115 IRQ_DB8500_SPI3, pdata, 0)
116
117#define db8500_add_uart0(parent, pdata) \
118 dbx500_add_uart(parent, "uart0", U8500_UART0_BASE, \
119 IRQ_DB8500_UART0, pdata)
120#define db8500_add_uart1(parent, pdata) \
121 dbx500_add_uart(parent, "uart1", U8500_UART1_BASE, \
122 IRQ_DB8500_UART1, pdata)
123#define db8500_add_uart2(parent, pdata) \
124 dbx500_add_uart(parent, "uart2", U8500_UART2_BASE, \
125 IRQ_DB8500_UART2, pdata)
100 126
101#endif 127#endif
diff --git a/arch/arm/mach-ux500/dma-db5500.c b/arch/arm/mach-ux500/dma-db5500.c
index 1cfab68ae417..41e9470fa0e6 100644
--- a/arch/arm/mach-ux500/dma-db5500.c
+++ b/arch/arm/mach-ux500/dma-db5500.c
@@ -125,10 +125,11 @@ static struct platform_device dma40_device = {
125 .resource = dma40_resources 125 .resource = dma40_resources
126}; 126};
127 127
128void __init db5500_dma_init(void) 128void __init db5500_dma_init(struct device *parent)
129{ 129{
130 int ret; 130 int ret;
131 131
132 dma40_device.dev.parent = parent;
132 ret = platform_device_register(&dma40_device); 133 ret = platform_device_register(&dma40_device);
133 if (ret) 134 if (ret)
134 dev_err(&dma40_device.dev, "unable to register device: %d\n", ret); 135 dev_err(&dma40_device.dev, "unable to register device: %d\n", ret);
diff --git a/arch/arm/mach-ux500/include/mach/db8500-regs.h b/arch/arm/mach-ux500/include/mach/db8500-regs.h
index 80e10f50282e..9ec20b96d8f2 100644
--- a/arch/arm/mach-ux500/include/mach/db8500-regs.h
+++ b/arch/arm/mach-ux500/include/mach/db8500-regs.h
@@ -161,4 +161,7 @@
161#define U8500_MODEM_BASE 0xe000000 161#define U8500_MODEM_BASE 0xe000000
162#define U8500_APE_BASE 0x6000000 162#define U8500_APE_BASE 0x6000000
163 163
164/* SoC identification number information */
165#define U8500_BB_UID_BASE (U8500_BACKUPRAM1_BASE + 0xFC0)
166
164#endif 167#endif
diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
index a7d363fdb4cd..3dc00ffa7bfa 100644
--- a/arch/arm/mach-ux500/include/mach/setup.h
+++ b/arch/arm/mach-ux500/include/mach/setup.h
@@ -18,17 +18,16 @@ void __init ux500_map_io(void);
18extern void __init u5500_map_io(void); 18extern void __init u5500_map_io(void);
19extern void __init u8500_map_io(void); 19extern void __init u8500_map_io(void);
20 20
21extern void __init u5500_init_devices(void); 21extern struct device * __init u5500_init_devices(void);
22extern void __init u8500_init_devices(void); 22extern struct device * __init u8500_init_devices(void);
23 23
24extern void __init ux500_init_irq(void); 24extern void __init ux500_init_irq(void);
25 25
26extern void __init u5500_sdi_init(void); 26extern void __init u5500_sdi_init(struct device *parent);
27 27
28extern void __init db5500_dma_init(void); 28extern void __init db5500_dma_init(struct device *parent);
29 29
30/* We re-use nomadik_timer for this platform */ 30extern struct device *ux500_soc_device_init(const char *soc_id);
31extern void nmdk_timer_init(void);
32 31
33struct amba_device; 32struct amba_device;
34extern void __init amba_add_devices(struct amba_device *devs[], int num); 33extern void __init amba_add_devices(struct amba_device *devs[], int num);
diff --git a/arch/arm/mach-ux500/include/mach/usb.h b/arch/arm/mach-ux500/include/mach/usb.h
index d3739d418813..4c1cc50a595a 100644
--- a/arch/arm/mach-ux500/include/mach/usb.h
+++ b/arch/arm/mach-ux500/include/mach/usb.h
@@ -20,6 +20,6 @@ struct ux500_musb_board_data {
20 bool (*dma_filter)(struct dma_chan *chan, void *filter_param); 20 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
21}; 21};
22 22
23void ux500_add_usb(resource_size_t base, int irq, int *dma_rx_cfg, 23void ux500_add_usb(struct device *parent, resource_size_t base,
24 int *dma_tx_cfg); 24 int irq, int *dma_rx_cfg, int *dma_tx_cfg);
25#endif 25#endif
diff --git a/arch/arm/mach-ux500/localtimer.c b/arch/arm/mach-ux500/localtimer.c
deleted file mode 100644
index 5ba113309a0b..000000000000
--- a/arch/arm/mach-ux500/localtimer.c
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright (C) 2008-2009 ST-Ericsson
3 * Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
4 *
5 * This file is heavily based on relaview platform, almost a copy.
6 *
7 * Copyright (C) 2002 ARM Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#include <linux/init.h>
14#include <linux/smp.h>
15#include <linux/clockchips.h>
16
17#include <asm/irq.h>
18#include <asm/smp_twd.h>
19#include <asm/localtimer.h>
20
21/*
22 * Setup the local clock events for a CPU.
23 */
24int __cpuinit local_timer_setup(struct clock_event_device *evt)
25{
26 evt->irq = IRQ_LOCALTIMER;
27 twd_timer_setup(evt);
28 return 0;
29}
diff --git a/arch/arm/mach-ux500/timer.c b/arch/arm/mach-ux500/timer.c
index aea467d04ff7..d37df98b5c32 100644
--- a/arch/arm/mach-ux500/timer.c
+++ b/arch/arm/mach-ux500/timer.c
@@ -7,29 +7,52 @@
7#include <linux/io.h> 7#include <linux/io.h>
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/clksrc-dbx500-prcmu.h> 9#include <linux/clksrc-dbx500-prcmu.h>
10#include <linux/of.h>
10 11
11#include <asm/localtimer.h> 12#include <asm/smp_twd.h>
12 13
13#include <plat/mtu.h> 14#include <plat/mtu.h>
14 15
15#include <mach/setup.h> 16#include <mach/setup.h>
16#include <mach/hardware.h> 17#include <mach/hardware.h>
18#include <mach/irqs.h>
19
20#ifdef CONFIG_HAVE_ARM_TWD
21static DEFINE_TWD_LOCAL_TIMER(u5500_twd_local_timer,
22 U5500_TWD_BASE, IRQ_LOCALTIMER);
23static DEFINE_TWD_LOCAL_TIMER(u8500_twd_local_timer,
24 U8500_TWD_BASE, IRQ_LOCALTIMER);
25
26static void __init ux500_twd_init(void)
27{
28 struct twd_local_timer *twd_local_timer;
29 int err;
30
31 twd_local_timer = cpu_is_u5500() ? &u5500_twd_local_timer :
32 &u8500_twd_local_timer;
33
34 if (of_have_populated_dt())
35 twd_local_timer_of_register();
36 else {
37 err = twd_local_timer_register(twd_local_timer);
38 if (err)
39 pr_err("twd_local_timer_register failed %d\n", err);
40 }
41}
42#else
43#define ux500_twd_init() do { } while(0)
44#endif
17 45
18static void __init ux500_timer_init(void) 46static void __init ux500_timer_init(void)
19{ 47{
48 void __iomem *mtu_timer_base;
20 void __iomem *prcmu_timer_base; 49 void __iomem *prcmu_timer_base;
21 50
22 if (cpu_is_u5500()) { 51 if (cpu_is_u5500()) {
23#ifdef CONFIG_LOCAL_TIMERS 52 mtu_timer_base = __io_address(U5500_MTU0_BASE);
24 twd_base = __io_address(U5500_TWD_BASE);
25#endif
26 mtu_base = __io_address(U5500_MTU0_BASE);
27 prcmu_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE); 53 prcmu_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE);
28 } else if (cpu_is_u8500()) { 54 } else if (cpu_is_u8500()) {
29#ifdef CONFIG_LOCAL_TIMERS 55 mtu_timer_base = __io_address(U8500_MTU0_BASE);
30 twd_base = __io_address(U8500_TWD_BASE);
31#endif
32 mtu_base = __io_address(U8500_MTU0_BASE);
33 prcmu_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE); 56 prcmu_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
34 } else { 57 } else {
35 ux500_unknown_soc(); 58 ux500_unknown_soc();
@@ -52,8 +75,9 @@ static void __init ux500_timer_init(void)
52 * 75 *
53 */ 76 */
54 77
55 nmdk_timer_init(); 78 nmdk_timer_init(mtu_timer_base);
56 clksrc_dbx500_prcmu_init(prcmu_timer_base); 79 clksrc_dbx500_prcmu_init(prcmu_timer_base);
80 ux500_twd_init();
57} 81}
58 82
59static void ux500_timer_reset(void) 83static void ux500_timer_reset(void)
diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c
index 9f9e1c203061..a74af389bc63 100644
--- a/arch/arm/mach-ux500/usb.c
+++ b/arch/arm/mach-ux500/usb.c
@@ -7,6 +7,7 @@
7#include <linux/platform_device.h> 7#include <linux/platform_device.h>
8#include <linux/usb/musb.h> 8#include <linux/usb/musb.h>
9#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
10
10#include <plat/ste_dma40.h> 11#include <plat/ste_dma40.h>
11#include <mach/hardware.h> 12#include <mach/hardware.h>
12#include <mach/usb.h> 13#include <mach/usb.h>
@@ -140,8 +141,8 @@ static inline void ux500_usb_dma_update_tx_ch_config(int *dst_dev_type)
140 musb_dma_tx_ch[idx].dst_dev_type = dst_dev_type[idx]; 141 musb_dma_tx_ch[idx].dst_dev_type = dst_dev_type[idx];
141} 142}
142 143
143void ux500_add_usb(resource_size_t base, int irq, int *dma_rx_cfg, 144void ux500_add_usb(struct device *parent, resource_size_t base, int irq,
144 int *dma_tx_cfg) 145 int *dma_rx_cfg, int *dma_tx_cfg)
145{ 146{
146 ux500_musb_device.resource[0].start = base; 147 ux500_musb_device.resource[0].start = base;
147 ux500_musb_device.resource[0].end = base + SZ_64K - 1; 148 ux500_musb_device.resource[0].end = base + SZ_64K - 1;
@@ -151,5 +152,7 @@ void ux500_add_usb(resource_size_t base, int irq, int *dma_rx_cfg,
151 ux500_usb_dma_update_rx_ch_config(dma_rx_cfg); 152 ux500_usb_dma_update_rx_ch_config(dma_rx_cfg);
152 ux500_usb_dma_update_tx_ch_config(dma_tx_cfg); 153 ux500_usb_dma_update_tx_ch_config(dma_tx_cfg);
153 154
155 ux500_musb_device.dev.parent = parent;
156
154 platform_device_register(&ux500_musb_device); 157 platform_device_register(&ux500_musb_device);
155} 158}
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index 73791f010297..c65cc3b462a5 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -42,15 +42,26 @@ static struct map_desc ct_ca9x4_io_desc[] __initdata = {
42static void __init ct_ca9x4_map_io(void) 42static void __init ct_ca9x4_map_io(void)
43{ 43{
44 iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc)); 44 iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
45#ifdef CONFIG_LOCAL_TIMERS
46 twd_base = ioremap(A9_MPCORE_TWD, SZ_32);
47#endif
48} 45}
49 46
47#ifdef CONFIG_HAVE_ARM_TWD
48static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER);
49
50static void __init ca9x4_twd_init(void)
51{
52 int err = twd_local_timer_register(&twd_local_timer);
53 if (err)
54 pr_err("twd_local_timer_register failed %d\n", err);
55}
56#else
57#define ca9x4_twd_init() do {} while(0)
58#endif
59
50static void __init ct_ca9x4_init_irq(void) 60static void __init ct_ca9x4_init_irq(void)
51{ 61{
52 gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K), 62 gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K),
53 ioremap(A9_MPCORE_GIC_CPU, SZ_256)); 63 ioremap(A9_MPCORE_GIC_CPU, SZ_256));
64 ca9x4_twd_init();
54} 65}
55 66
56static void ct_ca9x4_clcd_enable(struct clcd_fb *fb) 67static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
diff --git a/arch/arm/plat-nomadik/include/plat/mtu.h b/arch/arm/plat-nomadik/include/plat/mtu.h
index 6508e7694a4b..582641f3dc01 100644
--- a/arch/arm/plat-nomadik/include/plat/mtu.h
+++ b/arch/arm/plat-nomadik/include/plat/mtu.h
@@ -1,9 +1,7 @@
1#ifndef __PLAT_MTU_H 1#ifndef __PLAT_MTU_H
2#define __PLAT_MTU_H 2#define __PLAT_MTU_H
3 3
4/* should be set by the platform code */ 4void nmdk_timer_init(void __iomem *base);
5extern void __iomem *mtu_base;
6
7void nmdk_clkevt_reset(void); 5void nmdk_clkevt_reset(void);
8void nmdk_clksrc_reset(void); 6void nmdk_clksrc_reset(void);
9 7
diff --git a/arch/arm/plat-nomadik/timer.c b/arch/arm/plat-nomadik/timer.c
index ad1b45b605a4..9222e5522a43 100644
--- a/arch/arm/plat-nomadik/timer.c
+++ b/arch/arm/plat-nomadik/timer.c
@@ -21,12 +21,6 @@
21#include <asm/sched_clock.h> 21#include <asm/sched_clock.h>
22 22
23/* 23/*
24 * Guaranteed runtime conversion range in seconds for
25 * the clocksource and clockevent.
26 */
27#define MTU_MIN_RANGE 4
28
29/*
30 * The MTU device hosts four different counters, with 4 set of 24 * The MTU device hosts four different counters, with 4 set of
31 * registers. These are register names. 25 * registers. These are register names.
32 */ 26 */
@@ -66,12 +60,11 @@
66#define MTU_PCELL2 0xff8 60#define MTU_PCELL2 0xff8
67#define MTU_PCELL3 0xffC 61#define MTU_PCELL3 0xffC
68 62
63static void __iomem *mtu_base;
69static bool clkevt_periodic; 64static bool clkevt_periodic;
70static u32 clk_prescale; 65static u32 clk_prescale;
71static u32 nmdk_cycle; /* write-once */ 66static u32 nmdk_cycle; /* write-once */
72 67
73void __iomem *mtu_base; /* Assigned by machine code */
74
75#ifdef CONFIG_NOMADIK_MTU_SCHED_CLOCK 68#ifdef CONFIG_NOMADIK_MTU_SCHED_CLOCK
76/* 69/*
77 * Override the global weak sched_clock symbol with this 70 * Override the global weak sched_clock symbol with this
@@ -103,7 +96,6 @@ static int nmdk_clkevt_next(unsigned long evt, struct clock_event_device *ev)
103void nmdk_clkevt_reset(void) 96void nmdk_clkevt_reset(void)
104{ 97{
105 if (clkevt_periodic) { 98 if (clkevt_periodic) {
106
107 /* Timer: configure load and background-load, and fire it up */ 99 /* Timer: configure load and background-load, and fire it up */
108 writel(nmdk_cycle, mtu_base + MTU_LR(1)); 100 writel(nmdk_cycle, mtu_base + MTU_LR(1));
109 writel(nmdk_cycle, mtu_base + MTU_BGLR(1)); 101 writel(nmdk_cycle, mtu_base + MTU_BGLR(1));
@@ -121,7 +113,6 @@ void nmdk_clkevt_reset(void)
121static void nmdk_clkevt_mode(enum clock_event_mode mode, 113static void nmdk_clkevt_mode(enum clock_event_mode mode,
122 struct clock_event_device *dev) 114 struct clock_event_device *dev)
123{ 115{
124
125 switch (mode) { 116 switch (mode) {
126 case CLOCK_EVT_MODE_PERIODIC: 117 case CLOCK_EVT_MODE_PERIODIC:
127 clkevt_periodic = true; 118 clkevt_periodic = true;
@@ -183,15 +174,16 @@ void nmdk_clksrc_reset(void)
183 mtu_base + MTU_CR(0)); 174 mtu_base + MTU_CR(0));
184} 175}
185 176
186void __init nmdk_timer_init(void) 177void __init nmdk_timer_init(void __iomem *base)
187{ 178{
188 unsigned long rate; 179 unsigned long rate;
189 struct clk *clk0; 180 struct clk *clk0;
190 181
182 mtu_base = base;
191 clk0 = clk_get_sys("mtu0", NULL); 183 clk0 = clk_get_sys("mtu0", NULL);
192 BUG_ON(IS_ERR(clk0)); 184 BUG_ON(IS_ERR(clk0));
193 185 BUG_ON(clk_prepare(clk0) < 0);
194 clk_enable(clk0); 186 BUG_ON(clk_enable(clk0) < 0);
195 187
196 /* 188 /*
197 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz 189 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz
@@ -224,17 +216,8 @@ void __init nmdk_timer_init(void)
224 setup_sched_clock(nomadik_read_sched_clock, 32, rate); 216 setup_sched_clock(nomadik_read_sched_clock, 32, rate);
225#endif 217#endif
226 218
227 /* Timer 1 is used for events */ 219 /* Timer 1 is used for events, register irq and clockevents */
228
229 clockevents_calc_mult_shift(&nmdk_clkevt, rate, MTU_MIN_RANGE);
230
231 nmdk_clkevt.max_delta_ns =
232 clockevent_delta2ns(0xffffffff, &nmdk_clkevt);
233 nmdk_clkevt.min_delta_ns =
234 clockevent_delta2ns(0x00000002, &nmdk_clkevt);
235 nmdk_clkevt.cpumask = cpumask_of(0);
236
237 /* Register irq and clockevents */
238 setup_irq(IRQ_MTU0, &nmdk_timer_irq); 220 setup_irq(IRQ_MTU0, &nmdk_timer_irq);
239 clockevents_register_device(&nmdk_clkevt); 221 nmdk_clkevt.cpumask = cpumask_of(0);
222 clockevents_config_and_register(&nmdk_clkevt, rate, 2, 0xffffffffU);
240} 223}
diff --git a/arch/arm/plat-versatile/Makefile b/arch/arm/plat-versatile/Makefile
index 69714db47c33..a5cb1945bdcc 100644
--- a/arch/arm/plat-versatile/Makefile
+++ b/arch/arm/plat-versatile/Makefile
@@ -1,5 +1,4 @@
1obj-y := clock.o 1obj-y := clock.o
2obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
3obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o 2obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o
4obj-$(CONFIG_PLAT_VERSATILE_FPGA_IRQ) += fpga-irq.o 3obj-$(CONFIG_PLAT_VERSATILE_FPGA_IRQ) += fpga-irq.o
5obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o 4obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o
diff --git a/arch/arm/plat-versatile/localtimer.c b/arch/arm/plat-versatile/localtimer.c
deleted file mode 100644
index e15668793159..000000000000
--- a/arch/arm/plat-versatile/localtimer.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * linux/arch/arm/plat-versatile/localtimer.c
3 *
4 * Copyright (C) 2002 ARM Ltd.
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/init.h>
12#include <linux/smp.h>
13#include <linux/clockchips.h>
14#include <linux/of.h>
15#include <linux/of_address.h>
16
17#include <asm/smp_twd.h>
18#include <asm/localtimer.h>
19#include <mach/irqs.h>
20
21const static struct of_device_id twd_of_match[] __initconst = {
22 { .compatible = "arm,cortex-a9-twd-timer", },
23 { .compatible = "arm,cortex-a5-twd-timer", },
24 { .compatible = "arm,arm11mp-twd-timer", },
25 { },
26};
27
28/*
29 * Setup the local clock events for a CPU.
30 */
31int __cpuinit local_timer_setup(struct clock_event_device *evt)
32{
33#if defined(CONFIG_OF)
34 static int dt_node_probed;
35
36 /* Look for TWD node only once */
37 if (!dt_node_probed) {
38 struct device_node *node = of_find_matching_node(NULL,
39 twd_of_match);
40
41 if (node)
42 twd_base = of_iomap(node, 0);
43
44 dt_node_probed = 1;
45 }
46#endif
47 if (!twd_base)
48 return -ENXIO;
49
50 evt->irq = IRQ_LOCALTIMER;
51 twd_timer_setup(evt);
52 return 0;
53}