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 */
50 static int stingray_touch_suspend(int enable)
52 gpio_set_value(STINGRAY_TOUCH_WAKE_N_GPIO, enable);
58 struct qtouch_ts_platform_data stingray_touch_data_m1 = {
60 .flags = (QTOUCH_USE_MULTITOUCH |
62 .irqflags = (IRQF_TRIGGER_LOW),
73 .nv_checksum = 0x2c30,
78 .boot_i2c_addr = XMEGAT_BL_I2C_ADDR,
79 .hw_reset = stingray_touch_reset,
86 .fw_name = "mXT1386_08_E1.bin",
92 .base_fw_version = 0x00,
96 .active_acq_int = 0xff,
97 .active_idle_to = 0x00,
104 .touch_autocal = 0x00,
106 .atch_cal_suspend_time = 0,
107 .atch_cal_suspend_thres = 0,
108 .atch_cal_force_thres = 0x10,
109 .atch_cal_force_ratio = 0,
123 .mov_hyst_init = 0x05,
124 .mov_hyst_next = 0x02,
128 .merge_thresh = 0x0A,
142 .comms_config_cfg = {
146 .noise_suppression_cfg = {
165 .one_touch_gesture_proc_cfg = {
173 .short_press_time_out = 0,
174 .long_press_time_out = 0,
175 .repeat_press_time_out = 0,
176 .flick_threshold = 0,
179 .throw_threshold = 0,
184 .high_signal_limit_0 = 0,
185 .low_signal_limit_0 = 0,
186 .high_signal_limit_1 = 0,
187 .low_signal_limit_1 = 0,
188 .high_signal_limit_2 = 0,
189 .low_signal_limit_2 = 0,
191 .two_touch_gesture_proc_cfg = {
196 .rotate_threshold = 0,
203 .idle_gcaf_depth = 16,
204 .active_gcaf_depth = 16,
207 .gripsuppression_t40_cfg = {
214 .palm_suppression_cfg = {
222 .spt_digitizer_cfg = {
236 struct qtouch_ts_platform_data stingray_touch_data_p0 = {
238 .flags = (QTOUCH_USE_MULTITOUCH |
239 QTOUCH_CFG_BACKUPNV),
240 .irqflags = (IRQF_TRIGGER_LOW),
251 .nv_checksum = 0x5D0929,
256 .boot_i2c_addr = XMEGAT_BL_I2C_ADDR,
257 .hw_reset = stingray_touch_reset,
258 .hw_suspend = stingray_touch_suspend,
265 .fw_name = "mXT1386_10_AA.bin",
270 .boot_version = 0x20,
271 .base_fw_version = 0x00,
274 .idle_acq_int = 0x12,
275 .active_acq_int = 0xFF,
276 .active_idle_to = 0x0A,
283 .touch_autocal = 0x00,
285 .atch_cal_suspend_time = 0,
286 .atch_cal_suspend_thres = 0,
287 .atch_cal_force_thres = 0x10,
288 .atch_cal_force_ratio = 0x19,
302 .mov_hyst_init = 0x32,
303 .mov_hyst_next = 0x14,
307 .merge_thresh = 0x0A,
324 .comms_config_cfg = {
328 .noise_suppression_cfg = {
347 .one_touch_gesture_proc_cfg = {
355 .short_press_time_out = 0,
356 .long_press_time_out = 0,
357 .repeat_press_time_out = 0,
358 .flick_threshold = 0,
361 .throw_threshold = 0,
366 .high_signal_limit_0 = 0,
367 .low_signal_limit_0 = 0,
368 .high_signal_limit_1 = 0,
369 .low_signal_limit_1 = 0,
370 .high_signal_limit_2 = 0,
371 .low_signal_limit_2 = 0,
373 .two_touch_gesture_proc_cfg = {
378 .rotate_threshold = 0,
385 .idle_gcaf_depth = 20,
386 .active_gcaf_depth = 20,
389 .gripsuppression_t40_cfg = {
396 .palm_suppression_cfg = {
404 .spt_digitizer_cfg = {
417 /* Portable P1 and later versions */
418 struct qtouch_ts_platform_data stingray_touch_data_p1_or_later = {
420 .flags = (QTOUCH_USE_MULTITOUCH |
421 QTOUCH_CFG_BACKUPNV),
422 .irqflags = (IRQF_TRIGGER_LOW),
433 .nv_checksum = 0x5D0929,
438 .boot_i2c_addr = XMEGAT_BL_I2C_ADDR,
439 .hw_reset = stingray_touch_reset,
440 .hw_suspend = stingray_touch_suspend,
447 .fw_name = "mXT1386_10_AA.bin",
452 .boot_version = 0x20,
453 .base_fw_version = 0x00,
456 .idle_acq_int = 0x12,
457 .active_acq_int = 0xFF,
458 .active_idle_to = 0x0A,
465 .touch_autocal = 0x00,
467 .atch_cal_suspend_time = 0,
468 .atch_cal_suspend_thres = 0,
469 .atch_cal_force_thres = 0x10,
470 .atch_cal_force_ratio = 0x19,
484 .mov_hyst_init = 0x32,
485 .mov_hyst_next = 0x14,
489 .merge_thresh = 0x0A,
506 .comms_config_cfg = {
510 .noise_suppression_cfg = {
529 .one_touch_gesture_proc_cfg = {
537 .short_press_time_out = 0,
538 .long_press_time_out = 0,
539 .repeat_press_time_out = 0,
540 .flick_threshold = 0,
543 .throw_threshold = 0,
548 .high_signal_limit_0 = 0,
549 .low_signal_limit_0 = 0,
550 .high_signal_limit_1 = 0,
551 .low_signal_limit_1 = 0,
552 .high_signal_limit_2 = 0,
553 .low_signal_limit_2 = 0,
555 .two_touch_gesture_proc_cfg = {
560 .rotate_threshold = 0,
567 .idle_gcaf_depth = 20,
568 .active_gcaf_depth = 20,
571 .gripsuppression_t40_cfg = {
578 .palm_suppression_cfg = {
586 .spt_digitizer_cfg = {
599 static struct i2c_board_info __initdata stingray_i2c_bus1_touch_info[] = {
601 I2C_BOARD_INFO(QTOUCH_TS_NAME, 0x5B),
605 int __init stingray_touch_init(void)
607 unsigned touch_int_gpio;
609 if (stingray_revision() == STINGRAY_REVISION_P2)
610 touch_int_gpio = STINGRAY_TOUCH_INT_N_GPIO_P2;
612 touch_int_gpio = STINGRAY_TOUCH_INT_N_GPIO;
614 tegra_gpio_enable(touch_int_gpio);
615 gpio_request(touch_int_gpio, "touch_irq");
616 gpio_direction_input(touch_int_gpio);
618 tegra_gpio_enable(STINGRAY_TOUCH_WAKE_N_GPIO);
619 gpio_request(STINGRAY_TOUCH_WAKE_N_GPIO, "touch_wake");
620 gpio_direction_output(STINGRAY_TOUCH_WAKE_N_GPIO, 0);
622 tegra_gpio_enable(STINGRAY_TOUCH_RESET_N_GPIO);
623 gpio_request(STINGRAY_TOUCH_RESET_N_GPIO, "touch_reset");
624 gpio_direction_output(STINGRAY_TOUCH_RESET_N_GPIO, 1);
626 stingray_i2c_bus1_touch_info[0].irq =
627 TEGRA_GPIO_TO_IRQ(touch_int_gpio);
629 if ((stingray_revision() == STINGRAY_REVISION_P1) ||
630 (stingray_revision() == STINGRAY_REVISION_P2) ||
631 (stingray_revision() == STINGRAY_REVISION_P3))
632 stingray_i2c_bus1_touch_info[0].platform_data =
633 &stingray_touch_data_p1_or_later;
634 else if (stingray_revision() == STINGRAY_REVISION_P0)
635 stingray_i2c_bus1_touch_info[0].platform_data = &stingray_touch_data_p0;
637 stingray_i2c_bus1_touch_info[0].platform_data = &stingray_touch_data_m1;
639 i2c_register_board_info(0, stingray_i2c_bus1_touch_info, 1);