board-zoom-peripherals.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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 <asm/mach-types.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach/map.h>
  24. #include <plat/common.h>
  25. #include <plat/usb.h>
  26. #include <mach/board-zoom.h>
  27. #include "mux.h"
  28. #include "hsmmc.h"
  29. #define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
  30. #define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
  31. /* Zoom2 has Qwerty keyboard*/
  32. static uint32_t board_keymap[] = {
  33. KEY(0, 0, KEY_E),
  34. KEY(0, 1, KEY_R),
  35. KEY(0, 2, KEY_T),
  36. KEY(0, 3, KEY_HOME),
  37. KEY(0, 6, KEY_I),
  38. KEY(0, 7, KEY_LEFTSHIFT),
  39. KEY(1, 0, KEY_D),
  40. KEY(1, 1, KEY_F),
  41. KEY(1, 2, KEY_G),
  42. KEY(1, 3, KEY_SEND),
  43. KEY(1, 6, KEY_K),
  44. KEY(1, 7, KEY_ENTER),
  45. KEY(2, 0, KEY_X),
  46. KEY(2, 1, KEY_C),
  47. KEY(2, 2, KEY_V),
  48. KEY(2, 3, KEY_END),
  49. KEY(2, 6, KEY_DOT),
  50. KEY(2, 7, KEY_CAPSLOCK),
  51. KEY(3, 0, KEY_Z),
  52. KEY(3, 1, KEY_KPPLUS),
  53. KEY(3, 2, KEY_B),
  54. KEY(3, 3, KEY_F1),
  55. KEY(3, 6, KEY_O),
  56. KEY(3, 7, KEY_SPACE),
  57. KEY(4, 0, KEY_W),
  58. KEY(4, 1, KEY_Y),
  59. KEY(4, 2, KEY_U),
  60. KEY(4, 3, KEY_F2),
  61. KEY(4, 4, KEY_VOLUMEUP),
  62. KEY(4, 6, KEY_L),
  63. KEY(4, 7, KEY_LEFT),
  64. KEY(5, 0, KEY_S),
  65. KEY(5, 1, KEY_H),
  66. KEY(5, 2, KEY_J),
  67. KEY(5, 3, KEY_F3),
  68. KEY(5, 4, KEY_UNKNOWN),
  69. KEY(5, 5, KEY_VOLUMEDOWN),
  70. KEY(5, 6, KEY_M),
  71. KEY(5, 7, KEY_RIGHT),
  72. KEY(6, 0, KEY_Q),
  73. KEY(6, 1, KEY_A),
  74. KEY(6, 2, KEY_N),
  75. KEY(6, 3, KEY_BACKSPACE),
  76. KEY(6, 6, KEY_P),
  77. KEY(6, 7, KEY_UP),
  78. KEY(7, 0, KEY_PROG1), /*MACRO 1 <User defined> */
  79. KEY(7, 1, KEY_PROG2), /*MACRO 2 <User defined> */
  80. KEY(7, 2, KEY_PROG3), /*MACRO 3 <User defined> */
  81. KEY(7, 3, KEY_PROG4), /*MACRO 4 <User defined> */
  82. KEY(7, 6, KEY_SELECT),
  83. KEY(7, 7, KEY_DOWN)
  84. };
  85. static struct matrix_keymap_data board_map_data = {
  86. .keymap = board_keymap,
  87. .keymap_size = ARRAY_SIZE(board_keymap),
  88. };
  89. static struct twl4030_keypad_data zoom_kp_twl4030_data = {
  90. .keymap_data = &board_map_data,
  91. .rows = 8,
  92. .cols = 8,
  93. .rep = 1,
  94. };
  95. static struct regulator_consumer_supply zoom_vmmc1_supply = {
  96. .supply = "vmmc",
  97. };
  98. static struct regulator_consumer_supply zoom_vsim_supply = {
  99. .supply = "vmmc_aux",
  100. };
  101. static struct regulator_consumer_supply zoom_vmmc2_supply = {
  102. .supply = "vmmc",
  103. };
  104. static struct regulator_consumer_supply zoom_vmmc3_supply = {
  105. .supply = "vmmc",
  106. .dev_name = "mmci-omap-hs.2",
  107. };
  108. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  109. static struct regulator_init_data zoom_vmmc1 = {
  110. .constraints = {
  111. .min_uV = 1850000,
  112. .max_uV = 3150000,
  113. .valid_modes_mask = REGULATOR_MODE_NORMAL
  114. | REGULATOR_MODE_STANDBY,
  115. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  116. | REGULATOR_CHANGE_MODE
  117. | REGULATOR_CHANGE_STATUS,
  118. },
  119. .num_consumer_supplies = 1,
  120. .consumer_supplies = &zoom_vmmc1_supply,
  121. };
  122. /* VMMC2 for MMC2 card */
  123. static struct regulator_init_data zoom_vmmc2 = {
  124. .constraints = {
  125. .min_uV = 1850000,
  126. .max_uV = 1850000,
  127. .apply_uV = true,
  128. .valid_modes_mask = REGULATOR_MODE_NORMAL
  129. | REGULATOR_MODE_STANDBY,
  130. .valid_ops_mask = REGULATOR_CHANGE_MODE
  131. | REGULATOR_CHANGE_STATUS,
  132. },
  133. .num_consumer_supplies = 1,
  134. .consumer_supplies = &zoom_vmmc2_supply,
  135. };
  136. /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
  137. static struct regulator_init_data zoom_vsim = {
  138. .constraints = {
  139. .min_uV = 1800000,
  140. .max_uV = 3000000,
  141. .valid_modes_mask = REGULATOR_MODE_NORMAL
  142. | REGULATOR_MODE_STANDBY,
  143. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  144. | REGULATOR_CHANGE_MODE
  145. | REGULATOR_CHANGE_STATUS,
  146. },
  147. .num_consumer_supplies = 1,
  148. .consumer_supplies = &zoom_vsim_supply,
  149. };
  150. static struct regulator_init_data zoom_vmmc3 = {
  151. .constraints = {
  152. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  153. },
  154. .num_consumer_supplies = 1,
  155. .consumer_supplies = &zoom_vmmc3_supply,
  156. };
  157. static struct fixed_voltage_config zoom_vwlan = {
  158. .supply_name = "vwl1271",
  159. .microvolts = 1800000, /* 1.8V */
  160. .gpio = OMAP_ZOOM_WLAN_PMENA_GPIO,
  161. .startup_delay = 70000, /* 70msec */
  162. .enable_high = 1,
  163. .enabled_at_boot = 0,
  164. .init_data = &zoom_vmmc3,
  165. };
  166. static struct platform_device omap_vwlan_device = {
  167. .name = "reg-fixed-voltage",
  168. .id = 1,
  169. .dev = {
  170. .platform_data = &zoom_vwlan,
  171. },
  172. };
  173. struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
  174. .irq = OMAP_GPIO_IRQ(OMAP_ZOOM_WLAN_IRQ_GPIO),
  175. /* ZOOM ref clock is 26 MHz */
  176. .board_ref_clock = 1,
  177. };
  178. static struct omap2_hsmmc_info mmc[] __initdata = {
  179. {
  180. .name = "external",
  181. .mmc = 1,
  182. .caps = MMC_CAP_4_BIT_DATA,
  183. .gpio_wp = -EINVAL,
  184. .power_saving = true,
  185. },
  186. {
  187. .name = "internal",
  188. .mmc = 2,
  189. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  190. .gpio_cd = -EINVAL,
  191. .gpio_wp = -EINVAL,
  192. .nonremovable = true,
  193. .power_saving = true,
  194. },
  195. {
  196. .name = "wl1271",
  197. .mmc = 3,
  198. .caps = MMC_CAP_4_BIT_DATA,
  199. .gpio_wp = -EINVAL,
  200. .gpio_cd = -EINVAL,
  201. .nonremovable = true,
  202. },
  203. {} /* Terminator */
  204. };
  205. static int zoom_twl_gpio_setup(struct device *dev,
  206. unsigned gpio, unsigned ngpio)
  207. {
  208. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  209. mmc[0].gpio_cd = gpio + 0;
  210. omap2_hsmmc_init(mmc);
  211. /* link regulators to MMC adapters ... we "know" the
  212. * regulators will be set up only *after* we return.
  213. */
  214. zoom_vmmc1_supply.dev = mmc[0].dev;
  215. zoom_vsim_supply.dev = mmc[0].dev;
  216. zoom_vmmc2_supply.dev = mmc[1].dev;
  217. return 0;
  218. }
  219. /* EXTMUTE callback function */
  220. void zoom2_set_hs_extmute(int mute)
  221. {
  222. gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO, mute);
  223. }
  224. static int zoom_batt_table[] = {
  225. /* 0 C*/
  226. 30800, 29500, 28300, 27100,
  227. 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
  228. 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
  229. 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
  230. 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
  231. 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
  232. 4040, 3910, 3790, 3670, 3550
  233. };
  234. static struct twl4030_bci_platform_data zoom_bci_data = {
  235. .battery_tmp_tbl = zoom_batt_table,
  236. .tblsize = ARRAY_SIZE(zoom_batt_table),
  237. };
  238. static struct twl4030_usb_data zoom_usb_data = {
  239. .usb_mode = T2_USB_MODE_ULPI,
  240. };
  241. static struct twl4030_gpio_platform_data zoom_gpio_data = {
  242. .gpio_base = OMAP_MAX_GPIO_LINES,
  243. .irq_base = TWL4030_GPIO_IRQ_BASE,
  244. .irq_end = TWL4030_GPIO_IRQ_END,
  245. .setup = zoom_twl_gpio_setup,
  246. };
  247. static struct twl4030_madc_platform_data zoom_madc_data = {
  248. .irq_line = 1,
  249. };
  250. static struct twl4030_codec_audio_data zoom_audio_data = {
  251. .audio_mclk = 26000000,
  252. };
  253. static struct twl4030_codec_data zoom_codec_data = {
  254. .audio_mclk = 26000000,
  255. .audio = &zoom_audio_data,
  256. };
  257. static struct twl4030_platform_data zoom_twldata = {
  258. .irq_base = TWL4030_IRQ_BASE,
  259. .irq_end = TWL4030_IRQ_END,
  260. /* platform_data for children goes here */
  261. .bci = &zoom_bci_data,
  262. .madc = &zoom_madc_data,
  263. .usb = &zoom_usb_data,
  264. .gpio = &zoom_gpio_data,
  265. .keypad = &zoom_kp_twl4030_data,
  266. .codec = &zoom_codec_data,
  267. .vmmc1 = &zoom_vmmc1,
  268. .vmmc2 = &zoom_vmmc2,
  269. .vsim = &zoom_vsim,
  270. };
  271. static struct i2c_board_info __initdata zoom_i2c_boardinfo[] = {
  272. {
  273. I2C_BOARD_INFO("twl5030", 0x48),
  274. .flags = I2C_CLIENT_WAKE,
  275. .irq = INT_34XX_SYS_NIRQ,
  276. .platform_data = &zoom_twldata,
  277. },
  278. };
  279. static int __init omap_i2c_init(void)
  280. {
  281. if (machine_is_omap_zoom2()) {
  282. zoom_audio_data.ramp_delay_value = 3; /* 161 ms */
  283. zoom_audio_data.hs_extmute = 1;
  284. zoom_audio_data.set_hs_extmute = zoom2_set_hs_extmute;
  285. }
  286. omap_register_i2c_bus(1, 2400, zoom_i2c_boardinfo,
  287. ARRAY_SIZE(zoom_i2c_boardinfo));
  288. omap_register_i2c_bus(2, 400, NULL, 0);
  289. omap_register_i2c_bus(3, 400, NULL, 0);
  290. return 0;
  291. }
  292. static struct omap_musb_board_data musb_board_data = {
  293. .interface_type = MUSB_INTERFACE_ULPI,
  294. .mode = MUSB_OTG,
  295. .power = 100,
  296. };
  297. static void enable_board_wakeup_source(void)
  298. {
  299. /* T2 interrupt line (keypad) */
  300. omap_mux_init_signal("sys_nirq",
  301. OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
  302. }
  303. void __init zoom_peripherals_init(void)
  304. {
  305. if (wl12xx_set_platform_data(&omap_zoom_wlan_data))
  306. pr_err("error setting wl12xx data\n");
  307. omap_i2c_init();
  308. platform_device_register(&omap_vwlan_device);
  309. usb_musb_init(&musb_board_data);
  310. enable_board_wakeup_source();
  311. omap_serial_init();
  312. }