board-zoom-peripherals.c 8.0 KB

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