blob: 7e87ab3eb8d361842ff599b852886a565c145624 [file] [log] [blame]
Magnus Dammf411fad2011-12-14 01:36:12 +09001/*
2 * r8a7779 processor support
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Magnus Damm
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 as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
25#include <linux/delay.h>
26#include <linux/input.h>
27#include <linux/io.h>
28#include <linux/serial_sci.h>
29#include <linux/sh_intc.h>
30#include <linux/sh_timer.h>
31#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060032#include <mach/irqs.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090033#include <mach/r8a7779.h>
Magnus Damma662c082012-01-10 15:50:01 +090034#include <mach/common.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090035#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
Magnus Dammdf27a2d2012-03-06 17:37:01 +090037#include <asm/mach/time.h>
Magnus Damm3e353b872012-02-29 21:37:43 +090038#include <asm/mach/map.h>
Magnus Damm8bac13f2012-03-01 12:48:03 +090039#include <asm/hardware/cache-l2x0.h>
Magnus Damm3e353b872012-02-29 21:37:43 +090040
41static struct map_desc r8a7779_io_desc[] __initdata = {
42 /* 2M entity map for 0xf0000000 (MPCORE) */
43 {
44 .virtual = 0xf0000000,
45 .pfn = __phys_to_pfn(0xf0000000),
46 .length = SZ_2M,
47 .type = MT_DEVICE_NONSHARED
48 },
49 /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
50 {
51 .virtual = 0xfe000000,
52 .pfn = __phys_to_pfn(0xfe000000),
53 .length = SZ_16M,
54 .type = MT_DEVICE_NONSHARED
55 },
56};
57
58void __init r8a7779_map_io(void)
59{
60 iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc));
61}
Magnus Dammf411fad2011-12-14 01:36:12 +090062
63static struct plat_sci_port scif0_platform_data = {
64 .mapbase = 0xffe40000,
65 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
66 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
67 .scbrr_algo_id = SCBRR_ALGO_2,
68 .type = PORT_SCIF,
Kuninori Morimotoff8de982013-01-18 01:40:42 -080069 .irqs = SCIx_IRQ_MUXED(gic_spi(88)),
Magnus Dammf411fad2011-12-14 01:36:12 +090070};
71
72static struct platform_device scif0_device = {
73 .name = "sh-sci",
74 .id = 0,
75 .dev = {
76 .platform_data = &scif0_platform_data,
77 },
78};
79
80static struct plat_sci_port scif1_platform_data = {
81 .mapbase = 0xffe41000,
82 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
83 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
84 .scbrr_algo_id = SCBRR_ALGO_2,
85 .type = PORT_SCIF,
Kuninori Morimotoff8de982013-01-18 01:40:42 -080086 .irqs = SCIx_IRQ_MUXED(gic_spi(89)),
Magnus Dammf411fad2011-12-14 01:36:12 +090087};
88
89static struct platform_device scif1_device = {
90 .name = "sh-sci",
91 .id = 1,
92 .dev = {
93 .platform_data = &scif1_platform_data,
94 },
95};
96
97static struct plat_sci_port scif2_platform_data = {
98 .mapbase = 0xffe42000,
99 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
100 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
101 .scbrr_algo_id = SCBRR_ALGO_2,
102 .type = PORT_SCIF,
Kuninori Morimotoff8de982013-01-18 01:40:42 -0800103 .irqs = SCIx_IRQ_MUXED(gic_spi(90)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900104};
105
106static struct platform_device scif2_device = {
107 .name = "sh-sci",
108 .id = 2,
109 .dev = {
110 .platform_data = &scif2_platform_data,
111 },
112};
113
114static struct plat_sci_port scif3_platform_data = {
115 .mapbase = 0xffe43000,
116 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
117 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
118 .scbrr_algo_id = SCBRR_ALGO_2,
119 .type = PORT_SCIF,
Kuninori Morimotoff8de982013-01-18 01:40:42 -0800120 .irqs = SCIx_IRQ_MUXED(gic_spi(91)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900121};
122
123static struct platform_device scif3_device = {
124 .name = "sh-sci",
125 .id = 3,
126 .dev = {
127 .platform_data = &scif3_platform_data,
128 },
129};
130
131static struct plat_sci_port scif4_platform_data = {
132 .mapbase = 0xffe44000,
133 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
134 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
135 .scbrr_algo_id = SCBRR_ALGO_2,
136 .type = PORT_SCIF,
Kuninori Morimotoff8de982013-01-18 01:40:42 -0800137 .irqs = SCIx_IRQ_MUXED(gic_spi(92)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900138};
139
140static struct platform_device scif4_device = {
141 .name = "sh-sci",
142 .id = 4,
143 .dev = {
144 .platform_data = &scif4_platform_data,
145 },
146};
147
148static struct plat_sci_port scif5_platform_data = {
149 .mapbase = 0xffe45000,
150 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
151 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
152 .scbrr_algo_id = SCBRR_ALGO_2,
153 .type = PORT_SCIF,
Kuninori Morimotoff8de982013-01-18 01:40:42 -0800154 .irqs = SCIx_IRQ_MUXED(gic_spi(93)),
Magnus Dammf411fad2011-12-14 01:36:12 +0900155};
156
157static struct platform_device scif5_device = {
158 .name = "sh-sci",
159 .id = 5,
160 .dev = {
161 .platform_data = &scif5_platform_data,
162 },
163};
164
165/* TMU */
166static struct sh_timer_config tmu00_platform_data = {
167 .name = "TMU00",
168 .channel_offset = 0x4,
169 .timer_bit = 0,
170 .clockevent_rating = 200,
171};
172
173static struct resource tmu00_resources[] = {
174 [0] = {
175 .name = "TMU00",
176 .start = 0xffd80008,
177 .end = 0xffd80013,
178 .flags = IORESOURCE_MEM,
179 },
180 [1] = {
181 .start = gic_spi(32),
182 .flags = IORESOURCE_IRQ,
183 },
184};
185
186static struct platform_device tmu00_device = {
187 .name = "sh_tmu",
188 .id = 0,
189 .dev = {
190 .platform_data = &tmu00_platform_data,
191 },
192 .resource = tmu00_resources,
193 .num_resources = ARRAY_SIZE(tmu00_resources),
194};
195
196static struct sh_timer_config tmu01_platform_data = {
197 .name = "TMU01",
198 .channel_offset = 0x10,
199 .timer_bit = 1,
200 .clocksource_rating = 200,
201};
202
203static struct resource tmu01_resources[] = {
204 [0] = {
205 .name = "TMU01",
206 .start = 0xffd80014,
207 .end = 0xffd8001f,
208 .flags = IORESOURCE_MEM,
209 },
210 [1] = {
211 .start = gic_spi(33),
212 .flags = IORESOURCE_IRQ,
213 },
214};
215
216static struct platform_device tmu01_device = {
217 .name = "sh_tmu",
218 .id = 1,
219 .dev = {
220 .platform_data = &tmu01_platform_data,
221 },
222 .resource = tmu01_resources,
223 .num_resources = ARRAY_SIZE(tmu01_resources),
224};
225
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700226/* I2C */
227static struct resource rcar_i2c0_res[] = {
228 {
229 .start = 0xffc70000,
230 .end = 0xffc70fff,
231 .flags = IORESOURCE_MEM,
232 }, {
233 .start = gic_spi(79),
234 .flags = IORESOURCE_IRQ,
235 },
236};
237
238static struct platform_device i2c0_device = {
239 .name = "i2c-rcar",
240 .id = 0,
241 .resource = rcar_i2c0_res,
242 .num_resources = ARRAY_SIZE(rcar_i2c0_res),
243};
244
245static struct resource rcar_i2c1_res[] = {
246 {
247 .start = 0xffc71000,
248 .end = 0xffc71fff,
249 .flags = IORESOURCE_MEM,
250 }, {
251 .start = gic_spi(82),
252 .flags = IORESOURCE_IRQ,
253 },
254};
255
256static struct platform_device i2c1_device = {
257 .name = "i2c-rcar",
258 .id = 1,
259 .resource = rcar_i2c1_res,
260 .num_resources = ARRAY_SIZE(rcar_i2c1_res),
261};
262
263static struct resource rcar_i2c2_res[] = {
264 {
265 .start = 0xffc72000,
266 .end = 0xffc72fff,
267 .flags = IORESOURCE_MEM,
268 }, {
269 .start = gic_spi(80),
270 .flags = IORESOURCE_IRQ,
271 },
272};
273
274static struct platform_device i2c2_device = {
275 .name = "i2c-rcar",
276 .id = 2,
277 .resource = rcar_i2c2_res,
278 .num_resources = ARRAY_SIZE(rcar_i2c2_res),
279};
280
281static struct resource rcar_i2c3_res[] = {
282 {
283 .start = 0xffc73000,
284 .end = 0xffc73fff,
285 .flags = IORESOURCE_MEM,
286 }, {
287 .start = gic_spi(81),
288 .flags = IORESOURCE_IRQ,
289 },
290};
291
292static struct platform_device i2c3_device = {
293 .name = "i2c-rcar",
294 .id = 3,
295 .resource = rcar_i2c3_res,
296 .num_resources = ARRAY_SIZE(rcar_i2c3_res),
297};
298
Magnus Dammf411fad2011-12-14 01:36:12 +0900299static struct platform_device *r8a7779_early_devices[] __initdata = {
300 &scif0_device,
301 &scif1_device,
302 &scif2_device,
303 &scif3_device,
304 &scif4_device,
305 &scif5_device,
306 &tmu00_device,
307 &tmu01_device,
Kuninori Morimotoccc2a272012-10-10 19:56:51 -0700308 &i2c0_device,
309 &i2c1_device,
310 &i2c2_device,
311 &i2c3_device,
Magnus Dammf411fad2011-12-14 01:36:12 +0900312};
313
314static struct platform_device *r8a7779_late_devices[] __initdata = {
315};
316
317void __init r8a7779_add_standard_devices(void)
318{
Magnus Damm8bac13f2012-03-01 12:48:03 +0900319#ifdef CONFIG_CACHE_L2X0
320 /* Early BRESP enable, Shared attribute override enable, 64K*16way */
Kuninori Morimotoed7d1322012-10-14 23:35:24 -0700321 l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff);
Magnus Damm8bac13f2012-03-01 12:48:03 +0900322#endif
Magnus Damma662c082012-01-10 15:50:01 +0900323 r8a7779_pm_init();
324
Rafael J. Wysocki45e5ca52012-08-07 01:14:14 +0200325 r8a7779_init_pm_domains();
Magnus Damma662c082012-01-10 15:50:01 +0900326
Magnus Dammf411fad2011-12-14 01:36:12 +0900327 platform_add_devices(r8a7779_early_devices,
328 ARRAY_SIZE(r8a7779_early_devices));
329 platform_add_devices(r8a7779_late_devices,
330 ARRAY_SIZE(r8a7779_late_devices));
331}
332
Magnus Dammb759bd12012-05-10 14:57:22 +0900333/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
334void __init __weak r8a7779_register_twd(void) { }
335
Stephen Warren6bb27d72012-11-08 12:40:59 -0700336void __init r8a7779_earlytimer_init(void)
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900337{
338 r8a7779_clock_init();
339 shmobile_earlytimer_init();
Magnus Dammb759bd12012-05-10 14:57:22 +0900340 r8a7779_register_twd();
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900341}
342
Magnus Dammf411fad2011-12-14 01:36:12 +0900343void __init r8a7779_add_early_devices(void)
344{
345 early_platform_add_devices(r8a7779_early_devices,
346 ARRAY_SIZE(r8a7779_early_devices));
Magnus Damm3e353b872012-02-29 21:37:43 +0900347
348 /* Early serial console setup is not included here due to
349 * memory map collisions. The SCIF serial ports in r8a7779
350 * are difficult to entity map 1:1 due to collision with the
351 * virtual memory range used by the coherent DMA code on ARM.
352 *
353 * Anyone wanting to debug early can remove UPF_IOREMAP from
354 * the sh-sci serial console platform data, adjust mapbase
355 * to a static M:N virt:phys mapping that needs to be added to
356 * the mappings passed with iotable_init() above.
357 *
358 * Then add a call to shmobile_setup_console() from this function.
359 *
360 * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
361 * command line in case of the marzen board.
362 */
Magnus Dammf411fad2011-12-14 01:36:12 +0900363}