ARM: shmobile: remove NR_IRQS
[linux-flexiantxendom0-3.2.10.git] / arch / arm / mach-shmobile / board-kota2.c
1 /*
2  * kota2 board support
3  *
4  * Copyright (C) 2011  Renesas Solutions Corp.
5  * Copyright (C) 2011  Magnus Damm
6  * Copyright (C) 2010  Takashi Yoshii <yoshii.takashi.zj@renesas.com>
7  * Copyright (C) 2009  Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
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 as published by
11  * the Free Software Foundation; version 2 of the License.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #include <linux/kernel.h>
24 #include <linux/init.h>
25 #include <linux/interrupt.h>
26 #include <linux/irq.h>
27 #include <linux/platform_device.h>
28 #include <linux/delay.h>
29 #include <linux/io.h>
30 #include <linux/smsc911x.h>
31 #include <linux/gpio.h>
32 #include <linux/input.h>
33 #include <linux/input/sh_keysc.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/leds.h>
36 #include <linux/platform_data/leds-renesas-tpu.h>
37 #include <linux/mmc/host.h>
38 #include <linux/mmc/sh_mmcif.h>
39 #include <linux/mfd/tmio.h>
40 #include <linux/mmc/sh_mobile_sdhi.h>
41 #include <mach/hardware.h>
42 #include <mach/irqs.h>
43 #include <mach/sh73a0.h>
44 #include <mach/common.h>
45 #include <asm/mach-types.h>
46 #include <asm/mach/arch.h>
47 #include <asm/mach/map.h>
48 #include <asm/mach/time.h>
49 #include <asm/hardware/gic.h>
50 #include <asm/hardware/cache-l2x0.h>
51 #include <asm/traps.h>
52
53 /* SMSC 9220 */
54 static struct resource smsc9220_resources[] = {
55         [0] = {
56                 .start          = 0x14000000, /* CS5A */
57                 .end            = 0x140000ff, /* A1->A7 */
58                 .flags          = IORESOURCE_MEM,
59         },
60         [1] = {
61                 .start          = SH73A0_PINT0_IRQ(2), /* PINTA2 */
62                 .flags          = IORESOURCE_IRQ,
63         },
64 };
65
66 static struct smsc911x_platform_config smsc9220_platdata = {
67         .flags          = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
68         .phy_interface  = PHY_INTERFACE_MODE_MII,
69         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
70         .irq_type       = SMSC911X_IRQ_TYPE_PUSH_PULL,
71 };
72
73 static struct platform_device eth_device = {
74         .name           = "smsc911x",
75         .id             = 0,
76         .dev  = {
77                 .platform_data = &smsc9220_platdata,
78         },
79         .resource       = smsc9220_resources,
80         .num_resources  = ARRAY_SIZE(smsc9220_resources),
81 };
82
83 /* KEYSC */
84 static struct sh_keysc_info keysc_platdata = {
85         .mode           = SH_KEYSC_MODE_6,
86         .scan_timing    = 3,
87         .delay          = 100,
88         .keycodes       = {
89                 KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
90                 0, 0, 0, 0, 0,
91                 KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
92                 0, KEY_DOWN, 0, 0, 0,
93                 KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
94                 KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
95                 KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
96                 0, KEY_UP, 0, 0, 0,
97                 0, 0, 0, 0, 0, 0, 0, 0,
98                 0, 0, 0, 0, 0, 0, 0, 0,
99                 0, 0, 0, 0, 0, 0, 0, 0,
100                 0, 0, 0, 0, 0, 0, 0, 0,
101         },
102 };
103
104 static struct resource keysc_resources[] = {
105         [0] = {
106                 .name   = "KEYSC",
107                 .start  = 0xe61b0000,
108                 .end    = 0xe61b0098 - 1,
109                 .flags  = IORESOURCE_MEM,
110         },
111         [1] = {
112                 .start  = gic_spi(71),
113                 .flags  = IORESOURCE_IRQ,
114         },
115 };
116
117 static struct platform_device keysc_device = {
118         .name           = "sh_keysc",
119         .id             = 0,
120         .num_resources  = ARRAY_SIZE(keysc_resources),
121         .resource       = keysc_resources,
122         .dev            = {
123                 .platform_data  = &keysc_platdata,
124         },
125 };
126
127 /* GPIO KEY */
128 #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
129
130 static struct gpio_keys_button gpio_buttons[] = {
131         GPIO_KEY(KEY_VOLUMEUP, GPIO_PORT56, "+"), /* S2: VOL+ [IRQ9] */
132         GPIO_KEY(KEY_VOLUMEDOWN, GPIO_PORT54, "-"), /* S3: VOL- [IRQ10] */
133         GPIO_KEY(KEY_MENU, GPIO_PORT27, "Menu"), /* S4: MENU [IRQ30] */
134         GPIO_KEY(KEY_HOMEPAGE, GPIO_PORT26, "Home"), /* S5: HOME [IRQ31] */
135         GPIO_KEY(KEY_BACK, GPIO_PORT11, "Back"), /* S6: BACK [IRQ0] */
136         GPIO_KEY(KEY_PHONE, GPIO_PORT238, "Tel"), /* S7: TEL [IRQ11] */
137         GPIO_KEY(KEY_POWER, GPIO_PORT239, "C1"), /* S8: CAM [IRQ13] */
138         GPIO_KEY(KEY_MAIL, GPIO_PORT224, "Mail"), /* S9: MAIL [IRQ3] */
139         /* Omitted button "C3?": GPIO_PORT223 - S10: CUST [IRQ8] */
140         GPIO_KEY(KEY_CAMERA, GPIO_PORT164, "C2"), /* S11: CAM_HALF [IRQ25] */
141         /* Omitted button "?": GPIO_PORT152 - S12: CAM_FULL [No IRQ] */
142 };
143
144 static struct gpio_keys_platform_data gpio_key_info = {
145         .buttons        = gpio_buttons,
146         .nbuttons       = ARRAY_SIZE(gpio_buttons),
147         .poll_interval  = 250, /* polled for now */
148 };
149
150 static struct platform_device gpio_keys_device = {
151         .name   = "gpio-keys-polled", /* polled for now */
152         .id     = -1,
153         .dev    = {
154                 .platform_data  = &gpio_key_info,
155         },
156 };
157
158 /* GPIO LED */
159 #define GPIO_LED(n, g) { .name = n, .gpio = g }
160
161 static struct gpio_led gpio_leds[] = {
162         GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */
163         GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */
164         GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */
165 };
166
167 static struct gpio_led_platform_data gpio_leds_info = {
168         .leds           = gpio_leds,
169         .num_leds       = ARRAY_SIZE(gpio_leds),
170 };
171
172 static struct platform_device gpio_leds_device = {
173         .name   = "leds-gpio",
174         .id     = -1,
175         .dev    = {
176                 .platform_data  = &gpio_leds_info,
177         },
178 };
179
180 /* TPU LED */
181 static struct led_renesas_tpu_config led_renesas_tpu12_pdata = {
182         .name           = "V2513",
183         .pin_gpio_fn    = GPIO_FN_TPU1TO2,
184         .pin_gpio       = GPIO_PORT153,
185         .channel_offset = 0x90,
186         .timer_bit = 2,
187         .max_brightness = 1000,
188 };
189
190 static struct resource tpu12_resources[] = {
191         [0] = {
192                 .name   = "TPU12",
193                 .start  = 0xe6610090,
194                 .end    = 0xe66100b5,
195                 .flags  = IORESOURCE_MEM,
196         },
197 };
198
199 static struct platform_device leds_tpu12_device = {
200         .name = "leds-renesas-tpu",
201         .id = 12,
202         .dev = {
203                 .platform_data  = &led_renesas_tpu12_pdata,
204         },
205         .num_resources  = ARRAY_SIZE(tpu12_resources),
206         .resource       = tpu12_resources,
207 };
208
209 static struct led_renesas_tpu_config led_renesas_tpu41_pdata = {
210         .name           = "V2514",
211         .pin_gpio_fn    = GPIO_FN_TPU4TO1,
212         .pin_gpio       = GPIO_PORT199,
213         .channel_offset = 0x50,
214         .timer_bit = 1,
215         .max_brightness = 1000,
216 };
217
218 static struct resource tpu41_resources[] = {
219         [0] = {
220                 .name   = "TPU41",
221                 .start  = 0xe6640050,
222                 .end    = 0xe6640075,
223                 .flags  = IORESOURCE_MEM,
224         },
225 };
226
227 static struct platform_device leds_tpu41_device = {
228         .name = "leds-renesas-tpu",
229         .id = 41,
230         .dev = {
231                 .platform_data  = &led_renesas_tpu41_pdata,
232         },
233         .num_resources  = ARRAY_SIZE(tpu41_resources),
234         .resource       = tpu41_resources,
235 };
236
237 static struct led_renesas_tpu_config led_renesas_tpu21_pdata = {
238         .name           = "V2515",
239         .pin_gpio_fn    = GPIO_FN_TPU2TO1,
240         .pin_gpio       = GPIO_PORT197,
241         .channel_offset = 0x50,
242         .timer_bit = 1,
243         .max_brightness = 1000,
244 };
245
246 static struct resource tpu21_resources[] = {
247         [0] = {
248                 .name   = "TPU21",
249                 .start  = 0xe6620050,
250                 .end    = 0xe6620075,
251                 .flags  = IORESOURCE_MEM,
252         },
253 };
254
255 static struct platform_device leds_tpu21_device = {
256         .name = "leds-renesas-tpu",
257         .id = 21,
258         .dev = {
259                 .platform_data  = &led_renesas_tpu21_pdata,
260         },
261         .num_resources  = ARRAY_SIZE(tpu21_resources),
262         .resource       = tpu21_resources,
263 };
264
265 static struct led_renesas_tpu_config led_renesas_tpu30_pdata = {
266         .name           = "KEYLED",
267         .pin_gpio_fn    = GPIO_FN_TPU3TO0,
268         .pin_gpio       = GPIO_PORT163,
269         .channel_offset = 0x10,
270         .timer_bit = 0,
271         .max_brightness = 1000,
272 };
273
274 static struct resource tpu30_resources[] = {
275         [0] = {
276                 .name   = "TPU30",
277                 .start  = 0xe6630010,
278                 .end    = 0xe6630035,
279                 .flags  = IORESOURCE_MEM,
280         },
281 };
282
283 static struct platform_device leds_tpu30_device = {
284         .name = "leds-renesas-tpu",
285         .id = 30,
286         .dev = {
287                 .platform_data  = &led_renesas_tpu30_pdata,
288         },
289         .num_resources  = ARRAY_SIZE(tpu30_resources),
290         .resource       = tpu30_resources,
291 };
292
293 /* MMCIF */
294 static struct resource mmcif_resources[] = {
295         [0] = {
296                 .name   = "MMCIF",
297                 .start  = 0xe6bd0000,
298                 .end    = 0xe6bd00ff,
299                 .flags  = IORESOURCE_MEM,
300         },
301         [1] = {
302                 .start  = gic_spi(140),
303                 .flags  = IORESOURCE_IRQ,
304         },
305         [2] = {
306                 .start  = gic_spi(141),
307                 .flags  = IORESOURCE_IRQ,
308         },
309 };
310
311 static struct sh_mmcif_plat_data mmcif_info = {
312         .ocr            = MMC_VDD_165_195,
313         .caps           = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
314 };
315
316 static struct platform_device mmcif_device = {
317         .name           = "sh_mmcif",
318         .id             = 0,
319         .dev            = {
320                 .platform_data          = &mmcif_info,
321         },
322         .num_resources  = ARRAY_SIZE(mmcif_resources),
323         .resource       = mmcif_resources,
324 };
325
326 /* SDHI0 */
327 static struct sh_mobile_sdhi_info sdhi0_info = {
328         .tmio_caps      = MMC_CAP_SD_HIGHSPEED,
329         .tmio_flags     = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
330 };
331
332 static struct resource sdhi0_resources[] = {
333         [0] = {
334                 .name   = "SDHI0",
335                 .start  = 0xee100000,
336                 .end    = 0xee1000ff,
337                 .flags  = IORESOURCE_MEM,
338         },
339         [1] = {
340                 .start  = gic_spi(83),
341                 .flags  = IORESOURCE_IRQ,
342         },
343         [2] = {
344                 .start  = gic_spi(84),
345                 .flags  = IORESOURCE_IRQ,
346         },
347         [3] = {
348                 .start  = gic_spi(85),
349                 .flags  = IORESOURCE_IRQ,
350         },
351 };
352
353 static struct platform_device sdhi0_device = {
354         .name           = "sh_mobile_sdhi",
355         .id             = 0,
356         .num_resources  = ARRAY_SIZE(sdhi0_resources),
357         .resource       = sdhi0_resources,
358         .dev    = {
359                 .platform_data  = &sdhi0_info,
360         },
361 };
362
363 /* SDHI1 */
364 static struct sh_mobile_sdhi_info sdhi1_info = {
365         .tmio_caps      = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
366         .tmio_flags     = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
367 };
368
369 static struct resource sdhi1_resources[] = {
370         [0] = {
371                 .name   = "SDHI1",
372                 .start  = 0xee120000,
373                 .end    = 0xee1200ff,
374                 .flags  = IORESOURCE_MEM,
375         },
376         [1] = {
377                 .start  = gic_spi(87),
378                 .flags  = IORESOURCE_IRQ,
379         },
380         [2] = {
381                 .start  = gic_spi(88),
382                 .flags  = IORESOURCE_IRQ,
383         },
384         [3] = {
385                 .start  = gic_spi(89),
386                 .flags  = IORESOURCE_IRQ,
387         },
388 };
389
390 static struct platform_device sdhi1_device = {
391         .name           = "sh_mobile_sdhi",
392         .id             = 1,
393         .num_resources  = ARRAY_SIZE(sdhi1_resources),
394         .resource       = sdhi1_resources,
395         .dev    = {
396                 .platform_data  = &sdhi1_info,
397         },
398 };
399
400 static struct platform_device *kota2_devices[] __initdata = {
401         &eth_device,
402         &keysc_device,
403         &gpio_keys_device,
404         &gpio_leds_device,
405         &leds_tpu12_device,
406         &leds_tpu41_device,
407         &leds_tpu21_device,
408         &leds_tpu30_device,
409         &mmcif_device,
410         &sdhi0_device,
411         &sdhi1_device,
412 };
413
414 static struct map_desc kota2_io_desc[] __initdata = {
415         /* create a 1:1 entity map for 0xe6xxxxxx
416          * used by CPGA, INTC and PFC.
417          */
418         {
419                 .virtual        = 0xe6000000,
420                 .pfn            = __phys_to_pfn(0xe6000000),
421                 .length         = 256 << 20,
422                 .type           = MT_DEVICE_NONSHARED
423         },
424 };
425
426 static void __init kota2_map_io(void)
427 {
428         iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
429
430         /* setup early devices and console here as well */
431         sh73a0_add_early_devices();
432         shmobile_setup_console();
433 }
434
435 static void __init kota2_init(void)
436 {
437         sh73a0_pinmux_init();
438
439         /* SCIFA2 (UART2) */
440         gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
441         gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
442         gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
443         gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
444
445         /* SCIFA4 (UART1) */
446         gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
447         gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
448         gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
449         gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
450
451         /* SMSC911X */
452         gpio_request(GPIO_FN_D0_NAF0, NULL);
453         gpio_request(GPIO_FN_D1_NAF1, NULL);
454         gpio_request(GPIO_FN_D2_NAF2, NULL);
455         gpio_request(GPIO_FN_D3_NAF3, NULL);
456         gpio_request(GPIO_FN_D4_NAF4, NULL);
457         gpio_request(GPIO_FN_D5_NAF5, NULL);
458         gpio_request(GPIO_FN_D6_NAF6, NULL);
459         gpio_request(GPIO_FN_D7_NAF7, NULL);
460         gpio_request(GPIO_FN_D8_NAF8, NULL);
461         gpio_request(GPIO_FN_D9_NAF9, NULL);
462         gpio_request(GPIO_FN_D10_NAF10, NULL);
463         gpio_request(GPIO_FN_D11_NAF11, NULL);
464         gpio_request(GPIO_FN_D12_NAF12, NULL);
465         gpio_request(GPIO_FN_D13_NAF13, NULL);
466         gpio_request(GPIO_FN_D14_NAF14, NULL);
467         gpio_request(GPIO_FN_D15_NAF15, NULL);
468         gpio_request(GPIO_FN_CS5A_, NULL);
469         gpio_request(GPIO_FN_WE0__FWE, NULL);
470         gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
471         gpio_direction_input(GPIO_PORT144);
472         gpio_request(GPIO_PORT145, NULL); /* RESET */
473         gpio_direction_output(GPIO_PORT145, 1);
474
475         /* KEYSC */
476         gpio_request(GPIO_FN_KEYIN0_PU, NULL);
477         gpio_request(GPIO_FN_KEYIN1_PU, NULL);
478         gpio_request(GPIO_FN_KEYIN2_PU, NULL);
479         gpio_request(GPIO_FN_KEYIN3_PU, NULL);
480         gpio_request(GPIO_FN_KEYIN4_PU, NULL);
481         gpio_request(GPIO_FN_KEYIN5_PU, NULL);
482         gpio_request(GPIO_FN_KEYIN6_PU, NULL);
483         gpio_request(GPIO_FN_KEYIN7_PU, NULL);
484         gpio_request(GPIO_FN_KEYOUT0, NULL);
485         gpio_request(GPIO_FN_KEYOUT1, NULL);
486         gpio_request(GPIO_FN_KEYOUT2, NULL);
487         gpio_request(GPIO_FN_KEYOUT3, NULL);
488         gpio_request(GPIO_FN_KEYOUT4, NULL);
489         gpio_request(GPIO_FN_KEYOUT5, NULL);
490         gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
491         gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
492         gpio_request(GPIO_FN_KEYOUT8, NULL);
493
494         /* MMCIF */
495         gpio_request(GPIO_FN_MMCCLK0, NULL);
496         gpio_request(GPIO_FN_MMCD0_0, NULL);
497         gpio_request(GPIO_FN_MMCD0_1, NULL);
498         gpio_request(GPIO_FN_MMCD0_2, NULL);
499         gpio_request(GPIO_FN_MMCD0_3, NULL);
500         gpio_request(GPIO_FN_MMCD0_4, NULL);
501         gpio_request(GPIO_FN_MMCD0_5, NULL);
502         gpio_request(GPIO_FN_MMCD0_6, NULL);
503         gpio_request(GPIO_FN_MMCD0_7, NULL);
504         gpio_request(GPIO_FN_MMCCMD0, NULL);
505         gpio_request(GPIO_PORT208, NULL); /* Reset */
506         gpio_direction_output(GPIO_PORT208, 1);
507
508         /* SDHI0 (microSD) */
509         gpio_request(GPIO_FN_SDHICD0_PU, NULL);
510         gpio_request(GPIO_FN_SDHICMD0_PU, NULL);
511         gpio_request(GPIO_FN_SDHICLK0, NULL);
512         gpio_request(GPIO_FN_SDHID0_3_PU, NULL);
513         gpio_request(GPIO_FN_SDHID0_2_PU, NULL);
514         gpio_request(GPIO_FN_SDHID0_1_PU, NULL);
515         gpio_request(GPIO_FN_SDHID0_0_PU, NULL);
516
517         /* SCIFB (BT) */
518         gpio_request(GPIO_FN_PORT159_SCIFB_SCK, NULL);
519         gpio_request(GPIO_FN_PORT160_SCIFB_TXD, NULL);
520         gpio_request(GPIO_FN_PORT161_SCIFB_CTS_, NULL);
521         gpio_request(GPIO_FN_PORT162_SCIFB_RXD, NULL);
522         gpio_request(GPIO_FN_PORT163_SCIFB_RTS_, NULL);
523
524         /* SDHI1 (BCM4330) */
525         gpio_request(GPIO_FN_SDHICLK1, NULL);
526         gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
527         gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
528         gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
529         gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
530         gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
531
532 #ifdef CONFIG_CACHE_L2X0
533         /* Early BRESP enable, Shared attribute override enable, 64K*8way */
534         l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
535 #endif
536         sh73a0_add_standard_devices();
537         platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
538 }
539
540 static void __init kota2_timer_init(void)
541 {
542         sh73a0_clock_init();
543         shmobile_timer.init();
544         return;
545 }
546
547 struct sys_timer kota2_timer = {
548         .init   = kota2_timer_init,
549 };
550
551 MACHINE_START(KOTA2, "kota2")
552         .map_io         = kota2_map_io,
553         .nr_irqs        = NR_IRQS_LEGACY,
554         .init_irq       = sh73a0_init_irq,
555         .handle_irq     = gic_handle_irq,
556         .init_machine   = kota2_init,
557         .timer          = &kota2_timer,
558 MACHINE_END