ARM: mach-shmobile: armadillo800eva: add support ST1232
[linux-2.6/btrfs-unstable.git] / arch / arm / mach-shmobile / board-armadillo800eva.c
blob4d066f9230dd293a4e3e4f19e6a02a9fb78f0628
1 /*
2 * armadillo 800 eva board support
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@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/clk.h>
23 #include <linux/err.h>
24 #include <linux/kernel.h>
25 #include <linux/input.h>
26 #include <linux/platform_device.h>
27 #include <linux/gpio.h>
28 #include <linux/gpio_keys.h>
29 #include <linux/sh_eth.h>
30 #include <linux/videodev2.h>
31 #include <mach/common.h>
32 #include <mach/irqs.h>
33 #include <asm/page.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach/time.h>
38 #include <asm/hardware/cache-l2x0.h>
39 #include <mach/r8a7740.h>
40 #include <video/sh_mobile_lcdc.h>
43 * CON1 Camera Module
44 * CON2 Extension Bus
45 * CON3 HDMI Output
46 * CON4 Composite Video Output
47 * CON5 H-UDI JTAG
48 * CON6 ARM JTAG
49 * CON7 SD1
50 * CON8 SD2
51 * CON9 RTC BackUp
52 * CON10 Monaural Mic Input
53 * CON11 Stereo Headphone Output
54 * CON12 Audio Line Output(L)
55 * CON13 Audio Line Output(R)
56 * CON14 AWL13 Module
57 * CON15 Extension
58 * CON16 LCD1
59 * CON17 LCD2
60 * CON19 Power Input
61 * CON20 USB1
62 * CON21 USB2
63 * CON22 Serial
64 * CON23 LAN
65 * CON24 USB3
66 * LED1 Camera LED(Yellow)
67 * LED2 Power LED (Green)
68 * ED3-LED6 User LED(Yellow)
69 * LED7 LAN link LED(Green)
70 * LED8 LAN activity LED(Yellow)
74 * DipSwitch
76 * SW1
78 * -12345678-+---------------+----------------------------
79 * 1 | boot | hermit
80 * 0 | boot | OS auto boot
81 * -12345678-+---------------+----------------------------
82 * 00 | boot device | eMMC
83 * 10 | boot device | SDHI0 (CON7)
84 * 01 | boot device | -
85 * 11 | boot device | Extension Buss (CS0)
86 * -12345678-+---------------+----------------------------
87 * 0 | Extension Bus | D8-D15 disable, eMMC enable
88 * 1 | Extension Bus | D8-D15 enable, eMMC disable
89 * -12345678-+---------------+----------------------------
90 * 0 | SDHI1 | COM8 enable, COM14 disable
91 * 1 | SDHI1 | COM8 enable, COM14 disable
92 * -12345678-+---------------+----------------------------
93 * 00 | JTAG | SH-X2
94 * 10 | JTAG | ARM
95 * 01 | JTAG | -
96 * 11 | JTAG | Boundary Scan
97 *-----------+---------------+----------------------------
100 /* Ether */
101 static struct sh_eth_plat_data sh_eth_platdata = {
102 .phy = 0x00, /* LAN8710A */
103 .edmac_endian = EDMAC_LITTLE_ENDIAN,
104 .register_type = SH_ETH_REG_GIGABIT,
105 .phy_interface = PHY_INTERFACE_MODE_MII,
108 static struct resource sh_eth_resources[] = {
110 .start = 0xe9a00000,
111 .end = 0xe9a00800 - 1,
112 .flags = IORESOURCE_MEM,
113 }, {
114 .start = 0xe9a01800,
115 .end = 0xe9a02000 - 1,
116 .flags = IORESOURCE_MEM,
117 }, {
118 .start = evt2irq(0x0500),
119 .flags = IORESOURCE_IRQ,
123 static struct platform_device sh_eth_device = {
124 .name = "sh-eth",
125 .dev = {
126 .platform_data = &sh_eth_platdata,
128 .resource = sh_eth_resources,
129 .num_resources = ARRAY_SIZE(sh_eth_resources),
132 /* LCDC */
133 static struct fb_videomode lcdc0_mode = {
134 .name = "AMPIER/AM-800480",
135 .xres = 800,
136 .yres = 480,
137 .left_margin = 88,
138 .right_margin = 40,
139 .hsync_len = 128,
140 .upper_margin = 20,
141 .lower_margin = 5,
142 .vsync_len = 5,
143 .sync = 0,
146 static struct sh_mobile_lcdc_info lcdc0_info = {
147 .clock_source = LCDC_CLK_BUS,
148 .ch[0] = {
149 .chan = LCDC_CHAN_MAINLCD,
150 .fourcc = V4L2_PIX_FMT_RGB565,
151 .interface_type = RGB24,
152 .clock_divider = 5,
153 .flags = 0,
154 .lcd_modes = &lcdc0_mode,
155 .num_modes = 1,
156 .panel_cfg = {
157 .width = 111,
158 .height = 68,
163 static struct resource lcdc0_resources[] = {
164 [0] = {
165 .name = "LCD0",
166 .start = 0xfe940000,
167 .end = 0xfe943fff,
168 .flags = IORESOURCE_MEM,
170 [1] = {
171 .start = intcs_evt2irq(0x580),
172 .flags = IORESOURCE_IRQ,
176 static struct platform_device lcdc0_device = {
177 .name = "sh_mobile_lcdc_fb",
178 .num_resources = ARRAY_SIZE(lcdc0_resources),
179 .resource = lcdc0_resources,
180 .id = 0,
181 .dev = {
182 .platform_data = &lcdc0_info,
183 .coherent_dma_mask = ~0,
187 /* GPIO KEY */
188 #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
190 static struct gpio_keys_button gpio_buttons[] = {
191 GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"),
192 GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"),
193 GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"),
194 GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"),
197 static struct gpio_keys_platform_data gpio_key_info = {
198 .buttons = gpio_buttons,
199 .nbuttons = ARRAY_SIZE(gpio_buttons),
202 static struct platform_device gpio_keys_device = {
203 .name = "gpio-keys",
204 .id = -1,
205 .dev = {
206 .platform_data = &gpio_key_info,
210 /* I2C */
211 static struct i2c_board_info i2c0_devices[] = {
213 I2C_BOARD_INFO("st1232-ts", 0x55),
214 .irq = evt2irq(0x0340),
219 * board devices
221 static struct platform_device *eva_devices[] __initdata = {
222 &lcdc0_device,
223 &gpio_keys_device,
224 &sh_eth_device,
228 * board init
230 static void __init eva_init(void)
232 r8a7740_pinmux_init();
234 /* SCIFA1 */
235 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
236 gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
238 /* LCDC0 */
239 gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
240 gpio_request(GPIO_FN_LCD0_D0, NULL);
241 gpio_request(GPIO_FN_LCD0_D1, NULL);
242 gpio_request(GPIO_FN_LCD0_D2, NULL);
243 gpio_request(GPIO_FN_LCD0_D3, NULL);
244 gpio_request(GPIO_FN_LCD0_D4, NULL);
245 gpio_request(GPIO_FN_LCD0_D5, NULL);
246 gpio_request(GPIO_FN_LCD0_D6, NULL);
247 gpio_request(GPIO_FN_LCD0_D7, NULL);
248 gpio_request(GPIO_FN_LCD0_D8, NULL);
249 gpio_request(GPIO_FN_LCD0_D9, NULL);
250 gpio_request(GPIO_FN_LCD0_D10, NULL);
251 gpio_request(GPIO_FN_LCD0_D11, NULL);
252 gpio_request(GPIO_FN_LCD0_D12, NULL);
253 gpio_request(GPIO_FN_LCD0_D13, NULL);
254 gpio_request(GPIO_FN_LCD0_D14, NULL);
255 gpio_request(GPIO_FN_LCD0_D15, NULL);
256 gpio_request(GPIO_FN_LCD0_D16, NULL);
257 gpio_request(GPIO_FN_LCD0_D17, NULL);
258 gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL);
259 gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL);
260 gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL);
261 gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL);
262 gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL);
263 gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL);
264 gpio_request(GPIO_FN_LCD0_DCK, NULL);
265 gpio_request(GPIO_FN_LCD0_VSYN, NULL);
266 gpio_request(GPIO_FN_LCD0_HSYN, NULL);
267 gpio_request(GPIO_FN_LCD0_DISP, NULL);
268 gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL);
270 gpio_request(GPIO_PORT61, NULL); /* LCDDON */
271 gpio_direction_output(GPIO_PORT61, 1);
273 gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */
274 gpio_direction_output(GPIO_PORT202, 0);
276 /* Touchscreen */
277 gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */
278 gpio_request(GPIO_PORT166, NULL); /* TP_RST_B */
279 gpio_direction_output(GPIO_PORT166, 1);
281 /* GETHER */
282 gpio_request(GPIO_FN_ET_CRS, NULL);
283 gpio_request(GPIO_FN_ET_MDC, NULL);
284 gpio_request(GPIO_FN_ET_MDIO, NULL);
285 gpio_request(GPIO_FN_ET_TX_ER, NULL);
286 gpio_request(GPIO_FN_ET_RX_ER, NULL);
287 gpio_request(GPIO_FN_ET_ERXD0, NULL);
288 gpio_request(GPIO_FN_ET_ERXD1, NULL);
289 gpio_request(GPIO_FN_ET_ERXD2, NULL);
290 gpio_request(GPIO_FN_ET_ERXD3, NULL);
291 gpio_request(GPIO_FN_ET_TX_CLK, NULL);
292 gpio_request(GPIO_FN_ET_TX_EN, NULL);
293 gpio_request(GPIO_FN_ET_ETXD0, NULL);
294 gpio_request(GPIO_FN_ET_ETXD1, NULL);
295 gpio_request(GPIO_FN_ET_ETXD2, NULL);
296 gpio_request(GPIO_FN_ET_ETXD3, NULL);
297 gpio_request(GPIO_FN_ET_PHY_INT, NULL);
298 gpio_request(GPIO_FN_ET_COL, NULL);
299 gpio_request(GPIO_FN_ET_RX_DV, NULL);
300 gpio_request(GPIO_FN_ET_RX_CLK, NULL);
302 gpio_request(GPIO_PORT18, NULL); /* PHY_RST */
303 gpio_direction_output(GPIO_PORT18, 1);
306 * CAUTION
308 * DBGMD/LCDC0/FSIA MUX
309 * DBGMD_SELECT_B should be set after setting PFC Function.
311 gpio_request(GPIO_PORT176, NULL);
312 gpio_direction_output(GPIO_PORT176, 1);
314 #ifdef CONFIG_CACHE_L2X0
315 /* Early BRESP enable, Shared attribute override enable, 32K*8way */
316 l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
317 #endif
319 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
321 r8a7740_add_standard_devices();
323 platform_add_devices(eva_devices,
324 ARRAY_SIZE(eva_devices));
327 static void __init eva_earlytimer_init(void)
329 struct clk *xtal1;
331 r8a7740_clock_init(MD_CK0 | MD_CK2);
333 xtal1 = clk_get(NULL, "extal1");
334 if (!IS_ERR(xtal1)) {
335 /* armadillo 800 eva extal1 is 24MHz */
336 clk_set_rate(xtal1, 24000000);
337 clk_put(xtal1);
340 shmobile_earlytimer_init();
343 static void __init eva_add_early_devices(void)
345 r8a7740_add_early_devices();
347 /* override timer setup with board-specific code */
348 shmobile_timer.init = eva_earlytimer_init;
351 MACHINE_START(ARMADILLO800EVA, "armadillo800eva")
352 .map_io = r8a7740_map_io,
353 .init_early = eva_add_early_devices,
354 .init_irq = r8a7740_init_irq,
355 .handle_irq = shmobile_handle_irq_intc,
356 .init_machine = eva_init,
357 .timer = &shmobile_timer,
358 MACHINE_END