diff options
Diffstat (limited to 'drivers/input/touchscreen/h3600_ts_input.c')
-rw-r--r-- | drivers/input/touchscreen/h3600_ts_input.c | 149 |
1 files changed, 59 insertions, 90 deletions
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c index bcfa1e36f957..a18d56bdafd9 100644 --- a/drivers/input/touchscreen/h3600_ts_input.c +++ b/drivers/input/touchscreen/h3600_ts_input.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/serio.h> | 39 | #include <linux/serio.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | #include <linux/pm.h> | ||
43 | 42 | ||
44 | /* SA1100 serial defines */ | 43 | /* SA1100 serial defines */ |
45 | #include <asm/arch/hardware.h> | 44 | #include <asm/arch/hardware.h> |
@@ -93,16 +92,12 @@ MODULE_LICENSE("GPL"); | |||
93 | #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ | 92 | #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ |
94 | #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ | 93 | #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ |
95 | 94 | ||
96 | static char *h3600_name = "H3600 TouchScreen"; | ||
97 | |||
98 | /* | 95 | /* |
99 | * Per-touchscreen data. | 96 | * Per-touchscreen data. |
100 | */ | 97 | */ |
101 | struct h3600_dev { | 98 | struct h3600_dev { |
102 | struct input_dev dev; | 99 | struct input_dev *dev; |
103 | struct pm_dev *pm_dev; | ||
104 | struct serio *serio; | 100 | struct serio *serio; |
105 | struct pm_dev *pm_dev; | ||
106 | unsigned char event; /* event ID from packet */ | 101 | unsigned char event; /* event ID from packet */ |
107 | unsigned char chksum; | 102 | unsigned char chksum; |
108 | unsigned char len; | 103 | unsigned char len; |
@@ -163,33 +158,6 @@ unsigned int h3600_flite_power(struct input_dev *dev, enum flite_pwr pwr) | |||
163 | return 0; | 158 | return 0; |
164 | } | 159 | } |
165 | 160 | ||
166 | static int suspended = 0; | ||
167 | static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req, | ||
168 | void *data) | ||
169 | { | ||
170 | struct input_dev *dev = (struct input_dev *) data; | ||
171 | |||
172 | switch (req) { | ||
173 | case PM_SUSPEND: /* enter D1-D3 */ | ||
174 | suspended = 1; | ||
175 | h3600_flite_power(dev, FLITE_PWR_OFF); | ||
176 | break; | ||
177 | case PM_BLANK: | ||
178 | if (!suspended) | ||
179 | h3600_flite_power(dev, FLITE_PWR_OFF); | ||
180 | break; | ||
181 | case PM_RESUME: /* enter D0 */ | ||
182 | /* same as unblank */ | ||
183 | case PM_UNBLANK: | ||
184 | if (suspended) { | ||
185 | //initSerial(); | ||
186 | suspended = 0; | ||
187 | } | ||
188 | h3600_flite_power(dev, FLITE_PWR_ON); | ||
189 | break; | ||
190 | } | ||
191 | return 0; | ||
192 | } | ||
193 | #endif | 161 | #endif |
194 | 162 | ||
195 | /* | 163 | /* |
@@ -199,7 +167,7 @@ static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req, | |||
199 | */ | 167 | */ |
200 | static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | 168 | static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) |
201 | { | 169 | { |
202 | struct input_dev *dev = &ts->dev; | 170 | struct input_dev *dev = ts->dev; |
203 | static int touched = 0; | 171 | static int touched = 0; |
204 | int key, down = 0; | 172 | int key, down = 0; |
205 | 173 | ||
@@ -295,6 +263,7 @@ static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) | |||
295 | static int h3600ts_event(struct input_dev *dev, unsigned int type, | 263 | static int h3600ts_event(struct input_dev *dev, unsigned int type, |
296 | unsigned int code, int value) | 264 | unsigned int code, int value) |
297 | { | 265 | { |
266 | #if 0 | ||
298 | struct h3600_dev *ts = dev->private; | 267 | struct h3600_dev *ts = dev->private; |
299 | 268 | ||
300 | switch (type) { | 269 | switch (type) { |
@@ -304,6 +273,8 @@ static int h3600ts_event(struct input_dev *dev, unsigned int type, | |||
304 | } | 273 | } |
305 | } | 274 | } |
306 | return -1; | 275 | return -1; |
276 | #endif | ||
277 | return 0; | ||
307 | } | 278 | } |
308 | 279 | ||
309 | /* | 280 | /* |
@@ -380,14 +351,48 @@ static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data, | |||
380 | static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | 351 | static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) |
381 | { | 352 | { |
382 | struct h3600_dev *ts; | 353 | struct h3600_dev *ts; |
354 | struct input_dev *input_dev; | ||
383 | int err; | 355 | int err; |
384 | 356 | ||
385 | if (!(ts = kmalloc(sizeof(struct h3600_dev), GFP_KERNEL))) | 357 | ts = kzalloc(sizeof(struct h3600_dev), GFP_KERNEL); |
386 | return -ENOMEM; | 358 | input_dev = input_allocate_device(); |
359 | if (!ts || !input_dev) { | ||
360 | err = -ENOMEM; | ||
361 | goto fail1; | ||
362 | } | ||
387 | 363 | ||
388 | memset(ts, 0, sizeof(struct h3600_dev)); | 364 | ts->serio = serio; |
365 | ts->dev = input_dev; | ||
366 | sprintf(ts->phys, "%s/input0", serio->phys); | ||
389 | 367 | ||
390 | init_input_dev(&ts->dev); | 368 | input_dev->name = "H3600 TouchScreen"; |
369 | input_dev->phys = ts->phys; | ||
370 | input_dev->id.bustype = BUS_RS232; | ||
371 | input_dev->id.vendor = SERIO_H3600; | ||
372 | input_dev->id.product = 0x0666; /* FIXME !!! We can ask the hardware */ | ||
373 | input_dev->id.version = 0x0100; | ||
374 | input_dev->cdev.dev = &serio->dev; | ||
375 | input_dev->private = ts; | ||
376 | |||
377 | input_dev->event = h3600ts_event; | ||
378 | |||
379 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR); | ||
380 | input_dev->ledbit[0] = BIT(LED_SLEEP); | ||
381 | input_set_abs_params(input_dev, ABS_X, 60, 985, 0, 0); | ||
382 | input_set_abs_params(input_dev, ABS_Y, 35, 1024, 0, 0); | ||
383 | |||
384 | set_bit(KEY_RECORD, input_dev->keybit); | ||
385 | set_bit(KEY_Q, input_dev->keybit); | ||
386 | set_bit(KEY_PROG1, input_dev->keybit); | ||
387 | set_bit(KEY_PROG2, input_dev->keybit); | ||
388 | set_bit(KEY_PROG3, input_dev->keybit); | ||
389 | set_bit(KEY_UP, input_dev->keybit); | ||
390 | set_bit(KEY_RIGHT, input_dev->keybit); | ||
391 | set_bit(KEY_LEFT, input_dev->keybit); | ||
392 | set_bit(KEY_DOWN, input_dev->keybit); | ||
393 | set_bit(KEY_ENTER, input_dev->keybit); | ||
394 | set_bit(KEY_SUSPEND, input_dev->keybit); | ||
395 | set_bit(BTN_TOUCH, input_dev->keybit); | ||
391 | 396 | ||
392 | /* Device specific stuff */ | 397 | /* Device specific stuff */ |
393 | set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); | 398 | set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); |
@@ -397,73 +402,35 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
397 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, | 402 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, |
398 | "h3600_action", &ts->dev)) { | 403 | "h3600_action", &ts->dev)) { |
399 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); | 404 | printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); |
400 | kfree(ts); | 405 | err = -EBUSY; |
401 | return -EBUSY; | 406 | goto fail2; |
402 | } | 407 | } |
403 | 408 | ||
404 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, | 409 | if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, |
405 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, | 410 | SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, |
406 | "h3600_suspend", &ts->dev)) { | 411 | "h3600_suspend", &ts->dev)) { |
407 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); | ||
408 | printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); | 412 | printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); |
409 | kfree(ts); | 413 | err = -EBUSY; |
410 | return -EBUSY; | 414 | goto fail3; |
411 | } | 415 | } |
412 | 416 | ||
413 | /* Now we have things going we setup our input device */ | ||
414 | ts->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR); | ||
415 | ts->dev.ledbit[0] = BIT(LED_SLEEP); | ||
416 | input_set_abs_params(&ts->dev, ABS_X, 60, 985, 0, 0); | ||
417 | input_set_abs_params(&ts->dev, ABS_Y, 35, 1024, 0, 0); | ||
418 | |||
419 | set_bit(KEY_RECORD, ts->dev.keybit); | ||
420 | set_bit(KEY_Q, ts->dev.keybit); | ||
421 | set_bit(KEY_PROG1, ts->dev.keybit); | ||
422 | set_bit(KEY_PROG2, ts->dev.keybit); | ||
423 | set_bit(KEY_PROG3, ts->dev.keybit); | ||
424 | set_bit(KEY_UP, ts->dev.keybit); | ||
425 | set_bit(KEY_RIGHT, ts->dev.keybit); | ||
426 | set_bit(KEY_LEFT, ts->dev.keybit); | ||
427 | set_bit(KEY_DOWN, ts->dev.keybit); | ||
428 | set_bit(KEY_ENTER, ts->dev.keybit); | ||
429 | ts->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH); | ||
430 | ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND); | ||
431 | |||
432 | ts->serio = serio; | ||
433 | |||
434 | sprintf(ts->phys, "%s/input0", serio->phys); | ||
435 | |||
436 | ts->dev.event = h3600ts_event; | ||
437 | ts->dev.private = ts; | ||
438 | ts->dev.name = h3600_name; | ||
439 | ts->dev.phys = ts->phys; | ||
440 | ts->dev.id.bustype = BUS_RS232; | ||
441 | ts->dev.id.vendor = SERIO_H3600; | ||
442 | ts->dev.id.product = 0x0666; /* FIXME !!! We can ask the hardware */ | ||
443 | ts->dev.id.version = 0x0100; | ||
444 | |||
445 | serio_set_drvdata(serio, ts); | 417 | serio_set_drvdata(serio, ts); |
446 | 418 | ||
447 | err = serio_open(serio, drv); | 419 | err = serio_open(serio, drv); |
448 | if (err) { | 420 | if (err) |
449 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts); | ||
450 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts); | ||
451 | serio_set_drvdata(serio, NULL); | ||
452 | kfree(ts); | ||
453 | return err; | 421 | return err; |
454 | } | ||
455 | 422 | ||
456 | //h3600_flite_control(1, 25); /* default brightness */ | 423 | //h3600_flite_control(1, 25); /* default brightness */ |
457 | #ifdef CONFIG_PM | 424 | input_register_device(ts->dev); |
458 | ts->pm_dev = pm_register(PM_ILLUMINATION_DEV, PM_SYS_LIGHT, | ||
459 | h3600ts_pm_callback); | ||
460 | printk("registered pm callback\n"); | ||
461 | #endif | ||
462 | input_register_device(&ts->dev); | ||
463 | |||
464 | printk(KERN_INFO "input: %s on %s\n", h3600_name, serio->phys); | ||
465 | 425 | ||
466 | return 0; | 426 | return 0; |
427 | |||
428 | fail3: free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev); | ||
429 | fail2: free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev); | ||
430 | fail1: serio_set_drvdata(serio, NULL); | ||
431 | input_free_device(input_dev); | ||
432 | kfree(ts); | ||
433 | return err; | ||
467 | } | 434 | } |
468 | 435 | ||
469 | /* | 436 | /* |
@@ -476,9 +443,11 @@ static void h3600ts_disconnect(struct serio *serio) | |||
476 | 443 | ||
477 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); | 444 | free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); |
478 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); | 445 | free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); |
479 | input_unregister_device(&ts->dev); | 446 | input_get_device(ts->dev); |
447 | input_unregister_device(ts->dev); | ||
480 | serio_close(serio); | 448 | serio_close(serio); |
481 | serio_set_drvdata(serio, NULL); | 449 | serio_set_drvdata(serio, NULL); |
450 | input_put_device(ts->dev); | ||
482 | kfree(ts); | 451 | kfree(ts); |
483 | } | 452 | } |
484 | 453 | ||