1 /*
2  * sh73a0 processor support
3  *
4  * Copyright (C) 2010  Takashi Yoshii
5  * Copyright (C) 2010  Magnus Damm
6  * Copyright (C) 2008  Yoshihiro Shimoda
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 as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/interrupt.h>
24 #include <linux/irq.h>
25 #include <linux/platform_device.h>
26 #include <linux/delay.h>
27 #include <linux/input.h>
28 #include <linux/io.h>
29 #include <linux/serial_sci.h>
30 #include <linux/sh_intc.h>
31 #include <linux/sh_timer.h>
32 #include <mach/hardware.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 
36 static struct plat_sci_port scif0_platform_data = {
37 	.mapbase	= 0xe6c40000,
38 	.flags		= UPF_BOOT_AUTOCONF,
39 	.type		= PORT_SCIFA,
40 	.irqs		= { gic_spi(72), gic_spi(72),
41 			    gic_spi(72), gic_spi(72) },
42 };
43 
44 static struct platform_device scif0_device = {
45 	.name		= "sh-sci",
46 	.id		= 0,
47 	.dev		= {
48 		.platform_data	= &scif0_platform_data,
49 	},
50 };
51 
52 static struct plat_sci_port scif1_platform_data = {
53 	.mapbase	= 0xe6c50000,
54 	.flags		= UPF_BOOT_AUTOCONF,
55 	.type		= PORT_SCIFA,
56 	.irqs		= { gic_spi(73), gic_spi(73),
57 			    gic_spi(73), gic_spi(73) },
58 };
59 
60 static struct platform_device scif1_device = {
61 	.name		= "sh-sci",
62 	.id		= 1,
63 	.dev		= {
64 		.platform_data	= &scif1_platform_data,
65 	},
66 };
67 
68 static struct plat_sci_port scif2_platform_data = {
69 	.mapbase	= 0xe6c60000,
70 	.flags		= UPF_BOOT_AUTOCONF,
71 	.type		= PORT_SCIFA,
72 	.irqs		= { gic_spi(74), gic_spi(74),
73 			    gic_spi(74), gic_spi(74) },
74 };
75 
76 static struct platform_device scif2_device = {
77 	.name		= "sh-sci",
78 	.id		= 2,
79 	.dev		= {
80 		.platform_data	= &scif2_platform_data,
81 	},
82 };
83 
84 static struct plat_sci_port scif3_platform_data = {
85 	.mapbase	= 0xe6c70000,
86 	.flags		= UPF_BOOT_AUTOCONF,
87 	.type		= PORT_SCIFA,
88 	.irqs		= { gic_spi(75), gic_spi(75),
89 			    gic_spi(75), gic_spi(75) },
90 };
91 
92 static struct platform_device scif3_device = {
93 	.name		= "sh-sci",
94 	.id		= 3,
95 	.dev		= {
96 		.platform_data	= &scif3_platform_data,
97 	},
98 };
99 
100 static struct plat_sci_port scif4_platform_data = {
101 	.mapbase	= 0xe6c80000,
102 	.flags		= UPF_BOOT_AUTOCONF,
103 	.type		= PORT_SCIFA,
104 	.irqs		= { gic_spi(78), gic_spi(78),
105 			    gic_spi(78), gic_spi(78) },
106 };
107 
108 static struct platform_device scif4_device = {
109 	.name		= "sh-sci",
110 	.id		= 4,
111 	.dev		= {
112 		.platform_data	= &scif4_platform_data,
113 	},
114 };
115 
116 static struct plat_sci_port scif5_platform_data = {
117 	.mapbase	= 0xe6cb0000,
118 	.flags		= UPF_BOOT_AUTOCONF,
119 	.type		= PORT_SCIFA,
120 	.irqs		= { gic_spi(79), gic_spi(79),
121 			    gic_spi(79), gic_spi(79) },
122 };
123 
124 static struct platform_device scif5_device = {
125 	.name		= "sh-sci",
126 	.id		= 5,
127 	.dev		= {
128 		.platform_data	= &scif5_platform_data,
129 	},
130 };
131 
132 static struct plat_sci_port scif6_platform_data = {
133 	.mapbase	= 0xe6cc0000,
134 	.flags		= UPF_BOOT_AUTOCONF,
135 	.type		= PORT_SCIFA,
136 	.irqs		= { gic_spi(156), gic_spi(156),
137 			    gic_spi(156), gic_spi(156) },
138 };
139 
140 static struct platform_device scif6_device = {
141 	.name		= "sh-sci",
142 	.id		= 6,
143 	.dev		= {
144 		.platform_data	= &scif6_platform_data,
145 	},
146 };
147 
148 static struct plat_sci_port scif7_platform_data = {
149 	.mapbase	= 0xe6cd0000,
150 	.flags		= UPF_BOOT_AUTOCONF,
151 	.type		= PORT_SCIFA,
152 	.irqs		= { gic_spi(143), gic_spi(143),
153 			    gic_spi(143), gic_spi(143) },
154 };
155 
156 static struct platform_device scif7_device = {
157 	.name		= "sh-sci",
158 	.id		= 7,
159 	.dev		= {
160 		.platform_data	= &scif7_platform_data,
161 	},
162 };
163 
164 static struct plat_sci_port scif8_platform_data = {
165 	.mapbase	= 0xe6c30000,
166 	.flags		= UPF_BOOT_AUTOCONF,
167 	.type		= PORT_SCIFB,
168 	.irqs		= { gic_spi(80), gic_spi(80),
169 			    gic_spi(80), gic_spi(80) },
170 };
171 
172 static struct platform_device scif8_device = {
173 	.name		= "sh-sci",
174 	.id		= 8,
175 	.dev		= {
176 		.platform_data	= &scif8_platform_data,
177 	},
178 };
179 
180 static struct sh_timer_config cmt10_platform_data = {
181 	.name = "CMT10",
182 	.channel_offset = 0x10,
183 	.timer_bit = 0,
184 	.clockevent_rating = 125,
185 	.clocksource_rating = 125,
186 };
187 
188 static struct resource cmt10_resources[] = {
189 	[0] = {
190 		.name	= "CMT10",
191 		.start	= 0xe6138010,
192 		.end	= 0xe613801b,
193 		.flags	= IORESOURCE_MEM,
194 	},
195 	[1] = {
196 		.start	= gic_spi(65),
197 		.flags	= IORESOURCE_IRQ,
198 	},
199 };
200 
201 static struct platform_device cmt10_device = {
202 	.name		= "sh_cmt",
203 	.id		= 10,
204 	.dev = {
205 		.platform_data	= &cmt10_platform_data,
206 	},
207 	.resource	= cmt10_resources,
208 	.num_resources	= ARRAY_SIZE(cmt10_resources),
209 };
210 
211 static struct resource i2c0_resources[] = {
212 	[0] = {
213 		.name	= "IIC0",
214 		.start	= 0xe6820000,
215 		.end	= 0xe6820425 - 1,
216 		.flags	= IORESOURCE_MEM,
217 	},
218 	[1] = {
219 		.start	= gic_spi(167),
220 		.end	= gic_spi(170),
221 		.flags	= IORESOURCE_IRQ,
222 	},
223 };
224 
225 static struct resource i2c1_resources[] = {
226 	[0] = {
227 		.name	= "IIC1",
228 		.start	= 0xe6822000,
229 		.end	= 0xe6822425 - 1,
230 		.flags	= IORESOURCE_MEM,
231 	},
232 	[1] = {
233 		.start	= gic_spi(51),
234 		.end	= gic_spi(54),
235 		.flags	= IORESOURCE_IRQ,
236 	},
237 };
238 
239 static struct resource i2c2_resources[] = {
240 	[0] = {
241 		.name	= "IIC2",
242 		.start	= 0xe6824000,
243 		.end	= 0xe6824425 - 1,
244 		.flags	= IORESOURCE_MEM,
245 	},
246 	[1] = {
247 		.start	= gic_spi(171),
248 		.end	= gic_spi(174),
249 		.flags	= IORESOURCE_IRQ,
250 	},
251 };
252 
253 static struct resource i2c3_resources[] = {
254 	[0] = {
255 		.name	= "IIC3",
256 		.start	= 0xe6826000,
257 		.end	= 0xe6826425 - 1,
258 		.flags	= IORESOURCE_MEM,
259 	},
260 	[1] = {
261 		.start	= gic_spi(183),
262 		.end	= gic_spi(186),
263 		.flags	= IORESOURCE_IRQ,
264 	},
265 };
266 
267 static struct resource i2c4_resources[] = {
268 	[0] = {
269 		.name	= "IIC4",
270 		.start	= 0xe6828000,
271 		.end	= 0xe6828425 - 1,
272 		.flags	= IORESOURCE_MEM,
273 	},
274 	[1] = {
275 		.start	= gic_spi(187),
276 		.end	= gic_spi(190),
277 		.flags	= IORESOURCE_IRQ,
278 	},
279 };
280 
281 static struct platform_device i2c0_device = {
282 	.name		= "i2c-sh_mobile",
283 	.id		= 0,
284 	.resource	= i2c0_resources,
285 	.num_resources	= ARRAY_SIZE(i2c0_resources),
286 };
287 
288 static struct platform_device i2c1_device = {
289 	.name		= "i2c-sh_mobile",
290 	.id		= 1,
291 	.resource	= i2c1_resources,
292 	.num_resources	= ARRAY_SIZE(i2c1_resources),
293 };
294 
295 static struct platform_device i2c2_device = {
296 	.name		= "i2c-sh_mobile",
297 	.id		= 2,
298 	.resource	= i2c2_resources,
299 	.num_resources	= ARRAY_SIZE(i2c2_resources),
300 };
301 
302 static struct platform_device i2c3_device = {
303 	.name		= "i2c-sh_mobile",
304 	.id		= 3,
305 	.resource	= i2c3_resources,
306 	.num_resources	= ARRAY_SIZE(i2c3_resources),
307 };
308 
309 static struct platform_device i2c4_device = {
310 	.name		= "i2c-sh_mobile",
311 	.id		= 4,
312 	.resource	= i2c4_resources,
313 	.num_resources	= ARRAY_SIZE(i2c4_resources),
314 };
315 
316 static struct platform_device *sh73a0_early_devices[] __initdata = {
317 	&scif0_device,
318 	&scif1_device,
319 	&scif2_device,
320 	&scif3_device,
321 	&scif4_device,
322 	&scif5_device,
323 	&scif6_device,
324 	&scif7_device,
325 	&scif8_device,
326 	&cmt10_device,
327 };
328 
329 static struct platform_device *sh73a0_late_devices[] __initdata = {
330 	&i2c0_device,
331 	&i2c1_device,
332 	&i2c2_device,
333 	&i2c3_device,
334 	&i2c4_device,
335 };
336 
337 void __init sh73a0_add_standard_devices(void)
338 {
339 	platform_add_devices(sh73a0_early_devices,
340 			    ARRAY_SIZE(sh73a0_early_devices));
341 	platform_add_devices(sh73a0_late_devices,
342 			    ARRAY_SIZE(sh73a0_late_devices));
343 }
344 
345 void __init sh73a0_add_early_devices(void)
346 {
347 	early_platform_add_devices(sh73a0_early_devices,
348 				   ARRAY_SIZE(sh73a0_early_devices));
349 }
350