2 * arch/arm/mach-shmobile/board-ag5evm.c
4 * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
5 * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
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.
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.
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
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>
29 #include <linux/dma-mapping.h>
30 #include <linux/serial_sci.h>
31 #include <linux/smsc911x.h>
32 #include <linux/gpio.h>
33 #include <linux/input.h>
34 #include <linux/input/sh_keysc.h>
35 #include <linux/mmc/host.h>
36 #include <linux/mmc/sh_mmcif.h>
37 #include <linux/sh_clk.h>
38 #include <video/sh_mobile_lcdc.h>
39 #include <video/sh_mipi_dsi.h>
40 #include <sound/sh_fsi.h>
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>
52 static struct resource smsc9220_resources[] = {
55 .end = 0x14000000 + SZ_64K - 1,
56 .flags = IORESOURCE_MEM,
59 .start = gic_spi(33), /* PINT1 */
60 .flags = IORESOURCE_IRQ,
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,
71 static struct platform_device eth_device = {
75 .platform_data = &smsc9220_platdata,
77 .resource = smsc9220_resources,
78 .num_resources = ARRAY_SIZE(smsc9220_resources),
81 static struct sh_keysc_info keysc_platdata = {
82 .mode = SH_KEYSC_MODE_6,
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, \
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, \
98 static struct resource keysc_resources[] = {
102 .end = 0xe61b0098 - 1,
103 .flags = IORESOURCE_MEM,
106 .start = gic_spi(71),
107 .flags = IORESOURCE_IRQ,
111 static struct platform_device keysc_device = {
114 .num_resources = ARRAY_SIZE(keysc_resources),
115 .resource = keysc_resources,
117 .platform_data = &keysc_platdata,
122 static struct sh_fsi_platform_info fsi_info = {
123 .porta_flags = SH_FSI_OUT_SLAVE_MODE |
124 SH_FSI_IN_SLAVE_MODE |
129 static struct resource fsi_resources[] = {
133 .end = 0xEC230400 - 1,
134 .flags = IORESOURCE_MEM,
137 .start = gic_spi(146),
138 .flags = IORESOURCE_IRQ,
142 static struct platform_device fsi_device = {
145 .num_resources = ARRAY_SIZE(fsi_resources),
146 .resource = fsi_resources,
148 .platform_data = &fsi_info,
152 static struct resource sh_mmcif_resources[] = {
157 .flags = IORESOURCE_MEM,
160 .start = gic_spi(141),
161 .flags = IORESOURCE_IRQ,
164 .start = gic_spi(140),
165 .flags = IORESOURCE_IRQ,
169 static struct sh_mmcif_plat_data sh_mmcif_platdata = {
171 .ocr = MMC_VDD_165_195,
172 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
175 static struct platform_device mmc_device = {
180 .coherent_dma_mask = 0xffffffff,
181 .platform_data = &sh_mmcif_platdata,
183 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
184 .resource = sh_mmcif_resources,
188 static struct resource irda_resources[] = {
191 .end = 0xE6D01FD4 - 1,
192 .flags = IORESOURCE_MEM,
195 .start = gic_spi(95),
196 .flags = IORESOURCE_IRQ,
200 static struct platform_device irda_device = {
203 .resource = irda_resources,
204 .num_resources = ARRAY_SIZE(irda_resources),
207 static unsigned char lcd_backlight_seq[3][2] = {
213 static void lcd_backlight_on(void)
215 struct i2c_adapter *a;
219 a = i2c_get_adapter(1);
220 for (k = 0; a && k < 3; k++) {
222 msg.buf = &lcd_backlight_seq[k][0];
225 if (i2c_transfer(a, &msg, 1) != 1)
230 static void lcd_backlight_reset(void)
232 gpio_set_value(GPIO_PORT235, 0);
234 gpio_set_value(GPIO_PORT235, 1);
237 static void lcd_on(void *board_data, struct fb_info *info)
242 static void lcd_off(void *board_data)
244 lcd_backlight_reset();
248 static const struct fb_videomode lcdc0_modes[] = {
250 .name = "R63302(QHD)",
259 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
263 static struct sh_mobile_lcdc_info lcdc0_info = {
264 .clock_source = LCDC_CLK_PERIPHERAL,
266 .chan = LCDC_CHAN_MAINLCD,
267 .interface_type = RGB24,
269 .flags = LCDC_FLAGS_DWPOL,
270 .lcd_size_cfg.width = 44,
271 .lcd_size_cfg.height = 79,
273 .lcd_cfg = lcdc0_modes,
274 .num_cfg = ARRAY_SIZE(lcdc0_modes),
276 .display_on = lcd_on,
277 .display_off = lcd_off,
282 static struct resource lcdc0_resources[] = {
285 .start = 0xfe940000, /* P4-only space */
287 .flags = IORESOURCE_MEM,
290 .start = intcs_evt2irq(0x580),
291 .flags = IORESOURCE_IRQ,
295 static struct platform_device lcdc0_device = {
296 .name = "sh_mobile_lcdc_fb",
297 .num_resources = ARRAY_SIZE(lcdc0_resources),
298 .resource = lcdc0_resources,
301 .platform_data = &lcdc0_info,
302 .coherent_dma_mask = ~0,
307 static struct resource mipidsi0_resources[] = {
311 .flags = IORESOURCE_MEM,
316 .flags = IORESOURCE_MEM,
320 static struct sh_mipi_dsi_info mipidsi0_info = {
321 .data_format = MIPI_RGB888,
322 .lcd_chan = &lcdc0_info.ch[0],
325 .flags = SH_MIPI_DSI_HSABM,
328 static struct platform_device mipidsi0_device = {
329 .name = "sh-mipi-dsi",
330 .num_resources = ARRAY_SIZE(mipidsi0_resources),
331 .resource = mipidsi0_resources,
334 .platform_data = &mipidsi0_info,
338 static struct platform_device *ag5evm_devices[] __initdata = {
348 static struct map_desc ag5evm_io_desc[] __initdata = {
349 /* create a 1:1 entity map for 0xe6xxxxxx
350 * used by CPGA, INTC and PFC.
353 .virtual = 0xe6000000,
354 .pfn = __phys_to_pfn(0xe6000000),
356 .type = MT_DEVICE_NONSHARED
360 static void __init ag5evm_map_io(void)
362 iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
364 /* setup early devices and console here as well */
365 sh73a0_add_early_devices();
366 shmobile_setup_console();
369 #define PINTC_ADDR 0xe6900000
370 #define PINTER0A (PINTC_ADDR + 0xa0)
371 #define PINTCR0A (PINTC_ADDR + 0xb0)
373 void __init ag5evm_init_irq(void)
377 /* setup PINT: enable PINTA2 as active low */
378 __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
379 __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
382 #define DSI0PHYCR 0xe615006c
384 static void __init ag5evm_init(void)
386 sh73a0_pinmux_init();
389 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
390 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
391 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
392 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
395 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
396 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
397 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
398 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
399 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
400 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
401 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
402 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
403 gpio_request(GPIO_FN_KEYOUT0, NULL);
404 gpio_request(GPIO_FN_KEYOUT1, NULL);
405 gpio_request(GPIO_FN_KEYOUT2, NULL);
406 gpio_request(GPIO_FN_KEYOUT3, NULL);
407 gpio_request(GPIO_FN_KEYOUT4, NULL);
408 gpio_request(GPIO_FN_KEYOUT5, NULL);
409 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
410 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
411 gpio_request(GPIO_FN_KEYOUT8, NULL);
412 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
414 /* enable I2C channel 2 and 3 */
415 gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
416 gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
417 gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
418 gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
421 gpio_request(GPIO_FN_MMCCLK0, NULL);
422 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
423 gpio_request(GPIO_FN_MMCD0_0, NULL);
424 gpio_request(GPIO_FN_MMCD0_1, NULL);
425 gpio_request(GPIO_FN_MMCD0_2, NULL);
426 gpio_request(GPIO_FN_MMCD0_3, NULL);
427 gpio_request(GPIO_FN_MMCD0_4, NULL);
428 gpio_request(GPIO_FN_MMCD0_5, NULL);
429 gpio_request(GPIO_FN_MMCD0_6, NULL);
430 gpio_request(GPIO_FN_MMCD0_7, NULL);
431 gpio_request(GPIO_PORT208, NULL); /* Reset */
432 gpio_direction_output(GPIO_PORT208, 1);
434 /* enable SMSC911X */
435 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
436 gpio_direction_input(GPIO_PORT144);
437 gpio_request(GPIO_PORT145, NULL); /* RESET */
438 gpio_direction_output(GPIO_PORT145, 1);
441 gpio_request(GPIO_FN_FSIACK, NULL);
442 gpio_request(GPIO_FN_FSIAILR, NULL);
443 gpio_request(GPIO_FN_FSIAIBT, NULL);
444 gpio_request(GPIO_FN_FSIAISLD, NULL);
445 gpio_request(GPIO_FN_FSIAOSLD, NULL);
448 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
449 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
450 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
453 gpio_request(GPIO_PORT217, NULL); /* RESET */
454 gpio_direction_output(GPIO_PORT217, 0);
456 gpio_set_value(GPIO_PORT217, 1);
459 /* LCD backlight controller */
460 gpio_request(GPIO_PORT235, NULL); /* RESET */
461 gpio_direction_output(GPIO_PORT235, 0);
462 lcd_backlight_reset();
464 /* MIPI-DSI clock setup */
465 __raw_writel(0x2a809010, DSI0PHYCR);
467 #ifdef CONFIG_CACHE_L2X0
468 /* Shared attribute override enable, 64K*8way */
469 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
471 sh73a0_add_standard_devices();
472 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
475 static void __init ag5evm_timer_init(void)
478 shmobile_timer.init();
482 struct sys_timer ag5evm_timer = {
483 .init = ag5evm_timer_init,
486 MACHINE_START(AG5EVM, "ag5evm")
487 .map_io = ag5evm_map_io,
488 .init_irq = ag5evm_init_irq,
489 .handle_irq = shmobile_handle_irq_gic,
490 .init_machine = ag5evm_init,
491 .timer = &ag5evm_timer,