arm: omap2plus: GPIO cleanup
[deliverable/linux.git] / arch / arm / mach-omap2 / board-igep0030.c
CommitLineData
e844b1da
EBS
1/*
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>
a271c6cd 22#include <linux/regulator/fixed.h>
e844b1da
EBS
23#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"
fbd8071c 38#include "common-board-devices.h"
e844b1da
EBS
39
40#define IGEP3_GPIO_LED0_GREEN 54
41#define IGEP3_GPIO_LED0_RED 53
42#define IGEP3_GPIO_LED1_RED 16
43
44#define IGEP3_GPIO_WIFI_NPD 138
45#define IGEP3_GPIO_WIFI_NRESET 139
46#define IGEP3_GPIO_BT_NRESET 137
47
7b0d4b71 48#define IGEP3_GPIO_USBH_NRESET 183
e844b1da
EBS
49
50
51#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
52 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
53
54#define ONENAND_MAP 0x20000000
55
56/*
57 * x2 Flash built-in COMBO POP MEMORY
58 * Since the device is equipped with two DataRAMs, and two-plane NAND
59 * Flash memory array, these two component enables simultaneous program
60 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
61 * while Plane2 has only odd blocks such as block1, block3, block5.
62 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
63 */
64
65static struct mtd_partition igep3_onenand_partitions[] = {
66 {
67 .name = "X-Loader",
68 .offset = 0,
69 .size = 2 * (64*(2*2048))
70 },
71 {
72 .name = "U-Boot",
73 .offset = MTDPART_OFS_APPEND,
74 .size = 6 * (64*(2*2048)),
75 },
76 {
77 .name = "Environment",
78 .offset = MTDPART_OFS_APPEND,
79 .size = 2 * (64*(2*2048)),
80 },
81 {
82 .name = "Kernel",
83 .offset = MTDPART_OFS_APPEND,
84 .size = 12 * (64*(2*2048)),
85 },
86 {
87 .name = "File System",
88 .offset = MTDPART_OFS_APPEND,
89 .size = MTDPART_SIZ_FULL,
90 },
91};
92
93static struct omap_onenand_platform_data igep3_onenand_pdata = {
94 .parts = igep3_onenand_partitions,
95 .nr_parts = ARRAY_SIZE(igep3_onenand_partitions),
96 .onenand_setup = NULL,
97 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
98};
99
100static struct platform_device igep3_onenand_device = {
101 .name = "omap2-onenand",
102 .id = -1,
103 .dev = {
104 .platform_data = &igep3_onenand_pdata,
105 },
106};
107
2393608a 108static void __init igep3_flash_init(void)
e844b1da
EBS
109{
110 u8 cs = 0;
111 u8 onenandcs = GPMC_CS_NUM + 1;
112
113 for (cs = 0; cs < GPMC_CS_NUM; cs++) {
114 u32 ret;
115 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
116
117 /* Check if NAND/oneNAND is configured */
118 if ((ret & 0xC00) == 0x800)
119 /* NAND found */
120 pr_err("IGEP3: Unsupported NAND found\n");
121 else {
122 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
123
124 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
125 /* OneNAND found */
126 onenandcs = cs;
127 }
128 }
129
130 if (onenandcs > GPMC_CS_NUM) {
131 pr_err("IGEP3: Unable to find configuration in GPMC\n");
132 return;
133 }
134
135 igep3_onenand_pdata.cs = onenandcs;
136
137 if (platform_device_register(&igep3_onenand_device) < 0)
138 pr_err("IGEP3: Unable to register OneNAND device\n");
139}
140
141#else
2393608a 142static void __init igep3_flash_init(void) {}
e844b1da
EBS
143#endif
144
a271c6cd 145static struct regulator_consumer_supply igep3_vmmc1_supply =
0005ae73 146 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0");
e844b1da
EBS
147
148/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
149static struct regulator_init_data igep3_vmmc1 = {
150 .constraints = {
151 .min_uV = 1850000,
152 .max_uV = 3150000,
153 .valid_modes_mask = REGULATOR_MODE_NORMAL
154 | REGULATOR_MODE_STANDBY,
155 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
156 | REGULATOR_CHANGE_MODE
157 | REGULATOR_CHANGE_STATUS,
158 },
159 .num_consumer_supplies = 1,
160 .consumer_supplies = &igep3_vmmc1_supply,
161};
162
a271c6cd 163static struct regulator_consumer_supply igep3_vio_supply =
0005ae73 164 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1");
a271c6cd
EBS
165
166static struct regulator_init_data igep3_vio = {
167 .constraints = {
168 .min_uV = 1800000,
169 .max_uV = 1800000,
170 .apply_uV = 1,
171 .valid_modes_mask = REGULATOR_MODE_NORMAL
172 | REGULATOR_MODE_STANDBY,
173 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
174 | REGULATOR_CHANGE_MODE
175 | REGULATOR_CHANGE_STATUS,
176 },
177 .num_consumer_supplies = 1,
178 .consumer_supplies = &igep3_vio_supply,
179};
180
181static struct regulator_consumer_supply igep3_vmmc2_supply =
0005ae73 182 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1");
a271c6cd
EBS
183
184static struct regulator_init_data igep3_vmmc2 = {
185 .constraints = {
186 .valid_modes_mask = REGULATOR_MODE_NORMAL,
187 .always_on = 1,
188 },
189 .num_consumer_supplies = 1,
190 .consumer_supplies = &igep3_vmmc2_supply,
191};
192
193static struct fixed_voltage_config igep3_vwlan = {
194 .supply_name = "vwlan",
195 .microvolts = 3300000,
196 .gpio = -EINVAL,
197 .enabled_at_boot = 1,
198 .init_data = &igep3_vmmc2,
199};
200
201static struct platform_device igep3_vwlan_device = {
202 .name = "reg-fixed-voltage",
203 .id = 0,
204 .dev = {
205 .platform_data = &igep3_vwlan,
206 },
207};
208
e844b1da
EBS
209static struct omap2_hsmmc_info mmc[] = {
210 [0] = {
211 .mmc = 1,
212 .caps = MMC_CAP_4_BIT_DATA,
213 .gpio_cd = -EINVAL,
214 .gpio_wp = -EINVAL,
215 },
216#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
217 [1] = {
218 .mmc = 2,
219 .caps = MMC_CAP_4_BIT_DATA,
220 .gpio_cd = -EINVAL,
221 .gpio_wp = -EINVAL,
222 },
223#endif
224 {} /* Terminator */
225};
226
227#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
228#include <linux/leds.h>
229
230static struct gpio_led igep3_gpio_leds[] = {
231 [0] = {
232 .name = "gpio-led:red:d0",
233 .gpio = IGEP3_GPIO_LED0_RED,
234 .default_trigger = "default-off"
235 },
236 [1] = {
237 .name = "gpio-led:green:d0",
238 .gpio = IGEP3_GPIO_LED0_GREEN,
239 .default_trigger = "default-off",
240 },
241 [2] = {
242 .name = "gpio-led:red:d1",
243 .gpio = IGEP3_GPIO_LED1_RED,
244 .default_trigger = "default-off",
245 },
246 [3] = {
247 .name = "gpio-led:green:d1",
248 .default_trigger = "heartbeat",
249 .gpio = -EINVAL, /* gets replaced */
250 },
251};
252
253static struct gpio_led_platform_data igep3_led_pdata = {
254 .leds = igep3_gpio_leds,
255 .num_leds = ARRAY_SIZE(igep3_gpio_leds),
256};
257
258static struct platform_device igep3_led_device = {
259 .name = "leds-gpio",
260 .id = -1,
261 .dev = {
262 .platform_data = &igep3_led_pdata,
263 },
264};
265
266static void __init igep3_leds_init(void)
267{
268 platform_device_register(&igep3_led_device);
269}
270
271#else
bc593f5d
IG
272static struct gpio igep3_gpio_leds[] __initdata = {
273 { IGEP3_GPIO_LED0_RED, GPIOF_OUT_INIT_HIGH, "gpio-led:red:d0" },
274 { IGEP3_GPIO_LED0_GREEN, GPIOF_OUT_INIT_HIGH, "gpio-led:green:d0" },
275 { IGEP3_GPIO_LED1_RED, GPIOF_OUT_INIT_HIGH, "gpio-led:red:d1" },
276};
277
e844b1da
EBS
278static inline void igep3_leds_init(void)
279{
bc593f5d
IG
280 if (gpio_request_array(igep3_gpio_leds, ARRAY_SIZE(igep3_gpio_leds))) {
281 pr_warning("IGEP3: Could not obtain leds gpios\n");
282 return;
283 }
284 gpio_export(IGEP3_GPIO_LED0_RED, 0);
285 gpio_export(IGEP3_GPIO_LED0_GREEN, 0);
286 gpio_export(IGEP3_GPIO_LED1_RED, 0);
e844b1da
EBS
287}
288#endif
289
290static int igep3_twl4030_gpio_setup(struct device *dev,
291 unsigned gpio, unsigned ngpio)
292{
bc593f5d
IG
293#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
294 int ret;
e844b1da 295
e844b1da 296 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
bc593f5d
IG
297 ret = gpio_request_one(gpio + TWL4030_GPIO_MAX + 1, GPIOF_OUT_INIT_HIGH,
298 "gpio-led:green:d1");
299 if (ret)
e844b1da 300 pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_GREEN\n");
bc593f5d
IG
301 else
302 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
e844b1da
EBS
303#else
304 igep3_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
305#endif
bc593f5d
IG
306 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
307 mmc[0].gpio_cd = gpio + 0;
308 omap2_hsmmc_init(mmc);
e844b1da
EBS
309
310 return 0;
311};
312
313static struct twl4030_gpio_platform_data igep3_twl4030_gpio_pdata = {
314 .gpio_base = OMAP_MAX_GPIO_LINES,
315 .irq_base = TWL4030_GPIO_IRQ_BASE,
316 .irq_end = TWL4030_GPIO_IRQ_END,
317 .use_leds = true,
318 .setup = igep3_twl4030_gpio_setup,
319};
320
321static struct twl4030_usb_data igep3_twl4030_usb_data = {
322 .usb_mode = T2_USB_MODE_ULPI,
323};
324
a271c6cd
EBS
325static struct platform_device *igep3_devices[] __initdata = {
326 &igep3_vwlan_device,
327};
328
3dc3bad6 329static void __init igep3_init_early(void)
e844b1da 330{
4805734b
PW
331 omap2_init_common_infrastructure();
332 omap2_init_common_devices(m65kxxxxam_sdrc_params,
333 m65kxxxxam_sdrc_params);
e844b1da
EBS
334}
335
336static struct twl4030_platform_data igep3_twl4030_pdata = {
337 .irq_base = TWL4030_IRQ_BASE,
338 .irq_end = TWL4030_IRQ_END,
339
340 /* platform_data for children goes here */
341 .usb = &igep3_twl4030_usb_data,
342 .gpio = &igep3_twl4030_gpio_pdata,
343 .vmmc1 = &igep3_vmmc1,
a271c6cd 344 .vio = &igep3_vio,
e844b1da
EBS
345};
346
e844b1da
EBS
347static int __init igep3_i2c_init(void)
348{
fbd8071c 349 omap3_pmic_init("twl4030", &igep3_twl4030_pdata);
e844b1da
EBS
350
351 return 0;
352}
353
e844b1da 354#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
bc593f5d
IG
355static struct gpio igep3_wlan_bt_gpios[] __initdata = {
356 { IGEP3_GPIO_WIFI_NPD, GPIOF_OUT_INIT_HIGH, "GPIO_WIFI_NPD" },
357 { IGEP3_GPIO_WIFI_NRESET, GPIOF_OUT_INIT_HIGH, "GPIO_WIFI_NRESET" },
358 { IGEP3_GPIO_BT_NRESET, GPIOF_OUT_INIT_HIGH, "GPIO_BT_NRESET" },
359};
e844b1da
EBS
360
361static void __init igep3_wifi_bt_init(void)
362{
bc593f5d
IG
363 int err;
364
e844b1da
EBS
365 /* Configure MUX values for W-LAN + Bluetooth GPIO's */
366 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NPD, OMAP_PIN_OUTPUT);
367 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NRESET, OMAP_PIN_OUTPUT);
368 omap_mux_init_gpio(IGEP3_GPIO_BT_NRESET, OMAP_PIN_OUTPUT);
369
370 /* Set GPIO's for W-LAN + Bluetooth combo module */
bc593f5d
IG
371 err = gpio_request_array(igep3_wlan_bt_gpios,
372 ARRAY_SIZE(igep3_wlan_bt_gpios));
373 if (err) {
374 pr_warning("IGEP3: Could not obtain WIFI/BT gpios\n");
375 return;
376 }
377
378 gpio_export(IGEP3_GPIO_WIFI_NPD, 0);
379 gpio_export(IGEP3_GPIO_WIFI_NRESET, 0);
380 gpio_export(IGEP3_GPIO_BT_NRESET, 0);
381
382 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 0);
383 udelay(10);
384 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 1);
e844b1da
EBS
385}
386#else
387void __init igep3_wifi_bt_init(void) {}
388#endif
389
181b250c
KM
390static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
391 .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
392 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
393 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
7b0d4b71
EBS
394
395 .phy_reset = true,
396 .reset_gpio_port[0] = -EINVAL,
397 .reset_gpio_port[1] = IGEP3_GPIO_USBH_NRESET,
398 .reset_gpio_port[2] = -EINVAL,
399};
400
e844b1da
EBS
401#ifdef CONFIG_OMAP_MUX
402static struct omap_board_mux board_mux[] __initdata = {
7b0d4b71 403 OMAP3_MUX(I2C2_SDA, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
e844b1da
EBS
404 { .reg_offset = OMAP_MUX_TERMINATOR },
405};
e844b1da
EBS
406#endif
407
408static void __init igep3_init(void)
409{
410 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
411
412 /* Register I2C busses and drivers */
413 igep3_i2c_init();
a271c6cd 414 platform_add_devices(igep3_devices, ARRAY_SIZE(igep3_devices));
e844b1da 415 omap_serial_init();
9e18630b 416 usb_musb_init(NULL);
9e64bb1e 417 usbhs_init(&usbhs_bdata);
e844b1da
EBS
418
419 igep3_flash_init();
420 igep3_leds_init();
421
422 /*
25985edc 423 * WLAN-BT combo module from MuRata which has a Marvell WLAN
e844b1da
EBS
424 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
425 */
426 igep3_wifi_bt_init();
427
428}
429
430MACHINE_START(IGEP0030, "IGEP OMAP3 module")
e844b1da 431 .boot_params = 0x80000100,
0f7e2aaa 432 .reserve = omap_reserve,
e844b1da 433 .map_io = omap3_map_io,
3dc3bad6
RKAL
434 .init_early = igep3_init_early,
435 .init_irq = omap_init_irq,
e844b1da
EBS
436 .init_machine = igep3_init,
437 .timer = &omap_timer,
438MACHINE_END
This page took 0.079989 seconds and 5 git commands to generate.