mac80211: quiesce vif before suspending
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-shmobile / board-ag5evm.c
blob3e6f0aab460bd2382552a5723c738a739fbc4610
1 /*
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>
28 #include <linux/io.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[] = {
53 [0] = {
54 .start = 0x14000000,
55 .end = 0x14000000 + SZ_64K - 1,
56 .flags = IORESOURCE_MEM,
58 [1] = {
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 = {
72 .name = "smsc911x",
73 .id = 0,
74 .dev = {
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,
83 .scan_timing = 3,
84 .delay = 100,
85 .keycodes = {
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, \
91 KEY_COFFEE,
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, \
94 KEY_COMPUTER,
98 static struct resource keysc_resources[] = {
99 [0] = {
100 .name = "KEYSC",
101 .start = 0xe61b0000,
102 .end = 0xe61b0098 - 1,
103 .flags = IORESOURCE_MEM,
105 [1] = {
106 .start = gic_spi(71),
107 .flags = IORESOURCE_IRQ,
111 static struct platform_device keysc_device = {
112 .name = "sh_keysc",
113 .id = 0,
114 .num_resources = ARRAY_SIZE(keysc_resources),
115 .resource = keysc_resources,
116 .dev = {
117 .platform_data = &keysc_platdata,
121 /* FSI A */
122 static struct resource fsi_resources[] = {
123 [0] = {
124 .name = "FSI",
125 .start = 0xEC230000,
126 .end = 0xEC230400 - 1,
127 .flags = IORESOURCE_MEM,
129 [1] = {
130 .start = gic_spi(146),
131 .flags = IORESOURCE_IRQ,
135 static struct platform_device fsi_device = {
136 .name = "sh_fsi2",
137 .id = -1,
138 .num_resources = ARRAY_SIZE(fsi_resources),
139 .resource = fsi_resources,
142 static struct resource sh_mmcif_resources[] = {
143 [0] = {
144 .name = "MMCIF",
145 .start = 0xe6bd0000,
146 .end = 0xe6bd00ff,
147 .flags = IORESOURCE_MEM,
149 [1] = {
150 .start = gic_spi(141),
151 .flags = IORESOURCE_IRQ,
153 [2] = {
154 .start = gic_spi(140),
155 .flags = IORESOURCE_IRQ,
159 static struct sh_mmcif_plat_data sh_mmcif_platdata = {
160 .sup_pclk = 0,
161 .ocr = MMC_VDD_165_195,
162 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
165 static struct platform_device mmc_device = {
166 .name = "sh_mmcif",
167 .id = 0,
168 .dev = {
169 .dma_mask = NULL,
170 .coherent_dma_mask = 0xffffffff,
171 .platform_data = &sh_mmcif_platdata,
173 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
174 .resource = sh_mmcif_resources,
177 /* IrDA */
178 static struct resource irda_resources[] = {
179 [0] = {
180 .start = 0xE6D00000,
181 .end = 0xE6D01FD4 - 1,
182 .flags = IORESOURCE_MEM,
184 [1] = {
185 .start = gic_spi(95),
186 .flags = IORESOURCE_IRQ,
190 static struct platform_device irda_device = {
191 .name = "sh_irda",
192 .id = 0,
193 .resource = irda_resources,
194 .num_resources = ARRAY_SIZE(irda_resources),
197 static unsigned char lcd_backlight_seq[3][2] = {
198 { 0x04, 0x07 },
199 { 0x23, 0x80 },
200 { 0x03, 0x01 },
203 static void lcd_backlight_on(void)
205 struct i2c_adapter *a;
206 struct i2c_msg msg;
207 int k;
209 a = i2c_get_adapter(1);
210 for (k = 0; a && k < 3; k++) {
211 msg.addr = 0x6d;
212 msg.buf = &lcd_backlight_seq[k][0];
213 msg.len = 2;
214 msg.flags = 0;
215 if (i2c_transfer(a, &msg, 1) != 1)
216 break;
220 static void lcd_backlight_reset(void)
222 gpio_set_value(GPIO_PORT235, 0);
223 mdelay(24);
224 gpio_set_value(GPIO_PORT235, 1);
227 static void lcd_on(void *board_data, struct fb_info *info)
229 lcd_backlight_on();
232 static void lcd_off(void *board_data)
234 lcd_backlight_reset();
237 /* LCDC0 */
238 static const struct fb_videomode lcdc0_modes[] = {
240 .name = "R63302(QHD)",
241 .xres = 544,
242 .yres = 961,
243 .left_margin = 72,
244 .right_margin = 600,
245 .hsync_len = 16,
246 .upper_margin = 8,
247 .lower_margin = 8,
248 .vsync_len = 2,
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,
255 .ch[0] = {
256 .chan = LCDC_CHAN_MAINLCD,
257 .interface_type = RGB24,
258 .clock_divider = 1,
259 .flags = LCDC_FLAGS_DWPOL,
260 .lcd_size_cfg.width = 44,
261 .lcd_size_cfg.height = 79,
262 .bpp = 16,
263 .lcd_cfg = lcdc0_modes,
264 .num_cfg = ARRAY_SIZE(lcdc0_modes),
265 .board_cfg = {
266 .display_on = lcd_on,
267 .display_off = lcd_off,
272 static struct resource lcdc0_resources[] = {
273 [0] = {
274 .name = "LCDC0",
275 .start = 0xfe940000, /* P4-only space */
276 .end = 0xfe943fff,
277 .flags = IORESOURCE_MEM,
279 [1] = {
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,
289 .id = 0,
290 .dev = {
291 .platform_data = &lcdc0_info,
292 .coherent_dma_mask = ~0,
296 /* MIPI-DSI */
297 static struct resource mipidsi0_resources[] = {
298 [0] = {
299 .start = 0xfeab0000,
300 .end = 0xfeab3fff,
301 .flags = IORESOURCE_MEM,
303 [1] = {
304 .start = 0xfeab4000,
305 .end = 0xfeab7fff,
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],
313 .vsynw_offset = 20,
314 .clksrc = 1,
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,
322 .id = 0,
323 .dev = {
324 .platform_data = &mipidsi0_info,
328 static struct platform_device *ag5evm_devices[] __initdata = {
329 &eth_device,
330 &keysc_device,
331 &fsi_device,
332 &mmc_device,
333 &irda_device,
334 &lcdc0_device,
335 &mipidsi0_device,
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),
345 .length = 256 << 20,
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)
365 sh73a0_init_irq();
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();
378 /* enable SCIFA2 */
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);
384 /* enable KEYSC */
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);
410 /* enable MMCIF */
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);
430 /* FSI A */
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);
437 /* IrDA */
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);
442 /* LCD panel */
443 gpio_request(GPIO_PORT217, NULL); /* RESET */
444 gpio_direction_output(GPIO_PORT217, 0);
445 mdelay(1);
446 gpio_set_value(GPIO_PORT217, 1);
447 mdelay(100);
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);
460 #endif
461 sh73a0_add_standard_devices();
462 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
465 static void __init ag5evm_timer_init(void)
467 sh73a0_clock_init();
468 shmobile_timer.init();
469 return;
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,
482 MACHINE_END