blob: ce57d90c4bbcf0ad1a485812989ca7b028d1b513 [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>
32#include <mach/r8a7779.h>
Magnus Damma662c082012-01-10 15:50:01 +090033#include <mach/common.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090034#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
Magnus Dammdf27a2d2012-03-06 17:37:01 +090036#include <asm/mach/time.h>
Magnus Damm3e353b872012-02-29 21:37:43 +090037#include <asm/mach/map.h>
Magnus Damm8bac13f2012-03-01 12:48:03 +090038#include <asm/hardware/cache-l2x0.h>
Magnus Damm3e353b872012-02-29 21:37:43 +090039
40static struct map_desc r8a7779_io_desc[] __initdata = {
41 /* 2M entity map for 0xf0000000 (MPCORE) */
42 {
43 .virtual = 0xf0000000,
44 .pfn = __phys_to_pfn(0xf0000000),
45 .length = SZ_2M,
46 .type = MT_DEVICE_NONSHARED
47 },
48 /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
49 {
50 .virtual = 0xfe000000,
51 .pfn = __phys_to_pfn(0xfe000000),
52 .length = SZ_16M,
53 .type = MT_DEVICE_NONSHARED
54 },
55};
56
57void __init r8a7779_map_io(void)
58{
59 iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc));
60}
Magnus Dammf411fad2011-12-14 01:36:12 +090061
62static struct plat_sci_port scif0_platform_data = {
63 .mapbase = 0xffe40000,
64 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
65 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
66 .scbrr_algo_id = SCBRR_ALGO_2,
67 .type = PORT_SCIF,
68 .irqs = { gic_spi(88), gic_spi(88),
69 gic_spi(88), gic_spi(88) },
70};
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,
86 .irqs = { gic_spi(89), gic_spi(89),
87 gic_spi(89), gic_spi(89) },
88};
89
90static struct platform_device scif1_device = {
91 .name = "sh-sci",
92 .id = 1,
93 .dev = {
94 .platform_data = &scif1_platform_data,
95 },
96};
97
98static struct plat_sci_port scif2_platform_data = {
99 .mapbase = 0xffe42000,
100 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
101 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
102 .scbrr_algo_id = SCBRR_ALGO_2,
103 .type = PORT_SCIF,
104 .irqs = { gic_spi(90), gic_spi(90),
105 gic_spi(90), gic_spi(90) },
106};
107
108static struct platform_device scif2_device = {
109 .name = "sh-sci",
110 .id = 2,
111 .dev = {
112 .platform_data = &scif2_platform_data,
113 },
114};
115
116static struct plat_sci_port scif3_platform_data = {
117 .mapbase = 0xffe43000,
118 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
119 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
120 .scbrr_algo_id = SCBRR_ALGO_2,
121 .type = PORT_SCIF,
122 .irqs = { gic_spi(91), gic_spi(91),
123 gic_spi(91), gic_spi(91) },
124};
125
126static struct platform_device scif3_device = {
127 .name = "sh-sci",
128 .id = 3,
129 .dev = {
130 .platform_data = &scif3_platform_data,
131 },
132};
133
134static struct plat_sci_port scif4_platform_data = {
135 .mapbase = 0xffe44000,
136 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
137 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
138 .scbrr_algo_id = SCBRR_ALGO_2,
139 .type = PORT_SCIF,
140 .irqs = { gic_spi(92), gic_spi(92),
141 gic_spi(92), gic_spi(92) },
142};
143
144static struct platform_device scif4_device = {
145 .name = "sh-sci",
146 .id = 4,
147 .dev = {
148 .platform_data = &scif4_platform_data,
149 },
150};
151
152static struct plat_sci_port scif5_platform_data = {
153 .mapbase = 0xffe45000,
154 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
155 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
156 .scbrr_algo_id = SCBRR_ALGO_2,
157 .type = PORT_SCIF,
158 .irqs = { gic_spi(93), gic_spi(93),
159 gic_spi(93), gic_spi(93) },
160};
161
162static struct platform_device scif5_device = {
163 .name = "sh-sci",
164 .id = 5,
165 .dev = {
166 .platform_data = &scif5_platform_data,
167 },
168};
169
170/* TMU */
171static struct sh_timer_config tmu00_platform_data = {
172 .name = "TMU00",
173 .channel_offset = 0x4,
174 .timer_bit = 0,
175 .clockevent_rating = 200,
176};
177
178static struct resource tmu00_resources[] = {
179 [0] = {
180 .name = "TMU00",
181 .start = 0xffd80008,
182 .end = 0xffd80013,
183 .flags = IORESOURCE_MEM,
184 },
185 [1] = {
186 .start = gic_spi(32),
187 .flags = IORESOURCE_IRQ,
188 },
189};
190
191static struct platform_device tmu00_device = {
192 .name = "sh_tmu",
193 .id = 0,
194 .dev = {
195 .platform_data = &tmu00_platform_data,
196 },
197 .resource = tmu00_resources,
198 .num_resources = ARRAY_SIZE(tmu00_resources),
199};
200
201static struct sh_timer_config tmu01_platform_data = {
202 .name = "TMU01",
203 .channel_offset = 0x10,
204 .timer_bit = 1,
205 .clocksource_rating = 200,
206};
207
208static struct resource tmu01_resources[] = {
209 [0] = {
210 .name = "TMU01",
211 .start = 0xffd80014,
212 .end = 0xffd8001f,
213 .flags = IORESOURCE_MEM,
214 },
215 [1] = {
216 .start = gic_spi(33),
217 .flags = IORESOURCE_IRQ,
218 },
219};
220
221static struct platform_device tmu01_device = {
222 .name = "sh_tmu",
223 .id = 1,
224 .dev = {
225 .platform_data = &tmu01_platform_data,
226 },
227 .resource = tmu01_resources,
228 .num_resources = ARRAY_SIZE(tmu01_resources),
229};
230
231static struct platform_device *r8a7779_early_devices[] __initdata = {
232 &scif0_device,
233 &scif1_device,
234 &scif2_device,
235 &scif3_device,
236 &scif4_device,
237 &scif5_device,
238 &tmu00_device,
239 &tmu01_device,
240};
241
242static struct platform_device *r8a7779_late_devices[] __initdata = {
243};
244
245void __init r8a7779_add_standard_devices(void)
246{
Magnus Damm8bac13f2012-03-01 12:48:03 +0900247#ifdef CONFIG_CACHE_L2X0
248 /* Early BRESP enable, Shared attribute override enable, 64K*16way */
249 l2x0_init(__io(0xf0100000), 0x40470000, 0x82000fff);
250#endif
Magnus Damma662c082012-01-10 15:50:01 +0900251 r8a7779_pm_init();
252
253 r8a7779_init_pm_domain(&r8a7779_sh4a);
254 r8a7779_init_pm_domain(&r8a7779_sgx);
255 r8a7779_init_pm_domain(&r8a7779_vdp1);
256 r8a7779_init_pm_domain(&r8a7779_impx3);
257
Magnus Dammf411fad2011-12-14 01:36:12 +0900258 platform_add_devices(r8a7779_early_devices,
259 ARRAY_SIZE(r8a7779_early_devices));
260 platform_add_devices(r8a7779_late_devices,
261 ARRAY_SIZE(r8a7779_late_devices));
262}
263
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900264static void __init r8a7779_earlytimer_init(void)
265{
266 r8a7779_clock_init();
267 shmobile_earlytimer_init();
268}
269
Magnus Dammf411fad2011-12-14 01:36:12 +0900270void __init r8a7779_add_early_devices(void)
271{
272 early_platform_add_devices(r8a7779_early_devices,
273 ARRAY_SIZE(r8a7779_early_devices));
Magnus Damm3e353b872012-02-29 21:37:43 +0900274
275 /* Early serial console setup is not included here due to
276 * memory map collisions. The SCIF serial ports in r8a7779
277 * are difficult to entity map 1:1 due to collision with the
278 * virtual memory range used by the coherent DMA code on ARM.
279 *
280 * Anyone wanting to debug early can remove UPF_IOREMAP from
281 * the sh-sci serial console platform data, adjust mapbase
282 * to a static M:N virt:phys mapping that needs to be added to
283 * the mappings passed with iotable_init() above.
284 *
285 * Then add a call to shmobile_setup_console() from this function.
286 *
287 * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
288 * command line in case of the marzen board.
289 */
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900290
291 /* override timer setup with soc-specific code */
292 shmobile_timer.init = r8a7779_earlytimer_init;
Magnus Dammf411fad2011-12-14 01:36:12 +0900293}