board-omap4panda.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/clk.h>
  22. #include <linux/io.h>
  23. #include <linux/leds.h>
  24. #include <linux/gpio.h>
  25. #include <linux/usb/otg.h>
  26. #include <linux/i2c/twl.h>
  27. #include <linux/regulator/machine.h>
  28. #include <linux/regulator/fixed.h>
  29. #include <linux/wl12xx.h>
  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. #include <plat/board.h>
  36. #include <plat/common.h>
  37. #include <plat/usb.h>
  38. #include <plat/mmc.h>
  39. #include "timer-gp.h"
  40. #include "hsmmc.h"
  41. #include "control.h"
  42. #include "mux.h"
  43. #define GPIO_HUB_POWER 1
  44. #define GPIO_HUB_NRESET 62
  45. #define GPIO_WIFI_PMENA 43
  46. #define GPIO_WIFI_IRQ 53
  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. };
  59. static struct gpio_led_platform_data gpio_led_info = {
  60. .leds = gpio_leds,
  61. .num_leds = ARRAY_SIZE(gpio_leds),
  62. };
  63. static struct platform_device leds_gpio = {
  64. .name = "leds-gpio",
  65. .id = -1,
  66. .dev = {
  67. .platform_data = &gpio_led_info,
  68. },
  69. };
  70. static struct platform_device *panda_devices[] __initdata = {
  71. &leds_gpio,
  72. };
  73. static void __init omap4_panda_init_early(void)
  74. {
  75. omap2_init_common_infrastructure();
  76. omap2_init_common_devices(NULL, NULL);
  77. }
  78. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  79. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  80. .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  81. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  82. .phy_reset = false,
  83. .reset_gpio_port[0] = -EINVAL,
  84. .reset_gpio_port[1] = -EINVAL,
  85. .reset_gpio_port[2] = -EINVAL
  86. };
  87. static void __init omap4_ehci_init(void)
  88. {
  89. int ret;
  90. struct clk *phy_ref_clk;
  91. /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
  92. phy_ref_clk = clk_get(NULL, "auxclk3_ck");
  93. if (IS_ERR(phy_ref_clk)) {
  94. pr_err("Cannot request auxclk3\n");
  95. goto error1;
  96. }
  97. clk_set_rate(phy_ref_clk, 19200000);
  98. clk_enable(phy_ref_clk);
  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. /* reset phy+hub */
  109. ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
  110. if (ret) {
  111. pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
  112. goto error2;
  113. }
  114. gpio_export(GPIO_HUB_NRESET, 0);
  115. gpio_direction_output(GPIO_HUB_NRESET, 0);
  116. gpio_set_value(GPIO_HUB_NRESET, 0);
  117. gpio_set_value(GPIO_HUB_NRESET, 1);
  118. usb_ehci_init(&ehci_pdata);
  119. /* enable power to hub */
  120. gpio_set_value(GPIO_HUB_POWER, 1);
  121. return;
  122. error2:
  123. gpio_free(GPIO_HUB_POWER);
  124. error1:
  125. pr_err("Unable to initialize EHCI power/reset\n");
  126. return;
  127. }
  128. static struct omap_musb_board_data musb_board_data = {
  129. .interface_type = MUSB_INTERFACE_UTMI,
  130. .mode = MUSB_OTG,
  131. .power = 100,
  132. };
  133. static struct twl4030_usb_data omap4_usbphy_data = {
  134. .phy_init = omap4430_phy_init,
  135. .phy_exit = omap4430_phy_exit,
  136. .phy_power = omap4430_phy_power,
  137. .phy_set_clock = omap4430_phy_set_clk,
  138. };
  139. static struct omap2_hsmmc_info mmc[] = {
  140. {
  141. .mmc = 1,
  142. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  143. .gpio_wp = -EINVAL,
  144. .gpio_cd = -EINVAL,
  145. },
  146. {
  147. .name = "wl1271",
  148. .mmc = 5,
  149. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
  150. .gpio_wp = -EINVAL,
  151. .gpio_cd = -EINVAL,
  152. .ocr_mask = MMC_VDD_165_195,
  153. .nonremovable = true,
  154. },
  155. {} /* Terminator */
  156. };
  157. static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
  158. {
  159. .supply = "vmmc",
  160. .dev_name = "mmci-omap-hs.0",
  161. },
  162. };
  163. static struct regulator_consumer_supply omap4_panda_vmmc5_supply = {
  164. .supply = "vmmc",
  165. .dev_name = "mmci-omap-hs.4",
  166. };
  167. static struct regulator_init_data panda_vmmc5 = {
  168. .constraints = {
  169. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  170. },
  171. .num_consumer_supplies = 1,
  172. .consumer_supplies = &omap4_panda_vmmc5_supply,
  173. };
  174. static struct fixed_voltage_config panda_vwlan = {
  175. .supply_name = "vwl1271",
  176. .microvolts = 1800000, /* 1.8V */
  177. .gpio = GPIO_WIFI_PMENA,
  178. .startup_delay = 70000, /* 70msec */
  179. .enable_high = 1,
  180. .enabled_at_boot = 0,
  181. .init_data = &panda_vmmc5,
  182. };
  183. static struct platform_device omap_vwlan_device = {
  184. .name = "reg-fixed-voltage",
  185. .id = 1,
  186. .dev = {
  187. .platform_data = &panda_vwlan,
  188. },
  189. };
  190. struct wl12xx_platform_data omap_panda_wlan_data __initdata = {
  191. .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
  192. /* PANDA ref clock is 38.4 MHz */
  193. .board_ref_clock = 2,
  194. };
  195. static int omap4_twl6030_hsmmc_late_init(struct device *dev)
  196. {
  197. int ret = 0;
  198. struct platform_device *pdev = container_of(dev,
  199. struct platform_device, dev);
  200. struct omap_mmc_platform_data *pdata = dev->platform_data;
  201. if (!pdata) {
  202. dev_err(dev, "%s: NULL platform data\n", __func__);
  203. return -EINVAL;
  204. }
  205. /* Setting MMC1 Card detect Irq */
  206. if (pdev->id == 0) {
  207. ret = twl6030_mmc_card_detect_config();
  208. if (ret)
  209. dev_err(dev, "%s: Error card detect config(%d)\n",
  210. __func__, ret);
  211. else
  212. pdata->slots[0].card_detect = twl6030_mmc_card_detect;
  213. }
  214. return ret;
  215. }
  216. static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
  217. {
  218. struct omap_mmc_platform_data *pdata;
  219. /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
  220. if (!dev) {
  221. pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
  222. return;
  223. }
  224. pdata = dev->platform_data;
  225. pdata->init = omap4_twl6030_hsmmc_late_init;
  226. }
  227. static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
  228. {
  229. struct omap2_hsmmc_info *c;
  230. omap2_hsmmc_init(controllers);
  231. for (c = controllers; c->mmc; c++)
  232. omap4_twl6030_hsmmc_set_late_init(c->dev);
  233. return 0;
  234. }
  235. static struct regulator_init_data omap4_panda_vaux1 = {
  236. .constraints = {
  237. .min_uV = 1000000,
  238. .max_uV = 3000000,
  239. .apply_uV = true,
  240. .valid_modes_mask = REGULATOR_MODE_NORMAL
  241. | REGULATOR_MODE_STANDBY,
  242. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  243. | REGULATOR_CHANGE_MODE
  244. | REGULATOR_CHANGE_STATUS,
  245. },
  246. };
  247. static struct regulator_init_data omap4_panda_vaux2 = {
  248. .constraints = {
  249. .min_uV = 1200000,
  250. .max_uV = 2800000,
  251. .apply_uV = true,
  252. .valid_modes_mask = REGULATOR_MODE_NORMAL
  253. | REGULATOR_MODE_STANDBY,
  254. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  255. | REGULATOR_CHANGE_MODE
  256. | REGULATOR_CHANGE_STATUS,
  257. },
  258. };
  259. static struct regulator_init_data omap4_panda_vaux3 = {
  260. .constraints = {
  261. .min_uV = 1000000,
  262. .max_uV = 3000000,
  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. /* VMMC1 for MMC1 card */
  272. static struct regulator_init_data omap4_panda_vmmc = {
  273. .constraints = {
  274. .min_uV = 1200000,
  275. .max_uV = 3000000,
  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. .num_consumer_supplies = 1,
  284. .consumer_supplies = omap4_panda_vmmc_supply,
  285. };
  286. static struct regulator_init_data omap4_panda_vpp = {
  287. .constraints = {
  288. .min_uV = 1800000,
  289. .max_uV = 2500000,
  290. .apply_uV = true,
  291. .valid_modes_mask = REGULATOR_MODE_NORMAL
  292. | REGULATOR_MODE_STANDBY,
  293. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  294. | REGULATOR_CHANGE_MODE
  295. | REGULATOR_CHANGE_STATUS,
  296. },
  297. };
  298. static struct regulator_init_data omap4_panda_vusim = {
  299. .constraints = {
  300. .min_uV = 1200000,
  301. .max_uV = 2900000,
  302. .apply_uV = true,
  303. .valid_modes_mask = REGULATOR_MODE_NORMAL
  304. | REGULATOR_MODE_STANDBY,
  305. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  306. | REGULATOR_CHANGE_MODE
  307. | REGULATOR_CHANGE_STATUS,
  308. },
  309. };
  310. static struct regulator_init_data omap4_panda_vana = {
  311. .constraints = {
  312. .min_uV = 2100000,
  313. .max_uV = 2100000,
  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. static struct regulator_init_data omap4_panda_vcxio = {
  321. .constraints = {
  322. .min_uV = 1800000,
  323. .max_uV = 1800000,
  324. .valid_modes_mask = REGULATOR_MODE_NORMAL
  325. | REGULATOR_MODE_STANDBY,
  326. .valid_ops_mask = REGULATOR_CHANGE_MODE
  327. | REGULATOR_CHANGE_STATUS,
  328. },
  329. };
  330. static struct regulator_init_data omap4_panda_vdac = {
  331. .constraints = {
  332. .min_uV = 1800000,
  333. .max_uV = 1800000,
  334. .valid_modes_mask = REGULATOR_MODE_NORMAL
  335. | REGULATOR_MODE_STANDBY,
  336. .valid_ops_mask = REGULATOR_CHANGE_MODE
  337. | REGULATOR_CHANGE_STATUS,
  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. static struct twl4030_platform_data omap4_panda_twldata = {
  352. .irq_base = TWL6030_IRQ_BASE,
  353. .irq_end = TWL6030_IRQ_END,
  354. /* Regulators */
  355. .vmmc = &omap4_panda_vmmc,
  356. .vpp = &omap4_panda_vpp,
  357. .vusim = &omap4_panda_vusim,
  358. .vana = &omap4_panda_vana,
  359. .vcxio = &omap4_panda_vcxio,
  360. .vdac = &omap4_panda_vdac,
  361. .vusb = &omap4_panda_vusb,
  362. .vaux1 = &omap4_panda_vaux1,
  363. .vaux2 = &omap4_panda_vaux2,
  364. .vaux3 = &omap4_panda_vaux3,
  365. .usb = &omap4_usbphy_data,
  366. };
  367. static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
  368. {
  369. I2C_BOARD_INFO("twl6030", 0x48),
  370. .flags = I2C_CLIENT_WAKE,
  371. .irq = OMAP44XX_IRQ_SYS_1N,
  372. .platform_data = &omap4_panda_twldata,
  373. },
  374. };
  375. static int __init omap4_panda_i2c_init(void)
  376. {
  377. /*
  378. * Phoenix Audio IC needs I2C1 to
  379. * start with 400 KHz or less
  380. */
  381. omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
  382. ARRAY_SIZE(omap4_panda_i2c_boardinfo));
  383. omap_register_i2c_bus(2, 400, NULL, 0);
  384. omap_register_i2c_bus(3, 400, NULL, 0);
  385. omap_register_i2c_bus(4, 400, NULL, 0);
  386. return 0;
  387. }
  388. #ifdef CONFIG_OMAP_MUX
  389. static struct omap_board_mux board_mux[] __initdata = {
  390. /* WLAN IRQ - GPIO 53 */
  391. OMAP4_MUX(GPMC_NCS3, OMAP_MUX_MODE3 | OMAP_PIN_INPUT),
  392. /* WLAN POWER ENABLE - GPIO 43 */
  393. OMAP4_MUX(GPMC_A19, OMAP_MUX_MODE3 | OMAP_PIN_OUTPUT),
  394. /* WLAN SDIO: MMC5 CMD */
  395. OMAP4_MUX(SDMMC5_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  396. /* WLAN SDIO: MMC5 CLK */
  397. OMAP4_MUX(SDMMC5_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  398. /* WLAN SDIO: MMC5 DAT[0-3] */
  399. OMAP4_MUX(SDMMC5_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  400. OMAP4_MUX(SDMMC5_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  401. OMAP4_MUX(SDMMC5_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  402. OMAP4_MUX(SDMMC5_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  403. { .reg_offset = OMAP_MUX_TERMINATOR },
  404. };
  405. #else
  406. #define board_mux NULL
  407. #endif
  408. static void __init omap4_panda_init(void)
  409. {
  410. int package = OMAP_PACKAGE_CBS;
  411. if (omap_rev() == OMAP4430_REV_ES1_0)
  412. package = OMAP_PACKAGE_CBL;
  413. omap4_mux_init(board_mux, package);
  414. if (wl12xx_set_platform_data(&omap_panda_wlan_data))
  415. pr_err("error setting wl12xx data\n");
  416. omap4_panda_i2c_init();
  417. platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
  418. platform_device_register(&omap_vwlan_device);
  419. omap_serial_init();
  420. omap4_twl6030_hsmmc_init(mmc);
  421. omap4_ehci_init();
  422. usb_musb_init(&musb_board_data);
  423. }
  424. static void __init omap4_panda_map_io(void)
  425. {
  426. omap2_set_globals_443x();
  427. omap44xx_map_common_io();
  428. }
  429. MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
  430. /* Maintainer: David Anders - Texas Instruments Inc */
  431. .boot_params = 0x80000100,
  432. .reserve = omap_reserve,
  433. .map_io = omap4_panda_map_io,
  434. .init_early = omap4_panda_init_early,
  435. .init_irq = gic_init_irq,
  436. .init_machine = omap4_panda_init,
  437. .timer = &omap_timer,
  438. MACHINE_END