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/irqs.h>
47 #include <mach/sh73a0.h>
48 #include <mach/common.h>
49 #include <asm/mach-types.h>
50 #include <asm/mach/arch.h>
51 #include <asm/hardware/gic.h>
52 #include <asm/hardware/cache-l2x0.h>
53 #include <asm/traps.h>
55 static struct resource smsc9220_resources
[] = {
58 .end
= 0x14000000 + SZ_64K
- 1,
59 .flags
= IORESOURCE_MEM
,
62 .start
= SH73A0_PINT0_IRQ(2), /* PINTA2 */
63 .flags
= IORESOURCE_IRQ
,
67 static struct smsc911x_platform_config smsc9220_platdata
= {
68 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
69 .phy_interface
= PHY_INTERFACE_MODE_MII
,
70 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
71 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
74 static struct platform_device eth_device
= {
78 .platform_data
= &smsc9220_platdata
,
80 .resource
= smsc9220_resources
,
81 .num_resources
= ARRAY_SIZE(smsc9220_resources
),
84 static struct sh_keysc_info keysc_platdata
= {
85 .mode
= SH_KEYSC_MODE_6
,
89 KEY_A
, KEY_B
, KEY_C
, KEY_D
, KEY_E
, KEY_F
, KEY_G
,
90 KEY_H
, KEY_I
, KEY_J
, KEY_K
, KEY_L
, KEY_M
, KEY_N
,
91 KEY_O
, KEY_P
, KEY_Q
, KEY_R
, KEY_S
, KEY_T
, KEY_U
,
92 KEY_V
, KEY_W
, KEY_X
, KEY_Y
, KEY_Z
, KEY_HOME
, KEY_SLEEP
,
93 KEY_SPACE
, KEY_9
, KEY_6
, KEY_3
, KEY_WAKEUP
, KEY_RIGHT
, \
95 KEY_0
, KEY_8
, KEY_5
, KEY_2
, KEY_DOWN
, KEY_ENTER
, KEY_UP
,
96 KEY_KPASTERISK
, KEY_7
, KEY_4
, KEY_1
, KEY_STOP
, KEY_LEFT
, \
101 static struct resource keysc_resources
[] = {
105 .end
= 0xe61b0098 - 1,
106 .flags
= IORESOURCE_MEM
,
109 .start
= gic_spi(71),
110 .flags
= IORESOURCE_IRQ
,
114 static struct platform_device keysc_device
= {
117 .num_resources
= ARRAY_SIZE(keysc_resources
),
118 .resource
= keysc_resources
,
120 .platform_data
= &keysc_platdata
,
125 static struct resource fsi_resources
[] = {
129 .end
= 0xEC230400 - 1,
130 .flags
= IORESOURCE_MEM
,
133 .start
= gic_spi(146),
134 .flags
= IORESOURCE_IRQ
,
138 static struct platform_device fsi_device
= {
141 .num_resources
= ARRAY_SIZE(fsi_resources
),
142 .resource
= fsi_resources
,
145 static struct resource sh_mmcif_resources
[] = {
150 .flags
= IORESOURCE_MEM
,
153 .start
= gic_spi(141),
154 .flags
= IORESOURCE_IRQ
,
157 .start
= gic_spi(140),
158 .flags
= IORESOURCE_IRQ
,
162 static struct sh_mmcif_plat_data sh_mmcif_platdata
= {
164 .ocr
= MMC_VDD_165_195
,
165 .caps
= MMC_CAP_8_BIT_DATA
| MMC_CAP_NONREMOVABLE
,
166 .slave_id_tx
= SHDMA_SLAVE_MMCIF_TX
,
167 .slave_id_rx
= SHDMA_SLAVE_MMCIF_RX
,
170 static struct platform_device mmc_device
= {
175 .coherent_dma_mask
= 0xffffffff,
176 .platform_data
= &sh_mmcif_platdata
,
178 .num_resources
= ARRAY_SIZE(sh_mmcif_resources
),
179 .resource
= sh_mmcif_resources
,
183 static struct resource irda_resources
[] = {
186 .end
= 0xE6D01FD4 - 1,
187 .flags
= IORESOURCE_MEM
,
190 .start
= gic_spi(95),
191 .flags
= IORESOURCE_IRQ
,
195 static struct platform_device irda_device
= {
198 .resource
= irda_resources
,
199 .num_resources
= ARRAY_SIZE(irda_resources
),
202 static unsigned char lcd_backlight_seq
[3][2] = {
208 static void lcd_backlight_on(void)
210 struct i2c_adapter
*a
;
214 a
= i2c_get_adapter(1);
215 for (k
= 0; a
&& k
< 3; k
++) {
217 msg
.buf
= &lcd_backlight_seq
[k
][0];
220 if (i2c_transfer(a
, &msg
, 1) != 1)
225 static void lcd_backlight_reset(void)
227 gpio_set_value(GPIO_PORT235
, 0);
229 gpio_set_value(GPIO_PORT235
, 1);
233 static const struct fb_videomode lcdc0_modes
[] = {
235 .name
= "R63302(QHD)",
244 .sync
= FB_SYNC_VERT_HIGH_ACT
| FB_SYNC_HOR_HIGH_ACT
,
248 static struct sh_mobile_lcdc_info lcdc0_info
= {
249 .clock_source
= LCDC_CLK_PERIPHERAL
,
251 .chan
= LCDC_CHAN_MAINLCD
,
252 .interface_type
= RGB24
,
254 .flags
= LCDC_FLAGS_DWPOL
,
255 .fourcc
= V4L2_PIX_FMT_RGB565
,
256 .lcd_modes
= lcdc0_modes
,
257 .num_modes
= ARRAY_SIZE(lcdc0_modes
),
261 .display_on
= lcd_backlight_on
,
262 .display_off
= lcd_backlight_reset
,
267 static struct resource lcdc0_resources
[] = {
270 .start
= 0xfe940000, /* P4-only space */
272 .flags
= IORESOURCE_MEM
,
275 .start
= intcs_evt2irq(0x580),
276 .flags
= IORESOURCE_IRQ
,
280 static struct platform_device lcdc0_device
= {
281 .name
= "sh_mobile_lcdc_fb",
282 .num_resources
= ARRAY_SIZE(lcdc0_resources
),
283 .resource
= lcdc0_resources
,
286 .platform_data
= &lcdc0_info
,
287 .coherent_dma_mask
= ~0,
292 static struct resource mipidsi0_resources
[] = {
297 .flags
= IORESOURCE_MEM
,
303 .flags
= IORESOURCE_MEM
,
307 static int sh_mipi_set_dot_clock(struct platform_device
*pdev
,
311 struct clk
*pck
, *phy
;
314 pck
= clk_get(&pdev
->dev
, "dsip_clk");
317 goto sh_mipi_set_dot_clock_pck_err
;
320 phy
= clk_get(&pdev
->dev
, "dsiphy_clk");
323 goto sh_mipi_set_dot_clock_phy_err
;
327 clk_set_rate(pck
, clk_round_rate(pck
, 24000000));
328 clk_set_rate(phy
, clk_round_rate(pck
, 510000000));
339 sh_mipi_set_dot_clock_phy_err
:
341 sh_mipi_set_dot_clock_pck_err
:
345 static struct sh_mipi_dsi_info mipidsi0_info
= {
346 .data_format
= MIPI_RGB888
,
347 .lcd_chan
= &lcdc0_info
.ch
[0],
351 .flags
= SH_MIPI_DSI_HSABM
|
352 SH_MIPI_DSI_SYNC_PULSES_MODE
|
353 SH_MIPI_DSI_HSbyteCLK
,
354 .set_dot_clock
= sh_mipi_set_dot_clock
,
357 static struct platform_device mipidsi0_device
= {
358 .name
= "sh-mipi-dsi",
359 .num_resources
= ARRAY_SIZE(mipidsi0_resources
),
360 .resource
= mipidsi0_resources
,
363 .platform_data
= &mipidsi0_info
,
368 static struct sh_mobile_sdhi_info sdhi0_info
= {
369 .dma_slave_tx
= SHDMA_SLAVE_SDHI0_TX
,
370 .dma_slave_rx
= SHDMA_SLAVE_SDHI0_RX
,
371 .tmio_flags
= TMIO_MMC_HAS_IDLE_WAIT
| TMIO_MMC_USE_GPIO_CD
,
372 .tmio_caps
= MMC_CAP_SD_HIGHSPEED
,
373 .tmio_ocr_mask
= MMC_VDD_27_28
| MMC_VDD_28_29
,
374 .cd_gpio
= GPIO_PORT251
,
377 static struct resource sdhi0_resources
[] = {
382 .flags
= IORESOURCE_MEM
,
385 .name
= SH_MOBILE_SDHI_IRQ_CARD_DETECT
,
386 .start
= gic_spi(83),
387 .flags
= IORESOURCE_IRQ
,
390 .name
= SH_MOBILE_SDHI_IRQ_SDCARD
,
391 .start
= gic_spi(84),
392 .flags
= IORESOURCE_IRQ
,
395 .name
= SH_MOBILE_SDHI_IRQ_SDIO
,
396 .start
= gic_spi(85),
397 .flags
= IORESOURCE_IRQ
,
401 static struct platform_device sdhi0_device
= {
402 .name
= "sh_mobile_sdhi",
404 .num_resources
= ARRAY_SIZE(sdhi0_resources
),
405 .resource
= sdhi0_resources
,
407 .platform_data
= &sdhi0_info
,
411 void ag5evm_sdhi1_set_pwr(struct platform_device
*pdev
, int state
)
413 gpio_set_value(GPIO_PORT114
, state
);
416 static struct sh_mobile_sdhi_info sh_sdhi1_info
= {
417 .tmio_flags
= TMIO_MMC_WRPROTECT_DISABLE
| TMIO_MMC_HAS_IDLE_WAIT
,
418 .tmio_caps
= MMC_CAP_NONREMOVABLE
| MMC_CAP_SDIO_IRQ
,
419 .tmio_ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
420 .set_pwr
= ag5evm_sdhi1_set_pwr
,
423 static struct resource sdhi1_resources
[] = {
428 .flags
= IORESOURCE_MEM
,
431 .name
= SH_MOBILE_SDHI_IRQ_CARD_DETECT
,
432 .start
= gic_spi(87),
433 .flags
= IORESOURCE_IRQ
,
436 .name
= SH_MOBILE_SDHI_IRQ_SDCARD
,
437 .start
= gic_spi(88),
438 .flags
= IORESOURCE_IRQ
,
441 .name
= SH_MOBILE_SDHI_IRQ_SDIO
,
442 .start
= gic_spi(89),
443 .flags
= IORESOURCE_IRQ
,
447 static struct platform_device sdhi1_device
= {
448 .name
= "sh_mobile_sdhi",
451 .platform_data
= &sh_sdhi1_info
,
453 .num_resources
= ARRAY_SIZE(sdhi1_resources
),
454 .resource
= sdhi1_resources
,
457 static struct platform_device
*ag5evm_devices
[] __initdata
= {
469 static void __init
ag5evm_init(void)
471 sh73a0_pinmux_init();
474 gpio_request(GPIO_FN_SCIFA2_TXD1
, NULL
);
475 gpio_request(GPIO_FN_SCIFA2_RXD1
, NULL
);
476 gpio_request(GPIO_FN_SCIFA2_RTS1_
, NULL
);
477 gpio_request(GPIO_FN_SCIFA2_CTS1_
, NULL
);
480 gpio_request(GPIO_FN_KEYIN0_PU
, NULL
);
481 gpio_request(GPIO_FN_KEYIN1_PU
, NULL
);
482 gpio_request(GPIO_FN_KEYIN2_PU
, NULL
);
483 gpio_request(GPIO_FN_KEYIN3_PU
, NULL
);
484 gpio_request(GPIO_FN_KEYIN4_PU
, NULL
);
485 gpio_request(GPIO_FN_KEYIN5_PU
, NULL
);
486 gpio_request(GPIO_FN_KEYIN6_PU
, NULL
);
487 gpio_request(GPIO_FN_KEYIN7_PU
, NULL
);
488 gpio_request(GPIO_FN_KEYOUT0
, NULL
);
489 gpio_request(GPIO_FN_KEYOUT1
, NULL
);
490 gpio_request(GPIO_FN_KEYOUT2
, NULL
);
491 gpio_request(GPIO_FN_KEYOUT3
, NULL
);
492 gpio_request(GPIO_FN_KEYOUT4
, NULL
);
493 gpio_request(GPIO_FN_KEYOUT5
, NULL
);
494 gpio_request(GPIO_FN_PORT59_KEYOUT6
, NULL
);
495 gpio_request(GPIO_FN_PORT58_KEYOUT7
, NULL
);
496 gpio_request(GPIO_FN_KEYOUT8
, NULL
);
497 gpio_request(GPIO_FN_PORT149_KEYOUT9
, NULL
);
499 /* enable I2C channel 2 and 3 */
500 gpio_request(GPIO_FN_PORT236_I2C_SDA2
, NULL
);
501 gpio_request(GPIO_FN_PORT237_I2C_SCL2
, NULL
);
502 gpio_request(GPIO_FN_PORT248_I2C_SCL3
, NULL
);
503 gpio_request(GPIO_FN_PORT249_I2C_SDA3
, NULL
);
506 gpio_request(GPIO_FN_MMCCLK0
, NULL
);
507 gpio_request(GPIO_FN_MMCCMD0_PU
, NULL
);
508 gpio_request(GPIO_FN_MMCD0_0_PU
, NULL
);
509 gpio_request(GPIO_FN_MMCD0_1_PU
, NULL
);
510 gpio_request(GPIO_FN_MMCD0_2_PU
, NULL
);
511 gpio_request(GPIO_FN_MMCD0_3_PU
, NULL
);
512 gpio_request(GPIO_FN_MMCD0_4_PU
, NULL
);
513 gpio_request(GPIO_FN_MMCD0_5_PU
, NULL
);
514 gpio_request(GPIO_FN_MMCD0_6_PU
, NULL
);
515 gpio_request(GPIO_FN_MMCD0_7_PU
, NULL
);
516 gpio_request(GPIO_PORT208
, NULL
); /* Reset */
517 gpio_direction_output(GPIO_PORT208
, 1);
519 /* enable SMSC911X */
520 gpio_request(GPIO_PORT144
, NULL
); /* PINTA2 */
521 gpio_direction_input(GPIO_PORT144
);
522 gpio_request(GPIO_PORT145
, NULL
); /* RESET */
523 gpio_direction_output(GPIO_PORT145
, 1);
526 gpio_request(GPIO_FN_FSIACK
, NULL
);
527 gpio_request(GPIO_FN_FSIAILR
, NULL
);
528 gpio_request(GPIO_FN_FSIAIBT
, NULL
);
529 gpio_request(GPIO_FN_FSIAISLD
, NULL
);
530 gpio_request(GPIO_FN_FSIAOSLD
, NULL
);
533 gpio_request(GPIO_FN_PORT241_IRDA_OUT
, NULL
);
534 gpio_request(GPIO_FN_PORT242_IRDA_IN
, NULL
);
535 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL
, NULL
);
538 gpio_request(GPIO_PORT217
, NULL
); /* RESET */
539 gpio_direction_output(GPIO_PORT217
, 0);
541 gpio_set_value(GPIO_PORT217
, 1);
544 /* LCD backlight controller */
545 gpio_request(GPIO_PORT235
, NULL
); /* RESET */
546 gpio_direction_output(GPIO_PORT235
, 0);
547 lcd_backlight_reset();
549 /* enable SDHI0 on CN15 [SD I/F] */
550 gpio_request(GPIO_FN_SDHIWP0
, NULL
);
551 gpio_request(GPIO_FN_SDHICMD0
, NULL
);
552 gpio_request(GPIO_FN_SDHICLK0
, NULL
);
553 gpio_request(GPIO_FN_SDHID0_3
, NULL
);
554 gpio_request(GPIO_FN_SDHID0_2
, NULL
);
555 gpio_request(GPIO_FN_SDHID0_1
, NULL
);
556 gpio_request(GPIO_FN_SDHID0_0
, NULL
);
558 /* enable SDHI1 on CN4 [WLAN I/F] */
559 gpio_request(GPIO_FN_SDHICLK1
, NULL
);
560 gpio_request(GPIO_FN_SDHICMD1_PU
, NULL
);
561 gpio_request(GPIO_FN_SDHID1_3_PU
, NULL
);
562 gpio_request(GPIO_FN_SDHID1_2_PU
, NULL
);
563 gpio_request(GPIO_FN_SDHID1_1_PU
, NULL
);
564 gpio_request(GPIO_FN_SDHID1_0_PU
, NULL
);
565 gpio_request(GPIO_PORT114
, "sdhi1_power");
566 gpio_direction_output(GPIO_PORT114
, 0);
568 #ifdef CONFIG_CACHE_L2X0
569 /* Shared attribute override enable, 64K*8way */
570 l2x0_init(IOMEM(0xf0100000), 0x00460000, 0xc2000fff);
572 sh73a0_add_standard_devices();
573 platform_add_devices(ag5evm_devices
, ARRAY_SIZE(ag5evm_devices
));
576 MACHINE_START(AG5EVM
, "ag5evm")
577 .map_io
= sh73a0_map_io
,
578 .init_early
= sh73a0_add_early_devices
,
579 .nr_irqs
= NR_IRQS_LEGACY
,
580 .init_irq
= sh73a0_init_irq
,
581 .handle_irq
= gic_handle_irq
,
582 .init_machine
= ag5evm_init
,
583 .timer
= &shmobile_timer
,