2 * arch/arm/mach-tegra/board-stingray-touch.c
4 * Copyright (C) 2010 Motorola, Inc.
5 * Copyright (C) 2010 Google, Inc.
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include <linux/resource.h>
19 #include <linux/platform_device.h>
20 #include <linux/delay.h>
21 #include <linux/gpio.h>
22 #include <linux/i2c.h>
23 #include <asm/mach-types.h>
24 #include <mach/irqs.h>
25 #include <mach/iomap.h>
26 #include <mach/pinmux.h>
27 #include <linux/qtouch_obp_ts.h>
28 #include <linux/interrupt.h>
29 #include <linux/input.h>
31 #include "board-stingray.h"
32 #include "gpio-names.h"
34 #define XMEGAT_BL_I2C_ADDR 0x35
35 #define STINGRAY_TOUCH_RESET_N_GPIO TEGRA_GPIO_PR4
36 #define STINGRAY_TOUCH_INT_N_GPIO TEGRA_GPIO_PV2
37 #define STINGRAY_TOUCH_WAKE_N_GPIO TEGRA_GPIO_PJ2
39 #define STINGRAY_TOUCH_INT_N_GPIO_P2 TEGRA_GPIO_PZ2
41 static int stingray_touch_reset(void)
43 gpio_set_value(STINGRAY_TOUCH_RESET_N_GPIO, 0);
45 gpio_set_value(STINGRAY_TOUCH_RESET_N_GPIO, 1);
46 msleep(100); /* value from moto */
51 struct qtouch_ts_platform_data stingray_touch_data_m1 = {
53 .flags = (QTOUCH_USE_MULTITOUCH |
55 .irqflags = (IRQF_TRIGGER_LOW),
66 .nv_checksum = 0x2c30,
71 .boot_i2c_addr = XMEGAT_BL_I2C_ADDR,
72 .hw_reset = stingray_touch_reset,
79 .fw_name = "mXT1386_08_E1.bin",
85 .base_fw_version = 0x00,
89 .active_acq_int = 0xff,
90 .active_idle_to = 0x00,
97 .touch_autocal = 0x00,
99 .atch_cal_suspend_time = 0,
100 .atch_cal_suspend_thres = 0,
101 .atch_cal_force_thres = 0x10,
102 .atch_cal_force_ratio = 0,
116 .mov_hyst_init = 0x05,
117 .mov_hyst_next = 0x02,
121 .merge_thresh = 0x0A,
135 .comms_config_cfg = {
139 .noise_suppression_cfg = {
158 .one_touch_gesture_proc_cfg = {
166 .short_press_time_out = 0,
167 .long_press_time_out = 0,
168 .repeat_press_time_out = 0,
169 .flick_threshold = 0,
172 .throw_threshold = 0,
177 .high_signal_limit_0 = 0,
178 .low_signal_limit_0 = 0,
179 .high_signal_limit_1 = 0,
180 .low_signal_limit_1 = 0,
181 .high_signal_limit_2 = 0,
182 .low_signal_limit_2 = 0,
184 .two_touch_gesture_proc_cfg = {
189 .rotate_threshold = 0,
196 .idle_gcaf_depth = 16,
197 .active_gcaf_depth = 16,
200 .gripsuppression_t40_cfg = {
207 .palm_suppression_cfg = {
215 .spt_digitizer_cfg = {
229 struct qtouch_ts_platform_data stingray_touch_data_p0 = {
231 .flags = (QTOUCH_USE_MULTITOUCH |
232 QTOUCH_CFG_BACKUPNV),
233 .irqflags = (IRQF_TRIGGER_LOW),
244 .nv_checksum = 0x99469a,
249 .boot_i2c_addr = XMEGAT_BL_I2C_ADDR,
250 .hw_reset = stingray_touch_reset,
257 .fw_name = "mXT1386_09_AA.bin",
262 .boot_version = 0x20,
263 .base_fw_version = 0x00,
266 .idle_acq_int = 0xff,
267 .active_acq_int = 0xff,
268 .active_idle_to = 0x00,
275 .touch_autocal = 0x00,
277 .atch_cal_suspend_time = 0,
278 .atch_cal_suspend_thres = 0,
279 .atch_cal_force_thres = 0x10,
280 .atch_cal_force_ratio = 0,
294 .mov_hyst_init = 0x05,
295 .mov_hyst_next = 0x02,
299 .merge_thresh = 0x0A,
312 .tch_thres_hyst = 0x09,
316 .comms_config_cfg = {
320 .noise_suppression_cfg = {
339 .one_touch_gesture_proc_cfg = {
347 .short_press_time_out = 0,
348 .long_press_time_out = 0,
349 .repeat_press_time_out = 0,
350 .flick_threshold = 0,
353 .throw_threshold = 0,
358 .high_signal_limit_0 = 0,
359 .low_signal_limit_0 = 0,
360 .high_signal_limit_1 = 0,
361 .low_signal_limit_1 = 0,
362 .high_signal_limit_2 = 0,
363 .low_signal_limit_2 = 0,
365 .two_touch_gesture_proc_cfg = {
370 .rotate_threshold = 0,
377 .idle_gcaf_depth = 16,
378 .active_gcaf_depth = 16,
381 .gripsuppression_t40_cfg = {
388 .palm_suppression_cfg = {
396 .spt_digitizer_cfg = {
409 /* Portable P1 and later versions */
410 struct qtouch_ts_platform_data stingray_touch_data_p1_or_later = {
412 .flags = (QTOUCH_USE_MULTITOUCH |
413 QTOUCH_CFG_BACKUPNV),
414 .irqflags = (IRQF_TRIGGER_LOW),
425 .nv_checksum = 0x99469a,
430 .boot_i2c_addr = XMEGAT_BL_I2C_ADDR,
431 .hw_reset = stingray_touch_reset,
438 .fw_name = "mXT1386_09_AA.bin",
443 .boot_version = 0x20,
444 .base_fw_version = 0x00,
447 .idle_acq_int = 0xff,
448 .active_acq_int = 0xff,
449 .active_idle_to = 0x00,
456 .touch_autocal = 0x00,
458 .atch_cal_suspend_time = 0,
459 .atch_cal_suspend_thres = 0,
460 .atch_cal_force_thres = 0x10,
461 .atch_cal_force_ratio = 0,
475 .mov_hyst_init = 0x05,
476 .mov_hyst_next = 0x02,
480 .merge_thresh = 0x0A,
493 .tch_thres_hyst = 0x09,
497 .comms_config_cfg = {
501 .noise_suppression_cfg = {
520 .one_touch_gesture_proc_cfg = {
528 .short_press_time_out = 0,
529 .long_press_time_out = 0,
530 .repeat_press_time_out = 0,
531 .flick_threshold = 0,
534 .throw_threshold = 0,
539 .high_signal_limit_0 = 0,
540 .low_signal_limit_0 = 0,
541 .high_signal_limit_1 = 0,
542 .low_signal_limit_1 = 0,
543 .high_signal_limit_2 = 0,
544 .low_signal_limit_2 = 0,
546 .two_touch_gesture_proc_cfg = {
551 .rotate_threshold = 0,
558 .idle_gcaf_depth = 16,
559 .active_gcaf_depth = 16,
562 .gripsuppression_t40_cfg = {
569 .palm_suppression_cfg = {
577 .spt_digitizer_cfg = {
590 static struct i2c_board_info __initdata stingray_i2c_bus1_touch_info[] = {
592 I2C_BOARD_INFO(QTOUCH_TS_NAME, 0x5B),
596 int __init stingray_touch_init(void)
598 unsigned touch_int_gpio;
600 if (stingray_revision() == STINGRAY_REVISION_P2)
601 touch_int_gpio = STINGRAY_TOUCH_INT_N_GPIO_P2;
603 touch_int_gpio = STINGRAY_TOUCH_INT_N_GPIO;
605 tegra_gpio_enable(touch_int_gpio);
606 gpio_request(touch_int_gpio, "touch_irq");
607 gpio_direction_input(touch_int_gpio);
609 tegra_gpio_enable(STINGRAY_TOUCH_WAKE_N_GPIO);
610 gpio_request(STINGRAY_TOUCH_WAKE_N_GPIO, "touch_wake");
611 gpio_direction_output(STINGRAY_TOUCH_WAKE_N_GPIO, 0);
613 tegra_gpio_enable(STINGRAY_TOUCH_RESET_N_GPIO);
614 gpio_request(STINGRAY_TOUCH_RESET_N_GPIO, "touch_reset");
615 gpio_direction_output(STINGRAY_TOUCH_RESET_N_GPIO, 1);
617 stingray_i2c_bus1_touch_info[0].irq =
618 TEGRA_GPIO_TO_IRQ(touch_int_gpio);
620 if ((stingray_revision() == STINGRAY_REVISION_P1) ||
621 (stingray_revision() == STINGRAY_REVISION_P2) ||
622 (stingray_revision() == STINGRAY_REVISION_P3))
623 stingray_i2c_bus1_touch_info[0].platform_data =
624 &stingray_touch_data_p1_or_later;
625 else if (stingray_revision() == STINGRAY_REVISION_P0)
626 stingray_i2c_bus1_touch_info[0].platform_data = &stingray_touch_data_p0;
628 stingray_i2c_bus1_touch_info[0].platform_data = &stingray_touch_data_m1;
630 i2c_register_board_info(0, stingray_i2c_bus1_touch_info, 1);