summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/input/touchscreen
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/Kconfig98
-rw-r--r--drivers/input/touchscreen/Makefile13
-rw-r--r--drivers/input/touchscreen/corgi_ts.c380
-rw-r--r--drivers/input/touchscreen/elo.c315
-rw-r--r--drivers/input/touchscreen/gunze.c205
-rw-r--r--drivers/input/touchscreen/h3600_ts_input.c528
-rw-r--r--drivers/input/touchscreen/hp680_ts_input.c135
-rw-r--r--drivers/input/touchscreen/mk712.c222
-rw-r--r--drivers/input/touchscreen/mtouch.c219
9 files changed, 2115 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
new file mode 100644
index 000000000000..7e991274ea40
--- /dev/null
+++ b/drivers/input/touchscreen/Kconfig
@@ -0,0 +1,98 @@
+#
+# Mouse driver configuration
+#
+menuconfig INPUT_TOUCHSCREEN
+ bool "Touchscreens"
+ help
+ Say Y here, and a list of supported touchscreens will be displayed.
+ This option doesn't affect the kernel.
+
+ If unsure, say Y.
+
+if INPUT_TOUCHSCREEN
+
+config TOUCHSCREEN_BITSY
+ tristate "Compaq iPAQ H3600 (Bitsy) touchscreen"
+ depends on SA1100_BITSY
+ select SERIO
+ help
+ Say Y here if you have the h3600 (Bitsy) touchscreen.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called h3600_ts_input.
+
+config TOUCHSCREEN_CORGI
+ tristate "Corgi touchscreen (for Sharp SL-C7xx)"
+ depends on PXA_SHARPSL
+ default y
+ help
+ Say Y here to enable the driver for the touchscreen on the
+ Sharp SL-C7xx series of PDAs.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ads7846_ts.
+
+config TOUCHSCREEN_GUNZE
+ tristate "Gunze AHL-51S touchscreen"
+ select SERIO
+ help
+ Say Y here if you have the Gunze AHL-51 touchscreen connected to
+ your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called gunze.
+
+config TOUCHSCREEN_ELO
+ tristate "Elo serial touchscreens"
+ select SERIO
+ help
+ Say Y here if you have an Elo serial touchscreen connected to
+ your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called gunze.
+
+config TOUCHSCREEN_MTOUCH
+ tristate "MicroTouch serial touchscreens"
+ select SERIO
+ help
+ Say Y here if you have a MicroTouch (3M) serial touchscreen connected to
+ your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called mtouch.
+
+config TOUCHSCREEN_MK712
+ tristate "ICS MicroClock MK712 touchscreen"
+ help
+ Say Y here if you have the ICS MicroClock MK712 touchscreen
+ controller chip in your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called mk712.
+
+config TOUCHSCREEN_HP600
+ tristate "HP Jornada 680/690 touchscreen"
+ depends on SH_HP600 && SH_ADC
+ help
+ Say Y here if you have a HP Jornada 680 or 690 and want to
+ support the built-in touchscreen.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called hp680_ts_input.
+
+endif
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
new file mode 100644
index 000000000000..6842869c9a26
--- /dev/null
+++ b/drivers/input/touchscreen/Makefile
@@ -0,0 +1,13 @@
+#
+# Makefile for the mouse drivers.
+#
+
+# Each configuration option enables a list of files.
+
+obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
+obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
+obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
+obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
+obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
+obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o
+obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
new file mode 100644
index 000000000000..3f8b61cfbc37
--- /dev/null
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -0,0 +1,380 @@
+/*
+ * Touchscreen driver for Sharp Corgi models (SL-C7xx)
+ *
+ * Copyright (c) 2004-2005 Richard Purdie
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <asm/irq.h>
+
+#include <asm/arch/corgi.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/pxa-regs.h>
+
+
+#define PWR_MODE_ACTIVE 0
+#define PWR_MODE_SUSPEND 1
+
+#define X_AXIS_MAX 3830
+#define X_AXIS_MIN 150
+#define Y_AXIS_MAX 3830
+#define Y_AXIS_MIN 190
+#define PRESSURE_MIN 0
+#define PRESSURE_MAX 15000
+
+struct ts_event {
+ short pressure;
+ short x;
+ short y;
+};
+
+struct corgi_ts {
+ char phys[32];
+ struct input_dev input;
+ struct timer_list timer;
+ struct ts_event tc;
+ int pendown;
+ int power_mode;
+};
+
+#define STATUS_HSYNC (GPLR(CORGI_GPIO_HSYNC) & GPIO_bit(CORGI_GPIO_HSYNC))
+
+#define SyncHS() while((STATUS_HSYNC) == 0); while((STATUS_HSYNC) != 0);
+#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a))
+#define CCNT_ON() {int pmnc = 1; asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(pmnc));}
+#define CCNT_OFF() {int pmnc = 0; asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(pmnc));}
+
+#define WAIT_HS_400_VGA 7013U // 17.615us
+#define WAIT_HS_400_QVGA 16622U // 41.750us
+
+
+/* ADS7846 Touch Screen Controller bit definitions */
+#define ADSCTRL_PD0 (1u << 0) /* PD0 */
+#define ADSCTRL_PD1 (1u << 1) /* PD1 */
+#define ADSCTRL_DFR (1u << 2) /* SER/DFR */
+#define ADSCTRL_MOD (1u << 3) /* Mode */
+#define ADSCTRL_ADR_SH 4 /* Address setting */
+#define ADSCTRL_STS (1u << 7) /* Start Bit */
+
+/* External Functions */
+extern int w100fb_get_xres(void);
+extern int w100fb_get_blanking(void);
+extern int w100fb_get_fastsysclk(void);
+extern unsigned int get_clk_frequency_khz(int info);
+
+static unsigned long calc_waittime(void)
+{
+ int w100fb_xres = w100fb_get_xres();
+ unsigned int waittime = 0;
+
+ if (w100fb_xres == 480 || w100fb_xres == 640) {
+ waittime = WAIT_HS_400_VGA * get_clk_frequency_khz(0) / 398131U;
+
+ if (w100fb_get_fastsysclk() == 100)
+ waittime = waittime * 75 / 100;
+
+ if (w100fb_xres == 640)
+ waittime *= 3;
+
+ return waittime;
+ }
+
+ return WAIT_HS_400_QVGA * get_clk_frequency_khz(0) / 398131U;
+}
+
+static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int address, unsigned long wait_time)
+{
+ int pos = 0;
+ unsigned long timer1 = 0, timer2;
+ int dosleep;
+
+ dosleep = !w100fb_get_blanking();
+
+ if (dosleep && doSend) {
+ CCNT_ON();
+ /* polling HSync */
+ SyncHS();
+ /* get CCNT */
+ CCNT(timer1);
+ }
+
+ if (doRecive)
+ pos = corgi_ssp_ads7846_get();
+
+ if (doSend) {
+ int cmd = ADSCTRL_PD0 | ADSCTRL_PD1 | (address << ADSCTRL_ADR_SH) | ADSCTRL_STS;
+ /* dummy command */
+ corgi_ssp_ads7846_put(cmd);
+ corgi_ssp_ads7846_get();
+
+ if (dosleep) {
+ /* Wait after HSync */
+ CCNT(timer2);
+ if (timer2-timer1 > wait_time) {
+ /* timeout */
+ SyncHS();
+ /* get OSCR */
+ CCNT(timer1);
+ /* Wait after HSync */
+ CCNT(timer2);
+ }
+ while (timer2 - timer1 < wait_time)
+ CCNT(timer2);
+ }
+ corgi_ssp_ads7846_put(cmd);
+ if (dosleep)
+ CCNT_OFF();
+ }
+ return pos;
+}
+
+static int read_xydata(struct corgi_ts *corgi_ts)
+{
+ unsigned int x, y, z1, z2;
+ unsigned long flags, wait_time;
+
+ /* critical section */
+ local_irq_save(flags);
+ corgi_ssp_ads7846_lock();
+ wait_time=calc_waittime();
+
+ /* Y-axis */
+ sync_receive_data_send_cmd(0, 1, 1u, wait_time);
+
+ /* Y-axis */
+ sync_receive_data_send_cmd(1, 1, 1u, wait_time);
+
+ /* X-axis */
+ y = sync_receive_data_send_cmd(1, 1, 5u, wait_time);
+
+ /* Z1 */
+ x = sync_receive_data_send_cmd(1, 1, 3u, wait_time);
+
+ /* Z2 */
+ z1 = sync_receive_data_send_cmd(1, 1, 4u, wait_time);
+ z2 = sync_receive_data_send_cmd(1, 0, 4u, wait_time);
+
+ /* Power-Down Enable */
+ corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
+ corgi_ssp_ads7846_get();
+
+ corgi_ssp_ads7846_unlock();
+ local_irq_restore(flags);
+
+ if (x== 0 || y == 0 || z1 == 0 || (x * (z2 - z1) / z1) >= 15000) {
+ corgi_ts->tc.pressure = 0;
+ return 0;
+ }
+
+ corgi_ts->tc.x = x;
+ corgi_ts->tc.y = y;
+ corgi_ts->tc.pressure = (x * (z2 - z1)) / z1;
+ return 1;
+}
+
+static void new_data(struct corgi_ts *corgi_ts, struct pt_regs *regs)
+{
+ if (corgi_ts->power_mode != PWR_MODE_ACTIVE)
+ return;
+
+ if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0)
+ return;
+
+ if (regs)
+ input_regs(&corgi_ts->input, regs);
+
+ input_report_abs(&corgi_ts->input, ABS_X, corgi_ts->tc.x);
+ input_report_abs(&corgi_ts->input, ABS_Y, corgi_ts->tc.y);
+ input_report_abs(&corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure);
+ input_report_key(&corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0));
+ input_sync(&corgi_ts->input);
+}
+
+static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs)
+{
+ if ((GPLR(CORGI_GPIO_TP_INT) & GPIO_bit(CORGI_GPIO_TP_INT)) == 0) {
+ /* Disable Interrupt */
+ set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_NOEDGE);
+ if (read_xydata(corgi_ts)) {
+ corgi_ts->pendown = 1;
+ new_data(corgi_ts, regs);
+ }
+ mod_timer(&corgi_ts->timer, jiffies + HZ / 100);
+ } else {
+ if (corgi_ts->pendown == 1 || corgi_ts->pendown == 2) {
+ mod_timer(&corgi_ts->timer, jiffies + HZ / 100);
+ corgi_ts->pendown++;
+ return;
+ }
+
+ if (corgi_ts->pendown) {
+ corgi_ts->tc.pressure = 0;
+ new_data(corgi_ts, regs);
+ }
+
+ /* Enable Falling Edge */
+ set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING);
+ corgi_ts->pendown = 0;
+ }
+}
+
+static void corgi_ts_timer(unsigned long data)
+{
+ struct corgi_ts *corgits_data = (struct corgi_ts *) data;
+ ts_interrupt_main(corgits_data, 1, NULL);
+}
+
+static irqreturn_t ts_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct corgi_ts *corgits_data = dev_id;
+ ts_interrupt_main(corgits_data, 0, regs);
+ return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_PM
+static int corgits_suspend(struct device *dev, uint32_t state, uint32_t level)
+{
+ if (level == SUSPEND_POWER_DOWN) {
+ struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
+
+ if (corgi_ts->pendown) {
+ del_timer_sync(&corgi_ts->timer);
+ corgi_ts->tc.pressure = 0;
+ new_data(corgi_ts, NULL);
+ corgi_ts->pendown = 0;
+ }
+ corgi_ts->power_mode = PWR_MODE_SUSPEND;
+
+ corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
+ }
+ return 0;
+}
+
+static int corgits_resume(struct device *dev, uint32_t level)
+{
+ if (level == RESUME_POWER_ON) {
+ struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
+
+ corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
+ /* Enable Falling Edge */
+ set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING);
+ corgi_ts->power_mode = PWR_MODE_ACTIVE;
+ }
+ return 0;
+}
+#else
+#define corgits_suspend NULL
+#define corgits_resume NULL
+#endif
+
+static int __init corgits_probe(struct device *dev)
+{
+ struct corgi_ts *corgi_ts;
+
+ if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL)))
+ return -ENOMEM;
+
+ dev_set_drvdata(dev, corgi_ts);
+
+ memset(corgi_ts, 0, sizeof(struct corgi_ts));
+
+ init_input_dev(&corgi_ts->input);
+ corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_set_abs_params(&corgi_ts->input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
+ input_set_abs_params(&corgi_ts->input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
+ input_set_abs_params(&corgi_ts->input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0);
+
+ strcpy(corgi_ts->phys, "corgits/input0");
+
+ corgi_ts->input.private = corgi_ts;
+ corgi_ts->input.name = "Corgi Touchscreen";
+ corgi_ts->input.dev = dev;
+ corgi_ts->input.phys = corgi_ts->phys;
+ corgi_ts->input.id.bustype = BUS_HOST;
+ corgi_ts->input.id.vendor = 0x0001;
+ corgi_ts->input.id.product = 0x0002;
+ corgi_ts->input.id.version = 0x0100;
+
+ pxa_gpio_mode(CORGI_GPIO_TP_INT | GPIO_IN);
+ pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
+
+ /* Initiaize ADS7846 Difference Reference mode */
+ corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
+ mdelay(5);
+ corgi_ssp_ads7846_putget((3u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
+ mdelay(5);
+ corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
+ mdelay(5);
+ corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
+ mdelay(5);
+
+ init_timer(&corgi_ts->timer);
+ corgi_ts->timer.data = (unsigned long) corgi_ts;
+ corgi_ts->timer.function = corgi_ts_timer;
+
+ input_register_device(&corgi_ts->input);
+ corgi_ts->power_mode = PWR_MODE_ACTIVE;
+
+ if (request_irq(CORGI_IRQ_GPIO_TP_INT, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) {
+ input_unregister_device(&corgi_ts->input);
+ kfree(corgi_ts);
+ return -EBUSY;
+ }
+
+ /* Enable Falling Edge */
+ set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING);
+
+ printk(KERN_INFO "input: Corgi Touchscreen Registered\n");
+
+ return 0;
+}
+
+static int corgits_remove(struct device *dev)
+{
+ struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
+
+ free_irq(CORGI_IRQ_GPIO_TP_INT, NULL);
+ del_timer_sync(&corgi_ts->timer);
+ input_unregister_device(&corgi_ts->input);
+ kfree(corgi_ts);
+ return 0;
+}
+
+static struct device_driver corgits_driver = {
+ .name = "corgi-ts",
+ .bus = &platform_bus_type,
+ .probe = corgits_probe,
+ .remove = corgits_remove,
+ .suspend = corgits_suspend,
+ .resume = corgits_resume,
+};
+
+static int __devinit corgits_init(void)
+{
+ return driver_register(&corgits_driver);
+}
+
+static void __exit corgits_exit(void)
+{
+ driver_unregister(&corgits_driver);
+}
+
+module_init(corgits_init);
+module_exit(corgits_exit);
+
+MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
+MODULE_DESCRIPTION("Corgi TouchScreen Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
new file mode 100644
index 000000000000..546ce599334e
--- /dev/null
+++ b/drivers/input/touchscreen/elo.c
@@ -0,0 +1,315 @@
+/*
+ * Elo serial touchscreen driver
+ *
+ * Copyright (c) 2004 Vojtech Pavlik
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+/*
+ * This driver can handle serial Elo touchscreens using either the Elo standard
+ * 'E271-2210' 10-byte protocol, Elo legacy 'E281A-4002' 6-byte protocol, Elo
+ * legacy 'E271-140' 4-byte protocol and Elo legacy 'E261-280' 3-byte protocol.
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/serio.h>
+#include <linux/init.h>
+
+#define DRIVER_DESC "Elo serial touchscreen driver"
+
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+/*
+ * Definitions & global arrays.
+ */
+
+#define ELO_MAX_LENGTH 10
+
+static char *elo_name = "Elo Serial TouchScreen";
+
+/*
+ * Per-touchscreen data.
+ */
+
+struct elo {
+ struct input_dev dev;
+ struct serio *serio;
+ int id;
+ int idx;
+ unsigned char csum;
+ unsigned char data[ELO_MAX_LENGTH];
+ char phys[32];
+};
+
+static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs)
+{
+ struct input_dev *dev = &elo->dev;
+
+ elo->csum += elo->data[elo->idx] = data;
+
+ switch (elo->idx++) {
+
+ case 0:
+ if (data != 'U') {
+ elo->idx = 0;
+ elo->csum = 0;
+ }
+ break;
+
+ case 1:
+ if (data != 'T') {
+ elo->idx = 0;
+ elo->csum = 0;
+ }
+ break;
+
+ case 9:
+ if (elo->csum) {
+ input_regs(dev, regs);
+ input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]);
+ input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]);
+ input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]);
+ input_report_key(dev, BTN_TOUCH, elo->data[2] & 3);
+ input_sync(dev);
+ }
+ elo->idx = 0;
+ elo->csum = 0;
+ break;
+ }
+}
+
+static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs)
+{
+ struct input_dev *dev = &elo->dev;
+
+ elo->data[elo->idx] = data;
+
+ switch (elo->idx++) {
+
+ case 0: if ((data & 0xc0) != 0xc0) elo->idx = 0; break;
+ case 1: if ((data & 0xc0) != 0x80) elo->idx = 0; break;
+ case 2: if ((data & 0xc0) != 0x40) elo->idx = 0; break;
+
+ case 3:
+ if (data & 0xc0) {
+ elo->idx = 0;
+ break;
+ }
+
+ input_regs(dev, regs);
+ input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f));
+ input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f));
+
+ if (elo->id == 2) {
+ input_report_key(dev, BTN_TOUCH, 1);
+ input_sync(dev);
+ elo->idx = 0;
+ }
+
+ break;
+
+ case 4:
+ if (data) {
+ input_sync(dev);
+ elo->idx = 0;
+ }
+ break;
+
+ case 5:
+ if ((data & 0xf0) == 0) {
+ input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
+ input_report_key(dev, BTN_TOUCH, elo->data[5]);
+ }
+ input_sync(dev);
+ elo->idx = 0;
+ break;
+ }
+}
+
+static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs)
+{
+ struct input_dev *dev = &elo->dev;
+
+ elo->data[elo->idx] = data;
+
+ switch (elo->idx++) {
+
+ case 0:
+ if ((data & 0x7f) != 0x01)
+ elo->idx = 0;
+ break;
+ case 2:
+ input_regs(dev, regs);
+ input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80));
+ input_report_abs(dev, ABS_X, elo->data[1]);
+ input_report_abs(dev, ABS_Y, elo->data[2]);
+ input_sync(dev);
+ elo->idx = 0;
+ break;
+ }
+}
+
+static irqreturn_t elo_interrupt(struct serio *serio,
+ unsigned char data, unsigned int flags, struct pt_regs *regs)
+{
+ struct elo* elo = serio_get_drvdata(serio);
+
+ switch(elo->id) {
+ case 0:
+ elo_process_data_10(elo, data, regs);
+ break;
+
+ case 1:
+ case 2:
+ elo_process_data_6(elo, data, regs);
+ break;
+
+ case 3:
+ elo_process_data_3(elo, data, regs);
+ break;
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * elo_disconnect() is the opposite of elo_connect()
+ */
+
+static void elo_disconnect(struct serio *serio)
+{
+ struct elo* elo = serio_get_drvdata(serio);
+
+ input_unregister_device(&elo->dev);
+ serio_close(serio);
+ serio_set_drvdata(serio, NULL);
+ kfree(elo);
+}
+
+/*
+ * elo_connect() is the routine that is called when someone adds a
+ * new serio device that supports Gunze protocol and registers it as
+ * an input device.
+ */
+
+static int elo_connect(struct serio *serio, struct serio_driver *drv)
+{
+ struct elo *elo;
+ int err;
+
+ if (!(elo = kmalloc(sizeof(struct elo), GFP_KERNEL)))
+ return -ENOMEM;
+
+ memset(elo, 0, sizeof(struct elo));
+
+ init_input_dev(&elo->dev);
+ elo->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ elo->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+
+ elo->id = serio->id.id;
+
+ switch (elo->id) {
+
+ case 0: /* 10-byte protocol */
+ input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0);
+ input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0);
+ input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0);
+ break;
+
+ case 1: /* 6-byte protocol */
+ input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0);
+
+ case 2: /* 4-byte protocol */
+ input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0);
+ input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0);
+ break;
+
+ case 3: /* 3-byte protocol */
+ input_set_abs_params(&elo->dev, ABS_X, 0, 255, 0, 0);
+ input_set_abs_params(&elo->dev, ABS_Y, 0, 255, 0, 0);
+ break;
+ }
+
+ elo->serio = serio;
+
+ sprintf(elo->phys, "%s/input0", serio->phys);
+
+ elo->dev.private = elo;
+ elo->dev.name = elo_name;
+ elo->dev.phys = elo->phys;
+ elo->dev.id.bustype = BUS_RS232;
+ elo->dev.id.vendor = SERIO_ELO;
+ elo->dev.id.product = elo->id;
+ elo->dev.id.version = 0x0100;
+
+ serio_set_drvdata(serio, elo);
+
+ err = serio_open(serio, drv);
+ if (err) {
+ serio_set_drvdata(serio, NULL);
+ kfree(elo);
+ return err;
+ }
+
+ input_register_device(&elo->dev);
+
+ printk(KERN_INFO "input: %s on %s\n", elo_name, serio->phys);
+
+ return 0;
+}
+
+/*
+ * The serio driver structure.
+ */
+
+static struct serio_device_id elo_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_ELO,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(serio, elo_serio_ids);
+
+static struct serio_driver elo_drv = {
+ .driver = {
+ .name = "elo",
+ },
+ .description = DRIVER_DESC,
+ .id_table = elo_serio_ids,
+ .interrupt = elo_interrupt,
+ .connect = elo_connect,
+ .disconnect = elo_disconnect,
+};
+
+/*
+ * The functions for inserting/removing us as a module.
+ */
+
+static int __init elo_init(void)
+{
+ serio_register_driver(&elo_drv);
+ return 0;
+}
+
+static void __exit elo_exit(void)
+{
+ serio_unregister_driver(&elo_drv);
+}
+
+module_init(elo_init);
+module_exit(elo_exit);
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
new file mode 100644
index 000000000000..c9d0a153671c
--- /dev/null
+++ b/drivers/input/touchscreen/gunze.c
@@ -0,0 +1,205 @@
+/*
+ * $Id: gunze.c,v 1.12 2001/09/25 10:12:07 vojtech Exp $
+ *
+ * Copyright (c) 2000-2001 Vojtech Pavlik
+ */
+
+/*
+ * Gunze AHL-51S touchscreen driver for Linux
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Should you need to contact me, the author, you can do so either by
+ * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
+ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/serio.h>
+#include <linux/init.h>
+
+#define DRIVER_DESC "Gunze AHL-51S touchscreen driver"
+
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+/*
+ * Definitions & global arrays.
+ */
+
+#define GUNZE_MAX_LENGTH 10
+
+static char *gunze_name = "Gunze AHL-51S TouchScreen";
+
+/*
+ * Per-touchscreen data.
+ */
+
+struct gunze {
+ struct input_dev dev;
+ struct serio *serio;
+ int idx;
+ unsigned char data[GUNZE_MAX_LENGTH];
+ char phys[32];
+};
+
+static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs)
+{
+ struct input_dev *dev = &gunze->dev;
+
+ if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' ||
+ (gunze->data[0] != 'T' && gunze->data[0] != 'R')) {
+ gunze->data[10] = 0;
+ printk(KERN_WARNING "gunze.c: bad packet: >%s<\n", gunze->data);
+ return;
+ }
+
+ input_regs(dev, regs);
+ input_report_abs(dev, ABS_X, simple_strtoul(gunze->data + 1, NULL, 10));
+ input_report_abs(dev, ABS_Y, 1024 - simple_strtoul(gunze->data + 6, NULL, 10));
+ input_report_key(dev, BTN_TOUCH, gunze->data[0] == 'T');
+ input_sync(dev);
+}
+
+static irqreturn_t gunze_interrupt(struct serio *serio,
+ unsigned char data, unsigned int flags, struct pt_regs *regs)
+{
+ struct gunze* gunze = serio_get_drvdata(serio);
+
+ if (data == '\r') {
+ gunze_process_packet(gunze, regs);
+ gunze->idx = 0;
+ } else {
+ if (gunze->idx < GUNZE_MAX_LENGTH)
+ gunze->data[gunze->idx++] = data;
+ }
+ return IRQ_HANDLED;
+}
+
+/*
+ * gunze_disconnect() is the opposite of gunze_connect()
+ */
+
+static void gunze_disconnect(struct serio *serio)
+{
+ struct gunze* gunze = serio_get_drvdata(serio);
+
+ input_unregister_device(&gunze->dev);
+ serio_close(serio);
+ serio_set_drvdata(serio, NULL);
+ kfree(gunze);
+}
+
+/*
+ * gunze_connect() is the routine that is called when someone adds a
+ * new serio device that supports Gunze protocol and registers it as
+ * an input device.
+ */
+
+static int gunze_connect(struct serio *serio, struct serio_driver *drv)
+{
+ struct gunze *gunze;
+ int err;
+
+ if (!(gunze = kmalloc(sizeof(struct gunze), GFP_KERNEL)))
+ return -ENOMEM;
+
+ memset(gunze, 0, sizeof(struct gunze));
+
+ init_input_dev(&gunze->dev);
+ gunze->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ gunze->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+ input_set_abs_params(&gunze->dev, ABS_X, 24, 1000, 0, 0);
+ input_set_abs_params(&gunze->dev, ABS_Y, 24, 1000, 0, 0);
+
+ gunze->serio = serio;
+
+ sprintf(gunze->phys, "%s/input0", serio->phys);
+
+ gunze->dev.private = gunze;
+ gunze->dev.name = gunze_name;
+ gunze->dev.phys = gunze->phys;
+ gunze->dev.id.bustype = BUS_RS232;
+ gunze->dev.id.vendor = SERIO_GUNZE;
+ gunze->dev.id.product = 0x0051;
+ gunze->dev.id.version = 0x0100;
+
+ serio_set_drvdata(serio, gunze);
+
+ err = serio_open(serio, drv);
+ if (err) {
+ serio_set_drvdata(serio, NULL);
+ kfree(gunze);
+ return err;
+ }
+
+ input_register_device(&gunze->dev);
+
+ printk(KERN_INFO "input: %s on %s\n", gunze_name, serio->phys);
+
+ return 0;
+}
+
+/*
+ * The serio driver structure.
+ */
+
+static struct serio_device_id gunze_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_GUNZE,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(serio, gunze_serio_ids);
+
+static struct serio_driver gunze_drv = {
+ .driver = {
+ .name = "gunze",
+ },
+ .description = DRIVER_DESC,
+ .id_table = gunze_serio_ids,
+ .interrupt = gunze_interrupt,
+ .connect = gunze_connect,
+ .disconnect = gunze_disconnect,
+};
+
+/*
+ * The functions for inserting/removing us as a module.
+ */
+
+static int __init gunze_init(void)
+{
+ serio_register_driver(&gunze_drv);
+ return 0;
+}
+
+static void __exit gunze_exit(void)
+{
+ serio_unregister_driver(&gunze_drv);
+}
+
+module_init(gunze_init);
+module_exit(gunze_exit);
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
new file mode 100644
index 000000000000..acb9137a0226
--- /dev/null
+++ b/drivers/input/touchscreen/h3600_ts_input.c
@@ -0,0 +1,528 @@
+/*
+ * $Id: h3600_ts_input.c,v 1.4 2002/01/23 06:39:37 jsimmons Exp $
+ *
+ * Copyright (c) 2001 "Crazy" James Simmons jsimmons@transvirtual.com
+ *
+ * Sponsored by Transvirtual Technology.
+ *
+ * Derived from the code in h3600_ts.[ch] by Charles Flynn
+ */
+
+/*
+ * Driver for the h3600 Touch Screen and other Atmel controlled devices.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Should you need to contact me, the author, you can do so by
+ * e-mail - mail your message to <jsimmons@transvirtual.com>.
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/serio.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+
+/* SA1100 serial defines */
+#include <asm/arch/hardware.h>
+#include <asm/arch/irqs.h>
+
+#define DRIVER_DESC "H3600 touchscreen driver"
+
+MODULE_AUTHOR("James Simmons <jsimmons@transvirtual.com>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+/*
+ * Definitions & global arrays.
+ */
+
+/* The start and end of frame characters SOF and EOF */
+#define CHAR_SOF 0x02
+#define CHAR_EOF 0x03
+#define FRAME_OVERHEAD 3 /* CHAR_SOF,CHAR_EOF,LENGTH = 3 */
+
+/*
+ Atmel events and response IDs contained in frame.
+ Programmer has no control over these numbers.
+ TODO there are holes - specifically 1,7,0x0a
+*/
+#define VERSION_ID 0 /* Get Version (request/respose) */
+#define KEYBD_ID 2 /* Keyboard (event) */
+#define TOUCHS_ID 3 /* Touch Screen (event)*/
+#define EEPROM_READ_ID 4 /* (request/response) */
+#define EEPROM_WRITE_ID 5 /* (request/response) */
+#define THERMAL_ID 6 /* (request/response) */
+#define NOTIFY_LED_ID 8 /* (request/response) */
+#define BATTERY_ID 9 /* (request/response) */
+#define SPI_READ_ID 0x0b /* ( request/response) */
+#define SPI_WRITE_ID 0x0c /* ( request/response) */
+#define FLITE_ID 0x0d /* backlight ( request/response) */
+#define STX_ID 0xa1 /* extension pack status (req/resp) */
+
+#define MAX_ID 14
+
+#define H3600_MAX_LENGTH 16
+#define H3600_KEY 0xf
+
+#define H3600_SCANCODE_RECORD 1 /* 1 -> record button */
+#define H3600_SCANCODE_CALENDAR 2 /* 2 -> calendar */
+#define H3600_SCANCODE_CONTACTS 3 /* 3 -> contact */
+#define H3600_SCANCODE_Q 4 /* 4 -> Q button */
+#define H3600_SCANCODE_START 5 /* 5 -> start menu */
+#define H3600_SCANCODE_UP 6 /* 6 -> up */
+#define H3600_SCANCODE_RIGHT 7 /* 7 -> right */
+#define H3600_SCANCODE_LEFT 8 /* 8 -> left */
+#define H3600_SCANCODE_DOWN 9 /* 9 -> down */
+
+static char *h3600_name = "H3600 TouchScreen";
+
+/*
+ * Per-touchscreen data.
+ */
+struct h3600_dev {
+ struct input_dev dev;
+ struct pm_dev *pm_dev;
+ struct serio *serio;
+ struct pm_dev *pm_dev;
+ unsigned char event; /* event ID from packet */
+ unsigned char chksum;
+ unsigned char len;
+ unsigned char idx;
+ unsigned char buf[H3600_MAX_LENGTH];
+ char phys[32];
+};
+
+static irqreturn_t action_button_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+ int down = (GPLR & GPIO_BITSY_ACTION_BUTTON) ? 0 : 1;
+ struct input_dev *dev = (struct input_dev *) dev_id;
+
+ input_regs(dev, regs);
+ input_report_key(dev, KEY_ENTER, down);
+ input_sync(dev);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t npower_button_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+ int down = (GPLR & GPIO_BITSY_NPOWER_BUTTON) ? 0 : 1;
+ struct input_dev *dev = (struct input_dev *) dev_id;
+
+ /*
+ * This interrupt is only called when we release the key. So we have
+ * to fake a key press.
+ */
+ input_regs(dev, regs);
+ input_report_key(dev, KEY_SUSPEND, 1);
+ input_report_key(dev, KEY_SUSPEND, down);
+ input_sync(dev);
+
+ return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_PM
+
+static int flite_brightness = 25;
+
+enum flite_pwr {
+ FLITE_PWR_OFF = 0,
+ FLITE_PWR_ON = 1
+};
+
+/*
+ * h3600_flite_power: enables or disables power to frontlight, using last bright */
+unsigned int h3600_flite_power(struct input_dev *dev, enum flite_pwr pwr)
+{
+ unsigned char brightness = (pwr == FLITE_PWR_OFF) ? 0 : flite_brightness;
+ struct h3600_dev *ts = dev->private;
+
+ /* Must be in this order */
+ ts->serio->write(ts->serio, 1);
+ ts->serio->write(ts->serio, pwr);
+ ts->serio->write(ts->serio, brightness);
+ return 0;
+}
+
+static int suspended = 0;
+static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req,
+ void *data)
+{
+ struct input_dev *dev = (struct input_dev *) data;
+
+ switch (req) {
+ case PM_SUSPEND: /* enter D1-D3 */
+ suspended = 1;
+ h3600_flite_power(dev, FLITE_PWR_OFF);
+ break;
+ case PM_BLANK:
+ if (!suspended)
+ h3600_flite_power(dev, FLITE_PWR_OFF);
+ break;
+ case PM_RESUME: /* enter D0 */
+ /* same as unblank */
+ case PM_UNBLANK:
+ if (suspended) {
+ //initSerial();
+ suspended = 0;
+ }
+ h3600_flite_power(dev, FLITE_PWR_ON);
+ break;
+ }
+ return 0;
+}
+#endif
+
+/*
+ * This function translates the native event packets to linux input event
+ * packets. Some packets coming from serial are not touchscreen related. In
+ * this case we send them off to be processed elsewhere.
+ */
+static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs)
+{
+ struct input_dev *dev = &ts->dev;
+ static int touched = 0;
+ int key, down = 0;
+
+ input_regs(dev, regs);
+
+ switch (ts->event) {
+ /*
+ Buttons - returned as a single byte
+ 7 6 5 4 3 2 1 0
+ S x x x N N N N
+
+ S switch state ( 0=pressed 1=released)
+ x Unused.
+ NNNN switch number 0-15
+
+ Note: This is true for non interrupt generated key events.
+ */
+ case KEYBD_ID:
+ down = (ts->buf[0] & 0x80) ? 0 : 1;
+
+ switch (ts->buf[0] & 0x7f) {
+ case H3600_SCANCODE_RECORD:
+ key = KEY_RECORD;
+ break;
+ case H3600_SCANCODE_CALENDAR:
+ key = KEY_PROG1;
+ break;
+ case H3600_SCANCODE_CONTACTS:
+ key = KEY_PROG2;
+ break;
+ case H3600_SCANCODE_Q:
+ key = KEY_Q;
+ break;
+ case H3600_SCANCODE_START:
+ key = KEY_PROG3;
+ break;
+ case H3600_SCANCODE_UP:
+ key = KEY_UP;
+ break;
+ case H3600_SCANCODE_RIGHT:
+ key = KEY_RIGHT;
+ break;
+ case H3600_SCANCODE_LEFT:
+ key = KEY_LEFT;
+ break;
+ case H3600_SCANCODE_DOWN:
+ key = KEY_DOWN;
+ break;
+ default:
+ key = 0;
+ }
+ if (key)
+ input_report_key(dev, key, down);
+ break;
+ /*
+ * Native touchscreen event data is formatted as shown below:-
+ *
+ * +-------+-------+-------+-------+
+ * | Xmsb | Xlsb | Ymsb | Ylsb |
+ * +-------+-------+-------+-------+
+ * byte 0 1 2 3
+ */
+ case TOUCHS_ID:
+ if (!touched) {
+ input_report_key(dev, BTN_TOUCH, 1);
+ touched = 1;
+ }
+
+ if (ts->len) {
+ unsigned short x, y;
+
+ x = ts->buf[0]; x <<= 8; x += ts->buf[1];
+ y = ts->buf[2]; y <<= 8; y += ts->buf[3];
+
+ input_report_abs(dev, ABS_X, x);
+ input_report_abs(dev, ABS_Y, y);
+ } else {
+ input_report_key(dev, BTN_TOUCH, 0);
+ touched = 0;
+ }
+ break;
+ default:
+ /* Send a non input event elsewhere */
+ break;
+ }
+
+ input_sync(dev);
+}
+
+/*
+ * h3600ts_event() handles events from the input module.
+ */
+static int h3600ts_event(struct input_dev *dev, unsigned int type,
+ unsigned int code, int value)
+{
+ struct h3600_dev *ts = dev->private;
+
+ switch (type) {
+ case EV_LED: {
+ // ts->serio->write(ts->serio, SOME_CMD);
+ return 0;
+ }
+ }
+ return -1;
+}
+
+/*
+ Frame format
+ byte 1 2 3 len + 4
+ +-------+---------------+---------------+--=------------+
+ |SOF |id |len | len bytes | Chksum |
+ +-------+---------------+---------------+--=------------+
+ bit 0 7 8 11 12 15 16
+
+ +-------+---------------+-------+
+ |SOF |id |0 |Chksum | - Note Chksum does not include SOF
+ +-------+---------------+-------+
+ bit 0 7 8 11 12 15 16
+
+*/
+
+static int state;
+
+/* decode States */
+#define STATE_SOF 0 /* start of FRAME */
+#define STATE_ID 1 /* state where we decode the ID & len */
+#define STATE_DATA 2 /* state where we decode data */
+#define STATE_EOF 3 /* state where we decode checksum or EOF */
+
+static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data,
+ unsigned int flags, struct pt_regs *regs)
+{
+ struct h3600_dev *ts = serio_get_drvdata(serio);
+
+ /*
+ * We have a new frame coming in.
+ */
+ switch (state) {
+ case STATE_SOF:
+ if (data == CHAR_SOF)
+ state = STATE_ID;
+ break;
+ case STATE_ID:
+ ts->event = (data & 0xf0) >> 4;
+ ts->len = (data & 0xf);
+ ts->idx = 0;
+ if (ts->event >= MAX_ID) {
+ state = STATE_SOF;
+ break;
+ }
+ ts->chksum = data;
+ state = (ts->len > 0) ? STATE_DATA : STATE_EOF;
+ break;
+ case STATE_DATA:
+ ts->chksum += data;
+ ts->buf[ts->idx]= data;
+ if(++ts->idx == ts->len)
+ state = STATE_EOF;
+ break;
+ case STATE_EOF:
+ state = STATE_SOF;
+ if (data == CHAR_EOF || data == ts->chksum)
+ h3600ts_process_packet(ts, regs);
+ break;
+ default:
+ printk("Error3\n");
+ break;
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * h3600ts_connect() is the routine that is called when someone adds a
+ * new serio device that supports H3600 protocol and registers it as
+ * an input device.
+ */
+static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
+{
+ struct h3600_dev *ts;
+ int err;
+
+ if (!(ts = kmalloc(sizeof(struct h3600_dev), GFP_KERNEL)))
+ return -ENOMEM;
+
+ memset(ts, 0, sizeof(struct h3600_dev));
+
+ init_input_dev(&ts->dev);
+
+ /* Device specific stuff */
+ set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES);
+ set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE);
+
+ if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler,
+ SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
+ "h3600_action", &ts->dev)) {
+ printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n");
+ kfree(ts);
+ return -EBUSY;
+ }
+
+ if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler,
+ SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
+ "h3600_suspend", &ts->dev)) {
+ free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
+ printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n");
+ kfree(ts);
+ return -EBUSY;
+ }
+
+ /* Now we have things going we setup our input device */
+ ts->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR);
+ ts->dev.ledbit[0] = BIT(LED_SLEEP);
+ input_set_abs_params(&ts->dev, ABS_X, 60, 985, 0, 0);
+ input_set_abs_params(&ts->dev, ABS_Y, 35, 1024, 0, 0);
+
+ set_bit(KEY_RECORD, ts->dev.keybit);
+ set_bit(KEY_Q, ts->dev.keybit);
+ set_bit(KEY_PROG1, ts->dev.keybit);
+ set_bit(KEY_PROG2, ts->dev.keybit);
+ set_bit(KEY_PROG3, ts->dev.keybit);
+ set_bit(KEY_UP, ts->dev.keybit);
+ set_bit(KEY_RIGHT, ts->dev.keybit);
+ set_bit(KEY_LEFT, ts->dev.keybit);
+ set_bit(KEY_DOWN, ts->dev.keybit);
+ set_bit(KEY_ENTER, ts->dev.keybit);
+ ts->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+ ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND);
+
+ ts->serio = serio;
+
+ sprintf(ts->phys, "%s/input0", serio->phys);
+
+ ts->dev.event = h3600ts_event;
+ ts->dev.private = ts;
+ ts->dev.name = h3600_name;
+ ts->dev.phys = ts->phys;
+ ts->dev.id.bustype = BUS_RS232;
+ ts->dev.id.vendor = SERIO_H3600;
+ ts->dev.id.product = 0x0666; /* FIXME !!! We can ask the hardware */
+ ts->dev.id.version = 0x0100;
+
+ serio_set_drvdata(serio, ts);
+
+ err = serio_open(serio, drv);
+ if (err) {
+ free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts);
+ free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts);
+ serio_set_drvdata(serio, NULL);
+ kfree(ts);
+ return err;
+ }
+
+ //h3600_flite_control(1, 25); /* default brightness */
+#ifdef CONFIG_PM
+ ts->pm_dev = pm_register(PM_ILLUMINATION_DEV, PM_SYS_LIGHT,
+ h3600ts_pm_callback);
+ printk("registered pm callback\n");
+#endif
+ input_register_device(&ts->dev);
+
+ printk(KERN_INFO "input: %s on %s\n", h3600_name, serio->phys);
+
+ return 0;
+}
+
+/*
+ * h3600ts_disconnect() is the opposite of h3600ts_connect()
+ */
+
+static void h3600ts_disconnect(struct serio *serio)
+{
+ struct h3600_dev *ts = serio_get_drvdata(serio);
+
+ free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
+ free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev);
+ input_unregister_device(&ts->dev);
+ serio_close(serio);
+ serio_set_drvdata(serio, NULL);
+ kfree(ts);
+}
+
+/*
+ * The serio driver structure.
+ */
+
+static struct serio_device_id h3600ts_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_H3600,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(serio, h3600ts_serio_ids);
+
+static struct serio_driver h3600ts_drv = {
+ .driver = {
+ .name = "h3600ts",
+ },
+ .description = DRIVER_DESC,
+ .id_table = h3600ts_serio_ids,
+ .interrupt = h3600ts_interrupt,
+ .connect = h3600ts_connect,
+ .disconnect = h3600ts_disconnect,
+};
+
+/*
+ * The functions for inserting/removing us as a module.
+ */
+
+static int __init h3600ts_init(void)
+{
+ serio_register_driver(&h3600ts_drv);
+ return 0;
+}
+
+static void __exit h3600ts_exit(void)
+{
+ serio_unregister_driver(&h3600ts_drv);
+}
+
+module_init(h3600ts_init);
+module_exit(h3600ts_exit);
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c
new file mode 100644
index 000000000000..7e1404441eca
--- /dev/null
+++ b/drivers/input/touchscreen/hp680_ts_input.c
@@ -0,0 +1,135 @@
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <linux/interrupt.h>
+#include <asm/io.h>
+#include <asm/delay.h>
+#include <asm/adc.h>
+#include <asm/hp6xx/hp6xx.h>
+
+#define MODNAME "hp680_ts_input"
+
+#define HP680_TS_ABS_X_MIN 40
+#define HP680_TS_ABS_X_MAX 950
+#define HP680_TS_ABS_Y_MIN 80
+#define HP680_TS_ABS_Y_MAX 910
+
+#define SCPCR 0xa4000116
+#define PHDR 0xa400012e
+#define SCPDR 0xa4000136
+
+static void do_softint(void *data);
+
+static struct input_dev hp680_ts_dev;
+static DECLARE_WORK(work, do_softint, 0);
+static char *hp680_ts_name = "HP Jornada touchscreen";
+static char *hp680_ts_phys = "input0";
+
+static void do_softint(void *data)
+{
+ int absx = 0, absy = 0;
+ u8 scpdr;
+ int touched = 0;
+
+ if (ctrl_inb(PHDR) & PHDR_TS_PEN_DOWN) {
+ scpdr = ctrl_inb(SCPDR);
+ scpdr |= SCPDR_TS_SCAN_ENABLE;
+ scpdr &= ~SCPDR_TS_SCAN_Y;
+ ctrl_outb(scpdr, SCPDR);
+ udelay(30);
+
+ absy = adc_single(ADC_CHANNEL_TS_Y);
+
+ scpdr = ctrl_inb(SCPDR);
+ scpdr |= SCPDR_TS_SCAN_Y;
+ scpdr &= ~SCPDR_TS_SCAN_X;
+ ctrl_outb(scpdr, SCPDR);
+ udelay(30);
+
+ absx = adc_single(ADC_CHANNEL_TS_X);
+
+ scpdr = ctrl_inb(SCPDR);
+ scpdr |= SCPDR_TS_SCAN_X;
+ scpdr &= ~SCPDR_TS_SCAN_ENABLE;
+ ctrl_outb(scpdr, SCPDR);
+ udelay(100);
+ touched = ctrl_inb(PHDR) & PHDR_TS_PEN_DOWN;
+ }
+
+ if (touched) {
+ input_report_key(&hp680_ts_dev, BTN_TOUCH, 1);
+ input_report_abs(&hp680_ts_dev, ABS_X, absx);
+ input_report_abs(&hp680_ts_dev, ABS_Y, absy);
+ } else {
+ input_report_key(&hp680_ts_dev, BTN_TOUCH, 0);
+ }
+
+ input_sync(&hp680_ts_dev);
+ enable_irq(HP680_TS_IRQ);
+}
+
+static irqreturn_t hp680_ts_interrupt(int irq, void *dev, struct pt_regs *regs)
+{
+ disable_irq_nosync(irq);
+ schedule_delayed_work(&work, HZ / 20);
+
+ return IRQ_HANDLED;
+}
+
+static int __init hp680_ts_init(void)
+{
+ u8 scpdr;
+ u16 scpcr;
+
+ scpdr = ctrl_inb(SCPDR);
+ scpdr |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
+ scpdr &= ~SCPDR_TS_SCAN_ENABLE;
+ ctrl_outb(scpdr, SCPDR);
+
+ scpcr = ctrl_inw(SCPCR);
+ scpcr &= ~SCPCR_TS_MASK;
+ scpcr |= SCPCR_TS_ENABLE;
+ ctrl_outw(scpcr, SCPCR);
+
+ memset(&hp680_ts_dev, 0, sizeof(hp680_ts_dev));
+ init_input_dev(&hp680_ts_dev);
+
+ hp680_ts_dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
+ hp680_ts_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
+ hp680_ts_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+
+ hp680_ts_dev.absmin[ABS_X] = HP680_TS_ABS_X_MIN;
+ hp680_ts_dev.absmin[ABS_Y] = HP680_TS_ABS_Y_MIN;
+ hp680_ts_dev.absmax[ABS_X] = HP680_TS_ABS_X_MAX;
+ hp680_ts_dev.absmax[ABS_Y] = HP680_TS_ABS_Y_MAX;
+
+ hp680_ts_dev.name = hp680_ts_name;
+ hp680_ts_dev.phys = hp680_ts_phys;
+ input_register_device(&hp680_ts_dev);
+
+ if (request_irq
+ (HP680_TS_IRQ, hp680_ts_interrupt, SA_INTERRUPT, MODNAME, 0) < 0) {
+ printk(KERN_ERR "hp680_touchscreen.c : Can't allocate irq %d\n",
+ HP680_TS_IRQ);
+ input_unregister_device(&hp680_ts_dev);
+ return -EBUSY;
+ }
+
+ return 0;
+}
+
+static void __exit hp680_ts_exit(void)
+{
+ free_irq(HP680_TS_IRQ, 0);
+ cancel_delayed_work(&work);
+ flush_scheduled_work();
+ input_unregister_device(&hp680_ts_dev);
+}
+
+module_init(hp680_ts_init);
+module_exit(hp680_ts_exit);
+
+MODULE_AUTHOR("Andriy Skulysh, askulysh@image.kiev.ua");
+MODULE_DESCRIPTION("HP Jornada 680 touchscreen driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c
new file mode 100644
index 000000000000..2d14a57a05e5
--- /dev/null
+++ b/drivers/input/touchscreen/mk712.c
@@ -0,0 +1,222 @@
+/*
+ * ICS MK712 touchscreen controller driver
+ *
+ * Copyright (c) 1999-2002 Transmeta Corporation
+ * Copyright (c) 2005 Rick Koch <n1gp@hotmail.com>
+ * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+/*
+ * This driver supports the ICS MicroClock MK712 TouchScreen controller,
+ * found in Gateway AOL Connected Touchpad computers.
+ *
+ * Documentation for ICS MK712 can be found at:
+ * http://www.icst.com/pdf/mk712.pdf
+ */
+
+/*
+ * 1999-12-18: original version, Daniel Quinlan
+ * 1999-12-19: added anti-jitter code, report pen-up events, fixed mk712_poll
+ * to use queue_empty, Nathan Laredo
+ * 1999-12-20: improved random point rejection, Nathan Laredo
+ * 2000-01-05: checked in new anti-jitter code, changed mouse protocol, fixed
+ * queue code, added module options, other fixes, Daniel Quinlan
+ * 2002-03-15: Clean up for kernel merge <alan@redhat.com>
+ * Fixed multi open race, fixed memory checks, fixed resource
+ * allocation, fixed close/powerdown bug, switched to new init
+ * 2005-01-18: Ported to 2.6 from 2.4.28, Rick Koch
+ * 2005-02-05: Rewritten for the input layer, Vojtech Pavlik
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <asm/io.h>
+
+MODULE_AUTHOR("Daniel Quinlan <quinlan@pathname.com>, Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_DESCRIPTION("ICS MicroClock MK712 TouchScreen driver");
+MODULE_LICENSE("GPL");
+
+static unsigned int mk712_io = 0x260; /* Also 0x200, 0x208, 0x300 */
+module_param_named(io, mk712_io, uint, 0);
+MODULE_PARM_DESC(io, "I/O base address of MK712 touchscreen controller");
+
+static unsigned int mk712_irq = 10; /* Also 12, 14, 15 */
+module_param_named(irq, mk712_irq, uint, 0);
+MODULE_PARM_DESC(irq, "IRQ of MK712 touchscreen controller");
+
+/* eight 8-bit registers */
+#define MK712_STATUS 0
+#define MK712_X 2
+#define MK712_Y 4
+#define MK712_CONTROL 6
+#define MK712_RATE 7
+
+/* status */
+#define MK712_STATUS_TOUCH 0x10
+#define MK712_CONVERSION_COMPLETE 0x80
+
+/* control */
+#define MK712_ENABLE_INT 0x01
+#define MK712_INT_ON_CONVERSION_COMPLETE 0x02
+#define MK712_INT_ON_CHANGE_IN_TOUCH_STATUS 0x04
+#define MK712_ENABLE_PERIODIC_CONVERSIONS 0x10
+#define MK712_READ_ONE_POINT 0x20
+#define MK712_POWERUP 0x40
+
+static int mk712_used = 0;
+static struct input_dev mk712_dev;
+static DEFINE_SPINLOCK(mk712_lock);
+
+static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned char status;
+ static int debounce = 1;
+ static unsigned short last_x;
+ static unsigned short last_y;
+
+ spin_lock(&mk712_lock);
+ input_regs(&mk712_dev, regs);
+
+ status = inb(mk712_io + MK712_STATUS);
+
+ if (~status & MK712_CONVERSION_COMPLETE) {
+ debounce = 1;
+ goto end;
+ }
+
+ if (~status & MK712_STATUS_TOUCH)
+ {
+ debounce = 1;
+ input_report_key(&mk712_dev, BTN_TOUCH, 0);
+ goto end;
+ }
+
+ if (debounce)
+ {
+ debounce = 0;
+ goto end;
+ }
+
+ input_report_key(&mk712_dev, BTN_TOUCH, 1);
+ input_report_abs(&mk712_dev, ABS_X, last_x);
+ input_report_abs(&mk712_dev, ABS_Y, last_y);
+
+end:
+
+ last_x = inw(mk712_io + MK712_X) & 0x0fff;
+ last_y = inw(mk712_io + MK712_Y) & 0x0fff;
+ input_sync(&mk712_dev);
+ spin_unlock(&mk712_lock);
+ return IRQ_HANDLED;
+}
+
+static int mk712_open(struct input_dev *dev)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&mk712_lock, flags);
+
+ if (!mk712_used++) {
+
+ outb(0, mk712_io + MK712_CONTROL); /* Reset */
+
+ outb(MK712_ENABLE_INT | MK712_INT_ON_CONVERSION_COMPLETE |
+ MK712_INT_ON_CHANGE_IN_TOUCH_STATUS |
+ MK712_ENABLE_PERIODIC_CONVERSIONS |
+ MK712_POWERUP, mk712_io + MK712_CONTROL);
+
+ outb(10, mk712_io + MK712_RATE); /* 187 points per second */
+ }
+
+ spin_unlock_irqrestore(&mk712_lock, flags);
+
+ return 0;
+}
+
+static void mk712_close(struct input_dev *dev)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&mk712_lock, flags);
+
+ if (!--mk712_used)
+ outb(0, mk712_io + MK712_CONTROL);
+
+ spin_unlock_irqrestore(&mk712_lock, flags);
+}
+
+static struct input_dev mk712_dev = {
+ .evbit = { BIT(EV_KEY) | BIT(EV_ABS) },
+ .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
+ .absbit = { BIT(ABS_X) | BIT(ABS_Y) },
+ .open = mk712_open,
+ .close = mk712_close,
+ .name = "ICS MicroClock MK712 TouchScreen",
+ .phys = "isa0260/input0",
+ .absmin = { [ABS_X] = 0, [ABS_Y] = 0 },
+ .absmax = { [ABS_X] = 0xfff, [ABS_Y] = 0xfff },
+ .absfuzz = { [ABS_X] = 88, [ABS_Y] = 88 },
+ .id = {
+ .bustype = BUS_ISA,
+ .vendor = 0x0005,
+ .product = 0x0001,
+ .version = 0x0100,
+ },
+};
+
+int __init mk712_init(void)
+{
+
+ if(!request_region(mk712_io, 8, "mk712"))
+ {
+ printk(KERN_WARNING "mk712: unable to get IO region\n");
+ return -ENODEV;
+ }
+
+ outb(0, mk712_io + MK712_CONTROL);
+
+ if ((inw(mk712_io + MK712_X) & 0xf000) || /* Sanity check */
+ (inw(mk712_io + MK712_Y) & 0xf000) ||
+ (inw(mk712_io + MK712_STATUS) & 0xf333)) {
+ printk(KERN_WARNING "mk712: device not present\n");
+ release_region(mk712_io, 8);
+ return -ENODEV;
+ }
+
+ if(request_irq(mk712_irq, mk712_interrupt, 0, "mk712", &mk712_dev))
+ {
+ printk(KERN_WARNING "mk712: unable to get IRQ\n");
+ release_region(mk712_io, 8);
+ return -EBUSY;
+ }
+
+ input_register_device(&mk712_dev);
+
+ printk(KERN_INFO "input: ICS MicroClock MK712 TouchScreen at %#x irq %d\n", mk712_io, mk712_irq);
+
+ return 0;
+}
+
+static void __exit mk712_exit(void)
+{
+ input_unregister_device(&mk712_dev);
+ free_irq(mk712_irq, &mk712_dev);
+ release_region(mk712_io, 8);
+}
+
+module_init(mk712_init);
+module_exit(mk712_exit);
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c
new file mode 100644
index 000000000000..aa8ee7842179
--- /dev/null
+++ b/drivers/input/touchscreen/mtouch.c
@@ -0,0 +1,219 @@
+/*
+ * MicroTouch (3M) serial touchscreen driver
+ *
+ * Copyright (c) 2004 Vojtech Pavlik
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+/*
+ * 2005/02/19 Dan Streetman <ddstreet@ieee.org>
+ * Copied elo.c and edited for MicroTouch protocol
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/serio.h>
+#include <linux/init.h>
+
+#define DRIVER_DESC "MicroTouch serial touchscreen driver"
+
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+/*
+ * Definitions & global arrays.
+ */
+
+#define MTOUCH_FORMAT_TABLET_STATUS_BIT 0x80
+#define MTOUCH_FORMAT_TABLET_TOUCH_BIT 0x40
+#define MTOUCH_FORMAT_TABLET_LENGTH 5
+#define MTOUCH_RESPONSE_BEGIN_BYTE 0x01
+#define MTOUCH_RESPONSE_END_BYTE 0x0d
+
+/* todo: check specs for max length of all responses */
+#define MTOUCH_MAX_LENGTH 16
+
+#define MTOUCH_MIN_XC 0
+#define MTOUCH_MAX_XC 0x3fff
+#define MTOUCH_MIN_YC 0
+#define MTOUCH_MAX_YC 0x3fff
+
+#define MTOUCH_GET_XC(data) (((data[2])<<7) | data[1])
+#define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3])
+#define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0])
+
+static char *mtouch_name = "MicroTouch Serial TouchScreen";
+
+/*
+ * Per-touchscreen data.
+ */
+
+struct mtouch {
+ struct input_dev dev;
+ struct serio *serio;
+ int idx;
+ unsigned char data[MTOUCH_MAX_LENGTH];
+ char phys[32];
+};
+
+static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs)
+{
+ struct input_dev *dev = &mtouch->dev;
+
+ if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) {
+ input_regs(dev, regs);
+ input_report_abs(dev, ABS_X, MTOUCH_GET_XC(mtouch->data));
+ input_report_abs(dev, ABS_Y, MTOUCH_MAX_YC - MTOUCH_GET_YC(mtouch->data));
+ input_report_key(dev, BTN_TOUCH, MTOUCH_GET_TOUCHED(mtouch->data));
+ input_sync(dev);
+
+ mtouch->idx = 0;
+ }
+}
+
+static void mtouch_process_response(struct mtouch *mtouch, struct pt_regs *regs)
+{
+ if (MTOUCH_RESPONSE_END_BYTE == mtouch->data[mtouch->idx++]) {
+ /* FIXME - process response */
+ mtouch->idx = 0;
+ } else if (MTOUCH_MAX_LENGTH == mtouch->idx) {
+ printk(KERN_ERR "mtouch.c: too many response bytes\n");
+ mtouch->idx = 0;
+ }
+}
+
+static irqreturn_t mtouch_interrupt(struct serio *serio,
+ unsigned char data, unsigned int flags, struct pt_regs *regs)
+{
+ struct mtouch* mtouch = serio_get_drvdata(serio);
+
+ mtouch->data[mtouch->idx] = data;
+
+ if (MTOUCH_FORMAT_TABLET_STATUS_BIT & mtouch->data[0])
+ mtouch_process_format_tablet(mtouch, regs);
+ else if (MTOUCH_RESPONSE_BEGIN_BYTE == mtouch->data[0])
+ mtouch_process_response(mtouch, regs);
+ else
+ printk(KERN_DEBUG "mtouch.c: unknown/unsynchronized data from device, byte %x\n",mtouch->data[0]);
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * mtouch_disconnect() is the opposite of mtouch_connect()
+ */
+
+static void mtouch_disconnect(struct serio *serio)
+{
+ struct mtouch* mtouch = serio_get_drvdata(serio);
+
+ input_unregister_device(&mtouch->dev);
+ serio_close(serio);
+ serio_set_drvdata(serio, NULL);
+ kfree(mtouch);
+}
+
+/*
+ * mtouch_connect() is the routine that is called when someone adds a
+ * new serio device that supports MicroTouch (Format Tablet) protocol and registers it as
+ * an input device.
+ */
+
+static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
+{
+ struct mtouch *mtouch;
+ int err;
+
+ if (!(mtouch = kmalloc(sizeof(*mtouch), GFP_KERNEL)))
+ return -ENOMEM;
+
+ memset(mtouch, 0, sizeof(*mtouch));
+
+ init_input_dev(&mtouch->dev);
+ mtouch->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ mtouch->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+
+ input_set_abs_params(&mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
+ input_set_abs_params(&mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0);
+
+ mtouch->serio = serio;
+
+ sprintf(mtouch->phys, "%s/input0", serio->phys);
+
+ mtouch->dev.private = mtouch;
+ mtouch->dev.name = mtouch_name;
+ mtouch->dev.phys = mtouch->phys;
+ mtouch->dev.id.bustype = BUS_RS232;
+ mtouch->dev.id.vendor = SERIO_MICROTOUCH;
+ mtouch->dev.id.product = 0;
+ mtouch->dev.id.version = 0x0100;
+
+ serio_set_drvdata(serio, mtouch);
+
+ err = serio_open(serio, drv);
+ if (err) {
+ serio_set_drvdata(serio, NULL);
+ kfree(mtouch);
+ return err;
+ }
+
+ input_register_device(&mtouch->dev);
+
+ printk(KERN_INFO "input: %s on %s\n", mtouch->dev.name, serio->phys);
+
+ return 0;
+}
+
+/*
+ * The serio driver structure.
+ */
+
+static struct serio_device_id mtouch_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_MICROTOUCH,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(serio, mtouch_serio_ids);
+
+static struct serio_driver mtouch_drv = {
+ .driver = {
+ .name = "mtouch",
+ },
+ .description = DRIVER_DESC,
+ .id_table = mtouch_serio_ids,
+ .interrupt = mtouch_interrupt,
+ .connect = mtouch_connect,
+ .disconnect = mtouch_disconnect,
+};
+
+/*
+ * The functions for inserting/removing us as a module.
+ */
+
+static int __init mtouch_init(void)
+{
+ serio_register_driver(&mtouch_drv);
+ return 0;
+}
+
+static void __exit mtouch_exit(void)
+{
+ serio_unregister_driver(&mtouch_drv);
+}
+
+module_init(mtouch_init);
+module_exit(mtouch_exit);