IGEPv2: Added WIFI support
[linux-2.6/kvm.git] / arch / arm / mach-omap2 / board-igep0020.c
blob4a5d663e28699255f6dc7e117261dd8482f561c2
1 /*
2 * Copyright (C) 2009 Integration Software and Electronic Engineering.
4 * Modified from mach-omap2/board-generic.c
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/err.h>
16 #include <linux/clk.h>
17 #include <linux/io.h>
18 #include <linux/gpio.h>
19 #include <linux/interrupt.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/i2c/twl.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
27 #include <plat/board.h>
28 #include <plat/common.h>
29 #include <plat/gpmc.h>
30 #include <plat/usb.h>
31 #include <plat/display.h>
32 #include <plat/onenand.h>
34 #include "mux.h"
35 #include "hsmmc.h"
36 #include "sdram-numonyx-m65kxxxxam.h"
38 #define IGEP2_SMSC911X_CS 5
39 #define IGEP2_SMSC911X_GPIO 176
40 #define IGEP2_GPIO_USBH_NRESET 24
41 #define IGEP2_GPIO_LED0_RED 26
42 #define IGEP2_GPIO_LED0_GREEN 27
43 #define IGEP2_GPIO_LED1_RED 28
44 #define IGEP2_GPIO_DVI_PUP 170
45 #define IGEP2_GPIO_WIFI_NPD 94
46 #define IGEP2_GPIO_WIFI_NRESET 95
48 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
49 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
51 #define ONENAND_MAP 0x20000000
53 /* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY )
54 * Since the device is equipped with two DataRAMs, and two-plane NAND
55 * Flash memory array, these two component enables simultaneous program
56 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
57 * while Plane2 has only odd blocks such as block1, block3, block5.
58 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
61 static struct mtd_partition igep2_onenand_partitions[] = {
63 .name = "X-Loader",
64 .offset = 0,
65 .size = 2 * (64*(2*2048))
68 .name = "U-Boot",
69 .offset = MTDPART_OFS_APPEND,
70 .size = 6 * (64*(2*2048)),
73 .name = "Environment",
74 .offset = MTDPART_OFS_APPEND,
75 .size = 2 * (64*(2*2048)),
78 .name = "Kernel",
79 .offset = MTDPART_OFS_APPEND,
80 .size = 12 * (64*(2*2048)),
83 .name = "File System",
84 .offset = MTDPART_OFS_APPEND,
85 .size = MTDPART_SIZ_FULL,
89 static int igep2_onenand_setup(void __iomem *onenand_base, int freq)
91 /* nothing is required to be setup for onenand as of now */
92 return 0;
95 static struct omap_onenand_platform_data igep2_onenand_data = {
96 .parts = igep2_onenand_partitions,
97 .nr_parts = ARRAY_SIZE(igep2_onenand_partitions),
98 .onenand_setup = igep2_onenand_setup,
99 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
102 static struct platform_device igep2_onenand_device = {
103 .name = "omap2-onenand",
104 .id = -1,
105 .dev = {
106 .platform_data = &igep2_onenand_data,
110 void __init igep2_flash_init(void)
112 u8 cs = 0;
113 u8 onenandcs = GPMC_CS_NUM + 1;
115 while (cs < GPMC_CS_NUM) {
116 u32 ret = 0;
117 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
119 /* Check if NAND/oneNAND is configured */
120 if ((ret & 0xC00) == 0x800)
121 /* NAND found */
122 pr_err("IGEP v2: Unsupported NAND found\n");
123 else {
124 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
125 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
126 /* ONENAND found */
127 onenandcs = cs;
129 cs++;
131 if (onenandcs > GPMC_CS_NUM) {
132 pr_err("IGEP v2: Unable to find configuration in GPMC\n");
133 return;
136 if (onenandcs < GPMC_CS_NUM) {
137 igep2_onenand_data.cs = onenandcs;
138 if (platform_device_register(&igep2_onenand_device) < 0)
139 pr_err("IGEP v2: Unable to register OneNAND device\n");
143 #else
144 void __init igep2_flash_init(void) {}
145 #endif
147 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
149 #include <linux/smsc911x.h>
151 static struct smsc911x_platform_config igep2_smsc911x_config = {
152 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
153 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
154 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
155 .phy_interface = PHY_INTERFACE_MODE_MII,
158 static struct resource igep2_smsc911x_resources[] = {
160 .flags = IORESOURCE_MEM,
163 .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
164 .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
165 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
169 static struct platform_device igep2_smsc911x_device = {
170 .name = "smsc911x",
171 .id = 0,
172 .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
173 .resource = igep2_smsc911x_resources,
174 .dev = {
175 .platform_data = &igep2_smsc911x_config,
179 static inline void __init igep2_init_smsc911x(void)
181 unsigned long cs_mem_base;
183 if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
184 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
185 gpmc_cs_free(IGEP2_SMSC911X_CS);
186 return;
189 igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
190 igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
192 if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
193 (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
194 gpio_export(IGEP2_SMSC911X_GPIO, 0);
195 } else {
196 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
197 return;
200 platform_device_register(&igep2_smsc911x_device);
203 #else
204 static inline void __init igep2_init_smsc911x(void) { }
205 #endif
207 static struct omap_board_config_kernel igep2_config[] __initdata = {
210 static struct regulator_consumer_supply igep2_vmmc1_supply = {
211 .supply = "vmmc",
214 static struct regulator_consumer_supply igep2_vmmc2_supply = {
215 .supply = "vmmc",
218 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
219 static struct regulator_init_data igep2_vmmc1 = {
220 .constraints = {
221 .min_uV = 1850000,
222 .max_uV = 3150000,
223 .valid_modes_mask = REGULATOR_MODE_NORMAL
224 | REGULATOR_MODE_STANDBY,
225 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
226 | REGULATOR_CHANGE_MODE
227 | REGULATOR_CHANGE_STATUS,
229 .num_consumer_supplies = 1,
230 .consumer_supplies = &igep2_vmmc1_supply,
233 /* VMMC2 for OMAP VDD_MMC2 (i/o) and MMC2 WIFI */
234 static struct regulator_init_data igep2_vmmc2 = {
235 .constraints = {
236 .min_uV = 1850000,
237 .max_uV = 3150000,
238 .valid_modes_mask = REGULATOR_MODE_NORMAL
239 | REGULATOR_MODE_STANDBY,
240 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
241 | REGULATOR_CHANGE_MODE
242 | REGULATOR_CHANGE_STATUS,
244 .num_consumer_supplies = 1,
245 .consumer_supplies = &igep2_vmmc2_supply,
248 static struct omap2_hsmmc_info mmc[] = {
250 .mmc = 1,
251 .wires = 4,
252 .gpio_cd = -EINVAL,
253 .gpio_wp = -EINVAL,
256 .mmc = 2,
257 .wires = 4,
258 .gpio_cd = -EINVAL,
259 .gpio_wp = -EINVAL,
261 {} /* Terminator */
264 static int igep2_twl_gpio_setup(struct device *dev,
265 unsigned gpio, unsigned ngpio)
267 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
268 mmc[0].gpio_cd = gpio + 0;
269 omap2_hsmmc_init(mmc);
271 /* link regulators to MMC adapters ... we "know" the
272 * regulators will be set up only *after* we return.
274 igep2_vmmc1_supply.dev = mmc[0].dev;
275 igep2_vmmc2_supply.dev = mmc[1].dev;
277 return 0;
280 static struct twl4030_gpio_platform_data igep2_gpio_data = {
281 .gpio_base = OMAP_MAX_GPIO_LINES,
282 .irq_base = TWL4030_GPIO_IRQ_BASE,
283 .irq_end = TWL4030_GPIO_IRQ_END,
284 .use_leds = false,
285 .setup = igep2_twl_gpio_setup,
288 static struct twl4030_usb_data igep2_usb_data = {
289 .usb_mode = T2_USB_MODE_ULPI,
292 static int igep2_enable_dvi(struct omap_dss_device *dssdev)
294 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
296 return 0;
299 static void igep2_disable_dvi(struct omap_dss_device *dssdev)
301 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
304 static struct omap_dss_device igep2_dvi_device = {
305 .type = OMAP_DISPLAY_TYPE_DPI,
306 .name = "dvi",
307 .driver_name = "generic_panel",
308 .phy.dpi.data_lines = 24,
309 .platform_enable = igep2_enable_dvi,
310 .platform_disable = igep2_disable_dvi,
313 static struct omap_dss_device *igep2_dss_devices[] = {
314 &igep2_dvi_device
317 static struct omap_dss_board_info igep2_dss_data = {
318 .num_devices = ARRAY_SIZE(igep2_dss_devices),
319 .devices = igep2_dss_devices,
320 .default_device = &igep2_dvi_device,
323 static struct platform_device igep2_dss_device = {
324 .name = "omapdss",
325 .id = -1,
326 .dev = {
327 .platform_data = &igep2_dss_data,
331 static struct regulator_consumer_supply igep2_vpll2_supply = {
332 .supply = "vdds_dsi",
333 .dev = &igep2_dss_device.dev,
336 static struct regulator_init_data igep2_vpll2 = {
337 .constraints = {
338 .name = "VDVI",
339 .min_uV = 1800000,
340 .max_uV = 1800000,
341 .apply_uV = true,
342 .valid_modes_mask = REGULATOR_MODE_NORMAL
343 | REGULATOR_MODE_STANDBY,
344 .valid_ops_mask = REGULATOR_CHANGE_MODE
345 | REGULATOR_CHANGE_STATUS,
347 .num_consumer_supplies = 1,
348 .consumer_supplies = &igep2_vpll2_supply,
351 static void __init igep2_display_init(void)
353 if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") &&
354 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1))
355 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
358 static struct platform_device *igep2_devices[] __initdata = {
359 &igep2_dss_device,
362 static void __init igep2_init_irq(void)
364 omap_board_config = igep2_config;
365 omap_board_config_size = ARRAY_SIZE(igep2_config);
366 omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
367 omap_init_irq();
368 omap_gpio_init();
371 static struct twl4030_codec_audio_data igep2_audio_data = {
372 .audio_mclk = 26000000,
375 static struct twl4030_codec_data igep2_codec_data = {
376 .audio_mclk = 26000000,
377 .audio = &igep2_audio_data,
380 static struct twl4030_platform_data igep2_twldata = {
381 .irq_base = TWL4030_IRQ_BASE,
382 .irq_end = TWL4030_IRQ_END,
384 /* platform_data for children goes here */
385 .usb = &igep2_usb_data,
386 .codec = &igep2_codec_data,
387 .gpio = &igep2_gpio_data,
388 .vmmc1 = &igep2_vmmc1,
389 .vmmc2 = &igep2_vmmc2,
390 .vpll2 = &igep2_vpll2,
394 static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
396 I2C_BOARD_INFO("twl4030", 0x48),
397 .flags = I2C_CLIENT_WAKE,
398 .irq = INT_34XX_SYS_NIRQ,
399 .platform_data = &igep2_twldata,
403 static int __init igep2_i2c_init(void)
405 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
406 ARRAY_SIZE(igep2_i2c_boardinfo));
407 /* Bus 3 is attached to the DVI port where devices like the pico DLP
408 * projector don't work reliably with 400kHz */
409 omap_register_i2c_bus(3, 100, NULL, 0);
410 return 0;
413 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
414 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
415 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
416 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
418 .phy_reset = true,
419 .reset_gpio_port[0] = -EINVAL,
420 .reset_gpio_port[1] = IGEP2_GPIO_USBH_NRESET,
421 .reset_gpio_port[2] = -EINVAL,
424 #ifdef CONFIG_OMAP_MUX
425 static struct omap_board_mux board_mux[] __initdata = {
426 { .reg_offset = OMAP_MUX_TERMINATOR },
428 #else
429 #define board_mux NULL
430 #endif
432 static void __init igep2_init(void)
434 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
435 igep2_i2c_init();
436 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
437 omap_serial_init();
438 usb_musb_init();
439 usb_ehci_init(&ehci_pdata);
441 igep2_flash_init();
442 igep2_display_init();
443 igep2_init_smsc911x();
445 /* GPIO userspace leds */
446 if ((gpio_request(IGEP2_GPIO_LED0_RED, "GPIO_LED0_RED") == 0) &&
447 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
448 gpio_export(IGEP2_GPIO_LED0_RED, 0);
449 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
450 } else
451 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
453 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "GPIO_LED0_GREEN") == 0) &&
454 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
455 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
456 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
457 } else
458 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
460 if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_LED1_RED") == 0) &&
461 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
462 gpio_export(IGEP2_GPIO_LED1_RED, 0);
463 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
464 } else
465 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
467 /* GPIO W-LAN + Bluetooth combo module */
468 if ((gpio_request(IGEP2_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
469 (gpio_direction_output(IGEP2_GPIO_WIFI_NPD, 1) == 0)) {
470 gpio_export(IGEP2_GPIO_WIFI_NPD, 0);
471 /* gpio_set_value(IGEP2_GPIO_WIFI_NPD, 0); */
472 } else
473 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NPD\n");
475 if ((gpio_request(IGEP2_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
476 (gpio_direction_output(IGEP2_GPIO_WIFI_NRESET, 1) == 0)) {
477 gpio_export(IGEP2_GPIO_WIFI_NRESET, 0);
478 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 0);
479 udelay(10);
480 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 1);
481 } else
482 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NRESET\n");
485 static void __init igep2_map_io(void)
487 omap2_set_globals_343x();
488 omap34xx_map_common_io();
491 MACHINE_START(IGEP0020, "IGEP v2 board")
492 .phys_io = 0x48000000,
493 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
494 .boot_params = 0x80000100,
495 .map_io = igep2_map_io,
496 .init_irq = igep2_init_irq,
497 .init_machine = igep2_init,
498 .timer = &omap_timer,
499 MACHINE_END