32 #include <linux/errno.h>
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/slab.h>
36 #include <linux/input.h>
37 #include <linux/serio.h>
42 #include <mach/hardware.h>
43 #include <mach/irqs.h>
45 #define DRIVER_DESC "H3600 touchscreen driver"
58 #define FRAME_OVERHEAD 3
68 #define EEPROM_READ_ID 4
69 #define EEPROM_WRITE_ID 5
71 #define NOTIFY_LED_ID 8
73 #define SPI_READ_ID 0x0b
74 #define SPI_WRITE_ID 0x0c
80 #define H3600_MAX_LENGTH 16
83 #define H3600_SCANCODE_RECORD 1
84 #define H3600_SCANCODE_CALENDAR 2
85 #define H3600_SCANCODE_CONTACTS 3
86 #define H3600_SCANCODE_Q 4
87 #define H3600_SCANCODE_START 5
88 #define H3600_SCANCODE_UP 6
89 #define H3600_SCANCODE_RIGHT 7
90 #define H3600_SCANCODE_LEFT 8
91 #define H3600_SCANCODE_DOWN 9
97 struct input_dev *
dev;
109 int down = (
GPLR & GPIO_BITSY_ACTION_BUTTON) ? 0 : 1;
120 int down = (
GPLR & GPIO_BITSY_NPOWER_BUTTON) ? 0 : 1;
136 static int flite_brightness = 25;
145 unsigned int h3600_flite_power(
struct input_dev *
dev,
enum flite_pwr pwr)
147 unsigned char brightness = (pwr == FLITE_PWR_OFF) ? 0 : flite_brightness;
151 serio_write(ts->
serio, 1);
152 serio_write(ts->
serio, pwr);
153 serio_write(ts->
serio, brightness);
165 static void h3600ts_process_packet(
struct h3600_dev *
ts)
167 struct input_dev *
dev = ts->
dev;
168 static int touched = 0;
184 down = (ts->
buf[0] & 0x80) ? 0 : 1;
186 switch (ts->
buf[0] & 0x7f) {
218 input_report_key(dev, key, down);
237 x = ts->
buf[0]; x <<= 8; x += ts->
buf[1];
238 y = ts->
buf[2]; y <<= 8; y += ts->
buf[3];
240 input_report_abs(dev,
ABS_X, x);
241 input_report_abs(dev,
ABS_Y, y);
258 static int h3600ts_event(
struct input_dev *dev,
unsigned int type,
262 struct h3600_dev *ts = input_get_drvdata(dev);
301 struct h3600_dev *ts = serio_get_drvdata(serio);
312 ts->
event = (data & 0xf0) >> 4;
313 ts->
len = (data & 0xf);
331 h3600ts_process_packet(ts);
349 struct input_dev *input_dev;
353 input_dev = input_allocate_device();
354 if (!ts || !input_dev) {
363 input_dev->name =
"H3600 TouchScreen";
364 input_dev->phys = ts->
phys;
367 input_dev->id.product = 0x0666;
368 input_dev->id.version = 0x0100;
369 input_dev->dev.parent = &serio->
dev;
371 input_set_drvdata(input_dev, ts);
373 input_dev->event = h3600ts_event;
378 input_set_abs_params(input_dev,
ABS_X, 60, 985, 0, 0);
379 input_set_abs_params(input_dev,
ABS_Y, 35, 1024, 0, 0);
395 set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES);
396 set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE);
398 if (
request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler,
400 printk(
KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n");
405 if (
request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler,
407 printk(
KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n");
412 serio_set_drvdata(serio, ts);
419 err = input_register_device(ts->
dev);
426 fail3: serio_set_drvdata(serio,
NULL);
428 fail2:
free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->
dev);
429 fail1: input_free_device(input_dev);
438 static void h3600ts_disconnect(
struct serio *serio)
440 struct h3600_dev *ts = serio_get_drvdata(serio);
444 input_get_device(ts->
dev);
445 input_unregister_device(ts->
dev);
447 serio_set_drvdata(serio,
NULL);
448 input_put_device(ts->
dev);
473 .id_table = h3600ts_serio_ids,
474 .interrupt = h3600ts_interrupt,
475 .connect = h3600ts_connect,
476 .disconnect = h3600ts_disconnect,