board-zoom-peripherals.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /*
  2. * Copyright (C) 2009 Texas Instruments Inc.
  3. *
  4. * Modified from mach-omap2/board-zoom2.c
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/input.h>
  14. #include <linux/input/matrix_keypad.h>
  15. #include <linux/gpio.h>
  16. #include <linux/i2c/twl.h>
  17. #include <linux/regulator/machine.h>
  18. #include <linux/regulator/fixed.h>
  19. #include <linux/wl12xx.h>
  20. #include <linux/mmc/host.h>
  21. #include <linux/platform_data/gpio-omap.h>
  22. #include <linux/platform_data/omap-twl4030.h>
  23. #include <linux/usb/phy.h>
  24. #include <linux/pwm.h>
  25. #include <linux/leds_pwm.h>
  26. #include <linux/pwm_backlight.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include "common.h"
  31. #include "board-zoom.h"
  32. #include "mux.h"
  33. #include "hsmmc.h"
  34. #include "common-board-devices.h"
  35. #define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
  36. #define OMAP_ZOOM_TSC2004_IRQ_GPIO (153)
  37. #define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
  38. /* Zoom2 has Qwerty keyboard*/
  39. static uint32_t board_keymap[] = {
  40. KEY(0, 0, KEY_E),
  41. KEY(0, 1, KEY_R),
  42. KEY(0, 2, KEY_T),
  43. KEY(0, 3, KEY_HOME),
  44. KEY(0, 6, KEY_I),
  45. KEY(0, 7, KEY_LEFTSHIFT),
  46. KEY(1, 0, KEY_D),
  47. KEY(1, 1, KEY_F),
  48. KEY(1, 2, KEY_G),
  49. KEY(1, 3, KEY_SEND),
  50. KEY(1, 6, KEY_K),
  51. KEY(1, 7, KEY_ENTER),
  52. KEY(2, 0, KEY_X),
  53. KEY(2, 1, KEY_C),
  54. KEY(2, 2, KEY_V),
  55. KEY(2, 3, KEY_END),
  56. KEY(2, 6, KEY_DOT),
  57. KEY(2, 7, KEY_CAPSLOCK),
  58. KEY(3, 0, KEY_Z),
  59. KEY(3, 1, KEY_KPPLUS),
  60. KEY(3, 2, KEY_B),
  61. KEY(3, 3, KEY_F1),
  62. KEY(3, 6, KEY_O),
  63. KEY(3, 7, KEY_SPACE),
  64. KEY(4, 0, KEY_W),
  65. KEY(4, 1, KEY_Y),
  66. KEY(4, 2, KEY_U),
  67. KEY(4, 3, KEY_F2),
  68. KEY(4, 4, KEY_VOLUMEUP),
  69. KEY(4, 6, KEY_L),
  70. KEY(4, 7, KEY_LEFT),
  71. KEY(5, 0, KEY_S),
  72. KEY(5, 1, KEY_H),
  73. KEY(5, 2, KEY_J),
  74. KEY(5, 3, KEY_F3),
  75. KEY(5, 4, KEY_UNKNOWN),
  76. KEY(5, 5, KEY_VOLUMEDOWN),
  77. KEY(5, 6, KEY_M),
  78. KEY(5, 7, KEY_RIGHT),
  79. KEY(6, 0, KEY_Q),
  80. KEY(6, 1, KEY_A),
  81. KEY(6, 2, KEY_N),
  82. KEY(6, 3, KEY_BACKSPACE),
  83. KEY(6, 6, KEY_P),
  84. KEY(6, 7, KEY_UP),
  85. KEY(7, 0, KEY_PROG1), /*MACRO 1 <User defined> */
  86. KEY(7, 1, KEY_PROG2), /*MACRO 2 <User defined> */
  87. KEY(7, 2, KEY_PROG3), /*MACRO 3 <User defined> */
  88. KEY(7, 3, KEY_PROG4), /*MACRO 4 <User defined> */
  89. KEY(7, 6, KEY_SELECT),
  90. KEY(7, 7, KEY_DOWN)
  91. };
  92. static struct matrix_keymap_data board_map_data = {
  93. .keymap = board_keymap,
  94. .keymap_size = ARRAY_SIZE(board_keymap),
  95. };
  96. static struct twl4030_keypad_data zoom_kp_twl4030_data = {
  97. .keymap_data = &board_map_data,
  98. .rows = 8,
  99. .cols = 8,
  100. .rep = 1,
  101. };
  102. static struct regulator_consumer_supply zoom_vmmc1_supply[] = {
  103. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  104. };
  105. static struct regulator_consumer_supply zoom_vsim_supply[] = {
  106. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
  107. };
  108. static struct regulator_consumer_supply zoom_vmmc2_supply[] = {
  109. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
  110. };
  111. static struct regulator_consumer_supply zoom_vmmc3_supply[] = {
  112. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
  113. };
  114. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  115. static struct regulator_init_data zoom_vmmc1 = {
  116. .constraints = {
  117. .min_uV = 1850000,
  118. .max_uV = 3150000,
  119. .valid_modes_mask = REGULATOR_MODE_NORMAL
  120. | REGULATOR_MODE_STANDBY,
  121. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  122. | REGULATOR_CHANGE_MODE
  123. | REGULATOR_CHANGE_STATUS,
  124. },
  125. .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc1_supply),
  126. .consumer_supplies = zoom_vmmc1_supply,
  127. };
  128. /* VMMC2 for MMC2 card */
  129. static struct regulator_init_data zoom_vmmc2 = {
  130. .constraints = {
  131. .min_uV = 1850000,
  132. .max_uV = 1850000,
  133. .apply_uV = true,
  134. .valid_modes_mask = REGULATOR_MODE_NORMAL
  135. | REGULATOR_MODE_STANDBY,
  136. .valid_ops_mask = REGULATOR_CHANGE_MODE
  137. | REGULATOR_CHANGE_STATUS,
  138. },
  139. .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc2_supply),
  140. .consumer_supplies = zoom_vmmc2_supply,
  141. };
  142. /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
  143. static struct regulator_init_data zoom_vsim = {
  144. .constraints = {
  145. .min_uV = 1800000,
  146. .max_uV = 3000000,
  147. .valid_modes_mask = REGULATOR_MODE_NORMAL
  148. | REGULATOR_MODE_STANDBY,
  149. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  150. | REGULATOR_CHANGE_MODE
  151. | REGULATOR_CHANGE_STATUS,
  152. },
  153. .num_consumer_supplies = ARRAY_SIZE(zoom_vsim_supply),
  154. .consumer_supplies = zoom_vsim_supply,
  155. };
  156. static struct regulator_init_data zoom_vmmc3 = {
  157. .constraints = {
  158. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  159. },
  160. .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc3_supply),
  161. .consumer_supplies = zoom_vmmc3_supply,
  162. };
  163. static struct fixed_voltage_config zoom_vwlan = {
  164. .supply_name = "vwl1271",
  165. .microvolts = 1800000, /* 1.8V */
  166. .gpio = OMAP_ZOOM_WLAN_PMENA_GPIO,
  167. .startup_delay = 70000, /* 70msec */
  168. .enable_high = 1,
  169. .enabled_at_boot = 0,
  170. .init_data = &zoom_vmmc3,
  171. };
  172. static struct platform_device omap_vwlan_device = {
  173. .name = "reg-fixed-voltage",
  174. .id = 1,
  175. .dev = {
  176. .platform_data = &zoom_vwlan,
  177. },
  178. };
  179. static struct pwm_lookup zoom_pwm_lookup[] = {
  180. PWM_LOOKUP("twl-pwm", 0, "leds_pwm", "zoom::keypad"),
  181. PWM_LOOKUP("twl-pwm", 1, "pwm-backlight", "backlight"),
  182. };
  183. static struct led_pwm zoom_pwm_leds[] = {
  184. {
  185. .name = "zoom::keypad",
  186. .max_brightness = 127,
  187. .pwm_period_ns = 7812500,
  188. },
  189. };
  190. static struct led_pwm_platform_data zoom_pwm_data = {
  191. .num_leds = ARRAY_SIZE(zoom_pwm_leds),
  192. .leds = zoom_pwm_leds,
  193. };
  194. static struct platform_device zoom_leds_pwm = {
  195. .name = "leds_pwm",
  196. .id = -1,
  197. .dev = {
  198. .platform_data = &zoom_pwm_data,
  199. },
  200. };
  201. static struct platform_pwm_backlight_data zoom_backlight_data = {
  202. .pwm_id = 1,
  203. .max_brightness = 127,
  204. .dft_brightness = 127,
  205. .pwm_period_ns = 7812500,
  206. };
  207. static struct platform_device zoom_backlight_pwm = {
  208. .name = "pwm-backlight",
  209. .id = -1,
  210. .dev = {
  211. .platform_data = &zoom_backlight_data,
  212. },
  213. };
  214. static struct platform_device *zoom_devices[] __initdata = {
  215. &omap_vwlan_device,
  216. &zoom_leds_pwm,
  217. &zoom_backlight_pwm,
  218. };
  219. static struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
  220. .board_ref_clock = WL12XX_REFCLOCK_26, /* 26 MHz */
  221. };
  222. static struct omap2_hsmmc_info mmc[] = {
  223. {
  224. .name = "external",
  225. .mmc = 1,
  226. .caps = MMC_CAP_4_BIT_DATA,
  227. .gpio_wp = -EINVAL,
  228. .power_saving = true,
  229. .deferred = true,
  230. },
  231. {
  232. .name = "internal",
  233. .mmc = 2,
  234. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  235. .gpio_cd = -EINVAL,
  236. .gpio_wp = -EINVAL,
  237. .nonremovable = true,
  238. .power_saving = true,
  239. },
  240. {
  241. .name = "wl1271",
  242. .mmc = 3,
  243. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
  244. .gpio_wp = -EINVAL,
  245. .gpio_cd = -EINVAL,
  246. .nonremovable = true,
  247. },
  248. {} /* Terminator */
  249. };
  250. static struct omap_tw4030_pdata omap_twl4030_audio_data = {
  251. .voice_connected = true,
  252. .custom_routing = true,
  253. .has_hs = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
  254. .has_hf = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
  255. .has_mainmic = true,
  256. .has_submic = true,
  257. .has_hsmic = true,
  258. .has_linein = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
  259. };
  260. static int zoom_twl_gpio_setup(struct device *dev,
  261. unsigned gpio, unsigned ngpio)
  262. {
  263. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  264. mmc[0].gpio_cd = gpio + 0;
  265. omap_hsmmc_late_init(mmc);
  266. /* Audio setup */
  267. omap_twl4030_audio_data.jack_detect = gpio + 2;
  268. omap_twl4030_audio_init("Zoom2", &omap_twl4030_audio_data);
  269. return 0;
  270. }
  271. static struct twl4030_gpio_platform_data zoom_gpio_data = {
  272. .setup = zoom_twl_gpio_setup,
  273. };
  274. static struct twl4030_platform_data zoom_twldata = {
  275. /* platform_data for children goes here */
  276. .gpio = &zoom_gpio_data,
  277. .keypad = &zoom_kp_twl4030_data,
  278. .vmmc1 = &zoom_vmmc1,
  279. .vmmc2 = &zoom_vmmc2,
  280. .vsim = &zoom_vsim,
  281. };
  282. static int __init omap_i2c_init(void)
  283. {
  284. omap3_pmic_get_config(&zoom_twldata,
  285. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_BCI |
  286. TWL_COMMON_PDATA_MADC | TWL_COMMON_PDATA_AUDIO,
  287. TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
  288. if (machine_is_omap_zoom2())
  289. zoom_twldata.audio->codec->ramp_delay_value = 3; /* 161 ms */
  290. omap_pmic_init(1, 2400, "twl5030", 7 + OMAP_INTC_START, &zoom_twldata);
  291. omap_register_i2c_bus(2, 400, NULL, 0);
  292. omap_register_i2c_bus(3, 400, NULL, 0);
  293. return 0;
  294. }
  295. static void enable_board_wakeup_source(void)
  296. {
  297. /* T2 interrupt line (keypad) */
  298. omap_mux_init_signal("sys_nirq",
  299. OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
  300. }
  301. void __init zoom_peripherals_init(void)
  302. {
  303. int ret;
  304. omap_zoom_wlan_data.irq = gpio_to_irq(OMAP_ZOOM_WLAN_IRQ_GPIO);
  305. ret = wl12xx_set_platform_data(&omap_zoom_wlan_data);
  306. if (ret)
  307. pr_err("error setting wl12xx data: %d\n", ret);
  308. omap_hsmmc_init(mmc);
  309. omap_i2c_init();
  310. pwm_add_table(zoom_pwm_lookup, ARRAY_SIZE(zoom_pwm_lookup));
  311. platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
  312. usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
  313. usb_musb_init(NULL);
  314. enable_board_wakeup_source();
  315. omap_serial_init();
  316. }