omap3: Add external VBUS power switch and overcurrent detect onIGEP v2 board
[deliverable/linux.git] / arch / arm / mach-omap2 / board-igep0020.c
CommitLineData
58e11162
EBS
1/*
2 * Copyright (C) 2009 Integration Software and Electronic Engineering.
3 *
4 * Modified from mach-omap2/board-generic.c
5 *
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 */
10
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>
20
21#include <linux/regulator/machine.h>
ebeb53e1 22#include <linux/i2c/twl.h>
3a63833e 23#include <linux/mmc/host.h>
58e11162
EBS
24
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27
28#include <plat/board.h>
29#include <plat/common.h>
30#include <plat/gpmc.h>
58e11162 31#include <plat/usb.h>
691de27f 32#include <plat/display.h>
cddb483a 33#include <plat/onenand.h>
58e11162 34
ca5742bd 35#include "mux.h"
d02a900b 36#include "hsmmc.h"
22f1baac 37#include "sdram-numonyx-m65kxxxxam.h"
58e11162
EBS
38
39#define IGEP2_SMSC911X_CS 5
40#define IGEP2_SMSC911X_GPIO 176
41#define IGEP2_GPIO_USBH_NRESET 24
228893f9
EBS
42#define IGEP2_GPIO_LED0_GREEN 26
43#define IGEP2_GPIO_LED0_RED 27
58e11162 44#define IGEP2_GPIO_LED1_RED 28
691de27f 45#define IGEP2_GPIO_DVI_PUP 170
c67b0d98
JZ
46#define IGEP2_GPIO_WIFI_NPD 94
47#define IGEP2_GPIO_WIFI_NRESET 95
58e11162 48
cddb483a
EBS
49#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
50 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
51
52#define ONENAND_MAP 0x20000000
53
54/* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY )
55 * Since the device is equipped with two DataRAMs, and two-plane NAND
56 * Flash memory array, these two component enables simultaneous program
57 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
58 * while Plane2 has only odd blocks such as block1, block3, block5.
59 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
60 */
61
62static struct mtd_partition igep2_onenand_partitions[] = {
63 {
64 .name = "X-Loader",
65 .offset = 0,
66 .size = 2 * (64*(2*2048))
67 },
68 {
69 .name = "U-Boot",
70 .offset = MTDPART_OFS_APPEND,
71 .size = 6 * (64*(2*2048)),
72 },
73 {
74 .name = "Environment",
75 .offset = MTDPART_OFS_APPEND,
76 .size = 2 * (64*(2*2048)),
77 },
78 {
79 .name = "Kernel",
80 .offset = MTDPART_OFS_APPEND,
81 .size = 12 * (64*(2*2048)),
82 },
83 {
84 .name = "File System",
85 .offset = MTDPART_OFS_APPEND,
86 .size = MTDPART_SIZ_FULL,
87 },
88};
89
90static int igep2_onenand_setup(void __iomem *onenand_base, int freq)
91{
92 /* nothing is required to be setup for onenand as of now */
93 return 0;
94}
95
96static struct omap_onenand_platform_data igep2_onenand_data = {
97 .parts = igep2_onenand_partitions,
98 .nr_parts = ARRAY_SIZE(igep2_onenand_partitions),
99 .onenand_setup = igep2_onenand_setup,
100 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
101};
102
103static struct platform_device igep2_onenand_device = {
104 .name = "omap2-onenand",
105 .id = -1,
106 .dev = {
107 .platform_data = &igep2_onenand_data,
108 },
109};
110
04aeae77 111static void __init igep2_flash_init(void)
cddb483a
EBS
112{
113 u8 cs = 0;
114 u8 onenandcs = GPMC_CS_NUM + 1;
115
116 while (cs < GPMC_CS_NUM) {
117 u32 ret = 0;
118 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
119
120 /* Check if NAND/oneNAND is configured */
121 if ((ret & 0xC00) == 0x800)
122 /* NAND found */
123 pr_err("IGEP v2: Unsupported NAND found\n");
124 else {
125 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
126 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
127 /* ONENAND found */
128 onenandcs = cs;
129 }
130 cs++;
131 }
132 if (onenandcs > GPMC_CS_NUM) {
133 pr_err("IGEP v2: Unable to find configuration in GPMC\n");
134 return;
135 }
136
137 if (onenandcs < GPMC_CS_NUM) {
138 igep2_onenand_data.cs = onenandcs;
139 if (platform_device_register(&igep2_onenand_device) < 0)
140 pr_err("IGEP v2: Unable to register OneNAND device\n");
141 }
142}
143
144#else
04aeae77 145static void __init igep2_flash_init(void) {}
cddb483a
EBS
146#endif
147
58e11162
EBS
148#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
149
150#include <linux/smsc911x.h>
151
152static struct smsc911x_platform_config igep2_smsc911x_config = {
153 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
154 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
155 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
156 .phy_interface = PHY_INTERFACE_MODE_MII,
157};
158
159static struct resource igep2_smsc911x_resources[] = {
160 {
161 .flags = IORESOURCE_MEM,
162 },
163 {
164 .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
165 .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
166 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
167 },
168};
169
170static struct platform_device igep2_smsc911x_device = {
171 .name = "smsc911x",
172 .id = 0,
173 .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
174 .resource = igep2_smsc911x_resources,
175 .dev = {
176 .platform_data = &igep2_smsc911x_config,
177 },
178};
179
180static inline void __init igep2_init_smsc911x(void)
181{
182 unsigned long cs_mem_base;
183
184 if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
185 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
186 gpmc_cs_free(IGEP2_SMSC911X_CS);
187 return;
188 }
189
190 igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
191 igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
192
193 if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
194 (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
195 gpio_export(IGEP2_SMSC911X_GPIO, 0);
196 } else {
197 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
198 return;
199 }
200
201 platform_device_register(&igep2_smsc911x_device);
202}
203
204#else
205static inline void __init igep2_init_smsc911x(void) { }
206#endif
207
208static struct omap_board_config_kernel igep2_config[] __initdata = {
209};
210
211static struct regulator_consumer_supply igep2_vmmc1_supply = {
212 .supply = "vmmc",
213};
214
c67b0d98
JZ
215static struct regulator_consumer_supply igep2_vmmc2_supply = {
216 .supply = "vmmc",
217};
218
58e11162
EBS
219/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
220static struct regulator_init_data igep2_vmmc1 = {
221 .constraints = {
222 .min_uV = 1850000,
223 .max_uV = 3150000,
224 .valid_modes_mask = REGULATOR_MODE_NORMAL
225 | REGULATOR_MODE_STANDBY,
226 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
227 | REGULATOR_CHANGE_MODE
228 | REGULATOR_CHANGE_STATUS,
229 },
230 .num_consumer_supplies = 1,
231 .consumer_supplies = &igep2_vmmc1_supply,
232};
233
c67b0d98
JZ
234/* VMMC2 for OMAP VDD_MMC2 (i/o) and MMC2 WIFI */
235static struct regulator_init_data igep2_vmmc2 = {
236 .constraints = {
237 .min_uV = 1850000,
238 .max_uV = 3150000,
239 .valid_modes_mask = REGULATOR_MODE_NORMAL
240 | REGULATOR_MODE_STANDBY,
241 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
242 | REGULATOR_CHANGE_MODE
243 | REGULATOR_CHANGE_STATUS,
244 },
245 .num_consumer_supplies = 1,
246 .consumer_supplies = &igep2_vmmc2_supply,
247};
248
68ff0423 249static struct omap2_hsmmc_info mmc[] = {
58e11162
EBS
250 {
251 .mmc = 1,
3a63833e 252 .caps = MMC_CAP_4_BIT_DATA,
58e11162
EBS
253 .gpio_cd = -EINVAL,
254 .gpio_wp = -EINVAL,
255 },
256 {
257 .mmc = 2,
3a63833e 258 .caps = MMC_CAP_4_BIT_DATA,
58e11162
EBS
259 .gpio_cd = -EINVAL,
260 .gpio_wp = -EINVAL,
261 },
262 {} /* Terminator */
263};
264
265static int igep2_twl_gpio_setup(struct device *dev,
266 unsigned gpio, unsigned ngpio)
267{
268 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
269 mmc[0].gpio_cd = gpio + 0;
68ff0423 270 omap2_hsmmc_init(mmc);
58e11162
EBS
271
272 /* link regulators to MMC adapters ... we "know" the
273 * regulators will be set up only *after* we return.
274 */
275 igep2_vmmc1_supply.dev = mmc[0].dev;
c67b0d98 276 igep2_vmmc2_supply.dev = mmc[1].dev;
58e11162 277
61e118dd
EBS
278 /*
279 * REVISIT: need ehci-omap hooks for external VBUS
280 * power switch and overcurrent detect
281 */
282 if ((gpio_request(gpio + 1, "GPIO_EHCI_NOC") < 0) ||
283 (gpio_direction_input(gpio + 1) < 0))
284 pr_err("IGEP2: Could not obtain gpio for EHCI NOC");
285
286 /*
287 * TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN
288 * (out, active low)
289 */
290 if ((gpio_request(gpio + TWL4030_GPIO_MAX, "GPIO_USBH_CPEN") < 0) ||
291 (gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0) < 0))
292 pr_err("IGEP2: Could not obtain gpio for USBH_CPEN");
293
58e11162
EBS
294 return 0;
295};
296
297static struct twl4030_gpio_platform_data igep2_gpio_data = {
298 .gpio_base = OMAP_MAX_GPIO_LINES,
299 .irq_base = TWL4030_GPIO_IRQ_BASE,
300 .irq_end = TWL4030_GPIO_IRQ_END,
301 .use_leds = false,
302 .setup = igep2_twl_gpio_setup,
303};
304
305static struct twl4030_usb_data igep2_usb_data = {
306 .usb_mode = T2_USB_MODE_ULPI,
307};
308
691de27f
EBS
309static int igep2_enable_dvi(struct omap_dss_device *dssdev)
310{
311 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
312
313 return 0;
314}
315
316static void igep2_disable_dvi(struct omap_dss_device *dssdev)
317{
318 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
319}
320
321static struct omap_dss_device igep2_dvi_device = {
322 .type = OMAP_DISPLAY_TYPE_DPI,
323 .name = "dvi",
324 .driver_name = "generic_panel",
325 .phy.dpi.data_lines = 24,
326 .platform_enable = igep2_enable_dvi,
327 .platform_disable = igep2_disable_dvi,
328};
329
330static struct omap_dss_device *igep2_dss_devices[] = {
331 &igep2_dvi_device
332};
333
334static struct omap_dss_board_info igep2_dss_data = {
335 .num_devices = ARRAY_SIZE(igep2_dss_devices),
336 .devices = igep2_dss_devices,
337 .default_device = &igep2_dvi_device,
338};
339
340static struct platform_device igep2_dss_device = {
341 .name = "omapdss",
342 .id = -1,
343 .dev = {
344 .platform_data = &igep2_dss_data,
345 },
346};
347
348static struct regulator_consumer_supply igep2_vpll2_supply = {
349 .supply = "vdds_dsi",
350 .dev = &igep2_dss_device.dev,
351};
352
353static struct regulator_init_data igep2_vpll2 = {
354 .constraints = {
355 .name = "VDVI",
356 .min_uV = 1800000,
357 .max_uV = 1800000,
358 .apply_uV = true,
359 .valid_modes_mask = REGULATOR_MODE_NORMAL
360 | REGULATOR_MODE_STANDBY,
361 .valid_ops_mask = REGULATOR_CHANGE_MODE
362 | REGULATOR_CHANGE_STATUS,
363 },
364 .num_consumer_supplies = 1,
365 .consumer_supplies = &igep2_vpll2_supply,
366};
367
368static void __init igep2_display_init(void)
369{
370 if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") &&
371 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1))
372 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
373}
228893f9
EBS
374
375#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
376#include <linux/leds.h>
377
378static struct gpio_led igep2_gpio_leds[] = {
b344d87a 379 {
228893f9
EBS
380 .name = "led0:red",
381 .gpio = IGEP2_GPIO_LED0_RED,
382 },
383 {
384 .name = "led0:green",
b344d87a 385 .default_trigger = "heartbeat",
228893f9
EBS
386 .gpio = IGEP2_GPIO_LED0_GREEN,
387 },
388 {
389 .name = "led1:red",
b344d87a
JZ
390 .gpio = IGEP2_GPIO_LED1_RED,
391 },
392};
393
228893f9
EBS
394static struct gpio_led_platform_data igep2_led_pdata = {
395 .leds = igep2_gpio_leds,
396 .num_leds = ARRAY_SIZE(igep2_gpio_leds),
b344d87a
JZ
397};
398
228893f9 399static struct platform_device igep2_led_device = {
b344d87a
JZ
400 .name = "leds-gpio",
401 .id = -1,
402 .dev = {
228893f9 403 .platform_data = &igep2_led_pdata,
b344d87a
JZ
404 },
405};
228893f9
EBS
406
407static void __init igep2_init_led(void)
408{
409 platform_device_register(&igep2_led_device);
410}
411
412#else
413static inline void igep2_init_led(void) {}
b344d87a 414#endif
691de27f
EBS
415
416static struct platform_device *igep2_devices[] __initdata = {
417 &igep2_dss_device,
418};
419
58e11162
EBS
420static void __init igep2_init_irq(void)
421{
422 omap_board_config = igep2_config;
423 omap_board_config_size = ARRAY_SIZE(igep2_config);
22f1baac 424 omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
58e11162
EBS
425 omap_init_irq();
426 omap_gpio_init();
427}
428
7f5f23da
EBS
429static struct twl4030_codec_audio_data igep2_audio_data = {
430 .audio_mclk = 26000000,
431};
432
433static struct twl4030_codec_data igep2_codec_data = {
434 .audio_mclk = 26000000,
435 .audio = &igep2_audio_data,
436};
437
58e11162
EBS
438static struct twl4030_platform_data igep2_twldata = {
439 .irq_base = TWL4030_IRQ_BASE,
440 .irq_end = TWL4030_IRQ_END,
441
442 /* platform_data for children goes here */
443 .usb = &igep2_usb_data,
7f5f23da 444 .codec = &igep2_codec_data,
58e11162
EBS
445 .gpio = &igep2_gpio_data,
446 .vmmc1 = &igep2_vmmc1,
c67b0d98 447 .vmmc2 = &igep2_vmmc2,
691de27f 448 .vpll2 = &igep2_vpll2,
58e11162
EBS
449
450};
451
452static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
453 {
454 I2C_BOARD_INFO("twl4030", 0x48),
455 .flags = I2C_CLIENT_WAKE,
456 .irq = INT_34XX_SYS_NIRQ,
457 .platform_data = &igep2_twldata,
458 },
459};
460
461static int __init igep2_i2c_init(void)
462{
463 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
464 ARRAY_SIZE(igep2_i2c_boardinfo));
465 /* Bus 3 is attached to the DVI port where devices like the pico DLP
466 * projector don't work reliably with 400kHz */
467 omap_register_i2c_bus(3, 100, NULL, 0);
468 return 0;
469}
470
884b8369
MM
471static struct omap_musb_board_data musb_board_data = {
472 .interface_type = MUSB_INTERFACE_ULPI,
473 .mode = MUSB_OTG,
474 .power = 100,
475};
476
6f69a181 477static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
f6b74535
EBS
478 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
479 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
d0885486
EBS
480 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
481
482 .phy_reset = true,
f6b74535
EBS
483 .reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
484 .reset_gpio_port[1] = -EINVAL,
d0885486
EBS
485 .reset_gpio_port[2] = -EINVAL,
486};
487
ca5742bd
TL
488#ifdef CONFIG_OMAP_MUX
489static struct omap_board_mux board_mux[] __initdata = {
490 { .reg_offset = OMAP_MUX_TERMINATOR },
491};
492#else
493#define board_mux NULL
494#endif
495
58e11162
EBS
496static void __init igep2_init(void)
497{
ca5742bd 498 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
58e11162 499 igep2_i2c_init();
691de27f 500 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
58e11162 501 omap_serial_init();
884b8369 502 usb_musb_init(&musb_board_data);
d0885486 503 usb_ehci_init(&ehci_pdata);
58e11162 504
cddb483a 505 igep2_flash_init();
228893f9 506 igep2_init_led();
691de27f 507 igep2_display_init();
58e11162
EBS
508 igep2_init_smsc911x();
509
510 /* GPIO userspace leds */
228893f9
EBS
511#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
512 if ((gpio_request(IGEP2_GPIO_LED0_RED, "led0:red") == 0) &&
58e11162
EBS
513 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
514 gpio_export(IGEP2_GPIO_LED0_RED, 0);
515 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
516 } else
517 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
518
228893f9 519 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "led0:green") == 0) &&
58e11162
EBS
520 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
521 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
522 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
523 } else
524 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
228893f9
EBS
525
526 if ((gpio_request(IGEP2_GPIO_LED1_RED, "led1:red") == 0) &&
58e11162
EBS
527 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
528 gpio_export(IGEP2_GPIO_LED1_RED, 0);
529 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
530 } else
531 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
b344d87a 532#endif
228893f9 533
c67b0d98
JZ
534 /* GPIO W-LAN + Bluetooth combo module */
535 if ((gpio_request(IGEP2_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
536 (gpio_direction_output(IGEP2_GPIO_WIFI_NPD, 1) == 0)) {
537 gpio_export(IGEP2_GPIO_WIFI_NPD, 0);
538/* gpio_set_value(IGEP2_GPIO_WIFI_NPD, 0); */
539 } else
540 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NPD\n");
541
542 if ((gpio_request(IGEP2_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
543 (gpio_direction_output(IGEP2_GPIO_WIFI_NRESET, 1) == 0)) {
544 gpio_export(IGEP2_GPIO_WIFI_NRESET, 0);
545 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 0);
546 udelay(10);
547 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 1);
548 } else
549 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NRESET\n");
58e11162
EBS
550}
551
58e11162
EBS
552MACHINE_START(IGEP0020, "IGEP v2 board")
553 .phys_io = 0x48000000,
554 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
555 .boot_params = 0x80000100,
869fef41 556 .map_io = omap3_map_io,
71ee7dad 557 .reserve = omap_reserve,
58e11162
EBS
558 .init_irq = igep2_init_irq,
559 .init_machine = igep2_init,
560 .timer = &omap_timer,
561MACHINE_END
This page took 0.090661 seconds and 5 git commands to generate.