e1380df0131519129dc9c78970086bfff71b4128
[deliverable/linux.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/mmc/host.h>
37 #include <linux/mmc/sh_mmcif.h>
38 #include <mach/hardware.h>
39 #include <mach/sh73a0.h>
40 #include <mach/common.h>
41 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/time.h>
45 #include <asm/hardware/gic.h>
46 #include <asm/hardware/cache-l2x0.h>
47 #include <asm/traps.h>
48
49 static struct resource smsc9220_resources[] = {
50 [0] = {
51 .start = 0x14000000, /* CS5A */
52 .end = 0x140000ff, /* A1->A7 */
53 .flags = IORESOURCE_MEM,
54 },
55 [1] = {
56 .start = gic_spi(33), /* PINTA2 @ PORT144 */
57 .flags = IORESOURCE_IRQ,
58 },
59 };
60
61 static struct smsc911x_platform_config smsc9220_platdata = {
62 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
63 .phy_interface = PHY_INTERFACE_MODE_MII,
64 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
65 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
66 };
67
68 static struct platform_device eth_device = {
69 .name = "smsc911x",
70 .id = 0,
71 .dev = {
72 .platform_data = &smsc9220_platdata,
73 },
74 .resource = smsc9220_resources,
75 .num_resources = ARRAY_SIZE(smsc9220_resources),
76 };
77
78 static struct sh_keysc_info keysc_platdata = {
79 .mode = SH_KEYSC_MODE_6,
80 .scan_timing = 3,
81 .delay = 100,
82 .keycodes = {
83 KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
84 0, 0, 0, 0, 0,
85 KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
86 0, KEY_DOWN, 0, 0, 0,
87 KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
88 KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
89 KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
90 0, KEY_UP, 0, 0, 0,
91 0, 0, 0, 0, 0, 0, 0, 0,
92 0, 0, 0, 0, 0, 0, 0, 0,
93 0, 0, 0, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0,
95 },
96 };
97
98 static struct resource keysc_resources[] = {
99 [0] = {
100 .name = "KEYSC",
101 .start = 0xe61b0000,
102 .end = 0xe61b0098 - 1,
103 .flags = IORESOURCE_MEM,
104 },
105 [1] = {
106 .start = gic_spi(71),
107 .flags = IORESOURCE_IRQ,
108 },
109 };
110
111 static struct platform_device keysc_device = {
112 .name = "sh_keysc",
113 .id = 0,
114 .num_resources = ARRAY_SIZE(keysc_resources),
115 .resource = keysc_resources,
116 .dev = {
117 .platform_data = &keysc_platdata,
118 },
119 };
120
121 #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
122
123 static struct gpio_keys_button gpio_buttons[] = {
124 GPIO_KEY(KEY_VOLUMEUP, GPIO_PORT56, "+"), /* S2: VOL+ [IRQ9] */
125 GPIO_KEY(KEY_VOLUMEDOWN, GPIO_PORT54, "-"), /* S3: VOL- [IRQ10] */
126 GPIO_KEY(KEY_MENU, GPIO_PORT27, "Menu"), /* S4: MENU [IRQ30] */
127 GPIO_KEY(KEY_HOMEPAGE, GPIO_PORT26, "Home"), /* S5: HOME [IRQ31] */
128 GPIO_KEY(KEY_BACK, GPIO_PORT11, "Back"), /* S6: BACK [IRQ0] */
129 GPIO_KEY(KEY_PHONE, GPIO_PORT238, "Tel"), /* S7: TEL [IRQ11] */
130 GPIO_KEY(KEY_POWER, GPIO_PORT239, "C1"), /* S8: CAM [IRQ13] */
131 GPIO_KEY(KEY_MAIL, GPIO_PORT224, "Mail"), /* S9: MAIL [IRQ3] */
132 /* Omitted button "C3?": GPIO_PORT223 - S10: CUST [IRQ8] */
133 GPIO_KEY(KEY_CAMERA, GPIO_PORT164, "C2"), /* S11: CAM_HALF [IRQ25] */
134 /* Omitted button "?": GPIO_PORT152 - S12: CAM_FULL [No IRQ] */
135 };
136
137 static struct gpio_keys_platform_data gpio_key_info = {
138 .buttons = gpio_buttons,
139 .nbuttons = ARRAY_SIZE(gpio_buttons),
140 .poll_interval = 250, /* polled for now */
141 };
142
143 static struct platform_device gpio_keys_device = {
144 .name = "gpio-keys-polled", /* polled for now */
145 .id = -1,
146 .dev = {
147 .platform_data = &gpio_key_info,
148 },
149 };
150
151 #define GPIO_LED(n, g) { .name = n, .gpio = g }
152
153 static struct gpio_led gpio_leds[] = {
154 GPIO_LED("V2513", GPIO_PORT153), /* PORT153 [TPU1T02] -> V2513 */
155 GPIO_LED("V2514", GPIO_PORT199), /* PORT199 [TPU4TO1] -> V2514 */
156 GPIO_LED("V2515", GPIO_PORT197), /* PORT197 [TPU2TO1] -> V2515 */
157 GPIO_LED("KEYLED", GPIO_PORT163), /* PORT163 [TPU3TO0] -> KEYLED */
158 GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */
159 GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */
160 GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */
161 };
162
163 static struct gpio_led_platform_data gpio_leds_info = {
164 .leds = gpio_leds,
165 .num_leds = ARRAY_SIZE(gpio_leds),
166 };
167
168 static struct platform_device gpio_leds_device = {
169 .name = "leds-gpio",
170 .id = -1,
171 .dev = {
172 .platform_data = &gpio_leds_info,
173 },
174 };
175
176 static struct resource mmcif_resources[] = {
177 [0] = {
178 .name = "MMCIF",
179 .start = 0xe6bd0000,
180 .end = 0xe6bd00ff,
181 .flags = IORESOURCE_MEM,
182 },
183 [1] = {
184 .start = gic_spi(140),
185 .flags = IORESOURCE_IRQ,
186 },
187 [2] = {
188 .start = gic_spi(141),
189 .flags = IORESOURCE_IRQ,
190 },
191 };
192
193 static struct sh_mmcif_plat_data mmcif_info = {
194 .ocr = MMC_VDD_165_195,
195 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
196 };
197
198 static struct platform_device mmcif_device = {
199 .name = "sh_mmcif",
200 .id = 0,
201 .dev = {
202 .platform_data = &mmcif_info,
203 },
204 .num_resources = ARRAY_SIZE(mmcif_resources),
205 .resource = mmcif_resources,
206 };
207
208 static struct platform_device *kota2_devices[] __initdata = {
209 &eth_device,
210 &keysc_device,
211 &gpio_keys_device,
212 &gpio_leds_device,
213 &mmcif_device,
214 };
215
216 static struct map_desc kota2_io_desc[] __initdata = {
217 /* create a 1:1 entity map for 0xe6xxxxxx
218 * used by CPGA, INTC and PFC.
219 */
220 {
221 .virtual = 0xe6000000,
222 .pfn = __phys_to_pfn(0xe6000000),
223 .length = 256 << 20,
224 .type = MT_DEVICE_NONSHARED
225 },
226 };
227
228 static void __init kota2_map_io(void)
229 {
230 iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
231
232 /* setup early devices and console here as well */
233 sh73a0_add_early_devices();
234 shmobile_setup_console();
235 }
236
237 #define PINTER0A 0xe69000a0
238 #define PINTCR0A 0xe69000b0
239
240 void __init kota2_init_irq(void)
241 {
242 sh73a0_init_irq();
243
244 /* setup PINT: enable PINTA2 as active low */
245 __raw_writel(1 << 29, PINTER0A);
246 __raw_writew(2 << 10, PINTCR0A);
247 }
248
249 static void __init kota2_init(void)
250 {
251 sh73a0_pinmux_init();
252
253 /* SCIFA2 (UART2) */
254 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
255 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
256 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
257 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
258
259 /* SMSC911X */
260 gpio_request(GPIO_FN_D0_NAF0, NULL);
261 gpio_request(GPIO_FN_D1_NAF1, NULL);
262 gpio_request(GPIO_FN_D2_NAF2, NULL);
263 gpio_request(GPIO_FN_D3_NAF3, NULL);
264 gpio_request(GPIO_FN_D4_NAF4, NULL);
265 gpio_request(GPIO_FN_D5_NAF5, NULL);
266 gpio_request(GPIO_FN_D6_NAF6, NULL);
267 gpio_request(GPIO_FN_D7_NAF7, NULL);
268 gpio_request(GPIO_FN_D8_NAF8, NULL);
269 gpio_request(GPIO_FN_D9_NAF9, NULL);
270 gpio_request(GPIO_FN_D10_NAF10, NULL);
271 gpio_request(GPIO_FN_D11_NAF11, NULL);
272 gpio_request(GPIO_FN_D12_NAF12, NULL);
273 gpio_request(GPIO_FN_D13_NAF13, NULL);
274 gpio_request(GPIO_FN_D14_NAF14, NULL);
275 gpio_request(GPIO_FN_D15_NAF15, NULL);
276 gpio_request(GPIO_FN_CS5A_, NULL);
277 gpio_request(GPIO_FN_WE0__FWE, NULL);
278 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
279 gpio_direction_input(GPIO_PORT144);
280 gpio_request(GPIO_PORT145, NULL); /* RESET */
281 gpio_direction_output(GPIO_PORT145, 1);
282
283 /* KEYSC */
284 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
285 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
286 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
287 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
288 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
289 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
290 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
291 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
292 gpio_request(GPIO_FN_KEYOUT0, NULL);
293 gpio_request(GPIO_FN_KEYOUT1, NULL);
294 gpio_request(GPIO_FN_KEYOUT2, NULL);
295 gpio_request(GPIO_FN_KEYOUT3, NULL);
296 gpio_request(GPIO_FN_KEYOUT4, NULL);
297 gpio_request(GPIO_FN_KEYOUT5, NULL);
298 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
299 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
300 gpio_request(GPIO_FN_KEYOUT8, NULL);
301
302 /* MMCIF */
303 gpio_request(GPIO_FN_MMCCLK0, NULL);
304 gpio_request(GPIO_FN_MMCD0_0, NULL);
305 gpio_request(GPIO_FN_MMCD0_1, NULL);
306 gpio_request(GPIO_FN_MMCD0_2, NULL);
307 gpio_request(GPIO_FN_MMCD0_3, NULL);
308 gpio_request(GPIO_FN_MMCD0_4, NULL);
309 gpio_request(GPIO_FN_MMCD0_5, NULL);
310 gpio_request(GPIO_FN_MMCD0_6, NULL);
311 gpio_request(GPIO_FN_MMCD0_7, NULL);
312 gpio_request(GPIO_FN_MMCCMD0, NULL);
313 gpio_request(GPIO_PORT208, NULL); /* Reset */
314 gpio_direction_output(GPIO_PORT208, 1);
315
316 #ifdef CONFIG_CACHE_L2X0
317 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
318 l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
319 #endif
320 sh73a0_add_standard_devices();
321 platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
322 }
323
324 static void __init kota2_timer_init(void)
325 {
326 sh73a0_clock_init();
327 shmobile_timer.init();
328 return;
329 }
330
331 struct sys_timer kota2_timer = {
332 .init = kota2_timer_init,
333 };
334
335 MACHINE_START(KOTA2, "kota2")
336 .map_io = kota2_map_io,
337 .init_irq = kota2_init_irq,
338 .handle_irq = shmobile_handle_irq_gic,
339 .init_machine = kota2_init,
340 .timer = &kota2_timer,
341 MACHINE_END
This page took 0.036585 seconds and 4 git commands to generate.