aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/omap24xx/patches-3.3/330-n800-tsc2301-platform.patch
blob: 4ceada952ea4ed11a55769646133af033cc5894d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
From f0bb9e67f0f13021e5033fed3dfe8ef78fe6a538 Mon Sep 17 00:00:00 2001
From: Marat Radchenko <marat@slonopotamus.org>
Date: Tue, 18 Oct 2011 21:52:56 +0400
Subject: [PATCH 2/2] N800: add TSC2301 board info

This patch adds TSC2301 init logic to N800 board file
---
 arch/arm/mach-omap2/board-n8x0.c |  141 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 135 insertions(+), 6 deletions(-)

--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -27,6 +27,7 @@
 #include <linux/spi/tsc2005.h>
 #include <linux/input.h>
 #include <linux/i2c/lm8323.h>
+#include <linux/spi/tsc2301.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
@@ -63,7 +64,75 @@ static struct omap2_mcspi_device_config
 };
 #endif
 
-static void __init tsc2005_set_config(void)
+#ifdef CONFIG_TOUCHSCREEN_TSC2301
+
+#define N800_KEYB_IRQ_GPIO		109
+
+static struct tsc2301_platform_data tsc2301_config = {
+	.reset_gpio	= 118,
+	.keymap = {
+		-1,		/* Event for bit 0 */
+		KEY_UP,		/* Event for bit 1 (up) */
+		KEY_F5,		/* Event for bit 2 (home) */
+		-1,		/* Event for bit 3 */
+		KEY_LEFT,	/* Event for bit 4 (left) */
+		KEY_ENTER,	/* Event for bit 5 (enter) */
+		KEY_RIGHT,	/* Event for bit 6 (right) */
+		-1,		/* Event for bit 7 */
+		KEY_ESC,	/* Event for bit 8 (cycle) */
+		KEY_DOWN,	/* Event for bit 9 (down) */
+		KEY_F4,		/* Event for bit 10 (menu) */
+		-1,		/* Event for bit 11 */
+		KEY_F8,		/* Event for bit 12 (Zoom-) */
+		KEY_F6,		/* Event for bit 13 (FS) */
+		KEY_F7,		/* Event for bit 14 (Zoom+) */
+		-1,		/* Event for bit 15 */
+	},
+	.kp_rep 	= 0,
+	.keyb_name	= "Internal keypad",
+};
+
+static struct omap2_mcspi_device_config tsc2301_mcspi_config = {
+	.turbo_mode	= 0,
+	.single_channel = 1,
+};
+
+/*
+  TODO(Marat Radchenko): better pass GPIO to tsc2301 driver and let it
+  allocate irq itself (as it is already done for touchscreen)
+ */
+static void tsc2301_dev_init(void)
+{
+	int r;
+	int gpio = N800_KEYB_IRQ_GPIO;
+
+	r = gpio_request(gpio, "tsc2301 KBD IRQ");
+	if (r >= 0) {
+		gpio_direction_input(gpio);
+		tsc2301_config.keyb_int = gpio_to_irq(gpio);
+	} else {
+		printk(KERN_ERR "unable to get KBD GPIO");
+	}
+
+	gpio = 103;
+	r = gpio_request(gpio, "tsc2301 DAV IRQ");
+	if (r >= 0) {
+		gpio_direction_input(gpio);
+		tsc2301_config.dav_int = gpio_to_irq(gpio);
+	} else {
+		printk(KERN_ERR "unable to get DAV GPIO");
+	}
+}
+
+#else
+
+static void __init tsc2301_dev_init(void)
+{
+}
+
+#endif
+
+static void __init n8x0_ts_set_config(void)
 {
 	const struct omap_lcd_config *conf;
 
@@ -94,6 +163,37 @@ static void __init tsc2005_set_config(vo
 			tsc2005_config.ts_x_plate_ohm = 200;
 		}
 #endif
+
+#ifdef CONFIG_TOUCHSCREEN_TSC2301
+		if (strcmp(conf->panel_name, "lph8923") == 0) {
+			tsc2301_config.ts_x_plate_ohm	= 180;
+			tsc2301_config.ts_hw_avg	= 8;
+			tsc2301_config.ts_max_pressure	= 2048;
+			tsc2301_config.ts_touch_pressure = 400;
+			tsc2301_config.ts_stab_time	= 100;
+			tsc2301_config.ts_pressure_fudge = 2;
+			tsc2301_config.ts_x_max		= 4096;
+			tsc2301_config.ts_x_fudge	= 4;
+			tsc2301_config.ts_y_max		= 4096;
+			tsc2301_config.ts_y_fudge	= 7;
+		} else if (strcmp(conf->panel_name, "ls041y3") == 0) {
+			tsc2301_config.ts_x_plate_ohm	= 280;
+			tsc2301_config.ts_hw_avg	= 8;
+			tsc2301_config.ts_touch_pressure = 400;
+			tsc2301_config.ts_max_pressure	= 2048;
+			tsc2301_config.ts_stab_time	= 1000;
+			tsc2301_config.ts_pressure_fudge = 2;
+			tsc2301_config.ts_x_max		= 4096;
+			tsc2301_config.ts_x_fudge	= 4;
+			tsc2301_config.ts_y_max		= 4096;
+			tsc2301_config.ts_y_fudge	= 7;
+		} else {
+			printk(KERN_ERR "Unknown panel type, set default "
+			       "touchscreen configuration\n");
+			tsc2301_config.ts_x_plate_ohm	= 200;
+			tsc2301_config.ts_stab_time	= 100;
+		}
+#endif
 	}
 }
 
@@ -347,13 +447,12 @@ static void __init n8x0_usb_init(void) {
 
 #endif /*CONFIG_USB_MUSB_TUSB6010 */
 
-
 static struct omap2_mcspi_device_config p54spi_mcspi_config = {
 	.turbo_mode	= 0,
 	.single_channel = 1,
 };
 
-static struct spi_board_info n800_spi_board_info[] __initdata = {
+static struct spi_board_info n8x0_common_spi_board_info[] __initdata = {
 	{
 		.modalias	= "lcd_mipid",
 		.bus_num	= 1,
@@ -369,6 +468,10 @@ static struct spi_board_info n800_spi_bo
 		.max_speed_hz   = 48000000,
 		.controller_data = &p54spi_mcspi_config,
 	},
+};
+
+static struct spi_board_info n810_spi_board_info[] __initdata = {
+#ifdef CONFIG_TOUCHSCREEN_TSC2005
 	{
 		.modalias	 = "tsc2005",
 		.bus_num	 = 1,
@@ -378,6 +481,20 @@ static struct spi_board_info n800_spi_bo
 		.controller_data = &tsc2005_mcspi_config,
 		.platform_data   = &tsc2005_config,
 	},
+#endif
+};
+
+static struct spi_board_info n800_spi_board_info[] __initdata = {
+#if defined(CONFIG_TOUCHSCREEN_TSC2301)
+	{
+		.modalias	 = "tsc2301",
+		.bus_num	 = 1,
+		.chip_select	 = 0,
+		.max_speed_hz    = 6000000,
+		.controller_data = &tsc2301_mcspi_config,
+		.platform_data   = &tsc2301_config,
+	},
+#endif
 };
 
 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
@@ -1015,9 +1132,17 @@ static void __init n8x0_init_machine(voi
 	n8x0_bt_init();
 
 	/* FIXME: add n810 spi devices */
-	tsc2005_set_config();
-	spi_register_board_info(n800_spi_board_info,
-				ARRAY_SIZE(n800_spi_board_info));
+	n8x0_ts_set_config();
+
+	spi_register_board_info(n8x0_common_spi_board_info,
+				ARRAY_SIZE(n8x0_common_spi_board_info));
+	if (machine_is_nokia_n800())
+		spi_register_board_info(n800_spi_board_info,
+					ARRAY_SIZE(n800_spi_board_info));
+	else
+		spi_register_board_info(n810_spi_board_info,
+					ARRAY_SIZE(n810_spi_board_info));
+
 	omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
 			      ARRAY_SIZE(n8x0_i2c_board_info_1));
 	omap_register_i2c_bus(2, 400, NULL, 0);
@@ -1027,6 +1152,8 @@ static void __init n8x0_init_machine(voi
 	board_serial_init();
 	n8x0_mipid_init();
 	n8x0_blizzard_init();
+	if (machine_is_nokia_n800())
+		tsc2301_dev_init();
 	omap_sdrc_init(NULL, NULL);
 	gpmc_onenand_init(board_onenand_data);
 	n8x0_mmc_init();