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> | |
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> | |
29 | ||
30 | #include <mach/hardware.h> | |
31 | #include <mach/omap4-common.h> | |
32 | #include <asm/mach-types.h> | |
33 | #include <asm/mach/arch.h> | |
34 | #include <asm/mach/map.h> | |
35 | ||
36 | #include <plat/board.h> | |
37 | #include <plat/common.h> | |
b075f58b DA |
38 | #include <plat/usb.h> |
39 | #include <plat/mmc.h> | |
04aeae77 | 40 | #include "timer-gp.h" |
b075f58b | 41 | |
b075f58b | 42 | #include "hsmmc.h" |
4814ced5 | 43 | #include "control.h" |
fc63de82 | 44 | #include "mux.h" |
b075f58b | 45 | |
4415beb6 DA |
46 | #define GPIO_HUB_POWER 1 |
47 | #define GPIO_HUB_NRESET 62 | |
48 | ||
3da434ac RSA |
49 | static struct gpio_led gpio_leds[] = { |
50 | { | |
51 | .name = "pandaboard::status1", | |
52 | .default_trigger = "heartbeat", | |
53 | .gpio = 7, | |
54 | }, | |
55 | { | |
56 | .name = "pandaboard::status2", | |
57 | .default_trigger = "mmc0", | |
58 | .gpio = 8, | |
59 | }, | |
60 | }; | |
b075f58b | 61 | |
3da434ac RSA |
62 | static struct gpio_led_platform_data gpio_led_info = { |
63 | .leds = gpio_leds, | |
64 | .num_leds = ARRAY_SIZE(gpio_leds), | |
65 | }; | |
66 | ||
67 | static struct platform_device leds_gpio = { | |
68 | .name = "leds-gpio", | |
69 | .id = -1, | |
70 | .dev = { | |
71 | .platform_data = &gpio_led_info, | |
72 | }, | |
73 | }; | |
74 | ||
75 | static struct platform_device *panda_devices[] __initdata = { | |
76 | &leds_gpio, | |
77 | }; | |
b075f58b DA |
78 | |
79 | static void __init omap4_panda_init_irq(void) | |
80 | { | |
4805734b PW |
81 | omap2_init_common_infrastructure(); |
82 | omap2_init_common_devices(NULL, NULL); | |
b075f58b | 83 | gic_init_irq(); |
b075f58b DA |
84 | } |
85 | ||
4415beb6 DA |
86 | static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { |
87 | .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, | |
88 | .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN, | |
89 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, | |
90 | .phy_reset = false, | |
91 | .reset_gpio_port[0] = -EINVAL, | |
92 | .reset_gpio_port[1] = -EINVAL, | |
93 | .reset_gpio_port[2] = -EINVAL | |
94 | }; | |
95 | ||
96 | static void __init omap4_ehci_init(void) | |
97 | { | |
98 | int ret; | |
1740d483 | 99 | struct clk *phy_ref_clk; |
4415beb6 | 100 | |
1740d483 AG |
101 | /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */ |
102 | phy_ref_clk = clk_get(NULL, "auxclk3_ck"); | |
103 | if (IS_ERR(phy_ref_clk)) { | |
104 | pr_err("Cannot request auxclk3\n"); | |
105 | goto error1; | |
106 | } | |
107 | clk_set_rate(phy_ref_clk, 19200000); | |
108 | clk_enable(phy_ref_clk); | |
4415beb6 DA |
109 | |
110 | /* disable the power to the usb hub prior to init */ | |
111 | ret = gpio_request(GPIO_HUB_POWER, "hub_power"); | |
112 | if (ret) { | |
113 | pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER); | |
114 | goto error1; | |
115 | } | |
116 | gpio_export(GPIO_HUB_POWER, 0); | |
117 | gpio_direction_output(GPIO_HUB_POWER, 0); | |
118 | gpio_set_value(GPIO_HUB_POWER, 0); | |
119 | ||
120 | /* reset phy+hub */ | |
121 | ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset"); | |
122 | if (ret) { | |
123 | pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET); | |
124 | goto error2; | |
125 | } | |
126 | gpio_export(GPIO_HUB_NRESET, 0); | |
127 | gpio_direction_output(GPIO_HUB_NRESET, 0); | |
128 | gpio_set_value(GPIO_HUB_NRESET, 0); | |
129 | gpio_set_value(GPIO_HUB_NRESET, 1); | |
130 | ||
131 | usb_ehci_init(&ehci_pdata); | |
132 | ||
133 | /* enable power to hub */ | |
134 | gpio_set_value(GPIO_HUB_POWER, 1); | |
135 | return; | |
136 | ||
137 | error2: | |
138 | gpio_free(GPIO_HUB_POWER); | |
139 | error1: | |
140 | pr_err("Unable to initialize EHCI power/reset\n"); | |
141 | return; | |
142 | ||
143 | } | |
144 | ||
b075f58b DA |
145 | static struct omap_musb_board_data musb_board_data = { |
146 | .interface_type = MUSB_INTERFACE_UTMI, | |
09e72002 | 147 | .mode = MUSB_OTG, |
b075f58b DA |
148 | .power = 100, |
149 | }; | |
150 | ||
e70357e3 HH |
151 | static struct twl4030_usb_data omap4_usbphy_data = { |
152 | .phy_init = omap4430_phy_init, | |
153 | .phy_exit = omap4430_phy_exit, | |
154 | .phy_power = omap4430_phy_power, | |
155 | .phy_set_clock = omap4430_phy_set_clk, | |
156 | }; | |
157 | ||
b075f58b DA |
158 | static struct omap2_hsmmc_info mmc[] = { |
159 | { | |
160 | .mmc = 1, | |
3a63833e | 161 | .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, |
b075f58b | 162 | .gpio_wp = -EINVAL, |
5b59cc2f | 163 | .gpio_cd = -EINVAL, |
b075f58b DA |
164 | }, |
165 | {} /* Terminator */ | |
166 | }; | |
167 | ||
168 | static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = { | |
169 | { | |
170 | .supply = "vmmc", | |
171 | .dev_name = "mmci-omap-hs.0", | |
172 | }, | |
b075f58b DA |
173 | }; |
174 | ||
175 | static int omap4_twl6030_hsmmc_late_init(struct device *dev) | |
176 | { | |
177 | int ret = 0; | |
178 | struct platform_device *pdev = container_of(dev, | |
179 | struct platform_device, dev); | |
180 | struct omap_mmc_platform_data *pdata = dev->platform_data; | |
181 | ||
bf56f0a6 MN |
182 | if (!pdata) { |
183 | dev_err(dev, "%s: NULL platform data\n", __func__); | |
184 | return -EINVAL; | |
185 | } | |
b075f58b | 186 | /* Setting MMC1 Card detect Irq */ |
bf56f0a6 MN |
187 | if (pdev->id == 0) { |
188 | ret = twl6030_mmc_card_detect_config(); | |
189 | if (ret) | |
190 | dev_err(dev, "%s: Error card detect config(%d)\n", | |
191 | __func__, ret); | |
192 | else | |
193 | pdata->slots[0].card_detect = twl6030_mmc_card_detect; | |
194 | } | |
b075f58b DA |
195 | return ret; |
196 | } | |
197 | ||
198 | static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) | |
199 | { | |
b9b52620 DA |
200 | struct omap_mmc_platform_data *pdata; |
201 | ||
202 | /* dev can be null if CONFIG_MMC_OMAP_HS is not set */ | |
203 | if (!dev) { | |
204 | pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n"); | |
205 | return; | |
206 | } | |
207 | pdata = dev->platform_data; | |
b075f58b DA |
208 | |
209 | pdata->init = omap4_twl6030_hsmmc_late_init; | |
210 | } | |
211 | ||
212 | static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | |
213 | { | |
214 | struct omap2_hsmmc_info *c; | |
215 | ||
216 | omap2_hsmmc_init(controllers); | |
217 | for (c = controllers; c->mmc; c++) | |
218 | omap4_twl6030_hsmmc_set_late_init(c->dev); | |
219 | ||
220 | return 0; | |
221 | } | |
222 | ||
223 | static struct regulator_init_data omap4_panda_vaux1 = { | |
224 | .constraints = { | |
225 | .min_uV = 1000000, | |
226 | .max_uV = 3000000, | |
227 | .apply_uV = true, | |
228 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
229 | | REGULATOR_MODE_STANDBY, | |
230 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
231 | | REGULATOR_CHANGE_MODE | |
232 | | REGULATOR_CHANGE_STATUS, | |
233 | }, | |
234 | }; | |
235 | ||
236 | static struct regulator_init_data omap4_panda_vaux2 = { | |
237 | .constraints = { | |
238 | .min_uV = 1200000, | |
239 | .max_uV = 2800000, | |
240 | .apply_uV = true, | |
241 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
242 | | REGULATOR_MODE_STANDBY, | |
243 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
244 | | REGULATOR_CHANGE_MODE | |
245 | | REGULATOR_CHANGE_STATUS, | |
246 | }, | |
247 | }; | |
248 | ||
249 | static struct regulator_init_data omap4_panda_vaux3 = { | |
250 | .constraints = { | |
251 | .min_uV = 1000000, | |
252 | .max_uV = 3000000, | |
253 | .apply_uV = true, | |
254 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
255 | | REGULATOR_MODE_STANDBY, | |
256 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
257 | | REGULATOR_CHANGE_MODE | |
258 | | REGULATOR_CHANGE_STATUS, | |
259 | }, | |
260 | }; | |
261 | ||
262 | /* VMMC1 for MMC1 card */ | |
263 | static struct regulator_init_data omap4_panda_vmmc = { | |
264 | .constraints = { | |
265 | .min_uV = 1200000, | |
266 | .max_uV = 3000000, | |
267 | .apply_uV = true, | |
268 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
269 | | REGULATOR_MODE_STANDBY, | |
270 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
271 | | REGULATOR_CHANGE_MODE | |
272 | | REGULATOR_CHANGE_STATUS, | |
273 | }, | |
191183b9 | 274 | .num_consumer_supplies = 1, |
b075f58b DA |
275 | .consumer_supplies = omap4_panda_vmmc_supply, |
276 | }; | |
277 | ||
278 | static struct regulator_init_data omap4_panda_vpp = { | |
279 | .constraints = { | |
280 | .min_uV = 1800000, | |
281 | .max_uV = 2500000, | |
282 | .apply_uV = true, | |
283 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
284 | | REGULATOR_MODE_STANDBY, | |
285 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
286 | | REGULATOR_CHANGE_MODE | |
287 | | REGULATOR_CHANGE_STATUS, | |
288 | }, | |
289 | }; | |
290 | ||
291 | static struct regulator_init_data omap4_panda_vusim = { | |
292 | .constraints = { | |
293 | .min_uV = 1200000, | |
294 | .max_uV = 2900000, | |
295 | .apply_uV = true, | |
296 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
297 | | REGULATOR_MODE_STANDBY, | |
298 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
299 | | REGULATOR_CHANGE_MODE | |
300 | | REGULATOR_CHANGE_STATUS, | |
301 | }, | |
302 | }; | |
303 | ||
304 | static struct regulator_init_data omap4_panda_vana = { | |
305 | .constraints = { | |
306 | .min_uV = 2100000, | |
307 | .max_uV = 2100000, | |
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_vcxio = { | |
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_vdac = { | |
329 | .constraints = { | |
330 | .min_uV = 1800000, | |
331 | .max_uV = 1800000, | |
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 regulator_init_data omap4_panda_vusb = { | |
341 | .constraints = { | |
342 | .min_uV = 3300000, | |
343 | .max_uV = 3300000, | |
344 | .apply_uV = true, | |
345 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
346 | | REGULATOR_MODE_STANDBY, | |
347 | .valid_ops_mask = REGULATOR_CHANGE_MODE | |
348 | | REGULATOR_CHANGE_STATUS, | |
349 | }, | |
350 | }; | |
351 | ||
352 | static struct twl4030_platform_data omap4_panda_twldata = { | |
353 | .irq_base = TWL6030_IRQ_BASE, | |
354 | .irq_end = TWL6030_IRQ_END, | |
355 | ||
356 | /* Regulators */ | |
357 | .vmmc = &omap4_panda_vmmc, | |
358 | .vpp = &omap4_panda_vpp, | |
359 | .vusim = &omap4_panda_vusim, | |
360 | .vana = &omap4_panda_vana, | |
361 | .vcxio = &omap4_panda_vcxio, | |
362 | .vdac = &omap4_panda_vdac, | |
363 | .vusb = &omap4_panda_vusb, | |
364 | .vaux1 = &omap4_panda_vaux1, | |
365 | .vaux2 = &omap4_panda_vaux2, | |
366 | .vaux3 = &omap4_panda_vaux3, | |
e70357e3 | 367 | .usb = &omap4_usbphy_data, |
b075f58b DA |
368 | }; |
369 | ||
370 | static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = { | |
371 | { | |
372 | I2C_BOARD_INFO("twl6030", 0x48), | |
373 | .flags = I2C_CLIENT_WAKE, | |
374 | .irq = OMAP44XX_IRQ_SYS_1N, | |
375 | .platform_data = &omap4_panda_twldata, | |
376 | }, | |
377 | }; | |
378 | static int __init omap4_panda_i2c_init(void) | |
379 | { | |
380 | /* | |
381 | * Phoenix Audio IC needs I2C1 to | |
382 | * start with 400 KHz or less | |
383 | */ | |
384 | omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo, | |
385 | ARRAY_SIZE(omap4_panda_i2c_boardinfo)); | |
386 | omap_register_i2c_bus(2, 400, NULL, 0); | |
387 | omap_register_i2c_bus(3, 400, NULL, 0); | |
388 | omap_register_i2c_bus(4, 400, NULL, 0); | |
389 | return 0; | |
390 | } | |
fc63de82 | 391 | |
392 | #ifdef CONFIG_OMAP_MUX | |
393 | static struct omap_board_mux board_mux[] __initdata = { | |
394 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
395 | }; | |
396 | #else | |
397 | #define board_mux NULL | |
398 | #endif | |
399 | ||
b075f58b DA |
400 | static void __init omap4_panda_init(void) |
401 | { | |
fc63de82 | 402 | int package = OMAP_PACKAGE_CBS; |
403 | ||
404 | if (omap_rev() == OMAP4430_REV_ES1_0) | |
405 | package = OMAP_PACKAGE_CBL; | |
406 | omap4_mux_init(board_mux, package); | |
407 | ||
b075f58b | 408 | omap4_panda_i2c_init(); |
3da434ac | 409 | platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices)); |
b075f58b DA |
410 | omap_serial_init(); |
411 | omap4_twl6030_hsmmc_init(mmc); | |
4415beb6 | 412 | omap4_ehci_init(); |
1ea7f352 | 413 | usb_musb_init(&musb_board_data); |
b075f58b DA |
414 | } |
415 | ||
416 | static void __init omap4_panda_map_io(void) | |
417 | { | |
418 | omap2_set_globals_443x(); | |
419 | omap44xx_map_common_io(); | |
420 | } | |
421 | ||
422 | MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board") | |
423 | /* Maintainer: David Anders - Texas Instruments Inc */ | |
b075f58b | 424 | .boot_params = 0x80000100, |
d920e520 | 425 | .reserve = omap_reserve, |
b075f58b DA |
426 | .map_io = omap4_panda_map_io, |
427 | .init_irq = omap4_panda_init_irq, | |
428 | .init_machine = omap4_panda_init, | |
429 | .timer = &omap_timer, | |
430 | MACHINE_END |