board-omap4panda.c 9.4 KB

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