board-omap4panda.c 10 KB

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