1 From f0bb9e67f0f13021e5033fed3dfe8ef78fe6a538 Mon Sep 17 00:00:00 2001
2 From: Marat Radchenko <marat@slonopotamus.org>
3 Date: Tue, 18 Oct 2011 21:52:56 +0400
4 Subject: [PATCH 2/2] N800: add TSC2301 board info
6 This patch adds TSC2301 init logic to N800 board file
8 arch/arm/mach-omap2/board-n8x0.c | 141 ++++++++++++++++++++++++++++++++++++--
9 1 files changed, 135 insertions(+), 6 deletions(-)
11 Index: linux-3.1/arch/arm/mach-omap2/board-n8x0.c
12 ===================================================================
13 --- linux-3.1.orig/arch/arm/mach-omap2/board-n8x0.c 2011-10-30 19:32:22.288178756 +0100
14 +++ linux-3.1/arch/arm/mach-omap2/board-n8x0.c 2011-10-30 19:32:26.840094004 +0100
16 #include <linux/spi/tsc2005.h>
17 #include <linux/input.h>
18 #include <linux/i2c/lm8323.h>
19 +#include <linux/spi/tsc2301.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach-types.h>
23 @@ -63,7 +64,75 @@ static struct omap2_mcspi_device_config
27 -static void __init tsc2005_set_config(void)
28 +#ifdef CONFIG_TOUCHSCREEN_TSC2301
30 +#define N800_KEYB_IRQ_GPIO 109
32 +static struct tsc2301_platform_data tsc2301_config = {
35 + -1, /* Event for bit 0 */
36 + KEY_UP, /* Event for bit 1 (up) */
37 + KEY_F5, /* Event for bit 2 (home) */
38 + -1, /* Event for bit 3 */
39 + KEY_LEFT, /* Event for bit 4 (left) */
40 + KEY_ENTER, /* Event for bit 5 (enter) */
41 + KEY_RIGHT, /* Event for bit 6 (right) */
42 + -1, /* Event for bit 7 */
43 + KEY_ESC, /* Event for bit 8 (cycle) */
44 + KEY_DOWN, /* Event for bit 9 (down) */
45 + KEY_F4, /* Event for bit 10 (menu) */
46 + -1, /* Event for bit 11 */
47 + KEY_F8, /* Event for bit 12 (Zoom-) */
48 + KEY_F6, /* Event for bit 13 (FS) */
49 + KEY_F7, /* Event for bit 14 (Zoom+) */
50 + -1, /* Event for bit 15 */
53 + .keyb_name = "Internal keypad",
56 +static struct omap2_mcspi_device_config tsc2301_mcspi_config = {
58 + .single_channel = 1,
62 + TODO(Marat Radchenko): better pass GPIO to tsc2301 driver and let it
63 + allocate irq itself (as it is already done for touchscreen)
65 +static void tsc2301_dev_init(void)
68 + int gpio = N800_KEYB_IRQ_GPIO;
70 + r = gpio_request(gpio, "tsc2301 KBD IRQ");
72 + gpio_direction_input(gpio);
73 + tsc2301_config.keyb_int = gpio_to_irq(gpio);
75 + printk(KERN_ERR "unable to get KBD GPIO");
79 + r = gpio_request(gpio, "tsc2301 DAV IRQ");
81 + gpio_direction_input(gpio);
82 + tsc2301_config.dav_int = gpio_to_irq(gpio);
84 + printk(KERN_ERR "unable to get DAV GPIO");
90 +static void __init tsc2301_dev_init(void)
96 +static void __init n8x0_ts_set_config(void)
98 const struct omap_lcd_config *conf;
100 @@ -94,6 +163,37 @@ static void __init tsc2005_set_config(vo
101 tsc2005_config.ts_x_plate_ohm = 200;
105 +#ifdef CONFIG_TOUCHSCREEN_TSC2301
106 + if (strcmp(conf->panel_name, "lph8923") == 0) {
107 + tsc2301_config.ts_x_plate_ohm = 180;
108 + tsc2301_config.ts_hw_avg = 8;
109 + tsc2301_config.ts_max_pressure = 2048;
110 + tsc2301_config.ts_touch_pressure = 400;
111 + tsc2301_config.ts_stab_time = 100;
112 + tsc2301_config.ts_pressure_fudge = 2;
113 + tsc2301_config.ts_x_max = 4096;
114 + tsc2301_config.ts_x_fudge = 4;
115 + tsc2301_config.ts_y_max = 4096;
116 + tsc2301_config.ts_y_fudge = 7;
117 + } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
118 + tsc2301_config.ts_x_plate_ohm = 280;
119 + tsc2301_config.ts_hw_avg = 8;
120 + tsc2301_config.ts_touch_pressure = 400;
121 + tsc2301_config.ts_max_pressure = 2048;
122 + tsc2301_config.ts_stab_time = 1000;
123 + tsc2301_config.ts_pressure_fudge = 2;
124 + tsc2301_config.ts_x_max = 4096;
125 + tsc2301_config.ts_x_fudge = 4;
126 + tsc2301_config.ts_y_max = 4096;
127 + tsc2301_config.ts_y_fudge = 7;
129 + printk(KERN_ERR "Unknown panel type, set default "
130 + "touchscreen configuration\n");
131 + tsc2301_config.ts_x_plate_ohm = 200;
132 + tsc2301_config.ts_stab_time = 100;
138 @@ -347,13 +447,12 @@ static void __init n8x0_usb_init(void) {
140 #endif /*CONFIG_USB_MUSB_TUSB6010 */
143 static struct omap2_mcspi_device_config p54spi_mcspi_config = {
148 -static struct spi_board_info n800_spi_board_info[] __initdata = {
149 +static struct spi_board_info n8x0_common_spi_board_info[] __initdata = {
151 .modalias = "lcd_mipid",
153 @@ -369,6 +468,10 @@ static struct spi_board_info n800_spi_bo
154 .max_speed_hz = 48000000,
155 .controller_data = &p54spi_mcspi_config,
159 +static struct spi_board_info n810_spi_board_info[] __initdata = {
160 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
162 .modalias = "tsc2005",
164 @@ -378,6 +481,20 @@ static struct spi_board_info n800_spi_bo
165 .controller_data = &tsc2005_mcspi_config,
166 .platform_data = &tsc2005_config,
171 +static struct spi_board_info n800_spi_board_info[] __initdata = {
172 +#if defined(CONFIG_TOUCHSCREEN_TSC2301)
174 + .modalias = "tsc2301",
177 + .max_speed_hz = 6000000,
178 + .controller_data = &tsc2301_mcspi_config,
179 + .platform_data = &tsc2301_config,
184 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
185 @@ -1023,9 +1140,17 @@ static void __init n8x0_init_machine(voi
188 /* FIXME: add n810 spi devices */
189 - tsc2005_set_config();
190 - spi_register_board_info(n800_spi_board_info,
191 - ARRAY_SIZE(n800_spi_board_info));
192 + n8x0_ts_set_config();
194 + spi_register_board_info(n8x0_common_spi_board_info,
195 + ARRAY_SIZE(n8x0_common_spi_board_info));
196 + if (machine_is_nokia_n800())
197 + spi_register_board_info(n800_spi_board_info,
198 + ARRAY_SIZE(n800_spi_board_info));
200 + spi_register_board_info(n810_spi_board_info,
201 + ARRAY_SIZE(n810_spi_board_info));
203 omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
204 ARRAY_SIZE(n8x0_i2c_board_info_1));
205 omap_register_i2c_bus(2, 400, NULL, 0);
206 @@ -1035,6 +1160,8 @@ static void __init n8x0_init_machine(voi
209 n8x0_blizzard_init();
210 + if (machine_is_nokia_n800())
211 + tsc2301_dev_init();
212 gpmc_onenand_init(board_onenand_data);