[PATCH] w1: Fixed 64bit compilation warning.
[linux-2.6/verdex.git] / drivers / input / touchscreen / hp680_ts_input.c
blob7e1404441ecaa58736485f2515619f197473e799
1 #include <linux/input.h>
2 #include <linux/module.h>
3 #include <linux/init.h>
5 #include <linux/interrupt.h>
6 #include <asm/io.h>
7 #include <asm/delay.h>
8 #include <asm/adc.h>
9 #include <asm/hp6xx/hp6xx.h>
11 #define MODNAME "hp680_ts_input"
13 #define HP680_TS_ABS_X_MIN 40
14 #define HP680_TS_ABS_X_MAX 950
15 #define HP680_TS_ABS_Y_MIN 80
16 #define HP680_TS_ABS_Y_MAX 910
18 #define SCPCR 0xa4000116
19 #define PHDR 0xa400012e
20 #define SCPDR 0xa4000136
22 static void do_softint(void *data);
24 static struct input_dev hp680_ts_dev;
25 static DECLARE_WORK(work, do_softint, 0);
26 static char *hp680_ts_name = "HP Jornada touchscreen";
27 static char *hp680_ts_phys = "input0";
29 static void do_softint(void *data)
31 int absx = 0, absy = 0;
32 u8 scpdr;
33 int touched = 0;
35 if (ctrl_inb(PHDR) & PHDR_TS_PEN_DOWN) {
36 scpdr = ctrl_inb(SCPDR);
37 scpdr |= SCPDR_TS_SCAN_ENABLE;
38 scpdr &= ~SCPDR_TS_SCAN_Y;
39 ctrl_outb(scpdr, SCPDR);
40 udelay(30);
42 absy = adc_single(ADC_CHANNEL_TS_Y);
44 scpdr = ctrl_inb(SCPDR);
45 scpdr |= SCPDR_TS_SCAN_Y;
46 scpdr &= ~SCPDR_TS_SCAN_X;
47 ctrl_outb(scpdr, SCPDR);
48 udelay(30);
50 absx = adc_single(ADC_CHANNEL_TS_X);
52 scpdr = ctrl_inb(SCPDR);
53 scpdr |= SCPDR_TS_SCAN_X;
54 scpdr &= ~SCPDR_TS_SCAN_ENABLE;
55 ctrl_outb(scpdr, SCPDR);
56 udelay(100);
57 touched = ctrl_inb(PHDR) & PHDR_TS_PEN_DOWN;
60 if (touched) {
61 input_report_key(&hp680_ts_dev, BTN_TOUCH, 1);
62 input_report_abs(&hp680_ts_dev, ABS_X, absx);
63 input_report_abs(&hp680_ts_dev, ABS_Y, absy);
64 } else {
65 input_report_key(&hp680_ts_dev, BTN_TOUCH, 0);
68 input_sync(&hp680_ts_dev);
69 enable_irq(HP680_TS_IRQ);
72 static irqreturn_t hp680_ts_interrupt(int irq, void *dev, struct pt_regs *regs)
74 disable_irq_nosync(irq);
75 schedule_delayed_work(&work, HZ / 20);
77 return IRQ_HANDLED;
80 static int __init hp680_ts_init(void)
82 u8 scpdr;
83 u16 scpcr;
85 scpdr = ctrl_inb(SCPDR);
86 scpdr |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
87 scpdr &= ~SCPDR_TS_SCAN_ENABLE;
88 ctrl_outb(scpdr, SCPDR);
90 scpcr = ctrl_inw(SCPCR);
91 scpcr &= ~SCPCR_TS_MASK;
92 scpcr |= SCPCR_TS_ENABLE;
93 ctrl_outw(scpcr, SCPCR);
95 memset(&hp680_ts_dev, 0, sizeof(hp680_ts_dev));
96 init_input_dev(&hp680_ts_dev);
98 hp680_ts_dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
99 hp680_ts_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
100 hp680_ts_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
102 hp680_ts_dev.absmin[ABS_X] = HP680_TS_ABS_X_MIN;
103 hp680_ts_dev.absmin[ABS_Y] = HP680_TS_ABS_Y_MIN;
104 hp680_ts_dev.absmax[ABS_X] = HP680_TS_ABS_X_MAX;
105 hp680_ts_dev.absmax[ABS_Y] = HP680_TS_ABS_Y_MAX;
107 hp680_ts_dev.name = hp680_ts_name;
108 hp680_ts_dev.phys = hp680_ts_phys;
109 input_register_device(&hp680_ts_dev);
111 if (request_irq
112 (HP680_TS_IRQ, hp680_ts_interrupt, SA_INTERRUPT, MODNAME, 0) < 0) {
113 printk(KERN_ERR "hp680_touchscreen.c : Can't allocate irq %d\n",
114 HP680_TS_IRQ);
115 input_unregister_device(&hp680_ts_dev);
116 return -EBUSY;
119 return 0;
122 static void __exit hp680_ts_exit(void)
124 free_irq(HP680_TS_IRQ, 0);
125 cancel_delayed_work(&work);
126 flush_scheduled_work();
127 input_unregister_device(&hp680_ts_dev);
130 module_init(hp680_ts_init);
131 module_exit(hp680_ts_exit);
133 MODULE_AUTHOR("Andriy Skulysh, askulysh@image.kiev.ua");
134 MODULE_DESCRIPTION("HP Jornada 680 touchscreen driver");
135 MODULE_LICENSE("GPL");