board-omap4panda.c 9.8 KB

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