board-4430sdp.c 14 KB

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