blob: 4dc62a9b9cb24811fae3f0c1fc1149f31e7e0f34 [file] [log] [blame]
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -07001/*
2 * Copyright (C) 2010 - ISEE 2007 SL
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>
Enric Balletbo i Serraa271c6c2011-01-10 13:26:13 +000022#include <linux/regulator/fixed.h>
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -070023#include <linux/i2c/twl.h>
24#include <linux/mmc/host.h>
25
26#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28
29#include <plat/board.h>
30#include <plat/common.h>
31#include <plat/gpmc.h>
32#include <plat/usb.h>
33#include <plat/onenand.h>
34
35#include "mux.h"
36#include "hsmmc.h"
37#include "sdram-numonyx-m65kxxxxam.h"
38
39#define IGEP3_GPIO_LED0_GREEN 54
40#define IGEP3_GPIO_LED0_RED 53
41#define IGEP3_GPIO_LED1_RED 16
42
43#define IGEP3_GPIO_WIFI_NPD 138
44#define IGEP3_GPIO_WIFI_NRESET 139
45#define IGEP3_GPIO_BT_NRESET 137
46
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +000047#define IGEP3_GPIO_USBH_NRESET 183
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -070048
49
50#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
51 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
52
53#define ONENAND_MAP 0x20000000
54
55/*
56 * x2 Flash built-in COMBO POP MEMORY
57 * Since the device is equipped with two DataRAMs, and two-plane NAND
58 * Flash memory array, these two component enables simultaneous program
59 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
60 * while Plane2 has only odd blocks such as block1, block3, block5.
61 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
62 */
63
64static struct mtd_partition igep3_onenand_partitions[] = {
65 {
66 .name = "X-Loader",
67 .offset = 0,
68 .size = 2 * (64*(2*2048))
69 },
70 {
71 .name = "U-Boot",
72 .offset = MTDPART_OFS_APPEND,
73 .size = 6 * (64*(2*2048)),
74 },
75 {
76 .name = "Environment",
77 .offset = MTDPART_OFS_APPEND,
78 .size = 2 * (64*(2*2048)),
79 },
80 {
81 .name = "Kernel",
82 .offset = MTDPART_OFS_APPEND,
83 .size = 12 * (64*(2*2048)),
84 },
85 {
86 .name = "File System",
87 .offset = MTDPART_OFS_APPEND,
88 .size = MTDPART_SIZ_FULL,
89 },
90};
91
92static struct omap_onenand_platform_data igep3_onenand_pdata = {
93 .parts = igep3_onenand_partitions,
94 .nr_parts = ARRAY_SIZE(igep3_onenand_partitions),
95 .onenand_setup = NULL,
96 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
97};
98
99static struct platform_device igep3_onenand_device = {
100 .name = "omap2-onenand",
101 .id = -1,
102 .dev = {
103 .platform_data = &igep3_onenand_pdata,
104 },
105};
106
Nishanth Menon23936082011-01-06 19:49:29 -0800107static void __init igep3_flash_init(void)
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700108{
109 u8 cs = 0;
110 u8 onenandcs = GPMC_CS_NUM + 1;
111
112 for (cs = 0; cs < GPMC_CS_NUM; cs++) {
113 u32 ret;
114 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
115
116 /* Check if NAND/oneNAND is configured */
117 if ((ret & 0xC00) == 0x800)
118 /* NAND found */
119 pr_err("IGEP3: Unsupported NAND found\n");
120 else {
121 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
122
123 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
124 /* OneNAND found */
125 onenandcs = cs;
126 }
127 }
128
129 if (onenandcs > GPMC_CS_NUM) {
130 pr_err("IGEP3: Unable to find configuration in GPMC\n");
131 return;
132 }
133
134 igep3_onenand_pdata.cs = onenandcs;
135
136 if (platform_device_register(&igep3_onenand_device) < 0)
137 pr_err("IGEP3: Unable to register OneNAND device\n");
138}
139
140#else
Nishanth Menon23936082011-01-06 19:49:29 -0800141static void __init igep3_flash_init(void) {}
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700142#endif
143
Enric Balletbo i Serraa271c6c2011-01-10 13:26:13 +0000144static struct regulator_consumer_supply igep3_vmmc1_supply =
145 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700146
147/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
148static struct regulator_init_data igep3_vmmc1 = {
149 .constraints = {
150 .min_uV = 1850000,
151 .max_uV = 3150000,
152 .valid_modes_mask = REGULATOR_MODE_NORMAL
153 | REGULATOR_MODE_STANDBY,
154 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
155 | REGULATOR_CHANGE_MODE
156 | REGULATOR_CHANGE_STATUS,
157 },
158 .num_consumer_supplies = 1,
159 .consumer_supplies = &igep3_vmmc1_supply,
160};
161
Enric Balletbo i Serraa271c6c2011-01-10 13:26:13 +0000162static struct regulator_consumer_supply igep3_vio_supply =
163 REGULATOR_SUPPLY("vmmc_aux", "mmci-omap-hs.1");
164
165static struct regulator_init_data igep3_vio = {
166 .constraints = {
167 .min_uV = 1800000,
168 .max_uV = 1800000,
169 .apply_uV = 1,
170 .valid_modes_mask = REGULATOR_MODE_NORMAL
171 | REGULATOR_MODE_STANDBY,
172 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
173 | REGULATOR_CHANGE_MODE
174 | REGULATOR_CHANGE_STATUS,
175 },
176 .num_consumer_supplies = 1,
177 .consumer_supplies = &igep3_vio_supply,
178};
179
180static struct regulator_consumer_supply igep3_vmmc2_supply =
181 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
182
183static struct regulator_init_data igep3_vmmc2 = {
184 .constraints = {
185 .valid_modes_mask = REGULATOR_MODE_NORMAL,
186 .always_on = 1,
187 },
188 .num_consumer_supplies = 1,
189 .consumer_supplies = &igep3_vmmc2_supply,
190};
191
192static struct fixed_voltage_config igep3_vwlan = {
193 .supply_name = "vwlan",
194 .microvolts = 3300000,
195 .gpio = -EINVAL,
196 .enabled_at_boot = 1,
197 .init_data = &igep3_vmmc2,
198};
199
200static struct platform_device igep3_vwlan_device = {
201 .name = "reg-fixed-voltage",
202 .id = 0,
203 .dev = {
204 .platform_data = &igep3_vwlan,
205 },
206};
207
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700208static struct omap2_hsmmc_info mmc[] = {
209 [0] = {
210 .mmc = 1,
211 .caps = MMC_CAP_4_BIT_DATA,
212 .gpio_cd = -EINVAL,
213 .gpio_wp = -EINVAL,
214 },
215#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
216 [1] = {
217 .mmc = 2,
218 .caps = MMC_CAP_4_BIT_DATA,
219 .gpio_cd = -EINVAL,
220 .gpio_wp = -EINVAL,
221 },
222#endif
223 {} /* Terminator */
224};
225
226#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
227#include <linux/leds.h>
228
229static struct gpio_led igep3_gpio_leds[] = {
230 [0] = {
231 .name = "gpio-led:red:d0",
232 .gpio = IGEP3_GPIO_LED0_RED,
233 .default_trigger = "default-off"
234 },
235 [1] = {
236 .name = "gpio-led:green:d0",
237 .gpio = IGEP3_GPIO_LED0_GREEN,
238 .default_trigger = "default-off",
239 },
240 [2] = {
241 .name = "gpio-led:red:d1",
242 .gpio = IGEP3_GPIO_LED1_RED,
243 .default_trigger = "default-off",
244 },
245 [3] = {
246 .name = "gpio-led:green:d1",
247 .default_trigger = "heartbeat",
248 .gpio = -EINVAL, /* gets replaced */
249 },
250};
251
252static struct gpio_led_platform_data igep3_led_pdata = {
253 .leds = igep3_gpio_leds,
254 .num_leds = ARRAY_SIZE(igep3_gpio_leds),
255};
256
257static struct platform_device igep3_led_device = {
258 .name = "leds-gpio",
259 .id = -1,
260 .dev = {
261 .platform_data = &igep3_led_pdata,
262 },
263};
264
265static void __init igep3_leds_init(void)
266{
267 platform_device_register(&igep3_led_device);
268}
269
270#else
271static inline void igep3_leds_init(void)
272{
273 if ((gpio_request(IGEP3_GPIO_LED0_RED, "gpio-led:red:d0") == 0) &&
274 (gpio_direction_output(IGEP3_GPIO_LED0_RED, 1) == 0)) {
275 gpio_export(IGEP3_GPIO_LED0_RED, 0);
276 gpio_set_value(IGEP3_GPIO_LED0_RED, 1);
277 } else
278 pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_RED\n");
279
280 if ((gpio_request(IGEP3_GPIO_LED0_GREEN, "gpio-led:green:d0") == 0) &&
281 (gpio_direction_output(IGEP3_GPIO_LED0_GREEN, 1) == 0)) {
282 gpio_export(IGEP3_GPIO_LED0_GREEN, 0);
283 gpio_set_value(IGEP3_GPIO_LED0_GREEN, 1);
284 } else
285 pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_GREEN\n");
286
287 if ((gpio_request(IGEP3_GPIO_LED1_RED, "gpio-led:red:d1") == 0) &&
288 (gpio_direction_output(IGEP3_GPIO_LED1_RED, 1) == 0)) {
289 gpio_export(IGEP3_GPIO_LED1_RED, 0);
290 gpio_set_value(IGEP3_GPIO_LED1_RED, 1);
291 } else
292 pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_RED\n");
293}
294#endif
295
296static int igep3_twl4030_gpio_setup(struct device *dev,
297 unsigned gpio, unsigned ngpio)
298{
299 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
300 mmc[0].gpio_cd = gpio + 0;
301 omap2_hsmmc_init(mmc);
302
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700303 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
304#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
305 if ((gpio_request(gpio+TWL4030_GPIO_MAX+1, "gpio-led:green:d1") == 0)
306 && (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) {
307 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
308 gpio_set_value(gpio + TWL4030_GPIO_MAX + 1, 0);
309 } else
310 pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_GREEN\n");
311#else
312 igep3_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
313#endif
314
315 return 0;
316};
317
318static struct twl4030_gpio_platform_data igep3_twl4030_gpio_pdata = {
319 .gpio_base = OMAP_MAX_GPIO_LINES,
320 .irq_base = TWL4030_GPIO_IRQ_BASE,
321 .irq_end = TWL4030_GPIO_IRQ_END,
322 .use_leds = true,
323 .setup = igep3_twl4030_gpio_setup,
324};
325
326static struct twl4030_usb_data igep3_twl4030_usb_data = {
327 .usb_mode = T2_USB_MODE_ULPI,
328};
329
Enric Balletbo i Serraa271c6c2011-01-10 13:26:13 +0000330static struct platform_device *igep3_devices[] __initdata = {
331 &igep3_vwlan_device,
332};
333
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700334static void __init igep3_init_irq(void)
335{
Paul Walmsley48057342010-12-21 15:25:10 -0700336 omap2_init_common_infrastructure();
337 omap2_init_common_devices(m65kxxxxam_sdrc_params,
338 m65kxxxxam_sdrc_params);
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700339 omap_init_irq();
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700340}
341
342static struct twl4030_platform_data igep3_twl4030_pdata = {
343 .irq_base = TWL4030_IRQ_BASE,
344 .irq_end = TWL4030_IRQ_END,
345
346 /* platform_data for children goes here */
347 .usb = &igep3_twl4030_usb_data,
348 .gpio = &igep3_twl4030_gpio_pdata,
349 .vmmc1 = &igep3_vmmc1,
Enric Balletbo i Serraa271c6c2011-01-10 13:26:13 +0000350 .vio = &igep3_vio,
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700351};
352
353static struct i2c_board_info __initdata igep3_i2c_boardinfo[] = {
354 {
355 I2C_BOARD_INFO("twl4030", 0x48),
356 .flags = I2C_CLIENT_WAKE,
357 .irq = INT_34XX_SYS_NIRQ,
358 .platform_data = &igep3_twl4030_pdata,
359 },
360};
361
362static int __init igep3_i2c_init(void)
363{
364 omap_register_i2c_bus(1, 2600, igep3_i2c_boardinfo,
365 ARRAY_SIZE(igep3_i2c_boardinfo));
366
367 return 0;
368}
369
370static struct omap_musb_board_data musb_board_data = {
371 .interface_type = MUSB_INTERFACE_ULPI,
372 .mode = MUSB_OTG,
373 .power = 100,
374};
375
376#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
377
378static void __init igep3_wifi_bt_init(void)
379{
380 /* Configure MUX values for W-LAN + Bluetooth GPIO's */
381 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NPD, OMAP_PIN_OUTPUT);
382 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NRESET, OMAP_PIN_OUTPUT);
383 omap_mux_init_gpio(IGEP3_GPIO_BT_NRESET, OMAP_PIN_OUTPUT);
384
385 /* Set GPIO's for W-LAN + Bluetooth combo module */
386 if ((gpio_request(IGEP3_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
387 (gpio_direction_output(IGEP3_GPIO_WIFI_NPD, 1) == 0)) {
388 gpio_export(IGEP3_GPIO_WIFI_NPD, 0);
389 } else
390 pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NPD\n");
391
392 if ((gpio_request(IGEP3_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
393 (gpio_direction_output(IGEP3_GPIO_WIFI_NRESET, 1) == 0)) {
394 gpio_export(IGEP3_GPIO_WIFI_NRESET, 0);
395 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 0);
396 udelay(10);
397 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 1);
398 } else
399 pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NRESET\n");
400
401 if ((gpio_request(IGEP3_GPIO_BT_NRESET, "GPIO_BT_NRESET") == 0) &&
402 (gpio_direction_output(IGEP3_GPIO_BT_NRESET, 1) == 0)) {
403 gpio_export(IGEP3_GPIO_BT_NRESET, 0);
404 } else
405 pr_warning("IGEP3: Could not obtain gpio GPIO_BT_NRESET\n");
406}
407#else
408void __init igep3_wifi_bt_init(void) {}
409#endif
410
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +0000411static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
412 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
413 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
414 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
415
416 .phy_reset = true,
417 .reset_gpio_port[0] = -EINVAL,
418 .reset_gpio_port[1] = IGEP3_GPIO_USBH_NRESET,
419 .reset_gpio_port[2] = -EINVAL,
420};
421
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700422#ifdef CONFIG_OMAP_MUX
423static struct omap_board_mux board_mux[] __initdata = {
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +0000424 OMAP3_MUX(I2C2_SDA, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700425 { .reg_offset = OMAP_MUX_TERMINATOR },
426};
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700427#endif
428
429static void __init igep3_init(void)
430{
431 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
432
433 /* Register I2C busses and drivers */
434 igep3_i2c_init();
Enric Balletbo i Serraa271c6c2011-01-10 13:26:13 +0000435 platform_add_devices(igep3_devices, ARRAY_SIZE(igep3_devices));
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700436 omap_serial_init();
437 usb_musb_init(&musb_board_data);
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +0000438 usb_ehci_init(&ehci_pdata);
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700439
440 igep3_flash_init();
441 igep3_leds_init();
442
443 /*
444 * WLAN-BT combo module from MuRata wich has a Marvell WLAN
445 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
446 */
447 igep3_wifi_bt_init();
448
449}
450
451MACHINE_START(IGEP0030, "IGEP OMAP3 module")
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700452 .boot_params = 0x80000100,
Enric Balletbo i Serra0f7e2aa2011-01-11 15:47:54 +0000453 .reserve = omap_reserve,
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700454 .map_io = omap3_map_io,
455 .init_irq = igep3_init_irq,
456 .init_machine = igep3_init,
457 .timer = &omap_timer,
458MACHINE_END