Commit | Line | Data |
---|---|---|
6d9598e2 MD |
1 | /* |
2 | * arch/arm/mach-shmobile/board-ag5evm.c | |
3 | * | |
4 | * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com> | |
5 | * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> | |
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 | */ | |
21 | ||
22 | #include <linux/kernel.h> | |
23 | #include <linux/init.h> | |
24 | #include <linux/interrupt.h> | |
25 | #include <linux/irq.h> | |
26 | #include <linux/platform_device.h> | |
27 | #include <linux/delay.h> | |
28 | #include <linux/io.h> | |
29 | #include <linux/dma-mapping.h> | |
30 | #include <linux/serial_sci.h> | |
31 | #include <linux/smsc911x.h> | |
32 | #include <linux/gpio.h> | |
2d22d486 YT |
33 | #include <linux/input.h> |
34 | #include <linux/input/sh_keysc.h> | |
6bf45a10 TY |
35 | #include <linux/mmc/host.h> |
36 | #include <linux/mmc/sh_mmcif.h> | |
170c7ab5 MD |
37 | #include <linux/sh_clk.h> |
38 | #include <video/sh_mobile_lcdc.h> | |
39 | #include <video/sh_mipi_dsi.h> | |
208c7dc2 | 40 | #include <sound/sh_fsi.h> |
6d9598e2 MD |
41 | #include <mach/hardware.h> |
42 | #include <mach/sh73a0.h> | |
43 | #include <mach/common.h> | |
44 | #include <asm/mach-types.h> | |
45 | #include <asm/mach/arch.h> | |
46 | #include <asm/mach/map.h> | |
47 | #include <asm/mach/time.h> | |
48 | #include <asm/hardware/gic.h> | |
49 | #include <asm/hardware/cache-l2x0.h> | |
50 | #include <asm/traps.h> | |
51 | ||
52 | static struct resource smsc9220_resources[] = { | |
53 | [0] = { | |
54 | .start = 0x14000000, | |
55 | .end = 0x14000000 + SZ_64K - 1, | |
56 | .flags = IORESOURCE_MEM, | |
57 | }, | |
58 | [1] = { | |
59 | .start = gic_spi(33), /* PINT1 */ | |
60 | .flags = IORESOURCE_IRQ, | |
61 | }, | |
62 | }; | |
63 | ||
64 | static struct smsc911x_platform_config smsc9220_platdata = { | |
65 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
66 | .phy_interface = PHY_INTERFACE_MODE_MII, | |
67 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
68 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
69 | }; | |
70 | ||
71 | static struct platform_device eth_device = { | |
72 | .name = "smsc911x", | |
73 | .id = 0, | |
74 | .dev = { | |
75 | .platform_data = &smsc9220_platdata, | |
76 | }, | |
77 | .resource = smsc9220_resources, | |
78 | .num_resources = ARRAY_SIZE(smsc9220_resources), | |
79 | }; | |
80 | ||
2d22d486 YT |
81 | static struct sh_keysc_info keysc_platdata = { |
82 | .mode = SH_KEYSC_MODE_6, | |
83 | .scan_timing = 3, | |
84 | .delay = 100, | |
85 | .keycodes = { | |
86 | KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, | |
87 | KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, | |
88 | KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, | |
89 | KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP, | |
90 | KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \ | |
91 | KEY_COFFEE, | |
92 | KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP, | |
93 | KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \ | |
94 | KEY_COMPUTER, | |
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 | ||
208c7dc2 | 121 | /* FSI A */ |
208c7dc2 KM |
122 | static struct resource fsi_resources[] = { |
123 | [0] = { | |
124 | .name = "FSI", | |
125 | .start = 0xEC230000, | |
126 | .end = 0xEC230400 - 1, | |
127 | .flags = IORESOURCE_MEM, | |
128 | }, | |
129 | [1] = { | |
130 | .start = gic_spi(146), | |
131 | .flags = IORESOURCE_IRQ, | |
132 | }, | |
133 | }; | |
134 | ||
135 | static struct platform_device fsi_device = { | |
136 | .name = "sh_fsi2", | |
137 | .id = -1, | |
138 | .num_resources = ARRAY_SIZE(fsi_resources), | |
139 | .resource = fsi_resources, | |
208c7dc2 KM |
140 | }; |
141 | ||
6bf45a10 TY |
142 | static struct resource sh_mmcif_resources[] = { |
143 | [0] = { | |
144 | .name = "MMCIF", | |
145 | .start = 0xe6bd0000, | |
146 | .end = 0xe6bd00ff, | |
147 | .flags = IORESOURCE_MEM, | |
148 | }, | |
149 | [1] = { | |
150 | .start = gic_spi(141), | |
151 | .flags = IORESOURCE_IRQ, | |
152 | }, | |
153 | [2] = { | |
154 | .start = gic_spi(140), | |
155 | .flags = IORESOURCE_IRQ, | |
156 | }, | |
157 | }; | |
158 | ||
159 | static struct sh_mmcif_plat_data sh_mmcif_platdata = { | |
160 | .sup_pclk = 0, | |
161 | .ocr = MMC_VDD_165_195, | |
162 | .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, | |
163 | }; | |
164 | ||
165 | static struct platform_device mmc_device = { | |
166 | .name = "sh_mmcif", | |
167 | .id = 0, | |
168 | .dev = { | |
169 | .dma_mask = NULL, | |
170 | .coherent_dma_mask = 0xffffffff, | |
171 | .platform_data = &sh_mmcif_platdata, | |
172 | }, | |
173 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), | |
174 | .resource = sh_mmcif_resources, | |
175 | }; | |
176 | ||
a33bb8a2 KM |
177 | /* IrDA */ |
178 | static struct resource irda_resources[] = { | |
179 | [0] = { | |
180 | .start = 0xE6D00000, | |
181 | .end = 0xE6D01FD4 - 1, | |
182 | .flags = IORESOURCE_MEM, | |
183 | }, | |
184 | [1] = { | |
185 | .start = gic_spi(95), | |
186 | .flags = IORESOURCE_IRQ, | |
187 | }, | |
188 | }; | |
189 | ||
190 | static struct platform_device irda_device = { | |
191 | .name = "sh_irda", | |
192 | .id = 0, | |
193 | .resource = irda_resources, | |
194 | .num_resources = ARRAY_SIZE(irda_resources), | |
195 | }; | |
196 | ||
170c7ab5 MD |
197 | static unsigned char lcd_backlight_seq[3][2] = { |
198 | { 0x04, 0x07 }, | |
199 | { 0x23, 0x80 }, | |
200 | { 0x03, 0x01 }, | |
201 | }; | |
202 | ||
203 | static void lcd_backlight_on(void) | |
204 | { | |
205 | struct i2c_adapter *a; | |
206 | struct i2c_msg msg; | |
207 | int k; | |
208 | ||
209 | a = i2c_get_adapter(1); | |
210 | for (k = 0; a && k < 3; k++) { | |
211 | msg.addr = 0x6d; | |
212 | msg.buf = &lcd_backlight_seq[k][0]; | |
213 | msg.len = 2; | |
214 | msg.flags = 0; | |
215 | if (i2c_transfer(a, &msg, 1) != 1) | |
216 | break; | |
217 | } | |
218 | } | |
219 | ||
220 | static void lcd_backlight_reset(void) | |
221 | { | |
222 | gpio_set_value(GPIO_PORT235, 0); | |
223 | mdelay(24); | |
224 | gpio_set_value(GPIO_PORT235, 1); | |
225 | } | |
226 | ||
227 | static void lcd_on(void *board_data, struct fb_info *info) | |
228 | { | |
229 | lcd_backlight_on(); | |
230 | } | |
231 | ||
232 | static void lcd_off(void *board_data) | |
233 | { | |
234 | lcd_backlight_reset(); | |
235 | } | |
236 | ||
237 | /* LCDC0 */ | |
238 | static const struct fb_videomode lcdc0_modes[] = { | |
239 | { | |
240 | .name = "R63302(QHD)", | |
241 | .xres = 544, | |
242 | .yres = 961, | |
243 | .left_margin = 72, | |
244 | .right_margin = 600, | |
245 | .hsync_len = 16, | |
246 | .upper_margin = 8, | |
247 | .lower_margin = 8, | |
248 | .vsync_len = 2, | |
249 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT, | |
250 | }, | |
251 | }; | |
252 | ||
253 | static struct sh_mobile_lcdc_info lcdc0_info = { | |
254 | .clock_source = LCDC_CLK_PERIPHERAL, | |
255 | .ch[0] = { | |
256 | .chan = LCDC_CHAN_MAINLCD, | |
257 | .interface_type = RGB24, | |
258 | .clock_divider = 1, | |
259 | .flags = LCDC_FLAGS_DWPOL, | |
260 | .lcd_size_cfg.width = 44, | |
261 | .lcd_size_cfg.height = 79, | |
262 | .bpp = 16, | |
263 | .lcd_cfg = lcdc0_modes, | |
264 | .num_cfg = ARRAY_SIZE(lcdc0_modes), | |
265 | .board_cfg = { | |
266 | .display_on = lcd_on, | |
267 | .display_off = lcd_off, | |
268 | }, | |
269 | } | |
270 | }; | |
271 | ||
272 | static struct resource lcdc0_resources[] = { | |
273 | [0] = { | |
274 | .name = "LCDC0", | |
275 | .start = 0xfe940000, /* P4-only space */ | |
276 | .end = 0xfe943fff, | |
277 | .flags = IORESOURCE_MEM, | |
278 | }, | |
279 | [1] = { | |
280 | .start = intcs_evt2irq(0x580), | |
281 | .flags = IORESOURCE_IRQ, | |
282 | }, | |
283 | }; | |
284 | ||
285 | static struct platform_device lcdc0_device = { | |
286 | .name = "sh_mobile_lcdc_fb", | |
287 | .num_resources = ARRAY_SIZE(lcdc0_resources), | |
288 | .resource = lcdc0_resources, | |
289 | .id = 0, | |
290 | .dev = { | |
291 | .platform_data = &lcdc0_info, | |
292 | .coherent_dma_mask = ~0, | |
293 | }, | |
294 | }; | |
295 | ||
296 | /* MIPI-DSI */ | |
297 | static struct resource mipidsi0_resources[] = { | |
298 | [0] = { | |
6b36fdd1 | 299 | .name = "DSI0", |
170c7ab5 MD |
300 | .start = 0xfeab0000, |
301 | .end = 0xfeab3fff, | |
302 | .flags = IORESOURCE_MEM, | |
303 | }, | |
304 | [1] = { | |
6b36fdd1 | 305 | .name = "DSI0", |
170c7ab5 MD |
306 | .start = 0xfeab4000, |
307 | .end = 0xfeab7fff, | |
308 | .flags = IORESOURCE_MEM, | |
309 | }, | |
310 | }; | |
311 | ||
312 | static struct sh_mipi_dsi_info mipidsi0_info = { | |
313 | .data_format = MIPI_RGB888, | |
314 | .lcd_chan = &lcdc0_info.ch[0], | |
315 | .vsynw_offset = 20, | |
316 | .clksrc = 1, | |
317 | .flags = SH_MIPI_DSI_HSABM, | |
318 | }; | |
319 | ||
320 | static struct platform_device mipidsi0_device = { | |
321 | .name = "sh-mipi-dsi", | |
322 | .num_resources = ARRAY_SIZE(mipidsi0_resources), | |
323 | .resource = mipidsi0_resources, | |
324 | .id = 0, | |
325 | .dev = { | |
326 | .platform_data = &mipidsi0_info, | |
327 | }, | |
328 | }; | |
329 | ||
6d9598e2 MD |
330 | static struct platform_device *ag5evm_devices[] __initdata = { |
331 | ð_device, | |
2d22d486 | 332 | &keysc_device, |
208c7dc2 | 333 | &fsi_device, |
6bf45a10 | 334 | &mmc_device, |
a33bb8a2 | 335 | &irda_device, |
170c7ab5 MD |
336 | &lcdc0_device, |
337 | &mipidsi0_device, | |
6d9598e2 MD |
338 | }; |
339 | ||
340 | static struct map_desc ag5evm_io_desc[] __initdata = { | |
341 | /* create a 1:1 entity map for 0xe6xxxxxx | |
342 | * used by CPGA, INTC and PFC. | |
343 | */ | |
344 | { | |
345 | .virtual = 0xe6000000, | |
346 | .pfn = __phys_to_pfn(0xe6000000), | |
347 | .length = 256 << 20, | |
348 | .type = MT_DEVICE_NONSHARED | |
349 | }, | |
350 | }; | |
351 | ||
352 | static void __init ag5evm_map_io(void) | |
353 | { | |
354 | iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc)); | |
355 | ||
356 | /* setup early devices and console here as well */ | |
357 | sh73a0_add_early_devices(); | |
358 | shmobile_setup_console(); | |
359 | } | |
360 | ||
361 | #define PINTC_ADDR 0xe6900000 | |
362 | #define PINTER0A (PINTC_ADDR + 0xa0) | |
363 | #define PINTCR0A (PINTC_ADDR + 0xb0) | |
364 | ||
365 | void __init ag5evm_init_irq(void) | |
366 | { | |
5f53a56a MD |
367 | sh73a0_init_irq(); |
368 | ||
6d9598e2 MD |
369 | /* setup PINT: enable PINTA2 as active low */ |
370 | __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A); | |
371 | __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A); | |
6d9598e2 MD |
372 | } |
373 | ||
170c7ab5 MD |
374 | #define DSI0PHYCR 0xe615006c |
375 | ||
6d9598e2 MD |
376 | static void __init ag5evm_init(void) |
377 | { | |
3256c789 TY |
378 | sh73a0_pinmux_init(); |
379 | ||
6d9598e2 | 380 | /* enable SCIFA2 */ |
3256c789 TY |
381 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); |
382 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); | |
383 | gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL); | |
384 | gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL); | |
6d9598e2 | 385 | |
2d22d486 | 386 | /* enable KEYSC */ |
5d781472 TY |
387 | gpio_request(GPIO_FN_KEYIN0_PU, NULL); |
388 | gpio_request(GPIO_FN_KEYIN1_PU, NULL); | |
389 | gpio_request(GPIO_FN_KEYIN2_PU, NULL); | |
390 | gpio_request(GPIO_FN_KEYIN3_PU, NULL); | |
391 | gpio_request(GPIO_FN_KEYIN4_PU, NULL); | |
392 | gpio_request(GPIO_FN_KEYIN5_PU, NULL); | |
393 | gpio_request(GPIO_FN_KEYIN6_PU, NULL); | |
394 | gpio_request(GPIO_FN_KEYIN7_PU, NULL); | |
2d22d486 YT |
395 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
396 | gpio_request(GPIO_FN_KEYOUT1, NULL); | |
397 | gpio_request(GPIO_FN_KEYOUT2, NULL); | |
398 | gpio_request(GPIO_FN_KEYOUT3, NULL); | |
399 | gpio_request(GPIO_FN_KEYOUT4, NULL); | |
400 | gpio_request(GPIO_FN_KEYOUT5, NULL); | |
401 | gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL); | |
402 | gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL); | |
403 | gpio_request(GPIO_FN_KEYOUT8, NULL); | |
404 | gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL); | |
405 | ||
6bf45a10 | 406 | /* enable I2C channel 2 and 3 */ |
8e67b22a YT |
407 | gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL); |
408 | gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL); | |
409 | gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL); | |
410 | gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL); | |
411 | ||
6bf45a10 TY |
412 | /* enable MMCIF */ |
413 | gpio_request(GPIO_FN_MMCCLK0, NULL); | |
414 | gpio_request(GPIO_FN_MMCCMD0_PU, NULL); | |
415 | gpio_request(GPIO_FN_MMCD0_0, NULL); | |
416 | gpio_request(GPIO_FN_MMCD0_1, NULL); | |
417 | gpio_request(GPIO_FN_MMCD0_2, NULL); | |
418 | gpio_request(GPIO_FN_MMCD0_3, NULL); | |
419 | gpio_request(GPIO_FN_MMCD0_4, NULL); | |
420 | gpio_request(GPIO_FN_MMCD0_5, NULL); | |
421 | gpio_request(GPIO_FN_MMCD0_6, NULL); | |
422 | gpio_request(GPIO_FN_MMCD0_7, NULL); | |
423 | gpio_request(GPIO_PORT208, NULL); /* Reset */ | |
424 | gpio_direction_output(GPIO_PORT208, 1); | |
425 | ||
6d9598e2 | 426 | /* enable SMSC911X */ |
3256c789 TY |
427 | gpio_request(GPIO_PORT144, NULL); /* PINTA2 */ |
428 | gpio_direction_input(GPIO_PORT144); | |
429 | gpio_request(GPIO_PORT145, NULL); /* RESET */ | |
430 | gpio_direction_output(GPIO_PORT145, 1); | |
6d9598e2 | 431 | |
208c7dc2 KM |
432 | /* FSI A */ |
433 | gpio_request(GPIO_FN_FSIACK, NULL); | |
434 | gpio_request(GPIO_FN_FSIAILR, NULL); | |
435 | gpio_request(GPIO_FN_FSIAIBT, NULL); | |
436 | gpio_request(GPIO_FN_FSIAISLD, NULL); | |
437 | gpio_request(GPIO_FN_FSIAOSLD, NULL); | |
438 | ||
a33bb8a2 KM |
439 | /* IrDA */ |
440 | gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL); | |
441 | gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL); | |
442 | gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL); | |
443 | ||
170c7ab5 MD |
444 | /* LCD panel */ |
445 | gpio_request(GPIO_PORT217, NULL); /* RESET */ | |
446 | gpio_direction_output(GPIO_PORT217, 0); | |
447 | mdelay(1); | |
448 | gpio_set_value(GPIO_PORT217, 1); | |
f55398ab | 449 | mdelay(100); |
170c7ab5 MD |
450 | |
451 | /* LCD backlight controller */ | |
452 | gpio_request(GPIO_PORT235, NULL); /* RESET */ | |
453 | gpio_direction_output(GPIO_PORT235, 0); | |
454 | lcd_backlight_reset(); | |
455 | ||
456 | /* MIPI-DSI clock setup */ | |
457 | __raw_writel(0x2a809010, DSI0PHYCR); | |
458 | ||
6d9598e2 MD |
459 | #ifdef CONFIG_CACHE_L2X0 |
460 | /* Shared attribute override enable, 64K*8way */ | |
461 | l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff); | |
462 | #endif | |
463 | sh73a0_add_standard_devices(); | |
464 | platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices)); | |
465 | } | |
466 | ||
467 | static void __init ag5evm_timer_init(void) | |
468 | { | |
469 | sh73a0_clock_init(); | |
470 | shmobile_timer.init(); | |
471 | return; | |
472 | } | |
473 | ||
474 | struct sys_timer ag5evm_timer = { | |
475 | .init = ag5evm_timer_init, | |
476 | }; | |
477 | ||
478 | MACHINE_START(AG5EVM, "ag5evm") | |
479 | .map_io = ag5evm_map_io, | |
480 | .init_irq = ag5evm_init_irq, | |
e74a9625 | 481 | .handle_irq = shmobile_handle_irq_gic, |
6d9598e2 MD |
482 | .init_machine = ag5evm_init, |
483 | .timer = &ag5evm_timer, | |
484 | MACHINE_END |