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/mmc/sh_mobile_sdhi.h>
38 #include <linux/mfd/tmio.h>
39 #include <linux/sh_clk.h>
40 #include <video/sh_mobile_lcdc.h>
41 #include <video/sh_mipi_dsi.h>
42 #include <sound/sh_fsi.h>
43 #include <mach/hardware.h>
44 #include <mach/sh73a0.h>
45 #include <mach/common.h>
46 #include <asm/mach-types.h>
47 #include <asm/mach/arch.h>
48 #include <asm/mach/map.h>
49 #include <asm/mach/time.h>
50 #include <asm/hardware/gic.h>
51 #include <asm/hardware/cache-l2x0.h>
52 #include <asm/traps.h>
54 static struct resource smsc9220_resources
[] = {
57 .end
= 0x14000000 + SZ_64K
- 1,
58 .flags
= IORESOURCE_MEM
,
61 .start
= gic_spi(33), /* PINT1 */
62 .flags
= IORESOURCE_IRQ
,
66 static struct smsc911x_platform_config smsc9220_platdata
= {
67 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
68 .phy_interface
= PHY_INTERFACE_MODE_MII
,
69 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
70 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
73 static struct platform_device eth_device
= {
77 .platform_data
= &smsc9220_platdata
,
79 .resource
= smsc9220_resources
,
80 .num_resources
= ARRAY_SIZE(smsc9220_resources
),
83 static struct sh_keysc_info keysc_platdata
= {
84 .mode
= SH_KEYSC_MODE_6
,
88 KEY_A
, KEY_B
, KEY_C
, KEY_D
, KEY_E
, KEY_F
, KEY_G
,
89 KEY_H
, KEY_I
, KEY_J
, KEY_K
, KEY_L
, KEY_M
, KEY_N
,
90 KEY_O
, KEY_P
, KEY_Q
, KEY_R
, KEY_S
, KEY_T
, KEY_U
,
91 KEY_V
, KEY_W
, KEY_X
, KEY_Y
, KEY_Z
, KEY_HOME
, KEY_SLEEP
,
92 KEY_SPACE
, KEY_9
, KEY_6
, KEY_3
, KEY_WAKEUP
, KEY_RIGHT
, \
94 KEY_0
, KEY_8
, KEY_5
, KEY_2
, KEY_DOWN
, KEY_ENTER
, KEY_UP
,
95 KEY_KPASTERISK
, KEY_7
, KEY_4
, KEY_1
, KEY_STOP
, KEY_LEFT
, \
100 static struct resource keysc_resources
[] = {
104 .end
= 0xe61b0098 - 1,
105 .flags
= IORESOURCE_MEM
,
108 .start
= gic_spi(71),
109 .flags
= IORESOURCE_IRQ
,
113 static struct platform_device keysc_device
= {
116 .num_resources
= ARRAY_SIZE(keysc_resources
),
117 .resource
= keysc_resources
,
119 .platform_data
= &keysc_platdata
,
124 static struct resource fsi_resources
[] = {
128 .end
= 0xEC230400 - 1,
129 .flags
= IORESOURCE_MEM
,
132 .start
= gic_spi(146),
133 .flags
= IORESOURCE_IRQ
,
137 static struct platform_device fsi_device
= {
140 .num_resources
= ARRAY_SIZE(fsi_resources
),
141 .resource
= fsi_resources
,
144 static struct resource sh_mmcif_resources
[] = {
149 .flags
= IORESOURCE_MEM
,
152 .start
= gic_spi(141),
153 .flags
= IORESOURCE_IRQ
,
156 .start
= gic_spi(140),
157 .flags
= IORESOURCE_IRQ
,
161 static struct sh_mmcif_dma sh_mmcif_dma
= {
163 .slave_id
= SHDMA_SLAVE_MMCIF_RX
,
166 .slave_id
= SHDMA_SLAVE_MMCIF_TX
,
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
,
173 .dma
= &sh_mmcif_dma
,
176 static struct platform_device mmc_device
= {
181 .coherent_dma_mask
= 0xffffffff,
182 .platform_data
= &sh_mmcif_platdata
,
184 .num_resources
= ARRAY_SIZE(sh_mmcif_resources
),
185 .resource
= sh_mmcif_resources
,
189 static struct resource irda_resources
[] = {
192 .end
= 0xE6D01FD4 - 1,
193 .flags
= IORESOURCE_MEM
,
196 .start
= gic_spi(95),
197 .flags
= IORESOURCE_IRQ
,
201 static struct platform_device irda_device
= {
204 .resource
= irda_resources
,
205 .num_resources
= ARRAY_SIZE(irda_resources
),
208 static unsigned char lcd_backlight_seq
[3][2] = {
214 static void lcd_backlight_on(void)
216 struct i2c_adapter
*a
;
220 a
= i2c_get_adapter(1);
221 for (k
= 0; a
&& k
< 3; k
++) {
223 msg
.buf
= &lcd_backlight_seq
[k
][0];
226 if (i2c_transfer(a
, &msg
, 1) != 1)
231 static void lcd_backlight_reset(void)
233 gpio_set_value(GPIO_PORT235
, 0);
235 gpio_set_value(GPIO_PORT235
, 1);
238 static void lcd_on(void *board_data
, struct fb_info
*info
)
243 static void lcd_off(void *board_data
)
245 lcd_backlight_reset();
249 static const struct fb_videomode lcdc0_modes
[] = {
251 .name
= "R63302(QHD)",
260 .sync
= FB_SYNC_VERT_HIGH_ACT
| FB_SYNC_HOR_HIGH_ACT
,
264 static struct sh_mobile_lcdc_info lcdc0_info
= {
265 .clock_source
= LCDC_CLK_PERIPHERAL
,
267 .chan
= LCDC_CHAN_MAINLCD
,
268 .interface_type
= RGB24
,
270 .flags
= LCDC_FLAGS_DWPOL
,
271 .lcd_size_cfg
.width
= 44,
272 .lcd_size_cfg
.height
= 79,
274 .lcd_cfg
= lcdc0_modes
,
275 .num_cfg
= ARRAY_SIZE(lcdc0_modes
),
277 .display_on
= lcd_on
,
278 .display_off
= lcd_off
,
283 static struct resource lcdc0_resources
[] = {
286 .start
= 0xfe940000, /* P4-only space */
288 .flags
= IORESOURCE_MEM
,
291 .start
= intcs_evt2irq(0x580),
292 .flags
= IORESOURCE_IRQ
,
296 static struct platform_device lcdc0_device
= {
297 .name
= "sh_mobile_lcdc_fb",
298 .num_resources
= ARRAY_SIZE(lcdc0_resources
),
299 .resource
= lcdc0_resources
,
302 .platform_data
= &lcdc0_info
,
303 .coherent_dma_mask
= ~0,
308 static struct resource mipidsi0_resources
[] = {
313 .flags
= IORESOURCE_MEM
,
319 .flags
= IORESOURCE_MEM
,
323 static struct sh_mipi_dsi_info mipidsi0_info
= {
324 .data_format
= MIPI_RGB888
,
325 .lcd_chan
= &lcdc0_info
.ch
[0],
328 .flags
= SH_MIPI_DSI_HSABM
,
331 static struct platform_device mipidsi0_device
= {
332 .name
= "sh-mipi-dsi",
333 .num_resources
= ARRAY_SIZE(mipidsi0_resources
),
334 .resource
= mipidsi0_resources
,
337 .platform_data
= &mipidsi0_info
,
341 static struct sh_mobile_sdhi_info sdhi0_info
= {
342 .dma_slave_tx
= SHDMA_SLAVE_SDHI0_TX
,
343 .dma_slave_rx
= SHDMA_SLAVE_SDHI0_RX
,
344 .tmio_caps
= MMC_CAP_SD_HIGHSPEED
,
345 .tmio_ocr_mask
= MMC_VDD_27_28
| MMC_VDD_28_29
,
348 static struct resource sdhi0_resources
[] = {
353 .flags
= IORESOURCE_MEM
,
356 .start
= gic_spi(83),
357 .flags
= IORESOURCE_IRQ
,
360 .start
= gic_spi(84),
361 .flags
= IORESOURCE_IRQ
,
364 .start
= gic_spi(85),
365 .flags
= IORESOURCE_IRQ
,
369 static struct platform_device sdhi0_device
= {
370 .name
= "sh_mobile_sdhi",
372 .num_resources
= ARRAY_SIZE(sdhi0_resources
),
373 .resource
= sdhi0_resources
,
375 .platform_data
= &sdhi0_info
,
379 void ag5evm_sdhi1_set_pwr(struct platform_device
*pdev
, int state
)
381 gpio_set_value(GPIO_PORT114
, state
);
384 static struct sh_mobile_sdhi_info sh_sdhi1_info
= {
385 .tmio_flags
= TMIO_MMC_WRPROTECT_DISABLE
,
386 .tmio_caps
= MMC_CAP_NONREMOVABLE
| MMC_CAP_SDIO_IRQ
,
387 .tmio_ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
388 .set_pwr
= ag5evm_sdhi1_set_pwr
,
391 static struct resource sdhi1_resources
[] = {
396 .flags
= IORESOURCE_MEM
,
399 .start
= gic_spi(87),
400 .flags
= IORESOURCE_IRQ
,
403 .start
= gic_spi(88),
404 .flags
= IORESOURCE_IRQ
,
407 .start
= gic_spi(89),
408 .flags
= IORESOURCE_IRQ
,
412 static struct platform_device sdhi1_device
= {
413 .name
= "sh_mobile_sdhi",
416 .platform_data
= &sh_sdhi1_info
,
418 .num_resources
= ARRAY_SIZE(sdhi1_resources
),
419 .resource
= sdhi1_resources
,
422 static struct platform_device
*ag5evm_devices
[] __initdata
= {
434 static struct map_desc ag5evm_io_desc
[] __initdata
= {
435 /* create a 1:1 entity map for 0xe6xxxxxx
436 * used by CPGA, INTC and PFC.
439 .virtual = 0xe6000000,
440 .pfn
= __phys_to_pfn(0xe6000000),
442 .type
= MT_DEVICE_NONSHARED
446 static void __init
ag5evm_map_io(void)
448 iotable_init(ag5evm_io_desc
, ARRAY_SIZE(ag5evm_io_desc
));
450 /* setup early devices and console here as well */
451 sh73a0_add_early_devices();
452 shmobile_setup_console();
455 #define PINTC_ADDR 0xe6900000
456 #define PINTER0A (PINTC_ADDR + 0xa0)
457 #define PINTCR0A (PINTC_ADDR + 0xb0)
459 void __init
ag5evm_init_irq(void)
463 /* setup PINT: enable PINTA2 as active low */
464 __raw_writel(__raw_readl(PINTER0A
) | (1<<29), PINTER0A
);
465 __raw_writew(__raw_readw(PINTCR0A
) | (2<<10), PINTCR0A
);
468 #define DSI0PHYCR 0xe615006c
470 static void __init
ag5evm_init(void)
472 sh73a0_pinmux_init();
475 gpio_request(GPIO_FN_SCIFA2_TXD1
, NULL
);
476 gpio_request(GPIO_FN_SCIFA2_RXD1
, NULL
);
477 gpio_request(GPIO_FN_SCIFA2_RTS1_
, NULL
);
478 gpio_request(GPIO_FN_SCIFA2_CTS1_
, NULL
);
481 gpio_request(GPIO_FN_KEYIN0_PU
, NULL
);
482 gpio_request(GPIO_FN_KEYIN1_PU
, NULL
);
483 gpio_request(GPIO_FN_KEYIN2_PU
, NULL
);
484 gpio_request(GPIO_FN_KEYIN3_PU
, NULL
);
485 gpio_request(GPIO_FN_KEYIN4_PU
, NULL
);
486 gpio_request(GPIO_FN_KEYIN5_PU
, NULL
);
487 gpio_request(GPIO_FN_KEYIN6_PU
, NULL
);
488 gpio_request(GPIO_FN_KEYIN7_PU
, NULL
);
489 gpio_request(GPIO_FN_KEYOUT0
, NULL
);
490 gpio_request(GPIO_FN_KEYOUT1
, NULL
);
491 gpio_request(GPIO_FN_KEYOUT2
, NULL
);
492 gpio_request(GPIO_FN_KEYOUT3
, NULL
);
493 gpio_request(GPIO_FN_KEYOUT4
, NULL
);
494 gpio_request(GPIO_FN_KEYOUT5
, NULL
);
495 gpio_request(GPIO_FN_PORT59_KEYOUT6
, NULL
);
496 gpio_request(GPIO_FN_PORT58_KEYOUT7
, NULL
);
497 gpio_request(GPIO_FN_KEYOUT8
, NULL
);
498 gpio_request(GPIO_FN_PORT149_KEYOUT9
, NULL
);
500 /* enable I2C channel 2 and 3 */
501 gpio_request(GPIO_FN_PORT236_I2C_SDA2
, NULL
);
502 gpio_request(GPIO_FN_PORT237_I2C_SCL2
, NULL
);
503 gpio_request(GPIO_FN_PORT248_I2C_SCL3
, NULL
);
504 gpio_request(GPIO_FN_PORT249_I2C_SDA3
, NULL
);
507 gpio_request(GPIO_FN_MMCCLK0
, NULL
);
508 gpio_request(GPIO_FN_MMCCMD0_PU
, NULL
);
509 gpio_request(GPIO_FN_MMCD0_0
, NULL
);
510 gpio_request(GPIO_FN_MMCD0_1
, NULL
);
511 gpio_request(GPIO_FN_MMCD0_2
, NULL
);
512 gpio_request(GPIO_FN_MMCD0_3
, NULL
);
513 gpio_request(GPIO_FN_MMCD0_4
, NULL
);
514 gpio_request(GPIO_FN_MMCD0_5
, NULL
);
515 gpio_request(GPIO_FN_MMCD0_6
, NULL
);
516 gpio_request(GPIO_FN_MMCD0_7
, NULL
);
517 gpio_request(GPIO_PORT208
, NULL
); /* Reset */
518 gpio_direction_output(GPIO_PORT208
, 1);
520 /* enable SMSC911X */
521 gpio_request(GPIO_PORT144
, NULL
); /* PINTA2 */
522 gpio_direction_input(GPIO_PORT144
);
523 gpio_request(GPIO_PORT145
, NULL
); /* RESET */
524 gpio_direction_output(GPIO_PORT145
, 1);
527 gpio_request(GPIO_FN_FSIACK
, NULL
);
528 gpio_request(GPIO_FN_FSIAILR
, NULL
);
529 gpio_request(GPIO_FN_FSIAIBT
, NULL
);
530 gpio_request(GPIO_FN_FSIAISLD
, NULL
);
531 gpio_request(GPIO_FN_FSIAOSLD
, NULL
);
534 gpio_request(GPIO_FN_PORT241_IRDA_OUT
, NULL
);
535 gpio_request(GPIO_FN_PORT242_IRDA_IN
, NULL
);
536 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL
, NULL
);
539 gpio_request(GPIO_PORT217
, NULL
); /* RESET */
540 gpio_direction_output(GPIO_PORT217
, 0);
542 gpio_set_value(GPIO_PORT217
, 1);
545 /* LCD backlight controller */
546 gpio_request(GPIO_PORT235
, NULL
); /* RESET */
547 gpio_direction_output(GPIO_PORT235
, 0);
548 lcd_backlight_reset();
550 /* MIPI-DSI clock setup */
551 __raw_writel(0x2a809010, DSI0PHYCR
);
553 /* enable SDHI0 on CN15 [SD I/F] */
554 gpio_request(GPIO_FN_SDHICD0
, NULL
);
555 gpio_request(GPIO_FN_SDHIWP0
, NULL
);
556 gpio_request(GPIO_FN_SDHICMD0
, NULL
);
557 gpio_request(GPIO_FN_SDHICLK0
, NULL
);
558 gpio_request(GPIO_FN_SDHID0_3
, NULL
);
559 gpio_request(GPIO_FN_SDHID0_2
, NULL
);
560 gpio_request(GPIO_FN_SDHID0_1
, NULL
);
561 gpio_request(GPIO_FN_SDHID0_0
, NULL
);
563 /* enable SDHI1 on CN4 [WLAN I/F] */
564 gpio_request(GPIO_FN_SDHICLK1
, NULL
);
565 gpio_request(GPIO_FN_SDHICMD1_PU
, NULL
);
566 gpio_request(GPIO_FN_SDHID1_3_PU
, NULL
);
567 gpio_request(GPIO_FN_SDHID1_2_PU
, NULL
);
568 gpio_request(GPIO_FN_SDHID1_1_PU
, NULL
);
569 gpio_request(GPIO_FN_SDHID1_0_PU
, NULL
);
570 gpio_request(GPIO_PORT114
, "sdhi1_power");
571 gpio_direction_output(GPIO_PORT114
, 0);
573 #ifdef CONFIG_CACHE_L2X0
574 /* Shared attribute override enable, 64K*8way */
575 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
577 sh73a0_add_standard_devices();
578 platform_add_devices(ag5evm_devices
, ARRAY_SIZE(ag5evm_devices
));
581 static void __init
ag5evm_timer_init(void)
584 shmobile_timer
.init();
588 struct sys_timer ag5evm_timer
= {
589 .init
= ag5evm_timer_init
,
592 MACHINE_START(AG5EVM
, "ag5evm")
593 .map_io
= ag5evm_map_io
,
594 .init_irq
= ag5evm_init_irq
,
595 .handle_irq
= shmobile_handle_irq_gic
,
596 .init_machine
= ag5evm_init
,
597 .timer
= &ag5evm_timer
,