blob: b82f2319a091490e9b2bf03353d0a1346e91c3fc [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{
80 omap2_init_common_hw(NULL, NULL);
81 gic_init_irq();
David Andersb075f582010-08-02 13:18:05 +030082}
83
David Anders4415beb2010-10-07 19:36:30 +000084static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
85 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
86 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
87 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
88 .phy_reset = false,
89 .reset_gpio_port[0] = -EINVAL,
90 .reset_gpio_port[1] = -EINVAL,
91 .reset_gpio_port[2] = -EINVAL
92};
93
94static void __init omap4_ehci_init(void)
95{
96 int ret;
97
98
99 /* disable the power to the usb hub prior to init */
100 ret = gpio_request(GPIO_HUB_POWER, "hub_power");
101 if (ret) {
102 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
103 goto error1;
104 }
105 gpio_export(GPIO_HUB_POWER, 0);
106 gpio_direction_output(GPIO_HUB_POWER, 0);
107 gpio_set_value(GPIO_HUB_POWER, 0);
108
109 /* reset phy+hub */
110 ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
111 if (ret) {
112 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
113 goto error2;
114 }
115 gpio_export(GPIO_HUB_NRESET, 0);
116 gpio_direction_output(GPIO_HUB_NRESET, 0);
117 gpio_set_value(GPIO_HUB_NRESET, 0);
118 gpio_set_value(GPIO_HUB_NRESET, 1);
119
120 usb_ehci_init(&ehci_pdata);
121
122 /* enable power to hub */
123 gpio_set_value(GPIO_HUB_POWER, 1);
124 return;
125
126error2:
127 gpio_free(GPIO_HUB_POWER);
128error1:
129 pr_err("Unable to initialize EHCI power/reset\n");
130 return;
131
132}
133
David Andersb075f582010-08-02 13:18:05 +0300134static struct omap_musb_board_data musb_board_data = {
135 .interface_type = MUSB_INTERFACE_UTMI,
136 .mode = MUSB_PERIPHERAL,
137 .power = 100,
138};
139
140static struct omap2_hsmmc_info mmc[] = {
141 {
142 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000143 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
David Andersb075f582010-08-02 13:18:05 +0300144 .gpio_wp = -EINVAL,
145 },
146 {} /* Terminator */
147};
148
149static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
150 {
151 .supply = "vmmc",
152 .dev_name = "mmci-omap-hs.0",
153 },
David Andersb075f582010-08-02 13:18:05 +0300154};
155
156static int omap4_twl6030_hsmmc_late_init(struct device *dev)
157{
158 int ret = 0;
159 struct platform_device *pdev = container_of(dev,
160 struct platform_device, dev);
161 struct omap_mmc_platform_data *pdata = dev->platform_data;
162
Menon, Nishanthbf56f0a2010-10-19 09:50:25 -0500163 if (!pdata) {
164 dev_err(dev, "%s: NULL platform data\n", __func__);
165 return -EINVAL;
166 }
David Andersb075f582010-08-02 13:18:05 +0300167 /* Setting MMC1 Card detect Irq */
Menon, Nishanthbf56f0a2010-10-19 09:50:25 -0500168 if (pdev->id == 0) {
169 ret = twl6030_mmc_card_detect_config();
170 if (ret)
171 dev_err(dev, "%s: Error card detect config(%d)\n",
172 __func__, ret);
173 else
174 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
175 }
David Andersb075f582010-08-02 13:18:05 +0300176 return ret;
177}
178
179static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
180{
David Andersb9b52622010-10-07 19:36:29 +0000181 struct omap_mmc_platform_data *pdata;
182
183 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
184 if (!dev) {
185 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
186 return;
187 }
188 pdata = dev->platform_data;
David Andersb075f582010-08-02 13:18:05 +0300189
190 pdata->init = omap4_twl6030_hsmmc_late_init;
191}
192
193static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
194{
195 struct omap2_hsmmc_info *c;
196
197 omap2_hsmmc_init(controllers);
198 for (c = controllers; c->mmc; c++)
199 omap4_twl6030_hsmmc_set_late_init(c->dev);
200
201 return 0;
202}
203
204static struct regulator_init_data omap4_panda_vaux1 = {
205 .constraints = {
206 .min_uV = 1000000,
207 .max_uV = 3000000,
208 .apply_uV = true,
209 .valid_modes_mask = REGULATOR_MODE_NORMAL
210 | REGULATOR_MODE_STANDBY,
211 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
212 | REGULATOR_CHANGE_MODE
213 | REGULATOR_CHANGE_STATUS,
214 },
215};
216
217static struct regulator_init_data omap4_panda_vaux2 = {
218 .constraints = {
219 .min_uV = 1200000,
220 .max_uV = 2800000,
221 .apply_uV = true,
222 .valid_modes_mask = REGULATOR_MODE_NORMAL
223 | REGULATOR_MODE_STANDBY,
224 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
225 | REGULATOR_CHANGE_MODE
226 | REGULATOR_CHANGE_STATUS,
227 },
228};
229
230static struct regulator_init_data omap4_panda_vaux3 = {
231 .constraints = {
232 .min_uV = 1000000,
233 .max_uV = 3000000,
234 .apply_uV = true,
235 .valid_modes_mask = REGULATOR_MODE_NORMAL
236 | REGULATOR_MODE_STANDBY,
237 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
238 | REGULATOR_CHANGE_MODE
239 | REGULATOR_CHANGE_STATUS,
240 },
241};
242
243/* VMMC1 for MMC1 card */
244static struct regulator_init_data omap4_panda_vmmc = {
245 .constraints = {
246 .min_uV = 1200000,
247 .max_uV = 3000000,
248 .apply_uV = true,
249 .valid_modes_mask = REGULATOR_MODE_NORMAL
250 | REGULATOR_MODE_STANDBY,
251 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
252 | REGULATOR_CHANGE_MODE
253 | REGULATOR_CHANGE_STATUS,
254 },
David Anders191183b2010-10-07 19:36:28 +0000255 .num_consumer_supplies = 1,
David Andersb075f582010-08-02 13:18:05 +0300256 .consumer_supplies = omap4_panda_vmmc_supply,
257};
258
259static struct regulator_init_data omap4_panda_vpp = {
260 .constraints = {
261 .min_uV = 1800000,
262 .max_uV = 2500000,
263 .apply_uV = true,
264 .valid_modes_mask = REGULATOR_MODE_NORMAL
265 | REGULATOR_MODE_STANDBY,
266 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
267 | REGULATOR_CHANGE_MODE
268 | REGULATOR_CHANGE_STATUS,
269 },
270};
271
272static struct regulator_init_data omap4_panda_vusim = {
273 .constraints = {
274 .min_uV = 1200000,
275 .max_uV = 2900000,
276 .apply_uV = true,
277 .valid_modes_mask = REGULATOR_MODE_NORMAL
278 | REGULATOR_MODE_STANDBY,
279 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
280 | REGULATOR_CHANGE_MODE
281 | REGULATOR_CHANGE_STATUS,
282 },
283};
284
285static struct regulator_init_data omap4_panda_vana = {
286 .constraints = {
287 .min_uV = 2100000,
288 .max_uV = 2100000,
289 .apply_uV = true,
290 .valid_modes_mask = REGULATOR_MODE_NORMAL
291 | REGULATOR_MODE_STANDBY,
292 .valid_ops_mask = REGULATOR_CHANGE_MODE
293 | REGULATOR_CHANGE_STATUS,
294 },
295};
296
297static struct regulator_init_data omap4_panda_vcxio = {
298 .constraints = {
299 .min_uV = 1800000,
300 .max_uV = 1800000,
301 .apply_uV = true,
302 .valid_modes_mask = REGULATOR_MODE_NORMAL
303 | REGULATOR_MODE_STANDBY,
304 .valid_ops_mask = REGULATOR_CHANGE_MODE
305 | REGULATOR_CHANGE_STATUS,
306 },
307};
308
309static struct regulator_init_data omap4_panda_vdac = {
310 .constraints = {
311 .min_uV = 1800000,
312 .max_uV = 1800000,
313 .apply_uV = true,
314 .valid_modes_mask = REGULATOR_MODE_NORMAL
315 | REGULATOR_MODE_STANDBY,
316 .valid_ops_mask = REGULATOR_CHANGE_MODE
317 | REGULATOR_CHANGE_STATUS,
318 },
319};
320
321static struct regulator_init_data omap4_panda_vusb = {
322 .constraints = {
323 .min_uV = 3300000,
324 .max_uV = 3300000,
325 .apply_uV = true,
326 .valid_modes_mask = REGULATOR_MODE_NORMAL
327 | REGULATOR_MODE_STANDBY,
328 .valid_ops_mask = REGULATOR_CHANGE_MODE
329 | REGULATOR_CHANGE_STATUS,
330 },
331};
332
333static struct twl4030_platform_data omap4_panda_twldata = {
334 .irq_base = TWL6030_IRQ_BASE,
335 .irq_end = TWL6030_IRQ_END,
336
337 /* Regulators */
338 .vmmc = &omap4_panda_vmmc,
339 .vpp = &omap4_panda_vpp,
340 .vusim = &omap4_panda_vusim,
341 .vana = &omap4_panda_vana,
342 .vcxio = &omap4_panda_vcxio,
343 .vdac = &omap4_panda_vdac,
344 .vusb = &omap4_panda_vusb,
345 .vaux1 = &omap4_panda_vaux1,
346 .vaux2 = &omap4_panda_vaux2,
347 .vaux3 = &omap4_panda_vaux3,
348};
349
350static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
351 {
352 I2C_BOARD_INFO("twl6030", 0x48),
353 .flags = I2C_CLIENT_WAKE,
354 .irq = OMAP44XX_IRQ_SYS_1N,
355 .platform_data = &omap4_panda_twldata,
356 },
357};
358static int __init omap4_panda_i2c_init(void)
359{
360 /*
361 * Phoenix Audio IC needs I2C1 to
362 * start with 400 KHz or less
363 */
364 omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
365 ARRAY_SIZE(omap4_panda_i2c_boardinfo));
366 omap_register_i2c_bus(2, 400, NULL, 0);
367 omap_register_i2c_bus(3, 400, NULL, 0);
368 omap_register_i2c_bus(4, 400, NULL, 0);
369 return 0;
370}
sricharanfc63de822010-11-08 19:26:11 +0530371
372#ifdef CONFIG_OMAP_MUX
373static struct omap_board_mux board_mux[] __initdata = {
374 { .reg_offset = OMAP_MUX_TERMINATOR },
375};
376#else
377#define board_mux NULL
378#endif
379
David Andersb075f582010-08-02 13:18:05 +0300380static void __init omap4_panda_init(void)
381{
sricharanfc63de822010-11-08 19:26:11 +0530382 int package = OMAP_PACKAGE_CBS;
383
384 if (omap_rev() == OMAP4430_REV_ES1_0)
385 package = OMAP_PACKAGE_CBL;
386 omap4_mux_init(board_mux, package);
387
David Andersb075f582010-08-02 13:18:05 +0300388 omap4_panda_i2c_init();
Ricardo Salveti de Araujo3da434a2010-09-23 18:22:49 -0700389 platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
David Andersb075f582010-08-02 13:18:05 +0300390 omap_serial_init();
391 omap4_twl6030_hsmmc_init(mmc);
392 /* OMAP4 Panda uses internal transceiver so register nop transceiver */
393 usb_nop_xceiv_register();
David Anders4415beb2010-10-07 19:36:30 +0000394 omap4_ehci_init();
David Andersb075f582010-08-02 13:18:05 +0300395 /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
396 if (!cpu_is_omap44xx())
397 usb_musb_init(&musb_board_data);
398}
399
400static void __init omap4_panda_map_io(void)
401{
402 omap2_set_globals_443x();
403 omap44xx_map_common_io();
404}
405
406MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
407 /* Maintainer: David Anders - Texas Instruments Inc */
David Andersb075f582010-08-02 13:18:05 +0300408 .boot_params = 0x80000100,
Raghuveer Murthyd920e522010-12-17 18:15:07 -0800409 .reserve = omap_reserve,
David Andersb075f582010-08-02 13:18:05 +0300410 .map_io = omap4_panda_map_io,
411 .init_irq = omap4_panda_init_irq,
412 .init_machine = omap4_panda_init,
413 .timer = &omap_timer,
414MACHINE_END