board-4430sdp.c 14 KB

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