diff mbox

[0/4] qt602240_ts changes for Intel mid platform

Message ID 20101116203914.28796.23141.stgit@localhost6.localdomain6 (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Leech Nov. 16, 2010, 8:41 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kernel/mrst.c b/arch/x86/kernel/mrst.c
index 9ed9e6b..d1ebdc8 100644
--- a/arch/x86/kernel/mrst.c
+++ b/arch/x86/kernel/mrst.c
@@ -34,6 +34,7 @@ 
 #include <linux/i2c/tc35894xbg.h>
 #include <linux/bh1770glc.h>
 #include <linux/leds-lp5523.h>
+#include <linux/i2c/qt602240_ts.h>
 
 #include <asm/setup.h>
 #include <asm/mpspec_def.h>
@@ -1032,6 +1033,76 @@  void *tc35894xbg_n_platform_data(void *info)
 		&tc35894xbg_ncdk_data);
 }
 
+static int qt602240_reset;
+static int qt602240_intr;
+
+static int qt602240_hw_setup(struct i2c_client *client)
+{
+	int err;
+	int intr;
+
+	err = gpio_request(qt602240_intr, "maXTouch-intr");
+	if (err) {
+		dev_err(&client->dev, "GPIO-%d request failed (err %d)\n",
+			qt602240_intr, err);
+		goto err_request_intr;
+	}
+
+	err = gpio_request(qt602240_reset, "maXTouch-reset");
+	if (err) {
+		dev_err(&client->dev, "GPIO-%d request failed (err %d)\n",
+			qt602240_reset, err);
+		goto err_request_reset;
+	}
+
+	err = gpio_direction_output(qt602240_reset, 0);
+	if (err) {
+		dev_err(&client->dev, "GPIO-%d direction set failed (err %d)\n",
+			qt602240_reset, err);
+		goto err_reset_direction;
+	}
+
+	gpio_set_value(qt602240_reset, 1);
+	/* maXTouch wants 40mSec minimum after reset to get organized */
+	/* double that to be safe as a maximum required delay */
+	msleep(80);
+	return 0;
+
+err_reset_direction:
+	gpio_free(qt602240_reset);
+err_request_reset:
+	gpio_free(qt602240_intr);
+err_request_intr:
+	return -EIO;
+}
+
+static void qt602240_hw_teardown(struct i2c_client *client)
+{
+	gpio_set_value(qt602240_reset, 0);
+	gpio_free(qt602240_reset);
+	gpio_free(qt602240_intr);
+}
+
+static void *qt602240_platform_data(void *info)
+{
+	struct i2c_board_info *i2c_info = info;
+	static struct qt602240_platform_data pdata = {
+		.trust_nvm = 1,
+		.hw_setup = qt602240_hw_setup,
+		.hw_teardown = qt602240_hw_teardown,
+	};
+
+	qt602240_reset = get_gpio_by_name("TS0-reset");
+	qt602240_intr = get_gpio_by_name("TS0-intr");
+	if (qt602240_reset < 0  ||  qt602240_intr < 0) {
+		printk(KERN_ERR "Touchscreen-0 GPIOs not in SFI table\n");
+		return NULL;
+	}
+
+	i2c_info->irq = qt602240_intr + MRST_IRQ_OFFSET;
+	return &pdata;
+}
+
 static const struct devs_id device_ids[] = {
 	{"pmic_gpio", SFI_DEV_TYPE_SPI, 1, &pmic_gpio_platform_data},
 	{"pmic_gpio", SFI_DEV_TYPE_IPC, 1, &pmic_gpio_platform_data},
@@ -1053,6 +1124,7 @@  static const struct devs_id device_ids[] = {
 	{"pmic_audio", SFI_DEV_TYPE_IPC, 1, &no_platform_data},
 	{"msic_audio", SFI_DEV_TYPE_SPI, 1, &no_platform_data},
 	{"msic_audio", SFI_DEV_TYPE_IPC, 1, &no_platform_data},
+	{"mXT224", SFI_DEV_TYPE_I2C, 0, &qt602240_platform_data},
 	{"i2c_TC35894-nEB1", SFI_DEV_TYPE_I2C, 0, &tc35894xbg_n_platform_data},
 	{"i2c_TC35894-i", SFI_DEV_TYPE_I2C, 0, &tc35894xbg_i_platform_data},
 	{"bh1770glc", SFI_DEV_TYPE_I2C, 0, &bh1770glc_platform_data_init},