omap: panda: add fixed regulator device for wlan
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-omap2 / board-omap4panda.c
CommitLineData
b075f58b
DA
1/*
2 * Board support file for OMAP4430 based PandaBoard.
3 *
4 * Copyright (C) 2010 Texas Instruments
5 *
6 * Author: David Anders <x0132446@ti.com>
7 *
8 * Based on mach-omap2/board-4430sdp.c
9 *
10 * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
11 *
12 * Based on mach-omap2/board-3430sdp.c
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 */
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
1740d483 22#include <linux/clk.h>
b075f58b 23#include <linux/io.h>
3da434ac 24#include <linux/leds.h>
b075f58b
DA
25#include <linux/gpio.h>
26#include <linux/usb/otg.h>
27#include <linux/i2c/twl.h>
28#include <linux/regulator/machine.h>
edc84061 29#include <linux/regulator/fixed.h>
b075f58b
DA
30
31#include <mach/hardware.h>
32#include <mach/omap4-common.h>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36
37#include <plat/board.h>
38#include <plat/common.h>
b075f58b
DA
39#include <plat/usb.h>
40#include <plat/mmc.h>
04aeae77 41#include "timer-gp.h"
b075f58b 42
b075f58b 43#include "hsmmc.h"
4814ced5 44#include "control.h"
fc63de82 45#include "mux.h"
b075f58b 46
4415beb6
DA
47#define GPIO_HUB_POWER 1
48#define GPIO_HUB_NRESET 62
edc84061 49#define GPIO_WIFI_PMENA 43
4415beb6 50
3da434ac
RSA
51static struct gpio_led gpio_leds[] = {
52 {
53 .name = "pandaboard::status1",
54 .default_trigger = "heartbeat",
55 .gpio = 7,
56 },
57 {
58 .name = "pandaboard::status2",
59 .default_trigger = "mmc0",
60 .gpio = 8,
61 },
62};
b075f58b 63
3da434ac
RSA
64static struct gpio_led_platform_data gpio_led_info = {
65 .leds = gpio_leds,
66 .num_leds = ARRAY_SIZE(gpio_leds),
67};
68
69static struct platform_device leds_gpio = {
70 .name = "leds-gpio",
71 .id = -1,
72 .dev = {
73 .platform_data = &gpio_led_info,
74 },
75};
76
77static struct platform_device *panda_devices[] __initdata = {
78 &leds_gpio,
79};
b075f58b 80
3dc3bad6 81static void __init omap4_panda_init_early(void)
b075f58b 82{
4805734b
PW
83 omap2_init_common_infrastructure();
84 omap2_init_common_devices(NULL, NULL);
b075f58b
DA
85}
86
4415beb6
DA
87static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
88 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
89 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
90 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
91 .phy_reset = false,
92 .reset_gpio_port[0] = -EINVAL,
93 .reset_gpio_port[1] = -EINVAL,
94 .reset_gpio_port[2] = -EINVAL
95};
96
97static void __init omap4_ehci_init(void)
98{
99 int ret;
1740d483 100 struct clk *phy_ref_clk;
4415beb6 101
1740d483
AG
102 /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
103 phy_ref_clk = clk_get(NULL, "auxclk3_ck");
104 if (IS_ERR(phy_ref_clk)) {
105 pr_err("Cannot request auxclk3\n");
106 goto error1;
107 }
108 clk_set_rate(phy_ref_clk, 19200000);
109 clk_enable(phy_ref_clk);
4415beb6
DA
110
111 /* disable the power to the usb hub prior to init */
112 ret = gpio_request(GPIO_HUB_POWER, "hub_power");
113 if (ret) {
114 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
115 goto error1;
116 }
117 gpio_export(GPIO_HUB_POWER, 0);
118 gpio_direction_output(GPIO_HUB_POWER, 0);
119 gpio_set_value(GPIO_HUB_POWER, 0);
120
121 /* reset phy+hub */
122 ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
123 if (ret) {
124 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
125 goto error2;
126 }
127 gpio_export(GPIO_HUB_NRESET, 0);
128 gpio_direction_output(GPIO_HUB_NRESET, 0);
129 gpio_set_value(GPIO_HUB_NRESET, 0);
130 gpio_set_value(GPIO_HUB_NRESET, 1);
131
132 usb_ehci_init(&ehci_pdata);
133
134 /* enable power to hub */
135 gpio_set_value(GPIO_HUB_POWER, 1);
136 return;
137
138error2:
139 gpio_free(GPIO_HUB_POWER);
140error1:
141 pr_err("Unable to initialize EHCI power/reset\n");
142 return;
143
144}
145
b075f58b
DA
146static struct omap_musb_board_data musb_board_data = {
147 .interface_type = MUSB_INTERFACE_UTMI,
09e72002 148 .mode = MUSB_OTG,
b075f58b
DA
149 .power = 100,
150};
151
e70357e3
HH
152static struct twl4030_usb_data omap4_usbphy_data = {
153 .phy_init = omap4430_phy_init,
154 .phy_exit = omap4430_phy_exit,
155 .phy_power = omap4430_phy_power,
156 .phy_set_clock = omap4430_phy_set_clk,
157};
158
b075f58b
DA
159static struct omap2_hsmmc_info mmc[] = {
160 {
161 .mmc = 1,
3a63833e 162 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
b075f58b 163 .gpio_wp = -EINVAL,
5b59cc2f 164 .gpio_cd = -EINVAL,
b075f58b
DA
165 },
166 {} /* Terminator */
167};
168
169static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
170 {
171 .supply = "vmmc",
172 .dev_name = "mmci-omap-hs.0",
173 },
b075f58b
DA
174};
175
edc84061
PM
176static struct regulator_consumer_supply omap4_panda_vmmc5_supply = {
177 .supply = "vmmc",
178 .dev_name = "mmci-omap-hs.4",
179};
180
181static struct regulator_init_data panda_vmmc5 = {
182 .constraints = {
183 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
184 },
185 .num_consumer_supplies = 1,
186 .consumer_supplies = &omap4_panda_vmmc5_supply,
187};
188
189static struct fixed_voltage_config panda_vwlan = {
190 .supply_name = "vwl1271",
191 .microvolts = 1800000, /* 1.8V */
192 .gpio = GPIO_WIFI_PMENA,
193 .startup_delay = 70000, /* 70msec */
194 .enable_high = 1,
195 .enabled_at_boot = 0,
196 .init_data = &panda_vmmc5,
197};
198
199static struct platform_device omap_vwlan_device = {
200 .name = "reg-fixed-voltage",
201 .id = 1,
202 .dev = {
203 .platform_data = &panda_vwlan,
204 },
205};
206
b075f58b
DA
207static int omap4_twl6030_hsmmc_late_init(struct device *dev)
208{
209 int ret = 0;
210 struct platform_device *pdev = container_of(dev,
211 struct platform_device, dev);
212 struct omap_mmc_platform_data *pdata = dev->platform_data;
213
bf56f0a6
MN
214 if (!pdata) {
215 dev_err(dev, "%s: NULL platform data\n", __func__);
216 return -EINVAL;
217 }
b075f58b 218 /* Setting MMC1 Card detect Irq */
bf56f0a6
MN
219 if (pdev->id == 0) {
220 ret = twl6030_mmc_card_detect_config();
221 if (ret)
222 dev_err(dev, "%s: Error card detect config(%d)\n",
223 __func__, ret);
224 else
225 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
226 }
b075f58b
DA
227 return ret;
228}
229
230static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
231{
b9b52620
DA
232 struct omap_mmc_platform_data *pdata;
233
234 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
235 if (!dev) {
236 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
237 return;
238 }
239 pdata = dev->platform_data;
b075f58b
DA
240
241 pdata->init = omap4_twl6030_hsmmc_late_init;
242}
243
244static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
245{
246 struct omap2_hsmmc_info *c;
247
248 omap2_hsmmc_init(controllers);
249 for (c = controllers; c->mmc; c++)
250 omap4_twl6030_hsmmc_set_late_init(c->dev);
251
252 return 0;
253}
254
255static struct regulator_init_data omap4_panda_vaux1 = {
256 .constraints = {
257 .min_uV = 1000000,
258 .max_uV = 3000000,
259 .apply_uV = true,
260 .valid_modes_mask = REGULATOR_MODE_NORMAL
261 | REGULATOR_MODE_STANDBY,
262 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
263 | REGULATOR_CHANGE_MODE
264 | REGULATOR_CHANGE_STATUS,
265 },
266};
267
268static struct regulator_init_data omap4_panda_vaux2 = {
269 .constraints = {
270 .min_uV = 1200000,
271 .max_uV = 2800000,
272 .apply_uV = true,
273 .valid_modes_mask = REGULATOR_MODE_NORMAL
274 | REGULATOR_MODE_STANDBY,
275 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
276 | REGULATOR_CHANGE_MODE
277 | REGULATOR_CHANGE_STATUS,
278 },
279};
280
281static struct regulator_init_data omap4_panda_vaux3 = {
282 .constraints = {
283 .min_uV = 1000000,
284 .max_uV = 3000000,
285 .apply_uV = true,
286 .valid_modes_mask = REGULATOR_MODE_NORMAL
287 | REGULATOR_MODE_STANDBY,
288 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
289 | REGULATOR_CHANGE_MODE
290 | REGULATOR_CHANGE_STATUS,
291 },
292};
293
294/* VMMC1 for MMC1 card */
295static struct regulator_init_data omap4_panda_vmmc = {
296 .constraints = {
297 .min_uV = 1200000,
298 .max_uV = 3000000,
299 .apply_uV = true,
300 .valid_modes_mask = REGULATOR_MODE_NORMAL
301 | REGULATOR_MODE_STANDBY,
302 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
303 | REGULATOR_CHANGE_MODE
304 | REGULATOR_CHANGE_STATUS,
305 },
191183b9 306 .num_consumer_supplies = 1,
b075f58b
DA
307 .consumer_supplies = omap4_panda_vmmc_supply,
308};
309
310static struct regulator_init_data omap4_panda_vpp = {
311 .constraints = {
312 .min_uV = 1800000,
313 .max_uV = 2500000,
314 .apply_uV = true,
315 .valid_modes_mask = REGULATOR_MODE_NORMAL
316 | REGULATOR_MODE_STANDBY,
317 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
318 | REGULATOR_CHANGE_MODE
319 | REGULATOR_CHANGE_STATUS,
320 },
321};
322
323static struct regulator_init_data omap4_panda_vusim = {
324 .constraints = {
325 .min_uV = 1200000,
326 .max_uV = 2900000,
327 .apply_uV = true,
328 .valid_modes_mask = REGULATOR_MODE_NORMAL
329 | REGULATOR_MODE_STANDBY,
330 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
331 | REGULATOR_CHANGE_MODE
332 | REGULATOR_CHANGE_STATUS,
333 },
334};
335
336static struct regulator_init_data omap4_panda_vana = {
337 .constraints = {
338 .min_uV = 2100000,
339 .max_uV = 2100000,
b075f58b
DA
340 .valid_modes_mask = REGULATOR_MODE_NORMAL
341 | REGULATOR_MODE_STANDBY,
342 .valid_ops_mask = REGULATOR_CHANGE_MODE
343 | REGULATOR_CHANGE_STATUS,
344 },
345};
346
347static struct regulator_init_data omap4_panda_vcxio = {
348 .constraints = {
349 .min_uV = 1800000,
350 .max_uV = 1800000,
b075f58b
DA
351 .valid_modes_mask = REGULATOR_MODE_NORMAL
352 | REGULATOR_MODE_STANDBY,
353 .valid_ops_mask = REGULATOR_CHANGE_MODE
354 | REGULATOR_CHANGE_STATUS,
355 },
356};
357
358static struct regulator_init_data omap4_panda_vdac = {
359 .constraints = {
360 .min_uV = 1800000,
361 .max_uV = 1800000,
b075f58b
DA
362 .valid_modes_mask = REGULATOR_MODE_NORMAL
363 | REGULATOR_MODE_STANDBY,
364 .valid_ops_mask = REGULATOR_CHANGE_MODE
365 | REGULATOR_CHANGE_STATUS,
366 },
367};
368
369static struct regulator_init_data omap4_panda_vusb = {
370 .constraints = {
371 .min_uV = 3300000,
372 .max_uV = 3300000,
373 .apply_uV = true,
374 .valid_modes_mask = REGULATOR_MODE_NORMAL
375 | REGULATOR_MODE_STANDBY,
376 .valid_ops_mask = REGULATOR_CHANGE_MODE
377 | REGULATOR_CHANGE_STATUS,
378 },
379};
380
381static struct twl4030_platform_data omap4_panda_twldata = {
382 .irq_base = TWL6030_IRQ_BASE,
383 .irq_end = TWL6030_IRQ_END,
384
385 /* Regulators */
386 .vmmc = &omap4_panda_vmmc,
387 .vpp = &omap4_panda_vpp,
388 .vusim = &omap4_panda_vusim,
389 .vana = &omap4_panda_vana,
390 .vcxio = &omap4_panda_vcxio,
391 .vdac = &omap4_panda_vdac,
392 .vusb = &omap4_panda_vusb,
393 .vaux1 = &omap4_panda_vaux1,
394 .vaux2 = &omap4_panda_vaux2,
395 .vaux3 = &omap4_panda_vaux3,
e70357e3 396 .usb = &omap4_usbphy_data,
b075f58b
DA
397};
398
399static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
400 {
401 I2C_BOARD_INFO("twl6030", 0x48),
402 .flags = I2C_CLIENT_WAKE,
403 .irq = OMAP44XX_IRQ_SYS_1N,
404 .platform_data = &omap4_panda_twldata,
405 },
406};
407static int __init omap4_panda_i2c_init(void)
408{
409 /*
410 * Phoenix Audio IC needs I2C1 to
411 * start with 400 KHz or less
412 */
413 omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
414 ARRAY_SIZE(omap4_panda_i2c_boardinfo));
415 omap_register_i2c_bus(2, 400, NULL, 0);
416 omap_register_i2c_bus(3, 400, NULL, 0);
417 omap_register_i2c_bus(4, 400, NULL, 0);
418 return 0;
419}
fc63de82 420
421#ifdef CONFIG_OMAP_MUX
422static struct omap_board_mux board_mux[] __initdata = {
66e171a3
PM
423 /* WLAN IRQ - GPIO 53 */
424 OMAP4_MUX(GPMC_NCS3, OMAP_MUX_MODE3 | OMAP_PIN_INPUT),
425 /* WLAN POWER ENABLE - GPIO 43 */
426 OMAP4_MUX(GPMC_A19, OMAP_MUX_MODE3 | OMAP_PIN_OUTPUT),
427 /* WLAN SDIO: MMC5 CMD */
428 OMAP4_MUX(SDMMC5_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
429 /* WLAN SDIO: MMC5 CLK */
430 OMAP4_MUX(SDMMC5_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
431 /* WLAN SDIO: MMC5 DAT[0-3] */
432 OMAP4_MUX(SDMMC5_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
433 OMAP4_MUX(SDMMC5_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
434 OMAP4_MUX(SDMMC5_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
435 OMAP4_MUX(SDMMC5_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
fc63de82 436 { .reg_offset = OMAP_MUX_TERMINATOR },
437};
438#else
439#define board_mux NULL
440#endif
441
b075f58b
DA
442static void __init omap4_panda_init(void)
443{
fc63de82 444 int package = OMAP_PACKAGE_CBS;
445
446 if (omap_rev() == OMAP4430_REV_ES1_0)
447 package = OMAP_PACKAGE_CBL;
448 omap4_mux_init(board_mux, package);
449
b075f58b 450 omap4_panda_i2c_init();
3da434ac 451 platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
edc84061 452 platform_device_register(&omap_vwlan_device);
b075f58b
DA
453 omap_serial_init();
454 omap4_twl6030_hsmmc_init(mmc);
4415beb6 455 omap4_ehci_init();
1ea7f352 456 usb_musb_init(&musb_board_data);
b075f58b
DA
457}
458
459static void __init omap4_panda_map_io(void)
460{
461 omap2_set_globals_443x();
462 omap44xx_map_common_io();
463}
464
465MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
466 /* Maintainer: David Anders - Texas Instruments Inc */
b075f58b 467 .boot_params = 0x80000100,
d920e520 468 .reserve = omap_reserve,
b075f58b 469 .map_io = omap4_panda_map_io,
3dc3bad6
RKAL
470 .init_early = omap4_panda_init_early,
471 .init_irq = gic_init_irq,
b075f58b
DA
472 .init_machine = omap4_panda_init,
473 .timer = &omap_timer,
474MACHINE_END