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 resource fsi_resources
[] = {
126 .end
= 0xEC230400 - 1,
127 .flags
= IORESOURCE_MEM
,
130 .start
= gic_spi(146),
131 .flags
= IORESOURCE_IRQ
,
135 static struct platform_device fsi_device
= {
138 .num_resources
= ARRAY_SIZE(fsi_resources
),
139 .resource
= fsi_resources
,
142 static struct resource sh_mmcif_resources
[] = {
147 .flags
= IORESOURCE_MEM
,
150 .start
= gic_spi(141),
151 .flags
= IORESOURCE_IRQ
,
154 .start
= gic_spi(140),
155 .flags
= IORESOURCE_IRQ
,
159 static struct sh_mmcif_plat_data sh_mmcif_platdata
= {
161 .ocr
= MMC_VDD_165_195
,
162 .caps
= MMC_CAP_8_BIT_DATA
| MMC_CAP_NONREMOVABLE
,
165 static struct platform_device mmc_device
= {
170 .coherent_dma_mask
= 0xffffffff,
171 .platform_data
= &sh_mmcif_platdata
,
173 .num_resources
= ARRAY_SIZE(sh_mmcif_resources
),
174 .resource
= sh_mmcif_resources
,
178 static struct resource irda_resources
[] = {
181 .end
= 0xE6D01FD4 - 1,
182 .flags
= IORESOURCE_MEM
,
185 .start
= gic_spi(95),
186 .flags
= IORESOURCE_IRQ
,
190 static struct platform_device irda_device
= {
193 .resource
= irda_resources
,
194 .num_resources
= ARRAY_SIZE(irda_resources
),
197 static unsigned char lcd_backlight_seq
[3][2] = {
203 static void lcd_backlight_on(void)
205 struct i2c_adapter
*a
;
209 a
= i2c_get_adapter(1);
210 for (k
= 0; a
&& k
< 3; k
++) {
212 msg
.buf
= &lcd_backlight_seq
[k
][0];
215 if (i2c_transfer(a
, &msg
, 1) != 1)
220 static void lcd_backlight_reset(void)
222 gpio_set_value(GPIO_PORT235
, 0);
224 gpio_set_value(GPIO_PORT235
, 1);
227 static void lcd_on(void *board_data
, struct fb_info
*info
)
232 static void lcd_off(void *board_data
)
234 lcd_backlight_reset();
238 static const struct fb_videomode lcdc0_modes
[] = {
240 .name
= "R63302(QHD)",
249 .sync
= FB_SYNC_VERT_HIGH_ACT
| FB_SYNC_HOR_HIGH_ACT
,
253 static struct sh_mobile_lcdc_info lcdc0_info
= {
254 .clock_source
= LCDC_CLK_PERIPHERAL
,
256 .chan
= LCDC_CHAN_MAINLCD
,
257 .interface_type
= RGB24
,
259 .flags
= LCDC_FLAGS_DWPOL
,
260 .lcd_size_cfg
.width
= 44,
261 .lcd_size_cfg
.height
= 79,
263 .lcd_cfg
= lcdc0_modes
,
264 .num_cfg
= ARRAY_SIZE(lcdc0_modes
),
266 .display_on
= lcd_on
,
267 .display_off
= lcd_off
,
272 static struct resource lcdc0_resources
[] = {
275 .start
= 0xfe940000, /* P4-only space */
277 .flags
= IORESOURCE_MEM
,
280 .start
= intcs_evt2irq(0x580),
281 .flags
= IORESOURCE_IRQ
,
285 static struct platform_device lcdc0_device
= {
286 .name
= "sh_mobile_lcdc_fb",
287 .num_resources
= ARRAY_SIZE(lcdc0_resources
),
288 .resource
= lcdc0_resources
,
291 .platform_data
= &lcdc0_info
,
292 .coherent_dma_mask
= ~0,
297 static struct resource mipidsi0_resources
[] = {
301 .flags
= IORESOURCE_MEM
,
306 .flags
= IORESOURCE_MEM
,
310 static struct sh_mipi_dsi_info mipidsi0_info
= {
311 .data_format
= MIPI_RGB888
,
312 .lcd_chan
= &lcdc0_info
.ch
[0],
315 .flags
= SH_MIPI_DSI_HSABM
,
318 static struct platform_device mipidsi0_device
= {
319 .name
= "sh-mipi-dsi",
320 .num_resources
= ARRAY_SIZE(mipidsi0_resources
),
321 .resource
= mipidsi0_resources
,
324 .platform_data
= &mipidsi0_info
,
328 static struct platform_device
*ag5evm_devices
[] __initdata
= {
338 static struct map_desc ag5evm_io_desc
[] __initdata
= {
339 /* create a 1:1 entity map for 0xe6xxxxxx
340 * used by CPGA, INTC and PFC.
343 .virtual = 0xe6000000,
344 .pfn
= __phys_to_pfn(0xe6000000),
346 .type
= MT_DEVICE_NONSHARED
350 static void __init
ag5evm_map_io(void)
352 iotable_init(ag5evm_io_desc
, ARRAY_SIZE(ag5evm_io_desc
));
354 /* setup early devices and console here as well */
355 sh73a0_add_early_devices();
356 shmobile_setup_console();
359 #define PINTC_ADDR 0xe6900000
360 #define PINTER0A (PINTC_ADDR + 0xa0)
361 #define PINTCR0A (PINTC_ADDR + 0xb0)
363 void __init
ag5evm_init_irq(void)
367 /* setup PINT: enable PINTA2 as active low */
368 __raw_writel(__raw_readl(PINTER0A
) | (1<<29), PINTER0A
);
369 __raw_writew(__raw_readw(PINTCR0A
) | (2<<10), PINTCR0A
);
372 #define DSI0PHYCR 0xe615006c
374 static void __init
ag5evm_init(void)
376 sh73a0_pinmux_init();
379 gpio_request(GPIO_FN_SCIFA2_TXD1
, NULL
);
380 gpio_request(GPIO_FN_SCIFA2_RXD1
, NULL
);
381 gpio_request(GPIO_FN_SCIFA2_RTS1_
, NULL
);
382 gpio_request(GPIO_FN_SCIFA2_CTS1_
, NULL
);
385 gpio_request(GPIO_FN_KEYIN0_PU
, NULL
);
386 gpio_request(GPIO_FN_KEYIN1_PU
, NULL
);
387 gpio_request(GPIO_FN_KEYIN2_PU
, NULL
);
388 gpio_request(GPIO_FN_KEYIN3_PU
, NULL
);
389 gpio_request(GPIO_FN_KEYIN4_PU
, NULL
);
390 gpio_request(GPIO_FN_KEYIN5_PU
, NULL
);
391 gpio_request(GPIO_FN_KEYIN6_PU
, NULL
);
392 gpio_request(GPIO_FN_KEYIN7_PU
, NULL
);
393 gpio_request(GPIO_FN_KEYOUT0
, NULL
);
394 gpio_request(GPIO_FN_KEYOUT1
, NULL
);
395 gpio_request(GPIO_FN_KEYOUT2
, NULL
);
396 gpio_request(GPIO_FN_KEYOUT3
, NULL
);
397 gpio_request(GPIO_FN_KEYOUT4
, NULL
);
398 gpio_request(GPIO_FN_KEYOUT5
, NULL
);
399 gpio_request(GPIO_FN_PORT59_KEYOUT6
, NULL
);
400 gpio_request(GPIO_FN_PORT58_KEYOUT7
, NULL
);
401 gpio_request(GPIO_FN_KEYOUT8
, NULL
);
402 gpio_request(GPIO_FN_PORT149_KEYOUT9
, NULL
);
404 /* enable I2C channel 2 and 3 */
405 gpio_request(GPIO_FN_PORT236_I2C_SDA2
, NULL
);
406 gpio_request(GPIO_FN_PORT237_I2C_SCL2
, NULL
);
407 gpio_request(GPIO_FN_PORT248_I2C_SCL3
, NULL
);
408 gpio_request(GPIO_FN_PORT249_I2C_SDA3
, NULL
);
411 gpio_request(GPIO_FN_MMCCLK0
, NULL
);
412 gpio_request(GPIO_FN_MMCCMD0_PU
, NULL
);
413 gpio_request(GPIO_FN_MMCD0_0
, NULL
);
414 gpio_request(GPIO_FN_MMCD0_1
, NULL
);
415 gpio_request(GPIO_FN_MMCD0_2
, NULL
);
416 gpio_request(GPIO_FN_MMCD0_3
, NULL
);
417 gpio_request(GPIO_FN_MMCD0_4
, NULL
);
418 gpio_request(GPIO_FN_MMCD0_5
, NULL
);
419 gpio_request(GPIO_FN_MMCD0_6
, NULL
);
420 gpio_request(GPIO_FN_MMCD0_7
, NULL
);
421 gpio_request(GPIO_PORT208
, NULL
); /* Reset */
422 gpio_direction_output(GPIO_PORT208
, 1);
424 /* enable SMSC911X */
425 gpio_request(GPIO_PORT144
, NULL
); /* PINTA2 */
426 gpio_direction_input(GPIO_PORT144
);
427 gpio_request(GPIO_PORT145
, NULL
); /* RESET */
428 gpio_direction_output(GPIO_PORT145
, 1);
431 gpio_request(GPIO_FN_FSIACK
, NULL
);
432 gpio_request(GPIO_FN_FSIAILR
, NULL
);
433 gpio_request(GPIO_FN_FSIAIBT
, NULL
);
434 gpio_request(GPIO_FN_FSIAISLD
, NULL
);
435 gpio_request(GPIO_FN_FSIAOSLD
, NULL
);
438 gpio_request(GPIO_FN_PORT241_IRDA_OUT
, NULL
);
439 gpio_request(GPIO_FN_PORT242_IRDA_IN
, NULL
);
440 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL
, NULL
);
443 gpio_request(GPIO_PORT217
, NULL
); /* RESET */
444 gpio_direction_output(GPIO_PORT217
, 0);
446 gpio_set_value(GPIO_PORT217
, 1);
449 /* LCD backlight controller */
450 gpio_request(GPIO_PORT235
, NULL
); /* RESET */
451 gpio_direction_output(GPIO_PORT235
, 0);
452 lcd_backlight_reset();
454 /* MIPI-DSI clock setup */
455 __raw_writel(0x2a809010, DSI0PHYCR
);
457 #ifdef CONFIG_CACHE_L2X0
458 /* Shared attribute override enable, 64K*8way */
459 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
461 sh73a0_add_standard_devices();
462 platform_add_devices(ag5evm_devices
, ARRAY_SIZE(ag5evm_devices
));
465 static void __init
ag5evm_timer_init(void)
468 shmobile_timer
.init();
472 struct sys_timer ag5evm_timer
= {
473 .init
= ag5evm_timer_init
,
476 MACHINE_START(AG5EVM
, "ag5evm")
477 .map_io
= ag5evm_map_io
,
478 .init_irq
= ag5evm_init_irq
,
479 .handle_irq
= shmobile_handle_irq_gic
,
480 .init_machine
= ag5evm_init
,
481 .timer
= &ag5evm_timer
,