blob: f0a85c1d24a71dde8846e87899a7894482cc8192 [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>
22#include <linux/i2c/twl.h>
23#include <linux/mmc/host.h>
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>
31#include <plat/usb.h>
32#include <plat/onenand.h>
33
34#include "mux.h"
35#include "hsmmc.h"
36#include "sdram-numonyx-m65kxxxxam.h"
37
38#define IGEP3_GPIO_LED0_GREEN 54
39#define IGEP3_GPIO_LED0_RED 53
40#define IGEP3_GPIO_LED1_RED 16
41
42#define IGEP3_GPIO_WIFI_NPD 138
43#define IGEP3_GPIO_WIFI_NRESET 139
44#define IGEP3_GPIO_BT_NRESET 137
45
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +000046#define IGEP3_GPIO_USBH_NRESET 183
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -070047
48
49#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
50 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
51
52#define ONENAND_MAP 0x20000000
53
54/*
55 * x2 Flash built-in COMBO POP MEMORY
56 * Since the device is equipped with two DataRAMs, and two-plane NAND
57 * Flash memory array, these two component enables simultaneous program
58 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
59 * while Plane2 has only odd blocks such as block1, block3, block5.
60 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
61 */
62
63static struct mtd_partition igep3_onenand_partitions[] = {
64 {
65 .name = "X-Loader",
66 .offset = 0,
67 .size = 2 * (64*(2*2048))
68 },
69 {
70 .name = "U-Boot",
71 .offset = MTDPART_OFS_APPEND,
72 .size = 6 * (64*(2*2048)),
73 },
74 {
75 .name = "Environment",
76 .offset = MTDPART_OFS_APPEND,
77 .size = 2 * (64*(2*2048)),
78 },
79 {
80 .name = "Kernel",
81 .offset = MTDPART_OFS_APPEND,
82 .size = 12 * (64*(2*2048)),
83 },
84 {
85 .name = "File System",
86 .offset = MTDPART_OFS_APPEND,
87 .size = MTDPART_SIZ_FULL,
88 },
89};
90
91static struct omap_onenand_platform_data igep3_onenand_pdata = {
92 .parts = igep3_onenand_partitions,
93 .nr_parts = ARRAY_SIZE(igep3_onenand_partitions),
94 .onenand_setup = NULL,
95 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
96};
97
98static struct platform_device igep3_onenand_device = {
99 .name = "omap2-onenand",
100 .id = -1,
101 .dev = {
102 .platform_data = &igep3_onenand_pdata,
103 },
104};
105
Nishanth Menon23936082011-01-06 19:49:29 -0800106static void __init igep3_flash_init(void)
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700107{
108 u8 cs = 0;
109 u8 onenandcs = GPMC_CS_NUM + 1;
110
111 for (cs = 0; cs < GPMC_CS_NUM; cs++) {
112 u32 ret;
113 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
114
115 /* Check if NAND/oneNAND is configured */
116 if ((ret & 0xC00) == 0x800)
117 /* NAND found */
118 pr_err("IGEP3: Unsupported NAND found\n");
119 else {
120 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
121
122 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
123 /* OneNAND found */
124 onenandcs = cs;
125 }
126 }
127
128 if (onenandcs > GPMC_CS_NUM) {
129 pr_err("IGEP3: Unable to find configuration in GPMC\n");
130 return;
131 }
132
133 igep3_onenand_pdata.cs = onenandcs;
134
135 if (platform_device_register(&igep3_onenand_device) < 0)
136 pr_err("IGEP3: Unable to register OneNAND device\n");
137}
138
139#else
Nishanth Menon23936082011-01-06 19:49:29 -0800140static void __init igep3_flash_init(void) {}
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700141#endif
142
143static struct regulator_consumer_supply igep3_vmmc1_supply = {
144 .supply = "vmmc",
145};
146
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
162static struct omap2_hsmmc_info mmc[] = {
163 [0] = {
164 .mmc = 1,
165 .caps = MMC_CAP_4_BIT_DATA,
166 .gpio_cd = -EINVAL,
167 .gpio_wp = -EINVAL,
168 },
169#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
170 [1] = {
171 .mmc = 2,
172 .caps = MMC_CAP_4_BIT_DATA,
173 .gpio_cd = -EINVAL,
174 .gpio_wp = -EINVAL,
175 },
176#endif
177 {} /* Terminator */
178};
179
180#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
181#include <linux/leds.h>
182
183static struct gpio_led igep3_gpio_leds[] = {
184 [0] = {
185 .name = "gpio-led:red:d0",
186 .gpio = IGEP3_GPIO_LED0_RED,
187 .default_trigger = "default-off"
188 },
189 [1] = {
190 .name = "gpio-led:green:d0",
191 .gpio = IGEP3_GPIO_LED0_GREEN,
192 .default_trigger = "default-off",
193 },
194 [2] = {
195 .name = "gpio-led:red:d1",
196 .gpio = IGEP3_GPIO_LED1_RED,
197 .default_trigger = "default-off",
198 },
199 [3] = {
200 .name = "gpio-led:green:d1",
201 .default_trigger = "heartbeat",
202 .gpio = -EINVAL, /* gets replaced */
203 },
204};
205
206static struct gpio_led_platform_data igep3_led_pdata = {
207 .leds = igep3_gpio_leds,
208 .num_leds = ARRAY_SIZE(igep3_gpio_leds),
209};
210
211static struct platform_device igep3_led_device = {
212 .name = "leds-gpio",
213 .id = -1,
214 .dev = {
215 .platform_data = &igep3_led_pdata,
216 },
217};
218
219static void __init igep3_leds_init(void)
220{
221 platform_device_register(&igep3_led_device);
222}
223
224#else
225static inline void igep3_leds_init(void)
226{
227 if ((gpio_request(IGEP3_GPIO_LED0_RED, "gpio-led:red:d0") == 0) &&
228 (gpio_direction_output(IGEP3_GPIO_LED0_RED, 1) == 0)) {
229 gpio_export(IGEP3_GPIO_LED0_RED, 0);
230 gpio_set_value(IGEP3_GPIO_LED0_RED, 1);
231 } else
232 pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_RED\n");
233
234 if ((gpio_request(IGEP3_GPIO_LED0_GREEN, "gpio-led:green:d0") == 0) &&
235 (gpio_direction_output(IGEP3_GPIO_LED0_GREEN, 1) == 0)) {
236 gpio_export(IGEP3_GPIO_LED0_GREEN, 0);
237 gpio_set_value(IGEP3_GPIO_LED0_GREEN, 1);
238 } else
239 pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_GREEN\n");
240
241 if ((gpio_request(IGEP3_GPIO_LED1_RED, "gpio-led:red:d1") == 0) &&
242 (gpio_direction_output(IGEP3_GPIO_LED1_RED, 1) == 0)) {
243 gpio_export(IGEP3_GPIO_LED1_RED, 0);
244 gpio_set_value(IGEP3_GPIO_LED1_RED, 1);
245 } else
246 pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_RED\n");
247}
248#endif
249
250static int igep3_twl4030_gpio_setup(struct device *dev,
251 unsigned gpio, unsigned ngpio)
252{
253 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
254 mmc[0].gpio_cd = gpio + 0;
255 omap2_hsmmc_init(mmc);
256
257 /*
258 * link regulators to MMC adapters ... we "know" the
259 * regulators will be set up only *after* we return.
260 */
261 igep3_vmmc1_supply.dev = mmc[0].dev;
262
263 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
264#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
265 if ((gpio_request(gpio+TWL4030_GPIO_MAX+1, "gpio-led:green:d1") == 0)
266 && (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) {
267 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
268 gpio_set_value(gpio + TWL4030_GPIO_MAX + 1, 0);
269 } else
270 pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_GREEN\n");
271#else
272 igep3_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
273#endif
274
275 return 0;
276};
277
278static struct twl4030_gpio_platform_data igep3_twl4030_gpio_pdata = {
279 .gpio_base = OMAP_MAX_GPIO_LINES,
280 .irq_base = TWL4030_GPIO_IRQ_BASE,
281 .irq_end = TWL4030_GPIO_IRQ_END,
282 .use_leds = true,
283 .setup = igep3_twl4030_gpio_setup,
284};
285
286static struct twl4030_usb_data igep3_twl4030_usb_data = {
287 .usb_mode = T2_USB_MODE_ULPI,
288};
289
290static void __init igep3_init_irq(void)
291{
Paul Walmsley48057342010-12-21 15:25:10 -0700292 omap2_init_common_infrastructure();
293 omap2_init_common_devices(m65kxxxxam_sdrc_params,
294 m65kxxxxam_sdrc_params);
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700295 omap_init_irq();
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700296}
297
298static struct twl4030_platform_data igep3_twl4030_pdata = {
299 .irq_base = TWL4030_IRQ_BASE,
300 .irq_end = TWL4030_IRQ_END,
301
302 /* platform_data for children goes here */
303 .usb = &igep3_twl4030_usb_data,
304 .gpio = &igep3_twl4030_gpio_pdata,
305 .vmmc1 = &igep3_vmmc1,
306};
307
308static struct i2c_board_info __initdata igep3_i2c_boardinfo[] = {
309 {
310 I2C_BOARD_INFO("twl4030", 0x48),
311 .flags = I2C_CLIENT_WAKE,
312 .irq = INT_34XX_SYS_NIRQ,
313 .platform_data = &igep3_twl4030_pdata,
314 },
315};
316
317static int __init igep3_i2c_init(void)
318{
319 omap_register_i2c_bus(1, 2600, igep3_i2c_boardinfo,
320 ARRAY_SIZE(igep3_i2c_boardinfo));
321
322 return 0;
323}
324
325static struct omap_musb_board_data musb_board_data = {
326 .interface_type = MUSB_INTERFACE_ULPI,
327 .mode = MUSB_OTG,
328 .power = 100,
329};
330
331#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
332
333static void __init igep3_wifi_bt_init(void)
334{
335 /* Configure MUX values for W-LAN + Bluetooth GPIO's */
336 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NPD, OMAP_PIN_OUTPUT);
337 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NRESET, OMAP_PIN_OUTPUT);
338 omap_mux_init_gpio(IGEP3_GPIO_BT_NRESET, OMAP_PIN_OUTPUT);
339
340 /* Set GPIO's for W-LAN + Bluetooth combo module */
341 if ((gpio_request(IGEP3_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
342 (gpio_direction_output(IGEP3_GPIO_WIFI_NPD, 1) == 0)) {
343 gpio_export(IGEP3_GPIO_WIFI_NPD, 0);
344 } else
345 pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NPD\n");
346
347 if ((gpio_request(IGEP3_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
348 (gpio_direction_output(IGEP3_GPIO_WIFI_NRESET, 1) == 0)) {
349 gpio_export(IGEP3_GPIO_WIFI_NRESET, 0);
350 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 0);
351 udelay(10);
352 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 1);
353 } else
354 pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NRESET\n");
355
356 if ((gpio_request(IGEP3_GPIO_BT_NRESET, "GPIO_BT_NRESET") == 0) &&
357 (gpio_direction_output(IGEP3_GPIO_BT_NRESET, 1) == 0)) {
358 gpio_export(IGEP3_GPIO_BT_NRESET, 0);
359 } else
360 pr_warning("IGEP3: Could not obtain gpio GPIO_BT_NRESET\n");
361}
362#else
363void __init igep3_wifi_bt_init(void) {}
364#endif
365
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +0000366static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
367 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
368 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
369 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
370
371 .phy_reset = true,
372 .reset_gpio_port[0] = -EINVAL,
373 .reset_gpio_port[1] = IGEP3_GPIO_USBH_NRESET,
374 .reset_gpio_port[2] = -EINVAL,
375};
376
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700377#ifdef CONFIG_OMAP_MUX
378static struct omap_board_mux board_mux[] __initdata = {
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +0000379 OMAP3_MUX(I2C2_SDA, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700380 { .reg_offset = OMAP_MUX_TERMINATOR },
381};
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700382#endif
383
384static void __init igep3_init(void)
385{
386 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
387
388 /* Register I2C busses and drivers */
389 igep3_i2c_init();
390
391 omap_serial_init();
392 usb_musb_init(&musb_board_data);
Enric Balletbo i Serra7b0d4b72011-01-10 13:26:12 +0000393 usb_ehci_init(&ehci_pdata);
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700394
395 igep3_flash_init();
396 igep3_leds_init();
397
398 /*
399 * WLAN-BT combo module from MuRata wich has a Marvell WLAN
400 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
401 */
402 igep3_wifi_bt_init();
403
404}
405
406MACHINE_START(IGEP0030, "IGEP OMAP3 module")
Enric Balletbo i Serrae844b1d2010-10-08 10:22:11 -0700407 .boot_params = 0x80000100,
408 .map_io = omap3_map_io,
409 .init_irq = igep3_init_irq,
410 .init_machine = igep3_init,
411 .timer = &omap_timer,
412MACHINE_END