board-omap4panda.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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 usbhs_omap_board_data usbhs_bdata __initconst = {
  89. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  90. .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
  91. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  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. usbhs_init(&usbhs_bdata);
  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. .phy_suspend = omap4430_phy_suspend,
  149. };
  150. static struct omap2_hsmmc_info mmc[] = {
  151. {
  152. .mmc = 1,
  153. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  154. .gpio_wp = -EINVAL,
  155. .gpio_cd = -EINVAL,
  156. },
  157. {
  158. .name = "wl1271",
  159. .mmc = 5,
  160. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
  161. .gpio_wp = -EINVAL,
  162. .gpio_cd = -EINVAL,
  163. .ocr_mask = MMC_VDD_165_195,
  164. .nonremovable = true,
  165. },
  166. {} /* Terminator */
  167. };
  168. static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
  169. {
  170. .supply = "vmmc",
  171. .dev_name = "omap_hsmmc.0",
  172. },
  173. };
  174. static struct regulator_consumer_supply omap4_panda_vmmc5_supply = {
  175. .supply = "vmmc",
  176. .dev_name = "omap_hsmmc.4",
  177. };
  178. static struct regulator_init_data panda_vmmc5 = {
  179. .constraints = {
  180. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  181. },
  182. .num_consumer_supplies = 1,
  183. .consumer_supplies = &omap4_panda_vmmc5_supply,
  184. };
  185. static struct fixed_voltage_config panda_vwlan = {
  186. .supply_name = "vwl1271",
  187. .microvolts = 1800000, /* 1.8V */
  188. .gpio = GPIO_WIFI_PMENA,
  189. .startup_delay = 70000, /* 70msec */
  190. .enable_high = 1,
  191. .enabled_at_boot = 0,
  192. .init_data = &panda_vmmc5,
  193. };
  194. static struct platform_device omap_vwlan_device = {
  195. .name = "reg-fixed-voltage",
  196. .id = 1,
  197. .dev = {
  198. .platform_data = &panda_vwlan,
  199. },
  200. };
  201. struct wl12xx_platform_data omap_panda_wlan_data __initdata = {
  202. .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
  203. /* PANDA ref clock is 38.4 MHz */
  204. .board_ref_clock = 2,
  205. };
  206. static int omap4_twl6030_hsmmc_late_init(struct device *dev)
  207. {
  208. int ret = 0;
  209. struct platform_device *pdev = container_of(dev,
  210. struct platform_device, dev);
  211. struct omap_mmc_platform_data *pdata = dev->platform_data;
  212. if (!pdata) {
  213. dev_err(dev, "%s: NULL platform data\n", __func__);
  214. return -EINVAL;
  215. }
  216. /* Setting MMC1 Card detect Irq */
  217. if (pdev->id == 0) {
  218. ret = twl6030_mmc_card_detect_config();
  219. if (ret)
  220. dev_err(dev, "%s: Error card detect config(%d)\n",
  221. __func__, ret);
  222. else
  223. pdata->slots[0].card_detect = twl6030_mmc_card_detect;
  224. }
  225. return ret;
  226. }
  227. static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
  228. {
  229. struct omap_mmc_platform_data *pdata;
  230. /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
  231. if (!dev) {
  232. pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
  233. return;
  234. }
  235. pdata = dev->platform_data;
  236. pdata->init = omap4_twl6030_hsmmc_late_init;
  237. }
  238. static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
  239. {
  240. struct omap2_hsmmc_info *c;
  241. omap2_hsmmc_init(controllers);
  242. for (c = controllers; c->mmc; c++)
  243. omap4_twl6030_hsmmc_set_late_init(c->dev);
  244. return 0;
  245. }
  246. static struct regulator_init_data omap4_panda_vaux1 = {
  247. .constraints = {
  248. .min_uV = 1000000,
  249. .max_uV = 3000000,
  250. .apply_uV = true,
  251. .valid_modes_mask = REGULATOR_MODE_NORMAL
  252. | REGULATOR_MODE_STANDBY,
  253. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  254. | REGULATOR_CHANGE_MODE
  255. | REGULATOR_CHANGE_STATUS,
  256. },
  257. };
  258. static struct regulator_init_data omap4_panda_vaux2 = {
  259. .constraints = {
  260. .min_uV = 1200000,
  261. .max_uV = 2800000,
  262. .apply_uV = true,
  263. .valid_modes_mask = REGULATOR_MODE_NORMAL
  264. | REGULATOR_MODE_STANDBY,
  265. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  266. | REGULATOR_CHANGE_MODE
  267. | REGULATOR_CHANGE_STATUS,
  268. },
  269. };
  270. static struct regulator_init_data omap4_panda_vaux3 = {
  271. .constraints = {
  272. .min_uV = 1000000,
  273. .max_uV = 3000000,
  274. .apply_uV = true,
  275. .valid_modes_mask = REGULATOR_MODE_NORMAL
  276. | REGULATOR_MODE_STANDBY,
  277. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  278. | REGULATOR_CHANGE_MODE
  279. | REGULATOR_CHANGE_STATUS,
  280. },
  281. };
  282. /* VMMC1 for MMC1 card */
  283. static struct regulator_init_data omap4_panda_vmmc = {
  284. .constraints = {
  285. .min_uV = 1200000,
  286. .max_uV = 3000000,
  287. .apply_uV = true,
  288. .valid_modes_mask = REGULATOR_MODE_NORMAL
  289. | REGULATOR_MODE_STANDBY,
  290. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  291. | REGULATOR_CHANGE_MODE
  292. | REGULATOR_CHANGE_STATUS,
  293. },
  294. .num_consumer_supplies = 1,
  295. .consumer_supplies = omap4_panda_vmmc_supply,
  296. };
  297. static struct regulator_init_data omap4_panda_vpp = {
  298. .constraints = {
  299. .min_uV = 1800000,
  300. .max_uV = 2500000,
  301. .apply_uV = true,
  302. .valid_modes_mask = REGULATOR_MODE_NORMAL
  303. | REGULATOR_MODE_STANDBY,
  304. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  305. | REGULATOR_CHANGE_MODE
  306. | REGULATOR_CHANGE_STATUS,
  307. },
  308. };
  309. static struct regulator_init_data omap4_panda_vusim = {
  310. .constraints = {
  311. .min_uV = 1200000,
  312. .max_uV = 2900000,
  313. .apply_uV = true,
  314. .valid_modes_mask = REGULATOR_MODE_NORMAL
  315. | REGULATOR_MODE_STANDBY,
  316. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  317. | REGULATOR_CHANGE_MODE
  318. | REGULATOR_CHANGE_STATUS,
  319. },
  320. };
  321. static struct regulator_init_data omap4_panda_vana = {
  322. .constraints = {
  323. .min_uV = 2100000,
  324. .max_uV = 2100000,
  325. .valid_modes_mask = REGULATOR_MODE_NORMAL
  326. | REGULATOR_MODE_STANDBY,
  327. .valid_ops_mask = REGULATOR_CHANGE_MODE
  328. | REGULATOR_CHANGE_STATUS,
  329. },
  330. };
  331. static struct regulator_init_data omap4_panda_vcxio = {
  332. .constraints = {
  333. .min_uV = 1800000,
  334. .max_uV = 1800000,
  335. .valid_modes_mask = REGULATOR_MODE_NORMAL
  336. | REGULATOR_MODE_STANDBY,
  337. .valid_ops_mask = REGULATOR_CHANGE_MODE
  338. | REGULATOR_CHANGE_STATUS,
  339. },
  340. };
  341. static struct regulator_init_data omap4_panda_vdac = {
  342. .constraints = {
  343. .min_uV = 1800000,
  344. .max_uV = 1800000,
  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 regulator_init_data omap4_panda_vusb = {
  352. .constraints = {
  353. .min_uV = 3300000,
  354. .max_uV = 3300000,
  355. .apply_uV = true,
  356. .valid_modes_mask = REGULATOR_MODE_NORMAL
  357. | REGULATOR_MODE_STANDBY,
  358. .valid_ops_mask = REGULATOR_CHANGE_MODE
  359. | REGULATOR_CHANGE_STATUS,
  360. },
  361. };
  362. static struct twl4030_platform_data omap4_panda_twldata = {
  363. .irq_base = TWL6030_IRQ_BASE,
  364. .irq_end = TWL6030_IRQ_END,
  365. /* Regulators */
  366. .vmmc = &omap4_panda_vmmc,
  367. .vpp = &omap4_panda_vpp,
  368. .vusim = &omap4_panda_vusim,
  369. .vana = &omap4_panda_vana,
  370. .vcxio = &omap4_panda_vcxio,
  371. .vdac = &omap4_panda_vdac,
  372. .vusb = &omap4_panda_vusb,
  373. .vaux1 = &omap4_panda_vaux1,
  374. .vaux2 = &omap4_panda_vaux2,
  375. .vaux3 = &omap4_panda_vaux3,
  376. .usb = &omap4_usbphy_data,
  377. };
  378. static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
  379. {
  380. I2C_BOARD_INFO("twl6030", 0x48),
  381. .flags = I2C_CLIENT_WAKE,
  382. .irq = OMAP44XX_IRQ_SYS_1N,
  383. .platform_data = &omap4_panda_twldata,
  384. },
  385. };
  386. static int __init omap4_panda_i2c_init(void)
  387. {
  388. /*
  389. * Phoenix Audio IC needs I2C1 to
  390. * start with 400 KHz or less
  391. */
  392. omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
  393. ARRAY_SIZE(omap4_panda_i2c_boardinfo));
  394. omap_register_i2c_bus(2, 400, NULL, 0);
  395. omap_register_i2c_bus(3, 400, NULL, 0);
  396. omap_register_i2c_bus(4, 400, NULL, 0);
  397. return 0;
  398. }
  399. #ifdef CONFIG_OMAP_MUX
  400. static struct omap_board_mux board_mux[] __initdata = {
  401. /* WLAN IRQ - GPIO 53 */
  402. OMAP4_MUX(GPMC_NCS3, OMAP_MUX_MODE3 | OMAP_PIN_INPUT),
  403. /* WLAN POWER ENABLE - GPIO 43 */
  404. OMAP4_MUX(GPMC_A19, OMAP_MUX_MODE3 | OMAP_PIN_OUTPUT),
  405. /* WLAN SDIO: MMC5 CMD */
  406. OMAP4_MUX(SDMMC5_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  407. /* WLAN SDIO: MMC5 CLK */
  408. OMAP4_MUX(SDMMC5_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  409. /* WLAN SDIO: MMC5 DAT[0-3] */
  410. OMAP4_MUX(SDMMC5_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  411. OMAP4_MUX(SDMMC5_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  412. OMAP4_MUX(SDMMC5_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  413. OMAP4_MUX(SDMMC5_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
  414. { .reg_offset = OMAP_MUX_TERMINATOR },
  415. };
  416. static struct omap_device_pad serial2_pads[] __initdata = {
  417. OMAP_MUX_STATIC("uart2_cts.uart2_cts",
  418. OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  419. OMAP_MUX_STATIC("uart2_rts.uart2_rts",
  420. OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
  421. OMAP_MUX_STATIC("uart2_rx.uart2_rx",
  422. OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  423. OMAP_MUX_STATIC("uart2_tx.uart2_tx",
  424. OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
  425. };
  426. static struct omap_device_pad serial3_pads[] __initdata = {
  427. OMAP_MUX_STATIC("uart3_cts_rctx.uart3_cts_rctx",
  428. OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  429. OMAP_MUX_STATIC("uart3_rts_sd.uart3_rts_sd",
  430. OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
  431. OMAP_MUX_STATIC("uart3_rx_irrx.uart3_rx_irrx",
  432. OMAP_PIN_INPUT | OMAP_MUX_MODE0),
  433. OMAP_MUX_STATIC("uart3_tx_irtx.uart3_tx_irtx",
  434. OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
  435. };
  436. static struct omap_device_pad serial4_pads[] __initdata = {
  437. OMAP_MUX_STATIC("uart4_rx.uart4_rx",
  438. OMAP_PIN_INPUT | OMAP_MUX_MODE0),
  439. OMAP_MUX_STATIC("uart4_tx.uart4_tx",
  440. OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
  441. };
  442. static struct omap_board_data serial2_data = {
  443. .id = 1,
  444. .pads = serial2_pads,
  445. .pads_cnt = ARRAY_SIZE(serial2_pads),
  446. };
  447. static struct omap_board_data serial3_data = {
  448. .id = 2,
  449. .pads = serial3_pads,
  450. .pads_cnt = ARRAY_SIZE(serial3_pads),
  451. };
  452. static struct omap_board_data serial4_data = {
  453. .id = 3,
  454. .pads = serial4_pads,
  455. .pads_cnt = ARRAY_SIZE(serial4_pads),
  456. };
  457. static inline void board_serial_init(void)
  458. {
  459. struct omap_board_data bdata;
  460. bdata.flags = 0;
  461. bdata.pads = NULL;
  462. bdata.pads_cnt = 0;
  463. bdata.id = 0;
  464. /* pass dummy data for UART1 */
  465. omap_serial_init_port(&bdata);
  466. omap_serial_init_port(&serial2_data);
  467. omap_serial_init_port(&serial3_data);
  468. omap_serial_init_port(&serial4_data);
  469. }
  470. #else
  471. #define board_mux NULL
  472. static inline void board_serial_init(void)
  473. {
  474. omap_serial_init();
  475. }
  476. #endif
  477. static void __init omap4_panda_init(void)
  478. {
  479. int package = OMAP_PACKAGE_CBS;
  480. if (omap_rev() == OMAP4430_REV_ES1_0)
  481. package = OMAP_PACKAGE_CBL;
  482. omap4_mux_init(board_mux, package);
  483. if (wl12xx_set_platform_data(&omap_panda_wlan_data))
  484. pr_err("error setting wl12xx data\n");
  485. omap4_panda_i2c_init();
  486. platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
  487. platform_device_register(&omap_vwlan_device);
  488. board_serial_init();
  489. omap4_twl6030_hsmmc_init(mmc);
  490. omap4_ehci_init();
  491. usb_musb_init(&musb_board_data);
  492. }
  493. static void __init omap4_panda_map_io(void)
  494. {
  495. omap2_set_globals_443x();
  496. omap44xx_map_common_io();
  497. }
  498. MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
  499. /* Maintainer: David Anders - Texas Instruments Inc */
  500. .boot_params = 0x80000100,
  501. .reserve = omap_reserve,
  502. .map_io = omap4_panda_map_io,
  503. .init_early = omap4_panda_init_early,
  504. .init_irq = gic_init_irq,
  505. .init_machine = omap4_panda_init,
  506. .timer = &omap_timer,
  507. MACHINE_END