board-zoom-peripherals.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include "common.h"
  28. #include "board-zoom.h"
  29. #include "mux.h"
  30. #include "hsmmc.h"
  31. #include "common-board-devices.h"
  32. #define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
  33. #define OMAP_ZOOM_TSC2004_IRQ_GPIO (153)
  34. #define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
  35. /* Zoom2 has Qwerty keyboard*/
  36. static uint32_t board_keymap[] = {
  37. KEY(0, 0, KEY_E),
  38. KEY(0, 1, KEY_R),
  39. KEY(0, 2, KEY_T),
  40. KEY(0, 3, KEY_HOME),
  41. KEY(0, 6, KEY_I),
  42. KEY(0, 7, KEY_LEFTSHIFT),
  43. KEY(1, 0, KEY_D),
  44. KEY(1, 1, KEY_F),
  45. KEY(1, 2, KEY_G),
  46. KEY(1, 3, KEY_SEND),
  47. KEY(1, 6, KEY_K),
  48. KEY(1, 7, KEY_ENTER),
  49. KEY(2, 0, KEY_X),
  50. KEY(2, 1, KEY_C),
  51. KEY(2, 2, KEY_V),
  52. KEY(2, 3, KEY_END),
  53. KEY(2, 6, KEY_DOT),
  54. KEY(2, 7, KEY_CAPSLOCK),
  55. KEY(3, 0, KEY_Z),
  56. KEY(3, 1, KEY_KPPLUS),
  57. KEY(3, 2, KEY_B),
  58. KEY(3, 3, KEY_F1),
  59. KEY(3, 6, KEY_O),
  60. KEY(3, 7, KEY_SPACE),
  61. KEY(4, 0, KEY_W),
  62. KEY(4, 1, KEY_Y),
  63. KEY(4, 2, KEY_U),
  64. KEY(4, 3, KEY_F2),
  65. KEY(4, 4, KEY_VOLUMEUP),
  66. KEY(4, 6, KEY_L),
  67. KEY(4, 7, KEY_LEFT),
  68. KEY(5, 0, KEY_S),
  69. KEY(5, 1, KEY_H),
  70. KEY(5, 2, KEY_J),
  71. KEY(5, 3, KEY_F3),
  72. KEY(5, 4, KEY_UNKNOWN),
  73. KEY(5, 5, KEY_VOLUMEDOWN),
  74. KEY(5, 6, KEY_M),
  75. KEY(5, 7, KEY_RIGHT),
  76. KEY(6, 0, KEY_Q),
  77. KEY(6, 1, KEY_A),
  78. KEY(6, 2, KEY_N),
  79. KEY(6, 3, KEY_BACKSPACE),
  80. KEY(6, 6, KEY_P),
  81. KEY(6, 7, KEY_UP),
  82. KEY(7, 0, KEY_PROG1), /*MACRO 1 <User defined> */
  83. KEY(7, 1, KEY_PROG2), /*MACRO 2 <User defined> */
  84. KEY(7, 2, KEY_PROG3), /*MACRO 3 <User defined> */
  85. KEY(7, 3, KEY_PROG4), /*MACRO 4 <User defined> */
  86. KEY(7, 6, KEY_SELECT),
  87. KEY(7, 7, KEY_DOWN)
  88. };
  89. static struct matrix_keymap_data board_map_data = {
  90. .keymap = board_keymap,
  91. .keymap_size = ARRAY_SIZE(board_keymap),
  92. };
  93. static struct twl4030_keypad_data zoom_kp_twl4030_data = {
  94. .keymap_data = &board_map_data,
  95. .rows = 8,
  96. .cols = 8,
  97. .rep = 1,
  98. };
  99. static struct regulator_consumer_supply zoom_vmmc1_supply[] = {
  100. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  101. };
  102. static struct regulator_consumer_supply zoom_vsim_supply[] = {
  103. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
  104. };
  105. static struct regulator_consumer_supply zoom_vmmc2_supply[] = {
  106. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
  107. };
  108. static struct regulator_consumer_supply zoom_vmmc3_supply[] = {
  109. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
  110. };
  111. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  112. static struct regulator_init_data zoom_vmmc1 = {
  113. .constraints = {
  114. .min_uV = 1850000,
  115. .max_uV = 3150000,
  116. .valid_modes_mask = REGULATOR_MODE_NORMAL
  117. | REGULATOR_MODE_STANDBY,
  118. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  119. | REGULATOR_CHANGE_MODE
  120. | REGULATOR_CHANGE_STATUS,
  121. },
  122. .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc1_supply),
  123. .consumer_supplies = zoom_vmmc1_supply,
  124. };
  125. /* VMMC2 for MMC2 card */
  126. static struct regulator_init_data zoom_vmmc2 = {
  127. .constraints = {
  128. .min_uV = 1850000,
  129. .max_uV = 1850000,
  130. .apply_uV = true,
  131. .valid_modes_mask = REGULATOR_MODE_NORMAL
  132. | REGULATOR_MODE_STANDBY,
  133. .valid_ops_mask = REGULATOR_CHANGE_MODE
  134. | REGULATOR_CHANGE_STATUS,
  135. },
  136. .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc2_supply),
  137. .consumer_supplies = zoom_vmmc2_supply,
  138. };
  139. /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
  140. static struct regulator_init_data zoom_vsim = {
  141. .constraints = {
  142. .min_uV = 1800000,
  143. .max_uV = 3000000,
  144. .valid_modes_mask = REGULATOR_MODE_NORMAL
  145. | REGULATOR_MODE_STANDBY,
  146. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  147. | REGULATOR_CHANGE_MODE
  148. | REGULATOR_CHANGE_STATUS,
  149. },
  150. .num_consumer_supplies = ARRAY_SIZE(zoom_vsim_supply),
  151. .consumer_supplies = zoom_vsim_supply,
  152. };
  153. static struct regulator_init_data zoom_vmmc3 = {
  154. .constraints = {
  155. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  156. },
  157. .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc3_supply),
  158. .consumer_supplies = zoom_vmmc3_supply,
  159. };
  160. static struct fixed_voltage_config zoom_vwlan = {
  161. .supply_name = "vwl1271",
  162. .microvolts = 1800000, /* 1.8V */
  163. .gpio = OMAP_ZOOM_WLAN_PMENA_GPIO,
  164. .startup_delay = 70000, /* 70msec */
  165. .enable_high = 1,
  166. .enabled_at_boot = 0,
  167. .init_data = &zoom_vmmc3,
  168. };
  169. static struct platform_device omap_vwlan_device = {
  170. .name = "reg-fixed-voltage",
  171. .id = 1,
  172. .dev = {
  173. .platform_data = &zoom_vwlan,
  174. },
  175. };
  176. static struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
  177. .board_ref_clock = WL12XX_REFCLOCK_26, /* 26 MHz */
  178. };
  179. static struct omap2_hsmmc_info mmc[] = {
  180. {
  181. .name = "external",
  182. .mmc = 1,
  183. .caps = MMC_CAP_4_BIT_DATA,
  184. .gpio_wp = -EINVAL,
  185. .power_saving = true,
  186. .deferred = true,
  187. },
  188. {
  189. .name = "internal",
  190. .mmc = 2,
  191. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  192. .gpio_cd = -EINVAL,
  193. .gpio_wp = -EINVAL,
  194. .nonremovable = true,
  195. .power_saving = true,
  196. },
  197. {
  198. .name = "wl1271",
  199. .mmc = 3,
  200. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
  201. .gpio_wp = -EINVAL,
  202. .gpio_cd = -EINVAL,
  203. .nonremovable = true,
  204. },
  205. {} /* Terminator */
  206. };
  207. static struct omap_tw4030_pdata omap_twl4030_audio_data = {
  208. .voice_connected = true,
  209. .custom_routing = true,
  210. .has_hs = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
  211. .has_hf = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
  212. .has_mainmic = true,
  213. .has_submic = true,
  214. .has_hsmic = true,
  215. .has_linein = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
  216. };
  217. static int zoom_twl_gpio_setup(struct device *dev,
  218. unsigned gpio, unsigned ngpio)
  219. {
  220. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  221. mmc[0].gpio_cd = gpio + 0;
  222. omap_hsmmc_late_init(mmc);
  223. /* Audio setup */
  224. omap_twl4030_audio_data.jack_detect = gpio + 2;
  225. omap_twl4030_audio_init("Zoom2", &omap_twl4030_audio_data);
  226. return 0;
  227. }
  228. static struct twl4030_gpio_platform_data zoom_gpio_data = {
  229. .setup = zoom_twl_gpio_setup,
  230. };
  231. static struct twl4030_platform_data zoom_twldata = {
  232. /* platform_data for children goes here */
  233. .gpio = &zoom_gpio_data,
  234. .keypad = &zoom_kp_twl4030_data,
  235. .vmmc1 = &zoom_vmmc1,
  236. .vmmc2 = &zoom_vmmc2,
  237. .vsim = &zoom_vsim,
  238. };
  239. static int __init omap_i2c_init(void)
  240. {
  241. omap3_pmic_get_config(&zoom_twldata,
  242. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_BCI |
  243. TWL_COMMON_PDATA_MADC | TWL_COMMON_PDATA_AUDIO,
  244. TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
  245. if (machine_is_omap_zoom2())
  246. zoom_twldata.audio->codec->ramp_delay_value = 3; /* 161 ms */
  247. omap_pmic_init(1, 2400, "twl5030", 7 + OMAP_INTC_START, &zoom_twldata);
  248. omap_register_i2c_bus(2, 400, NULL, 0);
  249. omap_register_i2c_bus(3, 400, NULL, 0);
  250. return 0;
  251. }
  252. static void enable_board_wakeup_source(void)
  253. {
  254. /* T2 interrupt line (keypad) */
  255. omap_mux_init_signal("sys_nirq",
  256. OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
  257. }
  258. void __init zoom_peripherals_init(void)
  259. {
  260. int ret;
  261. omap_zoom_wlan_data.irq = gpio_to_irq(OMAP_ZOOM_WLAN_IRQ_GPIO);
  262. ret = wl12xx_set_platform_data(&omap_zoom_wlan_data);
  263. if (ret)
  264. pr_err("error setting wl12xx data: %d\n", ret);
  265. omap_hsmmc_init(mmc);
  266. omap_i2c_init();
  267. platform_device_register(&omap_vwlan_device);
  268. usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
  269. usb_musb_init(NULL);
  270. enable_board_wakeup_source();
  271. omap_serial_init();
  272. }