board-zoom-peripherals.c 7.5 KB

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