omap3: Add minimal OMAP3 IGEP module support
[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
EBS
277
278 return 0;
279};
280
281static struct twl4030_gpio_platform_data igep2_gpio_data = {
282 .gpio_base = OMAP_MAX_GPIO_LINES,
283 .irq_base = TWL4030_GPIO_IRQ_BASE,
284 .irq_end = TWL4030_GPIO_IRQ_END,
285 .use_leds = false,
286 .setup = igep2_twl_gpio_setup,
287};
288
289static struct twl4030_usb_data igep2_usb_data = {
290 .usb_mode = T2_USB_MODE_ULPI,
291};
292
691de27f
EBS
293static int igep2_enable_dvi(struct omap_dss_device *dssdev)
294{
295 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
296
297 return 0;
298}
299
300static void igep2_disable_dvi(struct omap_dss_device *dssdev)
301{
302 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
303}
304
305static struct omap_dss_device igep2_dvi_device = {
306 .type = OMAP_DISPLAY_TYPE_DPI,
307 .name = "dvi",
308 .driver_name = "generic_panel",
309 .phy.dpi.data_lines = 24,
310 .platform_enable = igep2_enable_dvi,
311 .platform_disable = igep2_disable_dvi,
312};
313
314static struct omap_dss_device *igep2_dss_devices[] = {
315 &igep2_dvi_device
316};
317
318static struct omap_dss_board_info igep2_dss_data = {
319 .num_devices = ARRAY_SIZE(igep2_dss_devices),
320 .devices = igep2_dss_devices,
321 .default_device = &igep2_dvi_device,
322};
323
324static struct platform_device igep2_dss_device = {
325 .name = "omapdss",
326 .id = -1,
327 .dev = {
328 .platform_data = &igep2_dss_data,
329 },
330};
331
332static struct regulator_consumer_supply igep2_vpll2_supply = {
333 .supply = "vdds_dsi",
334 .dev = &igep2_dss_device.dev,
335};
336
337static struct regulator_init_data igep2_vpll2 = {
338 .constraints = {
339 .name = "VDVI",
340 .min_uV = 1800000,
341 .max_uV = 1800000,
342 .apply_uV = true,
343 .valid_modes_mask = REGULATOR_MODE_NORMAL
344 | REGULATOR_MODE_STANDBY,
345 .valid_ops_mask = REGULATOR_CHANGE_MODE
346 | REGULATOR_CHANGE_STATUS,
347 },
348 .num_consumer_supplies = 1,
349 .consumer_supplies = &igep2_vpll2_supply,
350};
351
352static void __init igep2_display_init(void)
353{
354 if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") &&
355 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1))
356 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
357}
228893f9
EBS
358
359#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
360#include <linux/leds.h>
361
362static struct gpio_led igep2_gpio_leds[] = {
b344d87a 363 {
228893f9
EBS
364 .name = "led0:red",
365 .gpio = IGEP2_GPIO_LED0_RED,
366 },
367 {
368 .name = "led0:green",
b344d87a 369 .default_trigger = "heartbeat",
228893f9
EBS
370 .gpio = IGEP2_GPIO_LED0_GREEN,
371 },
372 {
373 .name = "led1:red",
b344d87a
JZ
374 .gpio = IGEP2_GPIO_LED1_RED,
375 },
376};
377
228893f9
EBS
378static struct gpio_led_platform_data igep2_led_pdata = {
379 .leds = igep2_gpio_leds,
380 .num_leds = ARRAY_SIZE(igep2_gpio_leds),
b344d87a
JZ
381};
382
228893f9 383static struct platform_device igep2_led_device = {
b344d87a
JZ
384 .name = "leds-gpio",
385 .id = -1,
386 .dev = {
228893f9 387 .platform_data = &igep2_led_pdata,
b344d87a
JZ
388 },
389};
228893f9
EBS
390
391static void __init igep2_init_led(void)
392{
393 platform_device_register(&igep2_led_device);
394}
395
396#else
397static inline void igep2_init_led(void) {}
b344d87a 398#endif
691de27f
EBS
399
400static struct platform_device *igep2_devices[] __initdata = {
401 &igep2_dss_device,
402};
403
58e11162
EBS
404static void __init igep2_init_irq(void)
405{
406 omap_board_config = igep2_config;
407 omap_board_config_size = ARRAY_SIZE(igep2_config);
22f1baac 408 omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
58e11162
EBS
409 omap_init_irq();
410 omap_gpio_init();
411}
412
7f5f23da
EBS
413static struct twl4030_codec_audio_data igep2_audio_data = {
414 .audio_mclk = 26000000,
415};
416
417static struct twl4030_codec_data igep2_codec_data = {
418 .audio_mclk = 26000000,
419 .audio = &igep2_audio_data,
420};
421
58e11162
EBS
422static struct twl4030_platform_data igep2_twldata = {
423 .irq_base = TWL4030_IRQ_BASE,
424 .irq_end = TWL4030_IRQ_END,
425
426 /* platform_data for children goes here */
427 .usb = &igep2_usb_data,
7f5f23da 428 .codec = &igep2_codec_data,
58e11162
EBS
429 .gpio = &igep2_gpio_data,
430 .vmmc1 = &igep2_vmmc1,
c67b0d98 431 .vmmc2 = &igep2_vmmc2,
691de27f 432 .vpll2 = &igep2_vpll2,
58e11162
EBS
433
434};
435
436static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
437 {
438 I2C_BOARD_INFO("twl4030", 0x48),
439 .flags = I2C_CLIENT_WAKE,
440 .irq = INT_34XX_SYS_NIRQ,
441 .platform_data = &igep2_twldata,
442 },
443};
444
445static int __init igep2_i2c_init(void)
446{
447 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
448 ARRAY_SIZE(igep2_i2c_boardinfo));
449 /* Bus 3 is attached to the DVI port where devices like the pico DLP
450 * projector don't work reliably with 400kHz */
451 omap_register_i2c_bus(3, 100, NULL, 0);
452 return 0;
453}
454
884b8369
MM
455static struct omap_musb_board_data musb_board_data = {
456 .interface_type = MUSB_INTERFACE_ULPI,
457 .mode = MUSB_OTG,
458 .power = 100,
459};
460
6f69a181 461static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
f6b74535
EBS
462 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
463 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
d0885486
EBS
464 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
465
466 .phy_reset = true,
f6b74535
EBS
467 .reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
468 .reset_gpio_port[1] = -EINVAL,
d0885486
EBS
469 .reset_gpio_port[2] = -EINVAL,
470};
471
ca5742bd
TL
472#ifdef CONFIG_OMAP_MUX
473static struct omap_board_mux board_mux[] __initdata = {
474 { .reg_offset = OMAP_MUX_TERMINATOR },
475};
476#else
477#define board_mux NULL
478#endif
479
58e11162
EBS
480static void __init igep2_init(void)
481{
ca5742bd 482 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
58e11162 483 igep2_i2c_init();
691de27f 484 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
58e11162 485 omap_serial_init();
884b8369 486 usb_musb_init(&musb_board_data);
d0885486 487 usb_ehci_init(&ehci_pdata);
58e11162 488
cddb483a 489 igep2_flash_init();
228893f9 490 igep2_init_led();
691de27f 491 igep2_display_init();
58e11162
EBS
492 igep2_init_smsc911x();
493
494 /* GPIO userspace leds */
228893f9
EBS
495#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
496 if ((gpio_request(IGEP2_GPIO_LED0_RED, "led0:red") == 0) &&
58e11162
EBS
497 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
498 gpio_export(IGEP2_GPIO_LED0_RED, 0);
499 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
500 } else
501 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
502
228893f9 503 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "led0:green") == 0) &&
58e11162
EBS
504 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
505 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
506 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
507 } else
508 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
228893f9
EBS
509
510 if ((gpio_request(IGEP2_GPIO_LED1_RED, "led1:red") == 0) &&
58e11162
EBS
511 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
512 gpio_export(IGEP2_GPIO_LED1_RED, 0);
513 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
514 } else
515 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
b344d87a 516#endif
228893f9 517
c67b0d98
JZ
518 /* GPIO W-LAN + Bluetooth combo module */
519 if ((gpio_request(IGEP2_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
520 (gpio_direction_output(IGEP2_GPIO_WIFI_NPD, 1) == 0)) {
521 gpio_export(IGEP2_GPIO_WIFI_NPD, 0);
522/* gpio_set_value(IGEP2_GPIO_WIFI_NPD, 0); */
523 } else
524 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NPD\n");
525
526 if ((gpio_request(IGEP2_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
527 (gpio_direction_output(IGEP2_GPIO_WIFI_NRESET, 1) == 0)) {
528 gpio_export(IGEP2_GPIO_WIFI_NRESET, 0);
529 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 0);
530 udelay(10);
531 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 1);
532 } else
533 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NRESET\n");
58e11162
EBS
534}
535
58e11162
EBS
536MACHINE_START(IGEP0020, "IGEP v2 board")
537 .phys_io = 0x48000000,
538 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
539 .boot_params = 0x80000100,
869fef41 540 .map_io = omap3_map_io,
71ee7dad 541 .reserve = omap_reserve,
58e11162
EBS
542 .init_irq = igep2_init_irq,
543 .init_machine = igep2_init,
544 .timer = &omap_timer,
545MACHINE_END
This page took 0.114738 seconds and 5 git commands to generate.