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 = 0x3fa414,
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_FF.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 = 0x4B,
285 .atch_cal_suspend_time = 0,
286 .atch_cal_suspend_thres = 0,
287 .atch_cal_force_thres = 0x10,
288 .atch_cal_force_ratio = 0x10,
302 .mov_hyst_init = 0x16,
303 .mov_hyst_next = 0x0B,
307 .merge_thresh = 0x23,
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 = {
400 .large_obj_thr = 0xD3,
401 .distance_thr = 0x05,
405 .spt_digitizer_cfg = {
418 /* Portable P1 and later versions */
419 struct qtouch_ts_platform_data stingray_touch_data_p1_or_later = {
421 .flags = (QTOUCH_USE_MULTITOUCH |
422 QTOUCH_CFG_BACKUPNV),
423 .irqflags = (IRQF_TRIGGER_LOW),
434 .nv_checksum = 0x3fa414,
439 .boot_i2c_addr = XMEGAT_BL_I2C_ADDR,
440 .hw_reset = stingray_touch_reset,
441 .hw_suspend = stingray_touch_suspend,
448 .fw_name = "mXT1386_10_FF.bin",
453 .boot_version = 0x20,
454 .base_fw_version = 0x00,
457 .idle_acq_int = 0x12,
458 .active_acq_int = 0xFF,
459 .active_idle_to = 0x0A,
466 .touch_autocal = 0x4B,
468 .atch_cal_suspend_time = 0,
469 .atch_cal_suspend_thres = 0,
470 .atch_cal_force_thres = 0x10,
471 .atch_cal_force_ratio = 0x10,
485 .mov_hyst_init = 0x16,
486 .mov_hyst_next = 0x0B,
490 .merge_thresh = 0x23,
507 .comms_config_cfg = {
511 .noise_suppression_cfg = {
530 .one_touch_gesture_proc_cfg = {
538 .short_press_time_out = 0,
539 .long_press_time_out = 0,
540 .repeat_press_time_out = 0,
541 .flick_threshold = 0,
544 .throw_threshold = 0,
549 .high_signal_limit_0 = 0,
550 .low_signal_limit_0 = 0,
551 .high_signal_limit_1 = 0,
552 .low_signal_limit_1 = 0,
553 .high_signal_limit_2 = 0,
554 .low_signal_limit_2 = 0,
556 .two_touch_gesture_proc_cfg = {
561 .rotate_threshold = 0,
568 .idle_gcaf_depth = 20,
569 .active_gcaf_depth = 20,
572 .gripsuppression_t40_cfg = {
579 .palm_suppression_cfg = {
583 .large_obj_thr = 0xD3,
584 .distance_thr = 0x05,
588 .spt_digitizer_cfg = {
601 static struct i2c_board_info __initdata stingray_i2c_bus1_touch_info[] = {
603 I2C_BOARD_INFO(QTOUCH_TS_NAME, 0x5B),
607 int __init stingray_touch_init(void)
609 unsigned touch_int_gpio;
611 if (stingray_revision() == STINGRAY_REVISION_P2)
612 touch_int_gpio = STINGRAY_TOUCH_INT_N_GPIO_P2;
614 touch_int_gpio = STINGRAY_TOUCH_INT_N_GPIO;
616 tegra_gpio_enable(touch_int_gpio);
617 gpio_request(touch_int_gpio, "touch_irq");
618 gpio_direction_input(touch_int_gpio);
620 tegra_gpio_enable(STINGRAY_TOUCH_WAKE_N_GPIO);
621 gpio_request(STINGRAY_TOUCH_WAKE_N_GPIO, "touch_wake");
622 gpio_direction_output(STINGRAY_TOUCH_WAKE_N_GPIO, 0);
624 tegra_gpio_enable(STINGRAY_TOUCH_RESET_N_GPIO);
625 gpio_request(STINGRAY_TOUCH_RESET_N_GPIO, "touch_reset");
626 gpio_direction_output(STINGRAY_TOUCH_RESET_N_GPIO, 1);
628 stingray_i2c_bus1_touch_info[0].irq =
629 TEGRA_GPIO_TO_IRQ(touch_int_gpio);
631 if ((stingray_revision() == STINGRAY_REVISION_P1) ||
632 (stingray_revision() == STINGRAY_REVISION_P2) ||
633 (stingray_revision() == STINGRAY_REVISION_P3))
634 stingray_i2c_bus1_touch_info[0].platform_data =
635 &stingray_touch_data_p1_or_later;
636 else if (stingray_revision() == STINGRAY_REVISION_P0)
637 stingray_i2c_bus1_touch_info[0].platform_data = &stingray_touch_data_p0;
639 stingray_i2c_bus1_touch_info[0].platform_data = &stingray_touch_data_m1;
641 i2c_register_board_info(0, stingray_i2c_bus1_touch_info, 1);