openwrt/target/linux/omap24xx/patches-3.3/330-n800-tsc2301-platform.p...

213 lines
5.9 KiB
Diff

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();