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/videodev2.h>
34 #include <linux/input.h>
35 #include <linux/input/sh_keysc.h>
36 #include <linux/mmc/host.h>
37 #include <linux/mmc/sh_mmcif.h>
38 #include <linux/mmc/sh_mobile_sdhi.h>
39 #include <linux/mfd/tmio.h>
40 #include <linux/sh_clk.h>
41 #include <linux/videodev2.h>
42 #include <video/sh_mobile_lcdc.h>
43 #include <video/sh_mipi_dsi.h>
44 #include <sound/sh_fsi.h>
45 #include <mach/hardware.h>
46 #include <mach/sh73a0.h>
47 #include <mach/common.h>
48 #include <asm/mach-types.h>
49 #include <asm/mach/arch.h>
50 #include <asm/mach/map.h>
51 #include <asm/mach/time.h>
52 #include <asm/hardware/gic.h>
53 #include <asm/hardware/cache-l2x0.h>
54 #include <asm/traps.h>
56 static struct resource smsc9220_resources
[] = {
59 .end
= 0x14000000 + SZ_64K
- 1,
60 .flags
= IORESOURCE_MEM
,
63 .start
= SH73A0_PINT0_IRQ(2), /* PINTA2 */
64 .flags
= IORESOURCE_IRQ
,
68 static struct smsc911x_platform_config smsc9220_platdata
= {
69 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
70 .phy_interface
= PHY_INTERFACE_MODE_MII
,
71 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
72 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
75 static struct platform_device eth_device
= {
79 .platform_data
= &smsc9220_platdata
,
81 .resource
= smsc9220_resources
,
82 .num_resources
= ARRAY_SIZE(smsc9220_resources
),
85 static struct sh_keysc_info keysc_platdata
= {
86 .mode
= SH_KEYSC_MODE_6
,
90 KEY_A
, KEY_B
, KEY_C
, KEY_D
, KEY_E
, KEY_F
, KEY_G
,
91 KEY_H
, KEY_I
, KEY_J
, KEY_K
, KEY_L
, KEY_M
, KEY_N
,
92 KEY_O
, KEY_P
, KEY_Q
, KEY_R
, KEY_S
, KEY_T
, KEY_U
,
93 KEY_V
, KEY_W
, KEY_X
, KEY_Y
, KEY_Z
, KEY_HOME
, KEY_SLEEP
,
94 KEY_SPACE
, KEY_9
, KEY_6
, KEY_3
, KEY_WAKEUP
, KEY_RIGHT
, \
96 KEY_0
, KEY_8
, KEY_5
, KEY_2
, KEY_DOWN
, KEY_ENTER
, KEY_UP
,
97 KEY_KPASTERISK
, KEY_7
, KEY_4
, KEY_1
, KEY_STOP
, KEY_LEFT
, \
102 static struct resource keysc_resources
[] = {
106 .end
= 0xe61b0098 - 1,
107 .flags
= IORESOURCE_MEM
,
110 .start
= gic_spi(71),
111 .flags
= IORESOURCE_IRQ
,
115 static struct platform_device keysc_device
= {
118 .num_resources
= ARRAY_SIZE(keysc_resources
),
119 .resource
= keysc_resources
,
121 .platform_data
= &keysc_platdata
,
126 static struct resource fsi_resources
[] = {
130 .end
= 0xEC230400 - 1,
131 .flags
= IORESOURCE_MEM
,
134 .start
= gic_spi(146),
135 .flags
= IORESOURCE_IRQ
,
139 static struct platform_device fsi_device
= {
142 .num_resources
= ARRAY_SIZE(fsi_resources
),
143 .resource
= fsi_resources
,
146 static struct resource sh_mmcif_resources
[] = {
151 .flags
= IORESOURCE_MEM
,
154 .start
= gic_spi(141),
155 .flags
= IORESOURCE_IRQ
,
158 .start
= gic_spi(140),
159 .flags
= IORESOURCE_IRQ
,
163 static struct sh_mmcif_plat_data sh_mmcif_platdata
= {
165 .ocr
= MMC_VDD_165_195
,
166 .caps
= MMC_CAP_8_BIT_DATA
| MMC_CAP_NONREMOVABLE
,
167 .slave_id_tx
= SHDMA_SLAVE_MMCIF_TX
,
168 .slave_id_rx
= SHDMA_SLAVE_MMCIF_RX
,
171 static struct platform_device mmc_device
= {
176 .coherent_dma_mask
= 0xffffffff,
177 .platform_data
= &sh_mmcif_platdata
,
179 .num_resources
= ARRAY_SIZE(sh_mmcif_resources
),
180 .resource
= sh_mmcif_resources
,
184 static struct resource irda_resources
[] = {
187 .end
= 0xE6D01FD4 - 1,
188 .flags
= IORESOURCE_MEM
,
191 .start
= gic_spi(95),
192 .flags
= IORESOURCE_IRQ
,
196 static struct platform_device irda_device
= {
199 .resource
= irda_resources
,
200 .num_resources
= ARRAY_SIZE(irda_resources
),
203 static unsigned char lcd_backlight_seq
[3][2] = {
209 static void lcd_backlight_on(void)
211 struct i2c_adapter
*a
;
215 a
= i2c_get_adapter(1);
216 for (k
= 0; a
&& k
< 3; k
++) {
218 msg
.buf
= &lcd_backlight_seq
[k
][0];
221 if (i2c_transfer(a
, &msg
, 1) != 1)
226 static void lcd_backlight_reset(void)
228 gpio_set_value(GPIO_PORT235
, 0);
230 gpio_set_value(GPIO_PORT235
, 1);
233 static void lcd_on(void *board_data
, struct fb_info
*info
)
238 static void lcd_off(void *board_data
)
240 lcd_backlight_reset();
244 static const struct fb_videomode lcdc0_modes
[] = {
246 .name
= "R63302(QHD)",
255 .sync
= FB_SYNC_VERT_HIGH_ACT
| FB_SYNC_HOR_HIGH_ACT
,
259 static struct sh_mobile_lcdc_info lcdc0_info
= {
260 .clock_source
= LCDC_CLK_PERIPHERAL
,
262 .chan
= LCDC_CHAN_MAINLCD
,
263 .interface_type
= RGB24
,
265 .flags
= LCDC_FLAGS_DWPOL
,
266 .lcd_size_cfg
.width
= 44,
267 .lcd_size_cfg
.height
= 79,
268 .fourcc
= V4L2_PIX_FMT_RGB565
,
269 .lcd_cfg
= lcdc0_modes
,
270 .num_cfg
= ARRAY_SIZE(lcdc0_modes
),
272 .display_on
= lcd_on
,
273 .display_off
= lcd_off
,
278 static struct resource lcdc0_resources
[] = {
281 .start
= 0xfe940000, /* P4-only space */
283 .flags
= IORESOURCE_MEM
,
286 .start
= intcs_evt2irq(0x580),
287 .flags
= IORESOURCE_IRQ
,
291 static struct platform_device lcdc0_device
= {
292 .name
= "sh_mobile_lcdc_fb",
293 .num_resources
= ARRAY_SIZE(lcdc0_resources
),
294 .resource
= lcdc0_resources
,
297 .platform_data
= &lcdc0_info
,
298 .coherent_dma_mask
= ~0,
303 static struct resource mipidsi0_resources
[] = {
308 .flags
= IORESOURCE_MEM
,
314 .flags
= IORESOURCE_MEM
,
318 static int sh_mipi_set_dot_clock(struct platform_device
*pdev
,
322 struct clk
*pck
, *phy
;
325 pck
= clk_get(&pdev
->dev
, "dsip_clk");
328 goto sh_mipi_set_dot_clock_pck_err
;
331 phy
= clk_get(&pdev
->dev
, "dsiphy_clk");
334 goto sh_mipi_set_dot_clock_phy_err
;
338 clk_set_rate(pck
, clk_round_rate(pck
, 24000000));
339 clk_set_rate(phy
, clk_round_rate(pck
, 510000000));
350 sh_mipi_set_dot_clock_phy_err
:
352 sh_mipi_set_dot_clock_pck_err
:
356 static struct sh_mipi_dsi_info mipidsi0_info
= {
357 .data_format
= MIPI_RGB888
,
358 .lcd_chan
= &lcdc0_info
.ch
[0],
362 .flags
= SH_MIPI_DSI_HSABM
|
363 SH_MIPI_DSI_SYNC_PULSES_MODE
|
364 SH_MIPI_DSI_HSbyteCLK
,
365 .set_dot_clock
= sh_mipi_set_dot_clock
,
368 static struct platform_device mipidsi0_device
= {
369 .name
= "sh-mipi-dsi",
370 .num_resources
= ARRAY_SIZE(mipidsi0_resources
),
371 .resource
= mipidsi0_resources
,
374 .platform_data
= &mipidsi0_info
,
379 static irqreturn_t
ag5evm_sdhi0_gpio_cd(int irq
, void *arg
)
381 struct device
*dev
= arg
;
382 struct sh_mobile_sdhi_info
*info
= dev
->platform_data
;
383 struct tmio_mmc_data
*pdata
= info
->pdata
;
385 tmio_mmc_cd_wakeup(pdata
);
390 static struct sh_mobile_sdhi_info sdhi0_info
= {
391 .dma_slave_tx
= SHDMA_SLAVE_SDHI0_TX
,
392 .dma_slave_rx
= SHDMA_SLAVE_SDHI0_RX
,
393 .tmio_flags
= TMIO_MMC_HAS_IDLE_WAIT
,
394 .tmio_caps
= MMC_CAP_SD_HIGHSPEED
,
395 .tmio_ocr_mask
= MMC_VDD_27_28
| MMC_VDD_28_29
,
398 static struct resource sdhi0_resources
[] = {
403 .flags
= IORESOURCE_MEM
,
406 .name
= SH_MOBILE_SDHI_IRQ_CARD_DETECT
,
407 .start
= gic_spi(83),
408 .flags
= IORESOURCE_IRQ
,
411 .name
= SH_MOBILE_SDHI_IRQ_SDCARD
,
412 .start
= gic_spi(84),
413 .flags
= IORESOURCE_IRQ
,
416 .name
= SH_MOBILE_SDHI_IRQ_SDIO
,
417 .start
= gic_spi(85),
418 .flags
= IORESOURCE_IRQ
,
422 static struct platform_device sdhi0_device
= {
423 .name
= "sh_mobile_sdhi",
425 .num_resources
= ARRAY_SIZE(sdhi0_resources
),
426 .resource
= sdhi0_resources
,
428 .platform_data
= &sdhi0_info
,
432 void ag5evm_sdhi1_set_pwr(struct platform_device
*pdev
, int state
)
434 gpio_set_value(GPIO_PORT114
, state
);
437 static struct sh_mobile_sdhi_info sh_sdhi1_info
= {
438 .tmio_flags
= TMIO_MMC_WRPROTECT_DISABLE
| TMIO_MMC_HAS_IDLE_WAIT
,
439 .tmio_caps
= MMC_CAP_NONREMOVABLE
| MMC_CAP_SDIO_IRQ
,
440 .tmio_ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
441 .set_pwr
= ag5evm_sdhi1_set_pwr
,
444 static struct resource sdhi1_resources
[] = {
449 .flags
= IORESOURCE_MEM
,
452 .name
= SH_MOBILE_SDHI_IRQ_CARD_DETECT
,
453 .start
= gic_spi(87),
454 .flags
= IORESOURCE_IRQ
,
457 .name
= SH_MOBILE_SDHI_IRQ_SDCARD
,
458 .start
= gic_spi(88),
459 .flags
= IORESOURCE_IRQ
,
462 .name
= SH_MOBILE_SDHI_IRQ_SDIO
,
463 .start
= gic_spi(89),
464 .flags
= IORESOURCE_IRQ
,
468 static struct platform_device sdhi1_device
= {
469 .name
= "sh_mobile_sdhi",
472 .platform_data
= &sh_sdhi1_info
,
474 .num_resources
= ARRAY_SIZE(sdhi1_resources
),
475 .resource
= sdhi1_resources
,
478 static struct platform_device
*ag5evm_devices
[] __initdata
= {
490 static struct map_desc ag5evm_io_desc
[] __initdata
= {
491 /* create a 1:1 entity map for 0xe6xxxxxx
492 * used by CPGA, INTC and PFC.
495 .virtual = 0xe6000000,
496 .pfn
= __phys_to_pfn(0xe6000000),
498 .type
= MT_DEVICE_NONSHARED
502 static void __init
ag5evm_map_io(void)
504 iotable_init(ag5evm_io_desc
, ARRAY_SIZE(ag5evm_io_desc
));
506 /* setup early devices and console here as well */
507 sh73a0_add_early_devices();
508 shmobile_setup_console();
511 static void __init
ag5evm_init(void)
513 sh73a0_pinmux_init();
516 gpio_request(GPIO_FN_SCIFA2_TXD1
, NULL
);
517 gpio_request(GPIO_FN_SCIFA2_RXD1
, NULL
);
518 gpio_request(GPIO_FN_SCIFA2_RTS1_
, NULL
);
519 gpio_request(GPIO_FN_SCIFA2_CTS1_
, NULL
);
522 gpio_request(GPIO_FN_KEYIN0_PU
, NULL
);
523 gpio_request(GPIO_FN_KEYIN1_PU
, NULL
);
524 gpio_request(GPIO_FN_KEYIN2_PU
, NULL
);
525 gpio_request(GPIO_FN_KEYIN3_PU
, NULL
);
526 gpio_request(GPIO_FN_KEYIN4_PU
, NULL
);
527 gpio_request(GPIO_FN_KEYIN5_PU
, NULL
);
528 gpio_request(GPIO_FN_KEYIN6_PU
, NULL
);
529 gpio_request(GPIO_FN_KEYIN7_PU
, NULL
);
530 gpio_request(GPIO_FN_KEYOUT0
, NULL
);
531 gpio_request(GPIO_FN_KEYOUT1
, NULL
);
532 gpio_request(GPIO_FN_KEYOUT2
, NULL
);
533 gpio_request(GPIO_FN_KEYOUT3
, NULL
);
534 gpio_request(GPIO_FN_KEYOUT4
, NULL
);
535 gpio_request(GPIO_FN_KEYOUT5
, NULL
);
536 gpio_request(GPIO_FN_PORT59_KEYOUT6
, NULL
);
537 gpio_request(GPIO_FN_PORT58_KEYOUT7
, NULL
);
538 gpio_request(GPIO_FN_KEYOUT8
, NULL
);
539 gpio_request(GPIO_FN_PORT149_KEYOUT9
, NULL
);
541 /* enable I2C channel 2 and 3 */
542 gpio_request(GPIO_FN_PORT236_I2C_SDA2
, NULL
);
543 gpio_request(GPIO_FN_PORT237_I2C_SCL2
, NULL
);
544 gpio_request(GPIO_FN_PORT248_I2C_SCL3
, NULL
);
545 gpio_request(GPIO_FN_PORT249_I2C_SDA3
, NULL
);
548 gpio_request(GPIO_FN_MMCCLK0
, NULL
);
549 gpio_request(GPIO_FN_MMCCMD0_PU
, NULL
);
550 gpio_request(GPIO_FN_MMCD0_0_PU
, NULL
);
551 gpio_request(GPIO_FN_MMCD0_1_PU
, NULL
);
552 gpio_request(GPIO_FN_MMCD0_2_PU
, NULL
);
553 gpio_request(GPIO_FN_MMCD0_3_PU
, NULL
);
554 gpio_request(GPIO_FN_MMCD0_4_PU
, NULL
);
555 gpio_request(GPIO_FN_MMCD0_5_PU
, NULL
);
556 gpio_request(GPIO_FN_MMCD0_6_PU
, NULL
);
557 gpio_request(GPIO_FN_MMCD0_7_PU
, NULL
);
558 gpio_request(GPIO_PORT208
, NULL
); /* Reset */
559 gpio_direction_output(GPIO_PORT208
, 1);
561 /* enable SMSC911X */
562 gpio_request(GPIO_PORT144
, NULL
); /* PINTA2 */
563 gpio_direction_input(GPIO_PORT144
);
564 gpio_request(GPIO_PORT145
, NULL
); /* RESET */
565 gpio_direction_output(GPIO_PORT145
, 1);
568 gpio_request(GPIO_FN_FSIACK
, NULL
);
569 gpio_request(GPIO_FN_FSIAILR
, NULL
);
570 gpio_request(GPIO_FN_FSIAIBT
, NULL
);
571 gpio_request(GPIO_FN_FSIAISLD
, NULL
);
572 gpio_request(GPIO_FN_FSIAOSLD
, NULL
);
575 gpio_request(GPIO_FN_PORT241_IRDA_OUT
, NULL
);
576 gpio_request(GPIO_FN_PORT242_IRDA_IN
, NULL
);
577 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL
, NULL
);
580 gpio_request(GPIO_PORT217
, NULL
); /* RESET */
581 gpio_direction_output(GPIO_PORT217
, 0);
583 gpio_set_value(GPIO_PORT217
, 1);
586 /* LCD backlight controller */
587 gpio_request(GPIO_PORT235
, NULL
); /* RESET */
588 gpio_direction_output(GPIO_PORT235
, 0);
589 lcd_backlight_reset();
591 /* enable SDHI0 on CN15 [SD I/F] */
592 gpio_request(GPIO_FN_SDHICD0
, NULL
);
593 gpio_request(GPIO_FN_SDHIWP0
, NULL
);
594 gpio_request(GPIO_FN_SDHICMD0
, NULL
);
595 gpio_request(GPIO_FN_SDHICLK0
, NULL
);
596 gpio_request(GPIO_FN_SDHID0_3
, NULL
);
597 gpio_request(GPIO_FN_SDHID0_2
, NULL
);
598 gpio_request(GPIO_FN_SDHID0_1
, NULL
);
599 gpio_request(GPIO_FN_SDHID0_0
, NULL
);
601 if (!request_irq(intcs_evt2irq(0x3c0), ag5evm_sdhi0_gpio_cd
,
602 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
603 "sdhi0 cd", &sdhi0_device
.dev
))
604 sdhi0_info
.tmio_flags
|= TMIO_MMC_HAS_COLD_CD
;
606 pr_warn("Unable to setup SDHI0 GPIO IRQ\n");
608 /* enable SDHI1 on CN4 [WLAN I/F] */
609 gpio_request(GPIO_FN_SDHICLK1
, NULL
);
610 gpio_request(GPIO_FN_SDHICMD1_PU
, NULL
);
611 gpio_request(GPIO_FN_SDHID1_3_PU
, NULL
);
612 gpio_request(GPIO_FN_SDHID1_2_PU
, NULL
);
613 gpio_request(GPIO_FN_SDHID1_1_PU
, NULL
);
614 gpio_request(GPIO_FN_SDHID1_0_PU
, NULL
);
615 gpio_request(GPIO_PORT114
, "sdhi1_power");
616 gpio_direction_output(GPIO_PORT114
, 0);
618 #ifdef CONFIG_CACHE_L2X0
619 /* Shared attribute override enable, 64K*8way */
620 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
622 sh73a0_add_standard_devices();
623 platform_add_devices(ag5evm_devices
, ARRAY_SIZE(ag5evm_devices
));
626 static void __init
ag5evm_timer_init(void)
629 shmobile_timer
.init();
633 struct sys_timer ag5evm_timer
= {
634 .init
= ag5evm_timer_init
,
637 MACHINE_START(AG5EVM
, "ag5evm")
638 .map_io
= ag5evm_map_io
,
639 .nr_irqs
= NR_IRQS_LEGACY
,
640 .init_irq
= sh73a0_init_irq
,
641 .handle_irq
= gic_handle_irq
,
642 .init_machine
= ag5evm_init
,
643 .timer
= &ag5evm_timer
,