board-4430sdp.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /*
  2. * Board support file for OMAP4430 SDP.
  3. *
  4. * Copyright (C) 2009 Texas Instruments
  5. *
  6. * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
  7. *
  8. * Based on mach-omap2/board-3430sdp.c
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/io.h>
  18. #include <linux/gpio.h>
  19. #include <linux/usb/otg.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/i2c/twl.h>
  22. #include <linux/gpio_keys.h>
  23. #include <linux/regulator/machine.h>
  24. #include <linux/leds.h>
  25. #include <mach/hardware.h>
  26. #include <mach/omap4-common.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <plat/board.h>
  31. #include <plat/common.h>
  32. #include <plat/usb.h>
  33. #include <plat/mmc.h>
  34. #include "hsmmc.h"
  35. #include "timer-gp.h"
  36. #include "control.h"
  37. #define ETH_KS8851_IRQ 34
  38. #define ETH_KS8851_POWER_ON 48
  39. #define ETH_KS8851_QUART 138
  40. #define OMAP4SDP_MDM_PWR_EN_GPIO 157
  41. #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
  42. #define OMAP4_SFH7741_ENABLE_GPIO 188
  43. static struct gpio_led sdp4430_gpio_leds[] = {
  44. {
  45. .name = "omap4:green:debug0",
  46. .gpio = 61,
  47. },
  48. {
  49. .name = "omap4:green:debug1",
  50. .gpio = 30,
  51. },
  52. {
  53. .name = "omap4:green:debug2",
  54. .gpio = 7,
  55. },
  56. {
  57. .name = "omap4:green:debug3",
  58. .gpio = 8,
  59. },
  60. {
  61. .name = "omap4:green:debug4",
  62. .gpio = 50,
  63. },
  64. {
  65. .name = "omap4:blue:user",
  66. .gpio = 169,
  67. },
  68. {
  69. .name = "omap4:red:user",
  70. .gpio = 170,
  71. },
  72. {
  73. .name = "omap4:green:user",
  74. .gpio = 139,
  75. },
  76. };
  77. static struct gpio_keys_button sdp4430_gpio_keys[] = {
  78. {
  79. .desc = "Proximity Sensor",
  80. .type = EV_SW,
  81. .code = SW_FRONT_PROXIMITY,
  82. .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
  83. .active_low = 0,
  84. }
  85. };
  86. static struct gpio_led_platform_data sdp4430_led_data = {
  87. .leds = sdp4430_gpio_leds,
  88. .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
  89. };
  90. static int omap_prox_activate(struct device *dev)
  91. {
  92. gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
  93. return 0;
  94. }
  95. static void omap_prox_deactivate(struct device *dev)
  96. {
  97. gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
  98. }
  99. static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
  100. .buttons = sdp4430_gpio_keys,
  101. .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
  102. .enable = omap_prox_activate,
  103. .disable = omap_prox_deactivate,
  104. };
  105. static struct platform_device sdp4430_gpio_keys_device = {
  106. .name = "gpio-keys",
  107. .id = -1,
  108. .dev = {
  109. .platform_data = &sdp4430_gpio_keys_data,
  110. },
  111. };
  112. static struct platform_device sdp4430_leds_gpio = {
  113. .name = "leds-gpio",
  114. .id = -1,
  115. .dev = {
  116. .platform_data = &sdp4430_led_data,
  117. },
  118. };
  119. static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
  120. {
  121. .modalias = "ks8851",
  122. .bus_num = 1,
  123. .chip_select = 0,
  124. .max_speed_hz = 24000000,
  125. .irq = ETH_KS8851_IRQ,
  126. },
  127. };
  128. static int omap_ethernet_init(void)
  129. {
  130. int status;
  131. /* Request of GPIO lines */
  132. status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
  133. if (status) {
  134. pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
  135. return status;
  136. }
  137. status = gpio_request(ETH_KS8851_QUART, "quart");
  138. if (status) {
  139. pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
  140. goto error1;
  141. }
  142. status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
  143. if (status) {
  144. pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
  145. goto error2;
  146. }
  147. /* Configuration of requested GPIO lines */
  148. status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
  149. if (status) {
  150. pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
  151. goto error3;
  152. }
  153. status = gpio_direction_output(ETH_KS8851_QUART, 1);
  154. if (status) {
  155. pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
  156. goto error3;
  157. }
  158. status = gpio_direction_input(ETH_KS8851_IRQ);
  159. if (status) {
  160. pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
  161. goto error3;
  162. }
  163. return 0;
  164. error3:
  165. gpio_free(ETH_KS8851_IRQ);
  166. error2:
  167. gpio_free(ETH_KS8851_QUART);
  168. error1:
  169. gpio_free(ETH_KS8851_POWER_ON);
  170. return status;
  171. }
  172. static struct platform_device sdp4430_lcd_device = {
  173. .name = "sdp4430_lcd",
  174. .id = -1,
  175. };
  176. static struct platform_device *sdp4430_devices[] __initdata = {
  177. &sdp4430_lcd_device,
  178. &sdp4430_gpio_keys_device,
  179. &sdp4430_leds_gpio,
  180. };
  181. static struct omap_lcd_config sdp4430_lcd_config __initdata = {
  182. .ctrl_name = "internal",
  183. };
  184. static struct omap_board_config_kernel sdp4430_config[] __initdata = {
  185. { OMAP_TAG_LCD, &sdp4430_lcd_config },
  186. };
  187. static void __init omap_4430sdp_init_irq(void)
  188. {
  189. omap_board_config = sdp4430_config;
  190. omap_board_config_size = ARRAY_SIZE(sdp4430_config);
  191. omap2_init_common_hw(NULL, NULL);
  192. #ifdef CONFIG_OMAP_32K_TIMER
  193. omap2_gp_clockevent_set_gptimer(1);
  194. #endif
  195. gic_init_irq();
  196. omap_gpio_init();
  197. }
  198. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  199. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  200. .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  201. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  202. .phy_reset = false,
  203. .reset_gpio_port[0] = -EINVAL,
  204. .reset_gpio_port[1] = -EINVAL,
  205. .reset_gpio_port[2] = -EINVAL,
  206. };
  207. static struct omap_musb_board_data musb_board_data = {
  208. .interface_type = MUSB_INTERFACE_UTMI,
  209. .mode = MUSB_OTG,
  210. .power = 100,
  211. };
  212. static struct twl4030_usb_data omap4_usbphy_data = {
  213. .phy_init = omap4430_phy_init,
  214. .phy_exit = omap4430_phy_exit,
  215. .phy_power = omap4430_phy_power,
  216. .phy_set_clock = omap4430_phy_set_clk,
  217. };
  218. static struct omap2_hsmmc_info mmc[] = {
  219. {
  220. .mmc = 1,
  221. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  222. .gpio_wp = -EINVAL,
  223. },
  224. {
  225. .mmc = 2,
  226. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  227. .gpio_cd = -EINVAL,
  228. .gpio_wp = -EINVAL,
  229. .nonremovable = true,
  230. .ocr_mask = MMC_VDD_29_30,
  231. },
  232. {} /* Terminator */
  233. };
  234. static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
  235. {
  236. .supply = "vmmc",
  237. .dev_name = "mmci-omap-hs.1",
  238. },
  239. };
  240. static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
  241. {
  242. .supply = "vmmc",
  243. .dev_name = "mmci-omap-hs.0",
  244. },
  245. };
  246. static int omap4_twl6030_hsmmc_late_init(struct device *dev)
  247. {
  248. int ret = 0;
  249. struct platform_device *pdev = container_of(dev,
  250. struct platform_device, dev);
  251. struct omap_mmc_platform_data *pdata = dev->platform_data;
  252. /* Setting MMC1 Card detect Irq */
  253. if (pdev->id == 0) {
  254. ret = twl6030_mmc_card_detect_config();
  255. if (ret)
  256. pr_err("Failed configuring MMC1 card detect\n");
  257. pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
  258. MMCDETECT_INTR_OFFSET;
  259. pdata->slots[0].card_detect = twl6030_mmc_card_detect;
  260. }
  261. return ret;
  262. }
  263. static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
  264. {
  265. struct omap_mmc_platform_data *pdata;
  266. /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
  267. if (!dev) {
  268. pr_err("Failed %s\n", __func__);
  269. return;
  270. }
  271. pdata = dev->platform_data;
  272. pdata->init = omap4_twl6030_hsmmc_late_init;
  273. }
  274. static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
  275. {
  276. struct omap2_hsmmc_info *c;
  277. omap2_hsmmc_init(controllers);
  278. for (c = controllers; c->mmc; c++)
  279. omap4_twl6030_hsmmc_set_late_init(c->dev);
  280. return 0;
  281. }
  282. static struct regulator_init_data sdp4430_vaux1 = {
  283. .constraints = {
  284. .min_uV = 1000000,
  285. .max_uV = 3000000,
  286. .apply_uV = true,
  287. .valid_modes_mask = REGULATOR_MODE_NORMAL
  288. | REGULATOR_MODE_STANDBY,
  289. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  290. | REGULATOR_CHANGE_MODE
  291. | REGULATOR_CHANGE_STATUS,
  292. },
  293. .num_consumer_supplies = 1,
  294. .consumer_supplies = sdp4430_vaux_supply,
  295. };
  296. static struct regulator_init_data sdp4430_vaux2 = {
  297. .constraints = {
  298. .min_uV = 1200000,
  299. .max_uV = 2800000,
  300. .apply_uV = true,
  301. .valid_modes_mask = REGULATOR_MODE_NORMAL
  302. | REGULATOR_MODE_STANDBY,
  303. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  304. | REGULATOR_CHANGE_MODE
  305. | REGULATOR_CHANGE_STATUS,
  306. },
  307. };
  308. static struct regulator_init_data sdp4430_vaux3 = {
  309. .constraints = {
  310. .min_uV = 1000000,
  311. .max_uV = 3000000,
  312. .apply_uV = true,
  313. .valid_modes_mask = REGULATOR_MODE_NORMAL
  314. | REGULATOR_MODE_STANDBY,
  315. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  316. | REGULATOR_CHANGE_MODE
  317. | REGULATOR_CHANGE_STATUS,
  318. },
  319. };
  320. /* VMMC1 for MMC1 card */
  321. static struct regulator_init_data sdp4430_vmmc = {
  322. .constraints = {
  323. .min_uV = 1200000,
  324. .max_uV = 3000000,
  325. .apply_uV = true,
  326. .valid_modes_mask = REGULATOR_MODE_NORMAL
  327. | REGULATOR_MODE_STANDBY,
  328. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  329. | REGULATOR_CHANGE_MODE
  330. | REGULATOR_CHANGE_STATUS,
  331. },
  332. .num_consumer_supplies = 1,
  333. .consumer_supplies = sdp4430_vmmc_supply,
  334. };
  335. static struct regulator_init_data sdp4430_vpp = {
  336. .constraints = {
  337. .min_uV = 1800000,
  338. .max_uV = 2500000,
  339. .apply_uV = true,
  340. .valid_modes_mask = REGULATOR_MODE_NORMAL
  341. | REGULATOR_MODE_STANDBY,
  342. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  343. | REGULATOR_CHANGE_MODE
  344. | REGULATOR_CHANGE_STATUS,
  345. },
  346. };
  347. static struct regulator_init_data sdp4430_vusim = {
  348. .constraints = {
  349. .min_uV = 1200000,
  350. .max_uV = 2900000,
  351. .apply_uV = true,
  352. .valid_modes_mask = REGULATOR_MODE_NORMAL
  353. | REGULATOR_MODE_STANDBY,
  354. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  355. | REGULATOR_CHANGE_MODE
  356. | REGULATOR_CHANGE_STATUS,
  357. },
  358. };
  359. static struct regulator_init_data sdp4430_vana = {
  360. .constraints = {
  361. .min_uV = 2100000,
  362. .max_uV = 2100000,
  363. .apply_uV = true,
  364. .valid_modes_mask = REGULATOR_MODE_NORMAL
  365. | REGULATOR_MODE_STANDBY,
  366. .valid_ops_mask = REGULATOR_CHANGE_MODE
  367. | REGULATOR_CHANGE_STATUS,
  368. },
  369. };
  370. static struct regulator_init_data sdp4430_vcxio = {
  371. .constraints = {
  372. .min_uV = 1800000,
  373. .max_uV = 1800000,
  374. .apply_uV = true,
  375. .valid_modes_mask = REGULATOR_MODE_NORMAL
  376. | REGULATOR_MODE_STANDBY,
  377. .valid_ops_mask = REGULATOR_CHANGE_MODE
  378. | REGULATOR_CHANGE_STATUS,
  379. },
  380. };
  381. static struct regulator_init_data sdp4430_vdac = {
  382. .constraints = {
  383. .min_uV = 1800000,
  384. .max_uV = 1800000,
  385. .apply_uV = true,
  386. .valid_modes_mask = REGULATOR_MODE_NORMAL
  387. | REGULATOR_MODE_STANDBY,
  388. .valid_ops_mask = REGULATOR_CHANGE_MODE
  389. | REGULATOR_CHANGE_STATUS,
  390. },
  391. };
  392. static struct regulator_init_data sdp4430_vusb = {
  393. .constraints = {
  394. .min_uV = 3300000,
  395. .max_uV = 3300000,
  396. .apply_uV = true,
  397. .valid_modes_mask = REGULATOR_MODE_NORMAL
  398. | REGULATOR_MODE_STANDBY,
  399. .valid_ops_mask = REGULATOR_CHANGE_MODE
  400. | REGULATOR_CHANGE_STATUS,
  401. },
  402. };
  403. static struct twl4030_platform_data sdp4430_twldata = {
  404. .irq_base = TWL6030_IRQ_BASE,
  405. .irq_end = TWL6030_IRQ_END,
  406. /* Regulators */
  407. .vmmc = &sdp4430_vmmc,
  408. .vpp = &sdp4430_vpp,
  409. .vusim = &sdp4430_vusim,
  410. .vana = &sdp4430_vana,
  411. .vcxio = &sdp4430_vcxio,
  412. .vdac = &sdp4430_vdac,
  413. .vusb = &sdp4430_vusb,
  414. .vaux1 = &sdp4430_vaux1,
  415. .vaux2 = &sdp4430_vaux2,
  416. .vaux3 = &sdp4430_vaux3,
  417. .usb = &omap4_usbphy_data
  418. };
  419. static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
  420. {
  421. I2C_BOARD_INFO("twl6030", 0x48),
  422. .flags = I2C_CLIENT_WAKE,
  423. .irq = OMAP44XX_IRQ_SYS_1N,
  424. .platform_data = &sdp4430_twldata,
  425. },
  426. };
  427. static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
  428. {
  429. I2C_BOARD_INFO("tmp105", 0x48),
  430. },
  431. };
  432. static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
  433. {
  434. I2C_BOARD_INFO("hmc5843", 0x1e),
  435. },
  436. };
  437. static int __init omap4_i2c_init(void)
  438. {
  439. /*
  440. * Phoenix Audio IC needs I2C1 to
  441. * start with 400 KHz or less
  442. */
  443. omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
  444. ARRAY_SIZE(sdp4430_i2c_boardinfo));
  445. omap_register_i2c_bus(2, 400, NULL, 0);
  446. omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
  447. ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
  448. omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
  449. ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
  450. return 0;
  451. }
  452. static void __init omap_sfh7741prox_init(void)
  453. {
  454. int error;
  455. error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
  456. if (error < 0) {
  457. pr_err("%s:failed to request GPIO %d, error %d\n",
  458. __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
  459. return;
  460. }
  461. error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
  462. if (error < 0) {
  463. pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
  464. __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
  465. gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
  466. }
  467. }
  468. static void __init omap_4430sdp_init(void)
  469. {
  470. int status;
  471. omap4_i2c_init();
  472. omap_sfh7741prox_init();
  473. platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
  474. omap_serial_init();
  475. omap4_twl6030_hsmmc_init(mmc);
  476. /* Power on the ULPI PHY */
  477. if (gpio_is_valid(OMAP4SDP_MDM_PWR_EN_GPIO)) {
  478. /* FIXME: Assumes pad is already muxed for GPIO mode */
  479. gpio_request(OMAP4SDP_MDM_PWR_EN_GPIO, "USBB1 PHY VMDM_3V3");
  480. gpio_direction_output(OMAP4SDP_MDM_PWR_EN_GPIO, 1);
  481. }
  482. usb_ehci_init(&ehci_pdata);
  483. usb_musb_init(&musb_board_data);
  484. status = omap_ethernet_init();
  485. if (status) {
  486. pr_err("Ethernet initialization failed: %d\n", status);
  487. } else {
  488. sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
  489. spi_register_board_info(sdp4430_spi_board_info,
  490. ARRAY_SIZE(sdp4430_spi_board_info));
  491. }
  492. }
  493. static void __init omap_4430sdp_map_io(void)
  494. {
  495. omap2_set_globals_443x();
  496. omap44xx_map_common_io();
  497. }
  498. MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
  499. /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
  500. .boot_params = 0x80000100,
  501. .map_io = omap_4430sdp_map_io,
  502. .reserve = omap_reserve,
  503. .init_irq = omap_4430sdp_init_irq,
  504. .init_machine = omap_4430sdp_init,
  505. .timer = &omap_timer,
  506. MACHINE_END