board-4430sdp.c 12 KB

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