board-omap4panda.c 12 KB

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