blob: 3094e20078448d0b010bca36cfe750c3b2216230 [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>
22#include <linux/io.h>
Ricardo Salveti de Araujo3da434a2010-09-23 18:22:49 -070023#include <linux/leds.h>
David Andersb075f582010-08-02 13:18:05 +030024#include <linux/gpio.h>
25#include <linux/usb/otg.h>
26#include <linux/i2c/twl.h>
27#include <linux/regulator/machine.h>
28
29#include <mach/hardware.h>
30#include <mach/omap4-common.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34
35#include <plat/board.h>
36#include <plat/common.h>
David Andersb075f582010-08-02 13:18:05 +030037#include <plat/usb.h>
38#include <plat/mmc.h>
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070039#include "timer-gp.h"
David Andersb075f582010-08-02 13:18:05 +030040
Paul Walmsley4814ced2010-10-08 11:40:20 -060041#include "hsmmc.h"
42#include "control.h"
sricharanfc63de822010-11-08 19:26:11 +053043#include "mux.h"
David Andersb075f582010-08-02 13:18:05 +030044
David Anders4415beb2010-10-07 19:36:30 +000045#define GPIO_HUB_POWER 1
46#define GPIO_HUB_NRESET 62
47
Ricardo Salveti de Araujo3da434a2010-09-23 18:22:49 -070048static struct gpio_led gpio_leds[] = {
49 {
50 .name = "pandaboard::status1",
51 .default_trigger = "heartbeat",
52 .gpio = 7,
53 },
54 {
55 .name = "pandaboard::status2",
56 .default_trigger = "mmc0",
57 .gpio = 8,
58 },
59};
60
61static struct gpio_led_platform_data gpio_led_info = {
62 .leds = gpio_leds,
63 .num_leds = ARRAY_SIZE(gpio_leds),
64};
65
66static struct platform_device leds_gpio = {
67 .name = "leds-gpio",
68 .id = -1,
69 .dev = {
70 .platform_data = &gpio_led_info,
71 },
72};
73
74static struct platform_device *panda_devices[] __initdata = {
75 &leds_gpio,
76};
David Andersb075f582010-08-02 13:18:05 +030077
78static void __init omap4_panda_init_irq(void)
79{
Paul Walmsley48057342010-12-21 15:25:10 -070080 omap2_init_common_infrastructure();
81 omap2_init_common_devices(NULL, NULL);
David Andersb075f582010-08-02 13:18:05 +030082 gic_init_irq();
David Andersb075f582010-08-02 13:18:05 +030083}
84
David Anders4415beb2010-10-07 19:36:30 +000085static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
86 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
87 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
88 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
89 .phy_reset = false,
90 .reset_gpio_port[0] = -EINVAL,
91 .reset_gpio_port[1] = -EINVAL,
92 .reset_gpio_port[2] = -EINVAL
93};
94
95static void __init omap4_ehci_init(void)
96{
97 int ret;
98
99
100 /* disable the power to the usb hub prior to init */
101 ret = gpio_request(GPIO_HUB_POWER, "hub_power");
102 if (ret) {
103 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
104 goto error1;
105 }
106 gpio_export(GPIO_HUB_POWER, 0);
107 gpio_direction_output(GPIO_HUB_POWER, 0);
108 gpio_set_value(GPIO_HUB_POWER, 0);
109
110 /* reset phy+hub */
111 ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
112 if (ret) {
113 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
114 goto error2;
115 }
116 gpio_export(GPIO_HUB_NRESET, 0);
117 gpio_direction_output(GPIO_HUB_NRESET, 0);
118 gpio_set_value(GPIO_HUB_NRESET, 0);
119 gpio_set_value(GPIO_HUB_NRESET, 1);
120
121 usb_ehci_init(&ehci_pdata);
122
123 /* enable power to hub */
124 gpio_set_value(GPIO_HUB_POWER, 1);
125 return;
126
127error2:
128 gpio_free(GPIO_HUB_POWER);
129error1:
130 pr_err("Unable to initialize EHCI power/reset\n");
131 return;
132
133}
134
David Andersb075f582010-08-02 13:18:05 +0300135static struct omap_musb_board_data musb_board_data = {
136 .interface_type = MUSB_INTERFACE_UTMI,
Hema HK09e72002010-12-10 18:11:42 +0530137 .mode = MUSB_OTG,
David Andersb075f582010-08-02 13:18:05 +0300138 .power = 100,
139};
140
Hema HKe70357e2010-12-10 18:09:52 +0530141static struct twl4030_usb_data omap4_usbphy_data = {
142 .phy_init = omap4430_phy_init,
143 .phy_exit = omap4430_phy_exit,
144 .phy_power = omap4430_phy_power,
145 .phy_set_clock = omap4430_phy_set_clk,
146};
147
David Andersb075f582010-08-02 13:18:05 +0300148static struct omap2_hsmmc_info mmc[] = {
149 {
150 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000151 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
David Andersb075f582010-08-02 13:18:05 +0300152 .gpio_wp = -EINVAL,
Raghuveer Murthy5b59cc22010-12-21 14:14:34 +0000153 .gpio_cd = -EINVAL,
David Andersb075f582010-08-02 13:18:05 +0300154 },
155 {} /* Terminator */
156};
157
158static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
159 {
160 .supply = "vmmc",
161 .dev_name = "mmci-omap-hs.0",
162 },
David Andersb075f582010-08-02 13:18:05 +0300163};
164
165static int omap4_twl6030_hsmmc_late_init(struct device *dev)
166{
167 int ret = 0;
168 struct platform_device *pdev = container_of(dev,
169 struct platform_device, dev);
170 struct omap_mmc_platform_data *pdata = dev->platform_data;
171
Menon, Nishanthbf56f0a2010-10-19 09:50:25 -0500172 if (!pdata) {
173 dev_err(dev, "%s: NULL platform data\n", __func__);
174 return -EINVAL;
175 }
David Andersb075f582010-08-02 13:18:05 +0300176 /* Setting MMC1 Card detect Irq */
Menon, Nishanthbf56f0a2010-10-19 09:50:25 -0500177 if (pdev->id == 0) {
178 ret = twl6030_mmc_card_detect_config();
179 if (ret)
180 dev_err(dev, "%s: Error card detect config(%d)\n",
181 __func__, ret);
182 else
183 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
184 }
David Andersb075f582010-08-02 13:18:05 +0300185 return ret;
186}
187
188static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
189{
David Andersb9b52622010-10-07 19:36:29 +0000190 struct omap_mmc_platform_data *pdata;
191
192 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
193 if (!dev) {
194 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
195 return;
196 }
197 pdata = dev->platform_data;
David Andersb075f582010-08-02 13:18:05 +0300198
199 pdata->init = omap4_twl6030_hsmmc_late_init;
200}
201
202static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
203{
204 struct omap2_hsmmc_info *c;
205
206 omap2_hsmmc_init(controllers);
207 for (c = controllers; c->mmc; c++)
208 omap4_twl6030_hsmmc_set_late_init(c->dev);
209
210 return 0;
211}
212
213static struct regulator_init_data omap4_panda_vaux1 = {
214 .constraints = {
215 .min_uV = 1000000,
216 .max_uV = 3000000,
217 .apply_uV = true,
218 .valid_modes_mask = REGULATOR_MODE_NORMAL
219 | REGULATOR_MODE_STANDBY,
220 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
221 | REGULATOR_CHANGE_MODE
222 | REGULATOR_CHANGE_STATUS,
223 },
224};
225
226static struct regulator_init_data omap4_panda_vaux2 = {
227 .constraints = {
228 .min_uV = 1200000,
229 .max_uV = 2800000,
230 .apply_uV = true,
231 .valid_modes_mask = REGULATOR_MODE_NORMAL
232 | REGULATOR_MODE_STANDBY,
233 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
234 | REGULATOR_CHANGE_MODE
235 | REGULATOR_CHANGE_STATUS,
236 },
237};
238
239static struct regulator_init_data omap4_panda_vaux3 = {
240 .constraints = {
241 .min_uV = 1000000,
242 .max_uV = 3000000,
243 .apply_uV = true,
244 .valid_modes_mask = REGULATOR_MODE_NORMAL
245 | REGULATOR_MODE_STANDBY,
246 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
247 | REGULATOR_CHANGE_MODE
248 | REGULATOR_CHANGE_STATUS,
249 },
250};
251
252/* VMMC1 for MMC1 card */
253static struct regulator_init_data omap4_panda_vmmc = {
254 .constraints = {
255 .min_uV = 1200000,
256 .max_uV = 3000000,
257 .apply_uV = true,
258 .valid_modes_mask = REGULATOR_MODE_NORMAL
259 | REGULATOR_MODE_STANDBY,
260 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
261 | REGULATOR_CHANGE_MODE
262 | REGULATOR_CHANGE_STATUS,
263 },
David Anders191183b2010-10-07 19:36:28 +0000264 .num_consumer_supplies = 1,
David Andersb075f582010-08-02 13:18:05 +0300265 .consumer_supplies = omap4_panda_vmmc_supply,
266};
267
268static struct regulator_init_data omap4_panda_vpp = {
269 .constraints = {
270 .min_uV = 1800000,
271 .max_uV = 2500000,
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_vusim = {
282 .constraints = {
283 .min_uV = 1200000,
284 .max_uV = 2900000,
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
294static struct regulator_init_data omap4_panda_vana = {
295 .constraints = {
296 .min_uV = 2100000,
297 .max_uV = 2100000,
298 .apply_uV = true,
299 .valid_modes_mask = REGULATOR_MODE_NORMAL
300 | REGULATOR_MODE_STANDBY,
301 .valid_ops_mask = REGULATOR_CHANGE_MODE
302 | REGULATOR_CHANGE_STATUS,
303 },
304};
305
306static struct regulator_init_data omap4_panda_vcxio = {
307 .constraints = {
308 .min_uV = 1800000,
309 .max_uV = 1800000,
310 .apply_uV = true,
311 .valid_modes_mask = REGULATOR_MODE_NORMAL
312 | REGULATOR_MODE_STANDBY,
313 .valid_ops_mask = REGULATOR_CHANGE_MODE
314 | REGULATOR_CHANGE_STATUS,
315 },
316};
317
318static struct regulator_init_data omap4_panda_vdac = {
319 .constraints = {
320 .min_uV = 1800000,
321 .max_uV = 1800000,
322 .apply_uV = true,
323 .valid_modes_mask = REGULATOR_MODE_NORMAL
324 | REGULATOR_MODE_STANDBY,
325 .valid_ops_mask = REGULATOR_CHANGE_MODE
326 | REGULATOR_CHANGE_STATUS,
327 },
328};
329
330static struct regulator_init_data omap4_panda_vusb = {
331 .constraints = {
332 .min_uV = 3300000,
333 .max_uV = 3300000,
334 .apply_uV = true,
335 .valid_modes_mask = REGULATOR_MODE_NORMAL
336 | REGULATOR_MODE_STANDBY,
337 .valid_ops_mask = REGULATOR_CHANGE_MODE
338 | REGULATOR_CHANGE_STATUS,
339 },
340};
341
342static struct twl4030_platform_data omap4_panda_twldata = {
343 .irq_base = TWL6030_IRQ_BASE,
344 .irq_end = TWL6030_IRQ_END,
345
346 /* Regulators */
347 .vmmc = &omap4_panda_vmmc,
348 .vpp = &omap4_panda_vpp,
349 .vusim = &omap4_panda_vusim,
350 .vana = &omap4_panda_vana,
351 .vcxio = &omap4_panda_vcxio,
352 .vdac = &omap4_panda_vdac,
353 .vusb = &omap4_panda_vusb,
354 .vaux1 = &omap4_panda_vaux1,
355 .vaux2 = &omap4_panda_vaux2,
356 .vaux3 = &omap4_panda_vaux3,
Hema HKe70357e2010-12-10 18:09:52 +0530357 .usb = &omap4_usbphy_data,
David Andersb075f582010-08-02 13:18:05 +0300358};
359
360static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
361 {
362 I2C_BOARD_INFO("twl6030", 0x48),
363 .flags = I2C_CLIENT_WAKE,
364 .irq = OMAP44XX_IRQ_SYS_1N,
365 .platform_data = &omap4_panda_twldata,
366 },
367};
368static int __init omap4_panda_i2c_init(void)
369{
370 /*
371 * Phoenix Audio IC needs I2C1 to
372 * start with 400 KHz or less
373 */
374 omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
375 ARRAY_SIZE(omap4_panda_i2c_boardinfo));
376 omap_register_i2c_bus(2, 400, NULL, 0);
377 omap_register_i2c_bus(3, 400, NULL, 0);
378 omap_register_i2c_bus(4, 400, NULL, 0);
379 return 0;
380}
sricharanfc63de822010-11-08 19:26:11 +0530381
382#ifdef CONFIG_OMAP_MUX
383static struct omap_board_mux board_mux[] __initdata = {
384 { .reg_offset = OMAP_MUX_TERMINATOR },
385};
386#else
387#define board_mux NULL
388#endif
389
David Andersb075f582010-08-02 13:18:05 +0300390static void __init omap4_panda_init(void)
391{
sricharanfc63de822010-11-08 19:26:11 +0530392 int package = OMAP_PACKAGE_CBS;
393
394 if (omap_rev() == OMAP4430_REV_ES1_0)
395 package = OMAP_PACKAGE_CBL;
396 omap4_mux_init(board_mux, package);
397
David Andersb075f582010-08-02 13:18:05 +0300398 omap4_panda_i2c_init();
Ricardo Salveti de Araujo3da434a2010-09-23 18:22:49 -0700399 platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
David Andersb075f582010-08-02 13:18:05 +0300400 omap_serial_init();
401 omap4_twl6030_hsmmc_init(mmc);
402 /* OMAP4 Panda uses internal transceiver so register nop transceiver */
403 usb_nop_xceiv_register();
David Anders4415beb2010-10-07 19:36:30 +0000404 omap4_ehci_init();
Felipe Balbi1ea7f352010-12-01 13:48:54 +0200405 usb_musb_init(&musb_board_data);
David Andersb075f582010-08-02 13:18:05 +0300406}
407
408static void __init omap4_panda_map_io(void)
409{
410 omap2_set_globals_443x();
411 omap44xx_map_common_io();
412}
413
414MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
415 /* Maintainer: David Anders - Texas Instruments Inc */
David Andersb075f582010-08-02 13:18:05 +0300416 .boot_params = 0x80000100,
Raghuveer Murthyd920e522010-12-17 18:15:07 -0800417 .reserve = omap_reserve,
David Andersb075f582010-08-02 13:18:05 +0300418 .map_io = omap4_panda_map_io,
419 .init_irq = omap4_panda_init_irq,
420 .init_machine = omap4_panda_init,
421 .timer = &omap_timer,
422MACHINE_END