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 --- a/arch/arm/mach-omap2/board-n8x0.c
12 +++ b/arch/arm/mach-omap2/board-n8x0.c
14 #include <linux/spi/tsc2005.h>
15 #include <linux/input.h>
16 #include <linux/i2c/lm8323.h>
17 +#include <linux/spi/tsc2301.h>
19 #include <asm/mach/arch.h>
20 #include <asm/mach-types.h>
21 @@ -63,7 +64,75 @@ static struct omap2_mcspi_device_config
25 -static void __init tsc2005_set_config(void)
26 +#ifdef CONFIG_TOUCHSCREEN_TSC2301
28 +#define N800_KEYB_IRQ_GPIO 109
30 +static struct tsc2301_platform_data tsc2301_config = {
33 + -1, /* Event for bit 0 */
34 + KEY_UP, /* Event for bit 1 (up) */
35 + KEY_F5, /* Event for bit 2 (home) */
36 + -1, /* Event for bit 3 */
37 + KEY_LEFT, /* Event for bit 4 (left) */
38 + KEY_ENTER, /* Event for bit 5 (enter) */
39 + KEY_RIGHT, /* Event for bit 6 (right) */
40 + -1, /* Event for bit 7 */
41 + KEY_ESC, /* Event for bit 8 (cycle) */
42 + KEY_DOWN, /* Event for bit 9 (down) */
43 + KEY_F4, /* Event for bit 10 (menu) */
44 + -1, /* Event for bit 11 */
45 + KEY_F8, /* Event for bit 12 (Zoom-) */
46 + KEY_F6, /* Event for bit 13 (FS) */
47 + KEY_F7, /* Event for bit 14 (Zoom+) */
48 + -1, /* Event for bit 15 */
51 + .keyb_name = "Internal keypad",
54 +static struct omap2_mcspi_device_config tsc2301_mcspi_config = {
56 + .single_channel = 1,
60 + TODO(Marat Radchenko): better pass GPIO to tsc2301 driver and let it
61 + allocate irq itself (as it is already done for touchscreen)
63 +static void tsc2301_dev_init(void)
66 + int gpio = N800_KEYB_IRQ_GPIO;
68 + r = gpio_request(gpio, "tsc2301 KBD IRQ");
70 + gpio_direction_input(gpio);
71 + tsc2301_config.keyb_int = gpio_to_irq(gpio);
73 + printk(KERN_ERR "unable to get KBD GPIO");
77 + r = gpio_request(gpio, "tsc2301 DAV IRQ");
79 + gpio_direction_input(gpio);
80 + tsc2301_config.dav_int = gpio_to_irq(gpio);
82 + printk(KERN_ERR "unable to get DAV GPIO");
88 +static void __init tsc2301_dev_init(void)
94 +static void __init n8x0_ts_set_config(void)
96 const struct omap_lcd_config *conf;
98 @@ -94,6 +163,37 @@ static void __init tsc2005_set_config(vo
99 tsc2005_config.ts_x_plate_ohm = 200;
103 +#ifdef CONFIG_TOUCHSCREEN_TSC2301
104 + if (strcmp(conf->panel_name, "lph8923") == 0) {
105 + tsc2301_config.ts_x_plate_ohm = 180;
106 + tsc2301_config.ts_hw_avg = 8;
107 + tsc2301_config.ts_max_pressure = 2048;
108 + tsc2301_config.ts_touch_pressure = 400;
109 + tsc2301_config.ts_stab_time = 100;
110 + tsc2301_config.ts_pressure_fudge = 2;
111 + tsc2301_config.ts_x_max = 4096;
112 + tsc2301_config.ts_x_fudge = 4;
113 + tsc2301_config.ts_y_max = 4096;
114 + tsc2301_config.ts_y_fudge = 7;
115 + } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
116 + tsc2301_config.ts_x_plate_ohm = 280;
117 + tsc2301_config.ts_hw_avg = 8;
118 + tsc2301_config.ts_touch_pressure = 400;
119 + tsc2301_config.ts_max_pressure = 2048;
120 + tsc2301_config.ts_stab_time = 1000;
121 + tsc2301_config.ts_pressure_fudge = 2;
122 + tsc2301_config.ts_x_max = 4096;
123 + tsc2301_config.ts_x_fudge = 4;
124 + tsc2301_config.ts_y_max = 4096;
125 + tsc2301_config.ts_y_fudge = 7;
127 + printk(KERN_ERR "Unknown panel type, set default "
128 + "touchscreen configuration\n");
129 + tsc2301_config.ts_x_plate_ohm = 200;
130 + tsc2301_config.ts_stab_time = 100;
136 @@ -347,13 +447,12 @@ static void __init n8x0_usb_init(void) {
138 #endif /*CONFIG_USB_MUSB_TUSB6010 */
141 static struct omap2_mcspi_device_config p54spi_mcspi_config = {
146 -static struct spi_board_info n800_spi_board_info[] __initdata = {
147 +static struct spi_board_info n8x0_common_spi_board_info[] __initdata = {
149 .modalias = "lcd_mipid",
151 @@ -369,6 +468,10 @@ static struct spi_board_info n800_spi_bo
152 .max_speed_hz = 48000000,
153 .controller_data = &p54spi_mcspi_config,
157 +static struct spi_board_info n810_spi_board_info[] __initdata = {
158 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
160 .modalias = "tsc2005",
162 @@ -378,6 +481,20 @@ static struct spi_board_info n800_spi_bo
163 .controller_data = &tsc2005_mcspi_config,
164 .platform_data = &tsc2005_config,
169 +static struct spi_board_info n800_spi_board_info[] __initdata = {
170 +#if defined(CONFIG_TOUCHSCREEN_TSC2301)
172 + .modalias = "tsc2301",
175 + .max_speed_hz = 6000000,
176 + .controller_data = &tsc2301_mcspi_config,
177 + .platform_data = &tsc2301_config,
182 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
183 @@ -1023,9 +1140,17 @@ static void __init n8x0_init_machine(voi
186 /* FIXME: add n810 spi devices */
187 - tsc2005_set_config();
188 - spi_register_board_info(n800_spi_board_info,
189 - ARRAY_SIZE(n800_spi_board_info));
190 + n8x0_ts_set_config();
192 + spi_register_board_info(n8x0_common_spi_board_info,
193 + ARRAY_SIZE(n8x0_common_spi_board_info));
194 + if (machine_is_nokia_n800())
195 + spi_register_board_info(n800_spi_board_info,
196 + ARRAY_SIZE(n800_spi_board_info));
198 + spi_register_board_info(n810_spi_board_info,
199 + ARRAY_SIZE(n810_spi_board_info));
201 omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
202 ARRAY_SIZE(n8x0_i2c_board_info_1));
203 omap_register_i2c_bus(2, 400, NULL, 0);
204 @@ -1035,6 +1160,8 @@ static void __init n8x0_init_machine(voi
207 n8x0_blizzard_init();
208 + if (machine_is_nokia_n800())
209 + tsc2301_dev_init();
210 gpmc_onenand_init(board_onenand_data);