ARM: OMAP: Convert to use ->reserve method to reserve boot time memory
[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>
58e11162
EBS
23
24#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26
27#include <plat/board.h>
28#include <plat/common.h>
29#include <plat/gpmc.h>
58e11162 30#include <plat/usb.h>
691de27f 31#include <plat/display.h>
cddb483a 32#include <plat/onenand.h>
58e11162 33
ca5742bd 34#include "mux.h"
d02a900b 35#include "hsmmc.h"
22f1baac 36#include "sdram-numonyx-m65kxxxxam.h"
58e11162
EBS
37
38#define IGEP2_SMSC911X_CS 5
39#define IGEP2_SMSC911X_GPIO 176
40#define IGEP2_GPIO_USBH_NRESET 24
228893f9
EBS
41#define IGEP2_GPIO_LED0_GREEN 26
42#define IGEP2_GPIO_LED0_RED 27
58e11162 43#define IGEP2_GPIO_LED1_RED 28
691de27f 44#define IGEP2_GPIO_DVI_PUP 170
c67b0d98
JZ
45#define IGEP2_GPIO_WIFI_NPD 94
46#define IGEP2_GPIO_WIFI_NRESET 95
58e11162 47
cddb483a
EBS
48#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
49 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
50
51#define ONENAND_MAP 0x20000000
52
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)
59 */
60
61static struct mtd_partition igep2_onenand_partitions[] = {
62 {
63 .name = "X-Loader",
64 .offset = 0,
65 .size = 2 * (64*(2*2048))
66 },
67 {
68 .name = "U-Boot",
69 .offset = MTDPART_OFS_APPEND,
70 .size = 6 * (64*(2*2048)),
71 },
72 {
73 .name = "Environment",
74 .offset = MTDPART_OFS_APPEND,
75 .size = 2 * (64*(2*2048)),
76 },
77 {
78 .name = "Kernel",
79 .offset = MTDPART_OFS_APPEND,
80 .size = 12 * (64*(2*2048)),
81 },
82 {
83 .name = "File System",
84 .offset = MTDPART_OFS_APPEND,
85 .size = MTDPART_SIZ_FULL,
86 },
87};
88
89static int igep2_onenand_setup(void __iomem *onenand_base, int freq)
90{
91 /* nothing is required to be setup for onenand as of now */
92 return 0;
93}
94
95static 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 */
100};
101
102static struct platform_device igep2_onenand_device = {
103 .name = "omap2-onenand",
104 .id = -1,
105 .dev = {
106 .platform_data = &igep2_onenand_data,
107 },
108};
109
110void __init igep2_flash_init(void)
111{
112 u8 cs = 0;
113 u8 onenandcs = GPMC_CS_NUM + 1;
114
115 while (cs < GPMC_CS_NUM) {
116 u32 ret = 0;
117 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
118
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;
128 }
129 cs++;
130 }
131 if (onenandcs > GPMC_CS_NUM) {
132 pr_err("IGEP v2: Unable to find configuration in GPMC\n");
133 return;
134 }
135
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");
140 }
141}
142
143#else
144void __init igep2_flash_init(void) {}
145#endif
146
58e11162
EBS
147#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
148
149#include <linux/smsc911x.h>
150
151static 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,
156};
157
158static struct resource igep2_smsc911x_resources[] = {
159 {
160 .flags = IORESOURCE_MEM,
161 },
162 {
163 .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
164 .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
165 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
166 },
167};
168
169static 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,
176 },
177};
178
179static inline void __init igep2_init_smsc911x(void)
180{
181 unsigned long cs_mem_base;
182
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;
187 }
188
189 igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
190 igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
191
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;
198 }
199
200 platform_device_register(&igep2_smsc911x_device);
201}
202
203#else
204static inline void __init igep2_init_smsc911x(void) { }
205#endif
206
207static struct omap_board_config_kernel igep2_config[] __initdata = {
208};
209
210static struct regulator_consumer_supply igep2_vmmc1_supply = {
211 .supply = "vmmc",
212};
213
c67b0d98
JZ
214static struct regulator_consumer_supply igep2_vmmc2_supply = {
215 .supply = "vmmc",
216};
217
58e11162
EBS
218/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
219static 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,
228 },
229 .num_consumer_supplies = 1,
230 .consumer_supplies = &igep2_vmmc1_supply,
231};
232
c67b0d98
JZ
233/* VMMC2 for OMAP VDD_MMC2 (i/o) and MMC2 WIFI */
234static 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,
243 },
244 .num_consumer_supplies = 1,
245 .consumer_supplies = &igep2_vmmc2_supply,
246};
247
68ff0423 248static struct omap2_hsmmc_info mmc[] = {
58e11162
EBS
249 {
250 .mmc = 1,
251 .wires = 4,
252 .gpio_cd = -EINVAL,
253 .gpio_wp = -EINVAL,
254 },
255 {
256 .mmc = 2,
257 .wires = 4,
258 .gpio_cd = -EINVAL,
259 .gpio_wp = -EINVAL,
260 },
261 {} /* Terminator */
262};
263
264static int igep2_twl_gpio_setup(struct device *dev,
265 unsigned gpio, unsigned ngpio)
266{
267 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
268 mmc[0].gpio_cd = gpio + 0;
68ff0423 269 omap2_hsmmc_init(mmc);
58e11162
EBS
270
271 /* link regulators to MMC adapters ... we "know" the
272 * regulators will be set up only *after* we return.
273 */
274 igep2_vmmc1_supply.dev = mmc[0].dev;
c67b0d98 275 igep2_vmmc2_supply.dev = mmc[1].dev;
58e11162
EBS
276
277 return 0;
278};
279
280static 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,
286};
287
288static struct twl4030_usb_data igep2_usb_data = {
289 .usb_mode = T2_USB_MODE_ULPI,
290};
291
691de27f
EBS
292static int igep2_enable_dvi(struct omap_dss_device *dssdev)
293{
294 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
295
296 return 0;
297}
298
299static void igep2_disable_dvi(struct omap_dss_device *dssdev)
300{
301 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
302}
303
304static 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,
311};
312
313static struct omap_dss_device *igep2_dss_devices[] = {
314 &igep2_dvi_device
315};
316
317static 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,
321};
322
323static struct platform_device igep2_dss_device = {
324 .name = "omapdss",
325 .id = -1,
326 .dev = {
327 .platform_data = &igep2_dss_data,
328 },
329};
330
331static struct regulator_consumer_supply igep2_vpll2_supply = {
332 .supply = "vdds_dsi",
333 .dev = &igep2_dss_device.dev,
334};
335
336static 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,
346 },
347 .num_consumer_supplies = 1,
348 .consumer_supplies = &igep2_vpll2_supply,
349};
350
351static void __init igep2_display_init(void)
352{
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");
356}
228893f9
EBS
357
358#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
359#include <linux/leds.h>
360
361static struct gpio_led igep2_gpio_leds[] = {
b344d87a 362 {
228893f9
EBS
363 .name = "led0:red",
364 .gpio = IGEP2_GPIO_LED0_RED,
365 },
366 {
367 .name = "led0:green",
b344d87a 368 .default_trigger = "heartbeat",
228893f9
EBS
369 .gpio = IGEP2_GPIO_LED0_GREEN,
370 },
371 {
372 .name = "led1:red",
b344d87a
JZ
373 .gpio = IGEP2_GPIO_LED1_RED,
374 },
375};
376
228893f9
EBS
377static struct gpio_led_platform_data igep2_led_pdata = {
378 .leds = igep2_gpio_leds,
379 .num_leds = ARRAY_SIZE(igep2_gpio_leds),
b344d87a
JZ
380};
381
228893f9 382static struct platform_device igep2_led_device = {
b344d87a
JZ
383 .name = "leds-gpio",
384 .id = -1,
385 .dev = {
228893f9 386 .platform_data = &igep2_led_pdata,
b344d87a
JZ
387 },
388};
228893f9
EBS
389
390static void __init igep2_init_led(void)
391{
392 platform_device_register(&igep2_led_device);
393}
394
395#else
396static inline void igep2_init_led(void) {}
b344d87a 397#endif
691de27f
EBS
398
399static struct platform_device *igep2_devices[] __initdata = {
400 &igep2_dss_device,
401};
402
58e11162
EBS
403static void __init igep2_init_irq(void)
404{
405 omap_board_config = igep2_config;
406 omap_board_config_size = ARRAY_SIZE(igep2_config);
22f1baac 407 omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
58e11162
EBS
408 omap_init_irq();
409 omap_gpio_init();
410}
411
7f5f23da
EBS
412static struct twl4030_codec_audio_data igep2_audio_data = {
413 .audio_mclk = 26000000,
414};
415
416static struct twl4030_codec_data igep2_codec_data = {
417 .audio_mclk = 26000000,
418 .audio = &igep2_audio_data,
419};
420
58e11162
EBS
421static struct twl4030_platform_data igep2_twldata = {
422 .irq_base = TWL4030_IRQ_BASE,
423 .irq_end = TWL4030_IRQ_END,
424
425 /* platform_data for children goes here */
426 .usb = &igep2_usb_data,
7f5f23da 427 .codec = &igep2_codec_data,
58e11162
EBS
428 .gpio = &igep2_gpio_data,
429 .vmmc1 = &igep2_vmmc1,
c67b0d98 430 .vmmc2 = &igep2_vmmc2,
691de27f 431 .vpll2 = &igep2_vpll2,
58e11162
EBS
432
433};
434
435static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
436 {
437 I2C_BOARD_INFO("twl4030", 0x48),
438 .flags = I2C_CLIENT_WAKE,
439 .irq = INT_34XX_SYS_NIRQ,
440 .platform_data = &igep2_twldata,
441 },
442};
443
444static int __init igep2_i2c_init(void)
445{
446 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
447 ARRAY_SIZE(igep2_i2c_boardinfo));
448 /* Bus 3 is attached to the DVI port where devices like the pico DLP
449 * projector don't work reliably with 400kHz */
450 omap_register_i2c_bus(3, 100, NULL, 0);
451 return 0;
452}
453
884b8369
MM
454static struct omap_musb_board_data musb_board_data = {
455 .interface_type = MUSB_INTERFACE_ULPI,
456 .mode = MUSB_OTG,
457 .power = 100,
458};
459
6f69a181 460static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
f6b74535
EBS
461 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
462 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
d0885486
EBS
463 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
464
465 .phy_reset = true,
f6b74535
EBS
466 .reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
467 .reset_gpio_port[1] = -EINVAL,
d0885486
EBS
468 .reset_gpio_port[2] = -EINVAL,
469};
470
ca5742bd
TL
471#ifdef CONFIG_OMAP_MUX
472static struct omap_board_mux board_mux[] __initdata = {
473 { .reg_offset = OMAP_MUX_TERMINATOR },
474};
475#else
476#define board_mux NULL
477#endif
478
58e11162
EBS
479static void __init igep2_init(void)
480{
ca5742bd 481 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
58e11162 482 igep2_i2c_init();
691de27f 483 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
58e11162 484 omap_serial_init();
884b8369 485 usb_musb_init(&musb_board_data);
d0885486 486 usb_ehci_init(&ehci_pdata);
58e11162 487
cddb483a 488 igep2_flash_init();
228893f9 489 igep2_init_led();
691de27f 490 igep2_display_init();
58e11162
EBS
491 igep2_init_smsc911x();
492
493 /* GPIO userspace leds */
228893f9
EBS
494#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
495 if ((gpio_request(IGEP2_GPIO_LED0_RED, "led0:red") == 0) &&
58e11162
EBS
496 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
497 gpio_export(IGEP2_GPIO_LED0_RED, 0);
498 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
499 } else
500 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
501
228893f9 502 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "led0:green") == 0) &&
58e11162
EBS
503 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
504 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
505 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
506 } else
507 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
228893f9
EBS
508
509 if ((gpio_request(IGEP2_GPIO_LED1_RED, "led1:red") == 0) &&
58e11162
EBS
510 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
511 gpio_export(IGEP2_GPIO_LED1_RED, 0);
512 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
513 } else
514 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
b344d87a 515#endif
228893f9 516
c67b0d98
JZ
517 /* GPIO W-LAN + Bluetooth combo module */
518 if ((gpio_request(IGEP2_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
519 (gpio_direction_output(IGEP2_GPIO_WIFI_NPD, 1) == 0)) {
520 gpio_export(IGEP2_GPIO_WIFI_NPD, 0);
521/* gpio_set_value(IGEP2_GPIO_WIFI_NPD, 0); */
522 } else
523 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NPD\n");
524
525 if ((gpio_request(IGEP2_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
526 (gpio_direction_output(IGEP2_GPIO_WIFI_NRESET, 1) == 0)) {
527 gpio_export(IGEP2_GPIO_WIFI_NRESET, 0);
528 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 0);
529 udelay(10);
530 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 1);
531 } else
532 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NRESET\n");
58e11162
EBS
533}
534
535static void __init igep2_map_io(void)
536{
537 omap2_set_globals_343x();
6fbd55d0 538 omap34xx_map_common_io();
58e11162
EBS
539}
540
541MACHINE_START(IGEP0020, "IGEP v2 board")
542 .phys_io = 0x48000000,
543 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
544 .boot_params = 0x80000100,
545 .map_io = igep2_map_io,
71ee7dad 546 .reserve = omap_reserve,
58e11162
EBS
547 .init_irq = igep2_init_irq,
548 .init_machine = igep2_init,
549 .timer = &omap_timer,
550MACHINE_END
This page took 0.07906 seconds and 5 git commands to generate.