blob: d56bef15d3c5c66c4fb7c2723209a4e5526a73a5 [file] [log] [blame]
David Andersb075f582010-08-02 13:18:05 +03001/*
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>
Anand Gadiyar1740d482011-01-10 14:42:15 +000022#include <linux/clk.h>
David Andersb075f582010-08-02 13:18:05 +030023#include <linux/io.h>
Ricardo Salveti de Araujo3da434a2010-09-23 18:22:49 -070024#include <linux/leds.h>
David Andersb075f582010-08-02 13:18:05 +030025#include <linux/gpio.h>
26#include <linux/usb/otg.h>
27#include <linux/i2c/twl.h>
28#include <linux/regulator/machine.h>
Panduranga Mallireddyedc84062011-02-15 03:40:34 -050029#include <linux/regulator/fixed.h>
David Andersb075f582010-08-02 13:18:05 +030030
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>
David Andersb075f582010-08-02 13:18:05 +030039#include <plat/usb.h>
40#include <plat/mmc.h>
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070041#include "timer-gp.h"
David Andersb075f582010-08-02 13:18:05 +030042
Paul Walmsley4814ced2010-10-08 11:40:20 -060043#include "hsmmc.h"
44#include "control.h"
sricharanfc63de822010-11-08 19:26:11 +053045#include "mux.h"
David Andersb075f582010-08-02 13:18:05 +030046
David Anders4415beb2010-10-07 19:36:30 +000047#define GPIO_HUB_POWER 1
48#define GPIO_HUB_NRESET 62
Panduranga Mallireddyedc84062011-02-15 03:40:34 -050049#define GPIO_WIFI_PMENA 43
David Anders4415beb2010-10-07 19:36:30 +000050
Ricardo Salveti de Araujo3da434a2010-09-23 18:22:49 -070051static 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};
63
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};
David Andersb075f582010-08-02 13:18:05 +030080
Russell King - ARM Linux3dc3bad2011-02-14 15:40:20 -080081static void __init omap4_panda_init_early(void)
David Andersb075f582010-08-02 13:18:05 +030082{
Paul Walmsley48057342010-12-21 15:25:10 -070083 omap2_init_common_infrastructure();
84 omap2_init_common_devices(NULL, NULL);
David Andersb075f582010-08-02 13:18:05 +030085}
86
David Anders4415beb2010-10-07 19:36:30 +000087static 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;
Anand Gadiyar1740d482011-01-10 14:42:15 +0000100 struct clk *phy_ref_clk;
David Anders4415beb2010-10-07 19:36:30 +0000101
Anand Gadiyar1740d482011-01-10 14:42:15 +0000102 /* 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);
David Anders4415beb2010-10-07 19:36:30 +0000110
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
David Andersb075f582010-08-02 13:18:05 +0300146static struct omap_musb_board_data musb_board_data = {
147 .interface_type = MUSB_INTERFACE_UTMI,
Hema HK09e72002010-12-10 18:11:42 +0530148 .mode = MUSB_OTG,
David Andersb075f582010-08-02 13:18:05 +0300149 .power = 100,
150};
151
Hema HKe70357e2010-12-10 18:09:52 +0530152static 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
David Andersb075f582010-08-02 13:18:05 +0300159static struct omap2_hsmmc_info mmc[] = {
160 {
161 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000162 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
David Andersb075f582010-08-02 13:18:05 +0300163 .gpio_wp = -EINVAL,
Raghuveer Murthy5b59cc22010-12-21 14:14:34 +0000164 .gpio_cd = -EINVAL,
David Andersb075f582010-08-02 13:18:05 +0300165 },
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 },
David Andersb075f582010-08-02 13:18:05 +0300174};
175
Panduranga Mallireddyedc84062011-02-15 03:40:34 -0500176static 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
David Andersb075f582010-08-02 13:18:05 +0300207static 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
Menon, Nishanthbf56f0a2010-10-19 09:50:25 -0500214 if (!pdata) {
215 dev_err(dev, "%s: NULL platform data\n", __func__);
216 return -EINVAL;
217 }
David Andersb075f582010-08-02 13:18:05 +0300218 /* Setting MMC1 Card detect Irq */
Menon, Nishanthbf56f0a2010-10-19 09:50:25 -0500219 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 }
David Andersb075f582010-08-02 13:18:05 +0300227 return ret;
228}
229
230static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
231{
David Andersb9b52622010-10-07 19:36:29 +0000232 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;
David Andersb075f582010-08-02 13:18:05 +0300240
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 },
David Anders191183b2010-10-07 19:36:28 +0000306 .num_consumer_supplies = 1,
David Andersb075f582010-08-02 13:18:05 +0300307 .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,
David Andersb075f582010-08-02 13:18:05 +0300340 .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,
David Andersb075f582010-08-02 13:18:05 +0300351 .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,
David Andersb075f582010-08-02 13:18:05 +0300362 .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,
Hema HKe70357e2010-12-10 18:09:52 +0530396 .usb = &omap4_usbphy_data,
David Andersb075f582010-08-02 13:18:05 +0300397};
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}
sricharanfc63de822010-11-08 19:26:11 +0530420
421#ifdef CONFIG_OMAP_MUX
422static struct omap_board_mux board_mux[] __initdata = {
Panduranga Mallireddy66e171a2011-02-15 03:40:32 -0500423 /* 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),
sricharanfc63de822010-11-08 19:26:11 +0530436 { .reg_offset = OMAP_MUX_TERMINATOR },
437};
438#else
439#define board_mux NULL
440#endif
441
David Andersb075f582010-08-02 13:18:05 +0300442static void __init omap4_panda_init(void)
443{
sricharanfc63de822010-11-08 19:26:11 +0530444 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
David Andersb075f582010-08-02 13:18:05 +0300450 omap4_panda_i2c_init();
Ricardo Salveti de Araujo3da434a2010-09-23 18:22:49 -0700451 platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
Panduranga Mallireddyedc84062011-02-15 03:40:34 -0500452 platform_device_register(&omap_vwlan_device);
David Andersb075f582010-08-02 13:18:05 +0300453 omap_serial_init();
454 omap4_twl6030_hsmmc_init(mmc);
David Anders4415beb2010-10-07 19:36:30 +0000455 omap4_ehci_init();
Felipe Balbi1ea7f352010-12-01 13:48:54 +0200456 usb_musb_init(&musb_board_data);
David Andersb075f582010-08-02 13:18:05 +0300457}
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 */
David Andersb075f582010-08-02 13:18:05 +0300467 .boot_params = 0x80000100,
Raghuveer Murthyd920e522010-12-17 18:15:07 -0800468 .reserve = omap_reserve,
David Andersb075f582010-08-02 13:18:05 +0300469 .map_io = omap4_panda_map_io,
Russell King - ARM Linux3dc3bad2011-02-14 15:40:20 -0800470 .init_early = omap4_panda_init_early,
471 .init_irq = gic_init_irq,
David Andersb075f582010-08-02 13:18:05 +0300472 .init_machine = omap4_panda_init,
473 .timer = &omap_timer,
474MACHINE_END