Commit | Line | Data |
---|---|---|
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> | |
22 | #include <linux/io.h> | |
3da434ac | 23 | #include <linux/leds.h> |
b075f58b DA |
24 | #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> | |
b075f58b DA |
37 | #include <plat/usb.h> |
38 | #include <plat/mmc.h> | |
04aeae77 | 39 | #include "timer-gp.h" |
b075f58b | 40 | |
b075f58b | 41 | #include "hsmmc.h" |
4814ced5 | 42 | #include "control.h" |
b075f58b | 43 | |
4415beb6 DA |
44 | #define GPIO_HUB_POWER 1 |
45 | #define GPIO_HUB_NRESET 62 | |
46 | ||
3da434ac RSA |
47 | static struct gpio_led gpio_leds[] = { |
48 | { | |
49 | .name = "pandaboard::status1", | |
50 | .default_trigger = "heartbeat", | |
51 | .gpio = 7, | |
52 | }, | |
53 | { | |
54 | .name = "pandaboard::status2", | |
55 | .default_trigger = "mmc0", | |
56 | .gpio = 8, | |
57 | }, | |
58 | }; | |
b075f58b | 59 | |
3da434ac RSA |
60 | static struct gpio_led_platform_data gpio_led_info = { |
61 | .leds = gpio_leds, | |
62 | .num_leds = ARRAY_SIZE(gpio_leds), | |
63 | }; | |
64 | ||
65 | static struct platform_device leds_gpio = { | |
66 | .name = "leds-gpio", | |
67 | .id = -1, | |
68 | .dev = { | |
69 | .platform_data = &gpio_led_info, | |
70 | }, | |
71 | }; | |
72 | ||
73 | static struct platform_device *panda_devices[] __initdata = { | |
74 | &leds_gpio, | |
75 | }; | |
b075f58b DA |
76 | |
77 | static void __init omap4_panda_init_irq(void) | |
78 | { | |
79 | omap2_init_common_hw(NULL, NULL); | |
80 | gic_init_irq(); | |
81 | omap_gpio_init(); | |
82 | } | |
83 | ||
4415beb6 DA |
84 | static 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 | ||
94 | static 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 | ||
126 | error2: | |
127 | gpio_free(GPIO_HUB_POWER); | |
128 | error1: | |
129 | pr_err("Unable to initialize EHCI power/reset\n"); | |
130 | return; | |
131 | ||
132 | } | |
133 | ||
b075f58b DA |
134 | static struct omap_musb_board_data musb_board_data = { |
135 | .interface_type = MUSB_INTERFACE_UTMI, | |
09e72002 | 136 | .mode = MUSB_OTG, |
b075f58b DA |
137 | .power = 100, |
138 | }; | |
139 | ||
e70357e3 HH |
140 | static struct twl4030_usb_data omap4_usbphy_data = { |
141 | .phy_init = omap4430_phy_init, | |
142 | .phy_exit = omap4430_phy_exit, | |
143 | .phy_power = omap4430_phy_power, | |
144 | .phy_set_clock = omap4430_phy_set_clk, | |
145 | }; | |
146 | ||
b075f58b DA |
147 | static struct omap2_hsmmc_info mmc[] = { |
148 | { | |
149 | .mmc = 1, | |
3a63833e | 150 | .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, |
b075f58b DA |
151 | .gpio_wp = -EINVAL, |
152 | }, | |
153 | {} /* Terminator */ | |
154 | }; | |
155 | ||
156 | static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = { | |
157 | { | |
158 | .supply = "vmmc", | |
159 | .dev_name = "mmci-omap-hs.0", | |
160 | }, | |
b075f58b DA |
161 | }; |
162 | ||
163 | static int omap4_twl6030_hsmmc_late_init(struct device *dev) | |
164 | { | |
165 | int ret = 0; | |
166 | struct platform_device *pdev = container_of(dev, | |
167 | struct platform_device, dev); | |
168 | struct omap_mmc_platform_data *pdata = dev->platform_data; | |
169 | ||
bf56f0a6 MN |
170 | if (!pdata) { |
171 | dev_err(dev, "%s: NULL platform data\n", __func__); | |
172 | return -EINVAL; | |
173 | } | |
b075f58b | 174 | /* Setting MMC1 Card detect Irq */ |
bf56f0a6 MN |
175 | if (pdev->id == 0) { |
176 | ret = twl6030_mmc_card_detect_config(); | |
177 | if (ret) | |
178 | dev_err(dev, "%s: Error card detect config(%d)\n", | |
179 | __func__, ret); | |
180 | else | |
181 | pdata->slots[0].card_detect = twl6030_mmc_card_detect; | |
182 | } | |
b075f58b DA |
183 | return ret; |
184 | } | |
185 | ||
186 | static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) | |
187 | { | |
b9b52620 DA |
188 | struct omap_mmc_platform_data *pdata; |
189 | ||
190 | /* dev can be null if CONFIG_MMC_OMAP_HS is not set */ | |
191 | if (!dev) { | |
192 | pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n"); | |
193 | return; | |
194 | } | |
195 | pdata = dev->platform_data; | |
b075f58b DA |
196 | |
197 | pdata->init = omap4_twl6030_hsmmc_late_init; | |
198 | } | |
199 | ||
200 | static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | |
201 | { | |
202 | struct omap2_hsmmc_info *c; | |
203 | ||
204 | omap2_hsmmc_init(controllers); | |
205 | for (c = controllers; c->mmc; c++) | |
206 | omap4_twl6030_hsmmc_set_late_init(c->dev); | |
207 | ||
208 | return 0; | |
209 | } | |
210 | ||
211 | static struct regulator_init_data omap4_panda_vaux1 = { | |
212 | .constraints = { | |
213 | .min_uV = 1000000, | |
214 | .max_uV = 3000000, | |
215 | .apply_uV = true, | |
216 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
217 | | REGULATOR_MODE_STANDBY, | |
218 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
219 | | REGULATOR_CHANGE_MODE | |
220 | | REGULATOR_CHANGE_STATUS, | |
221 | }, | |
222 | }; | |
223 | ||
224 | static struct regulator_init_data omap4_panda_vaux2 = { | |
225 | .constraints = { | |
226 | .min_uV = 1200000, | |
227 | .max_uV = 2800000, | |
228 | .apply_uV = true, | |
229 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
230 | | REGULATOR_MODE_STANDBY, | |
231 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
232 | | REGULATOR_CHANGE_MODE | |
233 | | REGULATOR_CHANGE_STATUS, | |
234 | }, | |
235 | }; | |
236 | ||
237 | static struct regulator_init_data omap4_panda_vaux3 = { | |
238 | .constraints = { | |
239 | .min_uV = 1000000, | |
240 | .max_uV = 3000000, | |
241 | .apply_uV = true, | |
242 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
243 | | REGULATOR_MODE_STANDBY, | |
244 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
245 | | REGULATOR_CHANGE_MODE | |
246 | | REGULATOR_CHANGE_STATUS, | |
247 | }, | |
248 | }; | |
249 | ||
250 | /* VMMC1 for MMC1 card */ | |
251 | static struct regulator_init_data omap4_panda_vmmc = { | |
252 | .constraints = { | |
253 | .min_uV = 1200000, | |
254 | .max_uV = 3000000, | |
255 | .apply_uV = true, | |
256 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
257 | | REGULATOR_MODE_STANDBY, | |
258 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
259 | | REGULATOR_CHANGE_MODE | |
260 | | REGULATOR_CHANGE_STATUS, | |
261 | }, | |
191183b9 | 262 | .num_consumer_supplies = 1, |
b075f58b DA |
263 | .consumer_supplies = omap4_panda_vmmc_supply, |
264 | }; | |
265 | ||
266 | static struct regulator_init_data omap4_panda_vpp = { | |
267 | .constraints = { | |
268 | .min_uV = 1800000, | |
269 | .max_uV = 2500000, | |
270 | .apply_uV = true, | |
271 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
272 | | REGULATOR_MODE_STANDBY, | |
273 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
274 | | REGULATOR_CHANGE_MODE | |
275 | | REGULATOR_CHANGE_STATUS, | |
276 | }, | |
277 | }; | |
278 | ||
279 | static struct regulator_init_data omap4_panda_vusim = { | |
280 | .constraints = { | |
281 | .min_uV = 1200000, | |
282 | .max_uV = 2900000, | |
283 | .apply_uV = true, | |
284 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
285 | | REGULATOR_MODE_STANDBY, | |
286 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
287 | | REGULATOR_CHANGE_MODE | |
288 | | REGULATOR_CHANGE_STATUS, | |
289 | }, | |
290 | }; | |
291 | ||
292 | static struct regulator_init_data omap4_panda_vana = { | |
293 | .constraints = { | |
294 | .min_uV = 2100000, | |
295 | .max_uV = 2100000, | |
296 | .apply_uV = true, | |
297 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
298 | | REGULATOR_MODE_STANDBY, | |
299 | .valid_ops_mask = REGULATOR_CHANGE_MODE | |
300 | | REGULATOR_CHANGE_STATUS, | |
301 | }, | |
302 | }; | |
303 | ||
304 | static struct regulator_init_data omap4_panda_vcxio = { | |
305 | .constraints = { | |
306 | .min_uV = 1800000, | |
307 | .max_uV = 1800000, | |
308 | .apply_uV = true, | |
309 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
310 | | REGULATOR_MODE_STANDBY, | |
311 | .valid_ops_mask = REGULATOR_CHANGE_MODE | |
312 | | REGULATOR_CHANGE_STATUS, | |
313 | }, | |
314 | }; | |
315 | ||
316 | static struct regulator_init_data omap4_panda_vdac = { | |
317 | .constraints = { | |
318 | .min_uV = 1800000, | |
319 | .max_uV = 1800000, | |
320 | .apply_uV = true, | |
321 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
322 | | REGULATOR_MODE_STANDBY, | |
323 | .valid_ops_mask = REGULATOR_CHANGE_MODE | |
324 | | REGULATOR_CHANGE_STATUS, | |
325 | }, | |
326 | }; | |
327 | ||
328 | static struct regulator_init_data omap4_panda_vusb = { | |
329 | .constraints = { | |
330 | .min_uV = 3300000, | |
331 | .max_uV = 3300000, | |
332 | .apply_uV = true, | |
333 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
334 | | REGULATOR_MODE_STANDBY, | |
335 | .valid_ops_mask = REGULATOR_CHANGE_MODE | |
336 | | REGULATOR_CHANGE_STATUS, | |
337 | }, | |
338 | }; | |
339 | ||
340 | static struct twl4030_platform_data omap4_panda_twldata = { | |
341 | .irq_base = TWL6030_IRQ_BASE, | |
342 | .irq_end = TWL6030_IRQ_END, | |
343 | ||
344 | /* Regulators */ | |
345 | .vmmc = &omap4_panda_vmmc, | |
346 | .vpp = &omap4_panda_vpp, | |
347 | .vusim = &omap4_panda_vusim, | |
348 | .vana = &omap4_panda_vana, | |
349 | .vcxio = &omap4_panda_vcxio, | |
350 | .vdac = &omap4_panda_vdac, | |
351 | .vusb = &omap4_panda_vusb, | |
352 | .vaux1 = &omap4_panda_vaux1, | |
353 | .vaux2 = &omap4_panda_vaux2, | |
354 | .vaux3 = &omap4_panda_vaux3, | |
e70357e3 | 355 | .usb = &omap4_usbphy_data, |
b075f58b DA |
356 | }; |
357 | ||
358 | static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = { | |
359 | { | |
360 | I2C_BOARD_INFO("twl6030", 0x48), | |
361 | .flags = I2C_CLIENT_WAKE, | |
362 | .irq = OMAP44XX_IRQ_SYS_1N, | |
363 | .platform_data = &omap4_panda_twldata, | |
364 | }, | |
365 | }; | |
366 | static int __init omap4_panda_i2c_init(void) | |
367 | { | |
368 | /* | |
369 | * Phoenix Audio IC needs I2C1 to | |
370 | * start with 400 KHz or less | |
371 | */ | |
372 | omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo, | |
373 | ARRAY_SIZE(omap4_panda_i2c_boardinfo)); | |
374 | omap_register_i2c_bus(2, 400, NULL, 0); | |
375 | omap_register_i2c_bus(3, 400, NULL, 0); | |
376 | omap_register_i2c_bus(4, 400, NULL, 0); | |
377 | return 0; | |
378 | } | |
379 | static void __init omap4_panda_init(void) | |
380 | { | |
b075f58b | 381 | omap4_panda_i2c_init(); |
3da434ac | 382 | platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices)); |
b075f58b DA |
383 | omap_serial_init(); |
384 | omap4_twl6030_hsmmc_init(mmc); | |
385 | /* OMAP4 Panda uses internal transceiver so register nop transceiver */ | |
386 | usb_nop_xceiv_register(); | |
4415beb6 | 387 | omap4_ehci_init(); |
1ea7f352 | 388 | usb_musb_init(&musb_board_data); |
b075f58b DA |
389 | } |
390 | ||
391 | static void __init omap4_panda_map_io(void) | |
392 | { | |
393 | omap2_set_globals_443x(); | |
394 | omap44xx_map_common_io(); | |
395 | } | |
396 | ||
397 | MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board") | |
398 | /* Maintainer: David Anders - Texas Instruments Inc */ | |
b075f58b DA |
399 | .boot_params = 0x80000100, |
400 | .map_io = omap4_panda_map_io, | |
401 | .init_irq = omap4_panda_init_irq, | |
402 | .init_machine = omap4_panda_init, | |
403 | .timer = &omap_timer, | |
404 | MACHINE_END |