board-omap4panda.c 10 KB

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