board-omap4panda.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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_PERIPHERAL,
  128. .power = 100,
  129. };
  130. static struct omap2_hsmmc_info mmc[] = {
  131. {
  132. .mmc = 1,
  133. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  134. .gpio_wp = -EINVAL,
  135. .gpio_cd = -EINVAL,
  136. },
  137. {} /* Terminator */
  138. };
  139. static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
  140. {
  141. .supply = "vmmc",
  142. .dev_name = "mmci-omap-hs.0",
  143. },
  144. };
  145. static int omap4_twl6030_hsmmc_late_init(struct device *dev)
  146. {
  147. int ret = 0;
  148. struct platform_device *pdev = container_of(dev,
  149. struct platform_device, dev);
  150. struct omap_mmc_platform_data *pdata = dev->platform_data;
  151. if (!pdata) {
  152. dev_err(dev, "%s: NULL platform data\n", __func__);
  153. return -EINVAL;
  154. }
  155. /* Setting MMC1 Card detect Irq */
  156. if (pdev->id == 0) {
  157. ret = twl6030_mmc_card_detect_config();
  158. if (ret)
  159. dev_err(dev, "%s: Error card detect config(%d)\n",
  160. __func__, ret);
  161. else
  162. pdata->slots[0].card_detect = twl6030_mmc_card_detect;
  163. }
  164. return ret;
  165. }
  166. static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
  167. {
  168. struct omap_mmc_platform_data *pdata;
  169. /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
  170. if (!dev) {
  171. pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
  172. return;
  173. }
  174. pdata = dev->platform_data;
  175. pdata->init = omap4_twl6030_hsmmc_late_init;
  176. }
  177. static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
  178. {
  179. struct omap2_hsmmc_info *c;
  180. omap2_hsmmc_init(controllers);
  181. for (c = controllers; c->mmc; c++)
  182. omap4_twl6030_hsmmc_set_late_init(c->dev);
  183. return 0;
  184. }
  185. static struct regulator_init_data omap4_panda_vaux1 = {
  186. .constraints = {
  187. .min_uV = 1000000,
  188. .max_uV = 3000000,
  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_vaux2 = {
  198. .constraints = {
  199. .min_uV = 1200000,
  200. .max_uV = 2800000,
  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. static struct regulator_init_data omap4_panda_vaux3 = {
  210. .constraints = {
  211. .min_uV = 1000000,
  212. .max_uV = 3000000,
  213. .apply_uV = true,
  214. .valid_modes_mask = REGULATOR_MODE_NORMAL
  215. | REGULATOR_MODE_STANDBY,
  216. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  217. | REGULATOR_CHANGE_MODE
  218. | REGULATOR_CHANGE_STATUS,
  219. },
  220. };
  221. /* VMMC1 for MMC1 card */
  222. static struct regulator_init_data omap4_panda_vmmc = {
  223. .constraints = {
  224. .min_uV = 1200000,
  225. .max_uV = 3000000,
  226. .apply_uV = true,
  227. .valid_modes_mask = REGULATOR_MODE_NORMAL
  228. | REGULATOR_MODE_STANDBY,
  229. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  230. | REGULATOR_CHANGE_MODE
  231. | REGULATOR_CHANGE_STATUS,
  232. },
  233. .num_consumer_supplies = 1,
  234. .consumer_supplies = omap4_panda_vmmc_supply,
  235. };
  236. static struct regulator_init_data omap4_panda_vpp = {
  237. .constraints = {
  238. .min_uV = 1800000,
  239. .max_uV = 2500000,
  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_vusim = {
  249. .constraints = {
  250. .min_uV = 1200000,
  251. .max_uV = 2900000,
  252. .apply_uV = true,
  253. .valid_modes_mask = REGULATOR_MODE_NORMAL
  254. | REGULATOR_MODE_STANDBY,
  255. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  256. | REGULATOR_CHANGE_MODE
  257. | REGULATOR_CHANGE_STATUS,
  258. },
  259. };
  260. static struct regulator_init_data omap4_panda_vana = {
  261. .constraints = {
  262. .min_uV = 2100000,
  263. .max_uV = 2100000,
  264. .apply_uV = true,
  265. .valid_modes_mask = REGULATOR_MODE_NORMAL
  266. | REGULATOR_MODE_STANDBY,
  267. .valid_ops_mask = REGULATOR_CHANGE_MODE
  268. | REGULATOR_CHANGE_STATUS,
  269. },
  270. };
  271. static struct regulator_init_data omap4_panda_vcxio = {
  272. .constraints = {
  273. .min_uV = 1800000,
  274. .max_uV = 1800000,
  275. .apply_uV = true,
  276. .valid_modes_mask = REGULATOR_MODE_NORMAL
  277. | REGULATOR_MODE_STANDBY,
  278. .valid_ops_mask = REGULATOR_CHANGE_MODE
  279. | REGULATOR_CHANGE_STATUS,
  280. },
  281. };
  282. static struct regulator_init_data omap4_panda_vdac = {
  283. .constraints = {
  284. .min_uV = 1800000,
  285. .max_uV = 1800000,
  286. .apply_uV = true,
  287. .valid_modes_mask = REGULATOR_MODE_NORMAL
  288. | REGULATOR_MODE_STANDBY,
  289. .valid_ops_mask = REGULATOR_CHANGE_MODE
  290. | REGULATOR_CHANGE_STATUS,
  291. },
  292. };
  293. static struct regulator_init_data omap4_panda_vusb = {
  294. .constraints = {
  295. .min_uV = 3300000,
  296. .max_uV = 3300000,
  297. .apply_uV = true,
  298. .valid_modes_mask = REGULATOR_MODE_NORMAL
  299. | REGULATOR_MODE_STANDBY,
  300. .valid_ops_mask = REGULATOR_CHANGE_MODE
  301. | REGULATOR_CHANGE_STATUS,
  302. },
  303. };
  304. static struct twl4030_platform_data omap4_panda_twldata = {
  305. .irq_base = TWL6030_IRQ_BASE,
  306. .irq_end = TWL6030_IRQ_END,
  307. /* Regulators */
  308. .vmmc = &omap4_panda_vmmc,
  309. .vpp = &omap4_panda_vpp,
  310. .vusim = &omap4_panda_vusim,
  311. .vana = &omap4_panda_vana,
  312. .vcxio = &omap4_panda_vcxio,
  313. .vdac = &omap4_panda_vdac,
  314. .vusb = &omap4_panda_vusb,
  315. .vaux1 = &omap4_panda_vaux1,
  316. .vaux2 = &omap4_panda_vaux2,
  317. .vaux3 = &omap4_panda_vaux3,
  318. };
  319. static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
  320. {
  321. I2C_BOARD_INFO("twl6030", 0x48),
  322. .flags = I2C_CLIENT_WAKE,
  323. .irq = OMAP44XX_IRQ_SYS_1N,
  324. .platform_data = &omap4_panda_twldata,
  325. },
  326. };
  327. static int __init omap4_panda_i2c_init(void)
  328. {
  329. /*
  330. * Phoenix Audio IC needs I2C1 to
  331. * start with 400 KHz or less
  332. */
  333. omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
  334. ARRAY_SIZE(omap4_panda_i2c_boardinfo));
  335. omap_register_i2c_bus(2, 400, NULL, 0);
  336. omap_register_i2c_bus(3, 400, NULL, 0);
  337. omap_register_i2c_bus(4, 400, NULL, 0);
  338. return 0;
  339. }
  340. #ifdef CONFIG_OMAP_MUX
  341. static struct omap_board_mux board_mux[] __initdata = {
  342. { .reg_offset = OMAP_MUX_TERMINATOR },
  343. };
  344. #else
  345. #define board_mux NULL
  346. #endif
  347. static void __init omap4_panda_init(void)
  348. {
  349. int package = OMAP_PACKAGE_CBS;
  350. if (omap_rev() == OMAP4430_REV_ES1_0)
  351. package = OMAP_PACKAGE_CBL;
  352. omap4_mux_init(board_mux, package);
  353. omap4_panda_i2c_init();
  354. platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
  355. omap_serial_init();
  356. omap4_twl6030_hsmmc_init(mmc);
  357. /* OMAP4 Panda uses internal transceiver so register nop transceiver */
  358. usb_nop_xceiv_register();
  359. omap4_ehci_init();
  360. /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
  361. if (!cpu_is_omap44xx())
  362. usb_musb_init(&musb_board_data);
  363. }
  364. static void __init omap4_panda_map_io(void)
  365. {
  366. omap2_set_globals_443x();
  367. omap44xx_map_common_io();
  368. }
  369. MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
  370. /* Maintainer: David Anders - Texas Instruments Inc */
  371. .boot_params = 0x80000100,
  372. .reserve = omap_reserve,
  373. .map_io = omap4_panda_map_io,
  374. .init_irq = omap4_panda_init_irq,
  375. .init_machine = omap4_panda_init,
  376. .timer = &omap_timer,
  377. MACHINE_END