/arch/arm/mach-msm/board-msm7627a-io.c

https://github.com/AICP/kernel_google_msm · C · 875 lines · 696 code · 122 blank · 57 comment · 43 complexity · b711382bcd29412d3cc3a52c72a2a220 MD5 · raw file

  1. /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include <linux/platform_device.h>
  14. #include <linux/regulator/consumer.h>
  15. #include <linux/gpio_event.h>
  16. #include <linux/leds.h>
  17. #include <linux/i2c/atmel_mxt_ts.h>
  18. #include <linux/i2c.h>
  19. #include <linux/input/rmi_platformdata.h>
  20. #include <linux/input/rmi_i2c.h>
  21. #include <linux/delay.h>
  22. #include <linux/atmel_maxtouch.h>
  23. #include <linux/input/ft5x06_ts.h>
  24. #include <linux/leds-msm-tricolor.h>
  25. #include <asm/gpio.h>
  26. #include <asm/mach-types.h>
  27. #include <mach/rpc_server_handset.h>
  28. #include <mach/pmic.h>
  29. #include "devices.h"
  30. #include "board-msm7627a.h"
  31. #include "devices-msm7x2xa.h"
  32. #define ATMEL_TS_I2C_NAME "maXTouch"
  33. #define ATMEL_X_OFFSET 13
  34. #define ATMEL_Y_OFFSET 0
  35. #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
  36. defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
  37. #ifndef CLEARPAD3000_ATTEN_GPIO
  38. #define CLEARPAD3000_ATTEN_GPIO (48)
  39. #endif
  40. #ifndef CLEARPAD3000_RESET_GPIO
  41. #define CLEARPAD3000_RESET_GPIO (26)
  42. #endif
  43. #define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
  44. static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
  45. static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
  46. static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
  47. ARRAY_SIZE(kp_row_gpios)] = {
  48. [KP_INDEX(0, 0)] = KEY_7,
  49. [KP_INDEX(0, 1)] = KEY_DOWN,
  50. [KP_INDEX(0, 2)] = KEY_UP,
  51. [KP_INDEX(0, 3)] = KEY_RIGHT,
  52. [KP_INDEX(0, 4)] = KEY_ENTER,
  53. [KP_INDEX(1, 0)] = KEY_LEFT,
  54. [KP_INDEX(1, 1)] = KEY_SEND,
  55. [KP_INDEX(1, 2)] = KEY_1,
  56. [KP_INDEX(1, 3)] = KEY_4,
  57. [KP_INDEX(1, 4)] = KEY_CLEAR,
  58. [KP_INDEX(2, 0)] = KEY_6,
  59. [KP_INDEX(2, 1)] = KEY_5,
  60. [KP_INDEX(2, 2)] = KEY_8,
  61. [KP_INDEX(2, 3)] = KEY_3,
  62. [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
  63. [KP_INDEX(3, 0)] = KEY_9,
  64. [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
  65. [KP_INDEX(3, 2)] = KEY_0,
  66. [KP_INDEX(3, 3)] = KEY_2,
  67. [KP_INDEX(3, 4)] = KEY_SLEEP,
  68. [KP_INDEX(4, 0)] = KEY_BACK,
  69. [KP_INDEX(4, 1)] = KEY_HOME,
  70. [KP_INDEX(4, 2)] = KEY_MENU,
  71. [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
  72. [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
  73. };
  74. /* SURF keypad platform device information */
  75. static struct gpio_event_matrix_info kp_matrix_info = {
  76. .info.func = gpio_event_matrix_func,
  77. .keymap = keymap,
  78. .output_gpios = kp_row_gpios,
  79. .input_gpios = kp_col_gpios,
  80. .noutputs = ARRAY_SIZE(kp_row_gpios),
  81. .ninputs = ARRAY_SIZE(kp_col_gpios),
  82. .settle_time.tv64 = 40 * NSEC_PER_USEC,
  83. .poll_time.tv64 = 20 * NSEC_PER_MSEC,
  84. .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
  85. GPIOKPF_PRINT_UNMAPPED_KEYS,
  86. };
  87. static struct gpio_event_info *kp_info[] = {
  88. &kp_matrix_info.info
  89. };
  90. static struct gpio_event_platform_data kp_pdata = {
  91. .name = "7x27a_kp",
  92. .info = kp_info,
  93. .info_count = ARRAY_SIZE(kp_info)
  94. };
  95. static struct platform_device kp_pdev = {
  96. .name = GPIO_EVENT_DEV_NAME,
  97. .id = -1,
  98. .dev = {
  99. .platform_data = &kp_pdata,
  100. },
  101. };
  102. /* 8625 keypad device information */
  103. static unsigned int kp_row_gpios_8625[] = {31};
  104. static unsigned int kp_col_gpios_8625[] = {36, 37};
  105. static const unsigned short keymap_8625[] = {
  106. KEY_VOLUMEUP,
  107. KEY_VOLUMEDOWN,
  108. };
  109. static const unsigned short keymap_8625_evt[] = {
  110. KEY_VOLUMEDOWN,
  111. KEY_VOLUMEUP,
  112. };
  113. static struct gpio_event_matrix_info kp_matrix_info_8625 = {
  114. .info.func = gpio_event_matrix_func,
  115. .keymap = keymap_8625,
  116. .output_gpios = kp_row_gpios_8625,
  117. .input_gpios = kp_col_gpios_8625,
  118. .noutputs = ARRAY_SIZE(kp_row_gpios_8625),
  119. .ninputs = ARRAY_SIZE(kp_col_gpios_8625),
  120. .settle_time.tv64 = 40 * NSEC_PER_USEC,
  121. .poll_time.tv64 = 20 * NSEC_PER_MSEC,
  122. .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
  123. GPIOKPF_PRINT_UNMAPPED_KEYS,
  124. };
  125. static struct gpio_event_info *kp_info_8625[] = {
  126. &kp_matrix_info_8625.info,
  127. };
  128. static struct gpio_event_platform_data kp_pdata_8625 = {
  129. .name = "7x27a_kp",
  130. .info = kp_info_8625,
  131. .info_count = ARRAY_SIZE(kp_info_8625)
  132. };
  133. static struct platform_device kp_pdev_8625 = {
  134. .name = GPIO_EVENT_DEV_NAME,
  135. .id = -1,
  136. .dev = {
  137. .platform_data = &kp_pdata_8625,
  138. },
  139. };
  140. #define LED_GPIO_PDM 96
  141. #define MXT_TS_IRQ_GPIO 48
  142. #define MXT_TS_RESET_GPIO 26
  143. #define MAX_VKEY_LEN 100
  144. static ssize_t mxt_virtual_keys_register(struct kobject *kobj,
  145. struct kobj_attribute *attr, char *buf)
  146. {
  147. char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \
  148. ":60:840:120:80" ":" __stringify(EV_KEY) \
  149. ":" __stringify(KEY_HOME) ":180:840:120:80" \
  150. ":" __stringify(EV_KEY) ":" \
  151. __stringify(KEY_BACK) ":300:840:120:80" \
  152. ":" __stringify(EV_KEY) ":" \
  153. __stringify(KEY_SEARCH) ":420:840:120:80" "\n";
  154. return snprintf(buf, strnlen(virtual_keys, MAX_VKEY_LEN) + 1 , "%s",
  155. virtual_keys);
  156. }
  157. static struct kobj_attribute mxt_virtual_keys_attr = {
  158. .attr = {
  159. .name = "virtualkeys.atmel_mxt_ts",
  160. .mode = S_IRUGO,
  161. },
  162. .show = &mxt_virtual_keys_register,
  163. };
  164. static struct attribute *mxt_virtual_key_properties_attrs[] = {
  165. &mxt_virtual_keys_attr.attr,
  166. NULL,
  167. };
  168. static struct attribute_group mxt_virtual_key_properties_attr_group = {
  169. .attrs = mxt_virtual_key_properties_attrs,
  170. };
  171. struct kobject *mxt_virtual_key_properties_kobj;
  172. static int mxt_vkey_setup(void)
  173. {
  174. int retval = 0;
  175. mxt_virtual_key_properties_kobj =
  176. kobject_create_and_add("board_properties", NULL);
  177. if (mxt_virtual_key_properties_kobj)
  178. retval = sysfs_create_group(mxt_virtual_key_properties_kobj,
  179. &mxt_virtual_key_properties_attr_group);
  180. if (!mxt_virtual_key_properties_kobj || retval)
  181. pr_err("failed to create mxt board_properties\n");
  182. return retval;
  183. }
  184. static const u8 mxt_config_data[] = {
  185. /* T6 Object */
  186. 0, 0, 0, 0, 0, 0,
  187. /* T38 Object */
  188. 16, 1, 0, 0, 0, 0, 0, 0,
  189. /* T7 Object */
  190. 32, 16, 50,
  191. /* T8 Object */
  192. 30, 0, 20, 20, 0, 0, 20, 0, 50, 0,
  193. /* T9 Object */
  194. 3, 0, 0, 18, 11, 0, 32, 75, 3, 3,
  195. 0, 1, 1, 0, 10, 10, 10, 10, 31, 3,
  196. 223, 1, 11, 11, 15, 15, 151, 43, 145, 80,
  197. 100, 15, 0, 0, 0,
  198. /* T15 Object */
  199. 131, 0, 11, 11, 1, 1, 0, 45, 3, 0,
  200. 0,
  201. /* T18 Object */
  202. 0, 0,
  203. /* T19 Object */
  204. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  205. 0, 0, 0, 0, 0, 0,
  206. /* T23 Object */
  207. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  208. 0, 0, 0, 0, 0,
  209. /* T25 Object */
  210. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  211. 0, 0, 0, 0,
  212. /* T40 Object */
  213. 0, 0, 0, 0, 0,
  214. /* T42 Object */
  215. 0, 0, 0, 0, 0, 0, 0, 0,
  216. /* T46 Object */
  217. 0, 2, 32, 48, 0, 0, 0, 0, 0,
  218. /* T47 Object */
  219. 1, 20, 60, 5, 2, 50, 40, 0, 0, 40,
  220. /* T48 Object */
  221. 1, 12, 80, 0, 0, 0, 0, 0, 0, 0,
  222. 0, 0, 0, 6, 6, 0, 0, 100, 4, 64,
  223. 10, 0, 20, 5, 0, 38, 0, 20, 0, 0,
  224. 0, 0, 0, 0, 16, 65, 3, 1, 1, 0,
  225. 10, 10, 10, 0, 0, 15, 15, 154, 58, 145,
  226. 80, 100, 15, 3,
  227. };
  228. static const u8 mxt_config_data_evt[] = {
  229. /* T6 Object */
  230. 0, 0, 0, 0, 0, 0,
  231. /* T38 Object */
  232. 20, 0, 0, 0, 0, 0, 0, 0,
  233. /* T7 Object */
  234. 24, 12, 10,
  235. /* T8 Object */
  236. 30, 0, 20, 20, 0, 0, 9, 45, 10, 192,
  237. /* T9 Object */
  238. 3, 0, 0, 18, 11, 0, 16, 60, 3, 1,
  239. 0, 1, 1, 0, 10, 10, 10, 10, 107, 3,
  240. 223, 1, 0, 0, 0, 0, 0, 0, 0, 0,
  241. 20, 15, 0, 0, 2,
  242. /* T15 Object */
  243. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  244. 0,
  245. /* T18 Object */
  246. 0, 0,
  247. /* T19 Object */
  248. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  249. 0, 0, 0, 0, 0, 0,
  250. /* T23 Object */
  251. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  252. 0, 0, 0, 0, 0,
  253. /* T25 Object */
  254. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  255. 0, 0, 0, 0,
  256. /* T40 Object */
  257. 17, 0, 0, 30, 30,
  258. /* T42 Object */
  259. 3, 20, 45, 40, 128, 0, 0, 0,
  260. /* T46 Object */
  261. 0, 2, 16, 16, 0, 0, 0, 0, 0,
  262. /* T47 Object */
  263. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  264. /* T48 Object */
  265. 1, 128, 96, 0, 0, 0, 0, 0, 0, 0,
  266. 0, 0, 0, 6, 6, 0, 0, 63, 4, 64,
  267. 10, 0, 32, 5, 0, 38, 0, 8, 0, 0,
  268. 0, 0, 0, 0, 16, 65, 3, 1, 1, 0,
  269. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  270. 0, 0, 0, 0,
  271. };
  272. static struct mxt_config_info mxt_config_array[] = {
  273. {
  274. .config = mxt_config_data,
  275. .config_length = ARRAY_SIZE(mxt_config_data),
  276. .family_id = 0x81,
  277. .variant_id = 0x01,
  278. .version = 0x10,
  279. .build = 0xAA,
  280. },
  281. };
  282. static int mxt_key_codes[MXT_KEYARRAY_MAX_KEYS] = {
  283. [0] = KEY_HOME,
  284. [1] = KEY_MENU,
  285. [9] = KEY_BACK,
  286. [10] = KEY_SEARCH,
  287. };
  288. static struct mxt_platform_data mxt_platform_data = {
  289. .config_array = mxt_config_array,
  290. .config_array_size = ARRAY_SIZE(mxt_config_array),
  291. .panel_minx = 0,
  292. .panel_maxx = 479,
  293. .panel_miny = 0,
  294. .panel_maxy = 799,
  295. .disp_minx = 0,
  296. .disp_maxx = 479,
  297. .disp_miny = 0,
  298. .disp_maxy = 799,
  299. .irqflags = IRQF_TRIGGER_FALLING,
  300. .i2c_pull_up = true,
  301. .reset_gpio = MXT_TS_RESET_GPIO,
  302. .irq_gpio = MXT_TS_IRQ_GPIO,
  303. .key_codes = mxt_key_codes,
  304. };
  305. static struct i2c_board_info mxt_device_info[] __initdata = {
  306. {
  307. I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
  308. .platform_data = &mxt_platform_data,
  309. .irq = MSM_GPIO_TO_INT(MXT_TS_IRQ_GPIO),
  310. },
  311. };
  312. static int synaptics_touchpad_setup(void);
  313. static struct msm_gpio clearpad3000_cfg_data[] = {
  314. {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT,
  315. GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"},
  316. {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
  317. GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"},
  318. };
  319. static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0};
  320. static struct rmi_range rmi_clipx = {.min = 48, .max = 980};
  321. static struct rmi_range rmi_clipy = {.min = 7, .max = 1647};
  322. static struct rmi_f11_functiondata synaptics_f11_data = {
  323. .swap_axes = false,
  324. .flipX = false,
  325. .flipY = false,
  326. .offset = &rmi_offset,
  327. .button_height = 113,
  328. .clipX = &rmi_clipx,
  329. .clipY = &rmi_clipy,
  330. };
  331. #define MAX_LEN 100
  332. static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj,
  333. struct kobj_attribute *attr, char *buf)
  334. {
  335. char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \
  336. ":60:830:120:60" ":" __stringify(EV_KEY) \
  337. ":" __stringify(KEY_HOME) ":180:830:120:60" \
  338. ":" __stringify(EV_KEY) ":" \
  339. __stringify(KEY_SEARCH) ":300:830:120:60" \
  340. ":" __stringify(EV_KEY) ":" \
  341. __stringify(KEY_BACK) ":420:830:120:60" "\n";
  342. return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s",
  343. virtual_keys);
  344. }
  345. static struct kobj_attribute clearpad3000_virtual_keys_attr = {
  346. .attr = {
  347. .name = "virtualkeys.sensor00fn11",
  348. .mode = S_IRUGO,
  349. },
  350. .show = &clearpad3000_virtual_keys_register,
  351. };
  352. static struct attribute *virtual_key_properties_attrs[] = {
  353. &clearpad3000_virtual_keys_attr.attr,
  354. NULL
  355. };
  356. static struct attribute_group virtual_key_properties_attr_group = {
  357. .attrs = virtual_key_properties_attrs,
  358. };
  359. struct kobject *virtual_key_properties_kobj;
  360. static struct rmi_functiondata synaptics_functiondata[] = {
  361. {
  362. .function_index = RMI_F11_INDEX,
  363. .data = &synaptics_f11_data,
  364. },
  365. };
  366. static struct rmi_functiondata_list synaptics_perfunctiondata = {
  367. .count = ARRAY_SIZE(synaptics_functiondata),
  368. .functiondata = synaptics_functiondata,
  369. };
  370. static struct rmi_sensordata synaptics_sensordata = {
  371. .perfunctiondata = &synaptics_perfunctiondata,
  372. .rmi_sensor_setup = synaptics_touchpad_setup,
  373. };
  374. static struct rmi_i2c_platformdata synaptics_platformdata = {
  375. .i2c_address = 0x2c,
  376. .irq_type = IORESOURCE_IRQ_LOWLEVEL,
  377. .sensordata = &synaptics_sensordata,
  378. };
  379. static struct i2c_board_info synaptic_i2c_clearpad3k[] = {
  380. {
  381. I2C_BOARD_INFO("rmi4_ts", 0x2c),
  382. .platform_data = &synaptics_platformdata,
  383. },
  384. };
  385. static int synaptics_touchpad_setup(void)
  386. {
  387. int retval = 0;
  388. virtual_key_properties_kobj =
  389. kobject_create_and_add("board_properties", NULL);
  390. if (virtual_key_properties_kobj)
  391. retval = sysfs_create_group(virtual_key_properties_kobj,
  392. &virtual_key_properties_attr_group);
  393. if (!virtual_key_properties_kobj || retval)
  394. pr_err("failed to create ft5202 board_properties\n");
  395. retval = msm_gpios_request_enable(clearpad3000_cfg_data,
  396. sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio));
  397. if (retval) {
  398. pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.",
  399. __func__, CLEARPAD3000_ATTEN_GPIO, retval);
  400. retval = 0; /* ignore the err */
  401. }
  402. synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO);
  403. gpio_set_value(CLEARPAD3000_RESET_GPIO, 0);
  404. usleep(10000);
  405. gpio_set_value(CLEARPAD3000_RESET_GPIO, 1);
  406. usleep(50000);
  407. return retval;
  408. }
  409. #endif
  410. static struct regulator_bulk_data regs_atmel[] = {
  411. { .supply = "ldo12", .min_uV = 2700000, .max_uV = 3300000 },
  412. { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
  413. };
  414. #define ATMEL_TS_GPIO_IRQ 82
  415. static int atmel_ts_power_on(bool on)
  416. {
  417. int rc = on ?
  418. regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
  419. regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
  420. if (rc)
  421. pr_err("%s: could not %sable regulators: %d\n",
  422. __func__, on ? "en" : "dis", rc);
  423. else
  424. msleep(50);
  425. return rc;
  426. }
  427. static int atmel_ts_platform_init(struct i2c_client *client)
  428. {
  429. int rc;
  430. struct device *dev = &client->dev;
  431. rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
  432. if (rc) {
  433. dev_err(dev, "%s: could not get regulators: %d\n",
  434. __func__, rc);
  435. goto out;
  436. }
  437. rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
  438. if (rc) {
  439. dev_err(dev, "%s: could not set voltages: %d\n",
  440. __func__, rc);
  441. goto reg_free;
  442. }
  443. rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
  444. GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
  445. GPIO_CFG_8MA), GPIO_CFG_ENABLE);
  446. if (rc) {
  447. dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
  448. __func__, ATMEL_TS_GPIO_IRQ);
  449. goto reg_free;
  450. }
  451. /* configure touchscreen interrupt gpio */
  452. rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
  453. if (rc) {
  454. dev_err(dev, "%s: unable to request gpio %d\n",
  455. __func__, ATMEL_TS_GPIO_IRQ);
  456. goto ts_gpio_tlmm_unconfig;
  457. }
  458. rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
  459. if (rc < 0) {
  460. dev_err(dev, "%s: unable to set the direction of gpio %d\n",
  461. __func__, ATMEL_TS_GPIO_IRQ);
  462. goto free_ts_gpio;
  463. }
  464. return 0;
  465. free_ts_gpio:
  466. gpio_free(ATMEL_TS_GPIO_IRQ);
  467. ts_gpio_tlmm_unconfig:
  468. gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
  469. GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
  470. GPIO_CFG_2MA), GPIO_CFG_DISABLE);
  471. reg_free:
  472. regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
  473. out:
  474. return rc;
  475. }
  476. static int atmel_ts_platform_exit(struct i2c_client *client)
  477. {
  478. gpio_free(ATMEL_TS_GPIO_IRQ);
  479. gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
  480. GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
  481. GPIO_CFG_2MA), GPIO_CFG_DISABLE);
  482. regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
  483. return 0;
  484. }
  485. static u8 atmel_ts_read_chg(void)
  486. {
  487. return gpio_get_value(ATMEL_TS_GPIO_IRQ);
  488. }
  489. static u8 atmel_ts_valid_interrupt(void)
  490. {
  491. return !atmel_ts_read_chg();
  492. }
  493. static struct maxtouch_platform_data atmel_ts_pdata = {
  494. .numtouch = 4,
  495. .init_platform_hw = atmel_ts_platform_init,
  496. .exit_platform_hw = atmel_ts_platform_exit,
  497. .power_on = atmel_ts_power_on,
  498. .display_res_x = 480,
  499. .display_res_y = 864,
  500. .min_x = ATMEL_X_OFFSET,
  501. .max_x = (505 - ATMEL_X_OFFSET),
  502. .min_y = ATMEL_Y_OFFSET,
  503. .max_y = (863 - ATMEL_Y_OFFSET),
  504. .valid_interrupt = atmel_ts_valid_interrupt,
  505. .read_chg = atmel_ts_read_chg,
  506. };
  507. static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
  508. {
  509. I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
  510. .platform_data = &atmel_ts_pdata,
  511. .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
  512. },
  513. };
  514. static struct msm_handset_platform_data hs_platform_data = {
  515. .hs_name = "7k_handset",
  516. .pwr_key_delay_ms = 500, /* 0 will disable end key */
  517. };
  518. static struct platform_device hs_pdev = {
  519. .name = "msm-handset",
  520. .id = -1,
  521. .dev = {
  522. .platform_data = &hs_platform_data,
  523. },
  524. };
  525. #define FT5X06_IRQ_GPIO 48
  526. #define FT5X06_RESET_GPIO 26
  527. static ssize_t
  528. ft5x06_virtual_keys_register(struct kobject *kobj,
  529. struct kobj_attribute *attr,
  530. char *buf)
  531. {
  532. return snprintf(buf, 200,
  533. __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":40:510:80:60"
  534. ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":120:510:80:60"
  535. ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":200:510:80:60"
  536. ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":280:510:80:60"
  537. "\n");
  538. }
  539. static struct kobj_attribute ft5x06_virtual_keys_attr = {
  540. .attr = {
  541. .name = "virtualkeys.ft5x06_ts",
  542. .mode = S_IRUGO,
  543. },
  544. .show = &ft5x06_virtual_keys_register,
  545. };
  546. static struct attribute *ft5x06_virtual_key_properties_attrs[] = {
  547. &ft5x06_virtual_keys_attr.attr,
  548. NULL,
  549. };
  550. static struct attribute_group ft5x06_virtual_key_properties_attr_group = {
  551. .attrs = ft5x06_virtual_key_properties_attrs,
  552. };
  553. struct kobject *ft5x06_virtual_key_properties_kobj;
  554. static struct ft5x06_ts_platform_data ft5x06_platformdata = {
  555. .x_max = 320,
  556. .y_max = 480,
  557. .reset_gpio = FT5X06_RESET_GPIO,
  558. .irq_gpio = FT5X06_IRQ_GPIO,
  559. .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
  560. };
  561. static struct i2c_board_info ft5x06_device_info[] __initdata = {
  562. {
  563. I2C_BOARD_INFO("ft5x06_ts", 0x38),
  564. .platform_data = &ft5x06_platformdata,
  565. .irq = MSM_GPIO_TO_INT(FT5X06_IRQ_GPIO),
  566. },
  567. };
  568. static void __init ft5x06_touchpad_setup(void)
  569. {
  570. int rc;
  571. rc = gpio_tlmm_config(GPIO_CFG(FT5X06_IRQ_GPIO, 0,
  572. GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
  573. GPIO_CFG_8MA), GPIO_CFG_ENABLE);
  574. if (rc)
  575. pr_err("%s: gpio_tlmm_config for %d failed\n",
  576. __func__, FT5X06_IRQ_GPIO);
  577. rc = gpio_tlmm_config(GPIO_CFG(FT5X06_RESET_GPIO, 0,
  578. GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
  579. GPIO_CFG_8MA), GPIO_CFG_ENABLE);
  580. if (rc)
  581. pr_err("%s: gpio_tlmm_config for %d failed\n",
  582. __func__, FT5X06_RESET_GPIO);
  583. ft5x06_virtual_key_properties_kobj =
  584. kobject_create_and_add("board_properties", NULL);
  585. if (ft5x06_virtual_key_properties_kobj)
  586. rc = sysfs_create_group(ft5x06_virtual_key_properties_kobj,
  587. &ft5x06_virtual_key_properties_attr_group);
  588. if (!ft5x06_virtual_key_properties_kobj || rc)
  589. pr_err("%s: failed to create board_properties\n", __func__);
  590. i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
  591. ft5x06_device_info,
  592. ARRAY_SIZE(ft5x06_device_info));
  593. }
  594. /* SKU3/SKU7 keypad device information */
  595. #define KP_INDEX_SKU3(row, col) ((row)*ARRAY_SIZE(kp_col_gpios_sku3) + (col))
  596. static unsigned int kp_row_gpios_sku3[] = {31, 32};
  597. static unsigned int kp_col_gpios_sku3[] = {36, 37};
  598. static const unsigned short keymap_sku3[] = {
  599. [KP_INDEX_SKU3(0, 0)] = KEY_VOLUMEUP,
  600. [KP_INDEX_SKU3(0, 1)] = KEY_VOLUMEDOWN,
  601. [KP_INDEX_SKU3(1, 1)] = KEY_CAMERA,
  602. };
  603. static struct gpio_event_matrix_info kp_matrix_info_sku3 = {
  604. .info.func = gpio_event_matrix_func,
  605. .keymap = keymap_sku3,
  606. .output_gpios = kp_row_gpios_sku3,
  607. .input_gpios = kp_col_gpios_sku3,
  608. .noutputs = ARRAY_SIZE(kp_row_gpios_sku3),
  609. .ninputs = ARRAY_SIZE(kp_col_gpios_sku3),
  610. .settle_time.tv64 = 40 * NSEC_PER_USEC,
  611. .poll_time.tv64 = 20 * NSEC_PER_MSEC,
  612. .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
  613. GPIOKPF_PRINT_UNMAPPED_KEYS,
  614. };
  615. static struct gpio_event_info *kp_info_sku3[] = {
  616. &kp_matrix_info_sku3.info,
  617. };
  618. static struct gpio_event_platform_data kp_pdata_sku3 = {
  619. .name = "7x27a_kp",
  620. .info = kp_info_sku3,
  621. .info_count = ARRAY_SIZE(kp_info_sku3)
  622. };
  623. static struct platform_device kp_pdev_sku3 = {
  624. .name = GPIO_EVENT_DEV_NAME,
  625. .id = -1,
  626. .dev = {
  627. .platform_data = &kp_pdata_sku3,
  628. },
  629. };
  630. static struct led_info ctp_backlight_info = {
  631. .name = "button-backlight",
  632. .flags = PM_MPP__I_SINK__LEVEL_40mA << 16 | PM_MPP_7,
  633. };
  634. static struct led_platform_data ctp_backlight_pdata = {
  635. .leds = &ctp_backlight_info,
  636. .num_leds = 1,
  637. };
  638. static struct platform_device pmic_mpp_leds_pdev = {
  639. .name = "pmic-mpp-leds",
  640. .id = -1,
  641. .dev = {
  642. .platform_data = &ctp_backlight_pdata,
  643. },
  644. };
  645. static struct led_info tricolor_led_info[] = {
  646. [0] = {
  647. .name = "red",
  648. .flags = LED_COLOR_RED,
  649. },
  650. [1] = {
  651. .name = "green",
  652. .flags = LED_COLOR_GREEN,
  653. },
  654. };
  655. static struct led_platform_data tricolor_led_pdata = {
  656. .leds = tricolor_led_info,
  657. .num_leds = ARRAY_SIZE(tricolor_led_info),
  658. };
  659. static struct platform_device tricolor_leds_pdev = {
  660. .name = "msm-tricolor-leds",
  661. .id = -1,
  662. .dev = {
  663. .platform_data = &tricolor_led_pdata,
  664. },
  665. };
  666. void __init msm7627a_add_io_devices(void)
  667. {
  668. /* touchscreen */
  669. if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
  670. atmel_ts_pdata.min_x = 0;
  671. atmel_ts_pdata.max_x = 480;
  672. atmel_ts_pdata.min_y = 0;
  673. atmel_ts_pdata.max_y = 320;
  674. }
  675. i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
  676. atmel_ts_i2c_info,
  677. ARRAY_SIZE(atmel_ts_i2c_info));
  678. /* keypad */
  679. platform_device_register(&kp_pdev);
  680. /* headset */
  681. platform_device_register(&hs_pdev);
  682. /* LED: configure it as a pdm function */
  683. if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
  684. GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
  685. GPIO_CFG_8MA), GPIO_CFG_ENABLE))
  686. pr_err("%s: gpio_tlmm_config for %d failed\n",
  687. __func__, LED_GPIO_PDM);
  688. else
  689. platform_device_register(&led_pdev);
  690. /* Vibrator */
  691. if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
  692. || machine_is_msm8625_ffa())
  693. msm_init_pmic_vibrator();
  694. }
  695. void __init qrd7627a_add_io_devices(void)
  696. {
  697. int rc;
  698. /* touchscreen */
  699. if (machine_is_msm7627a_qrd1()) {
  700. i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
  701. synaptic_i2c_clearpad3k,
  702. ARRAY_SIZE(synaptic_i2c_clearpad3k));
  703. } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb() ||
  704. machine_is_msm8625_evt()) {
  705. /* Use configuration data for EVT */
  706. if (machine_is_msm8625_evt()) {
  707. mxt_config_array[0].config = mxt_config_data_evt;
  708. mxt_config_array[0].config_length =
  709. ARRAY_SIZE(mxt_config_data_evt);
  710. mxt_platform_data.panel_maxy = 875;
  711. mxt_vkey_setup();
  712. }
  713. rc = gpio_tlmm_config(GPIO_CFG(MXT_TS_IRQ_GPIO, 0,
  714. GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
  715. GPIO_CFG_8MA), GPIO_CFG_ENABLE);
  716. if (rc) {
  717. pr_err("%s: gpio_tlmm_config for %d failed\n",
  718. __func__, MXT_TS_IRQ_GPIO);
  719. }
  720. rc = gpio_tlmm_config(GPIO_CFG(MXT_TS_RESET_GPIO, 0,
  721. GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
  722. GPIO_CFG_8MA), GPIO_CFG_ENABLE);
  723. if (rc) {
  724. pr_err("%s: gpio_tlmm_config for %d failed\n",
  725. __func__, MXT_TS_RESET_GPIO);
  726. }
  727. i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
  728. mxt_device_info,
  729. ARRAY_SIZE(mxt_device_info));
  730. } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
  731. ft5x06_touchpad_setup();
  732. }
  733. /* headset */
  734. platform_device_register(&hs_pdev);
  735. /* vibrator */
  736. #ifdef CONFIG_MSM_RPC_VIBRATOR
  737. msm_init_pmic_vibrator();
  738. #endif
  739. /* keypad */
  740. if (machine_is_msm8625_evt())
  741. kp_matrix_info_8625.keymap = keymap_8625_evt;
  742. if (machine_is_msm7627a_evb() || machine_is_msm8625_evb() ||
  743. machine_is_msm8625_evt())
  744. platform_device_register(&kp_pdev_8625);
  745. else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
  746. platform_device_register(&kp_pdev_sku3);
  747. /* leds */
  748. if (machine_is_msm7627a_evb() || machine_is_msm8625_evb() ||
  749. machine_is_msm8625_evt()) {
  750. platform_device_register(&pmic_mpp_leds_pdev);
  751. platform_device_register(&tricolor_leds_pdev);
  752. }
  753. }