diff options
Diffstat (limited to 'drivers/input/touchscreen/mk712.c')
-rw-r--r-- | drivers/input/touchscreen/mk712.c | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c index afaaebe5225b..4844d250a5eb 100644 --- a/drivers/input/touchscreen/mk712.c +++ b/drivers/input/touchscreen/mk712.c | |||
@@ -77,7 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ of MK712 touchscreen controller"); | |||
77 | #define MK712_READ_ONE_POINT 0x20 | 77 | #define MK712_READ_ONE_POINT 0x20 |
78 | #define MK712_POWERUP 0x40 | 78 | #define MK712_POWERUP 0x40 |
79 | 79 | ||
80 | static struct input_dev mk712_dev; | 80 | static struct input_dev *mk712_dev; |
81 | static DEFINE_SPINLOCK(mk712_lock); | 81 | static DEFINE_SPINLOCK(mk712_lock); |
82 | 82 | ||
83 | static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 83 | static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
@@ -88,7 +88,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
88 | static unsigned short last_y; | 88 | static unsigned short last_y; |
89 | 89 | ||
90 | spin_lock(&mk712_lock); | 90 | spin_lock(&mk712_lock); |
91 | input_regs(&mk712_dev, regs); | 91 | input_regs(mk712_dev, regs); |
92 | 92 | ||
93 | status = inb(mk712_io + MK712_STATUS); | 93 | status = inb(mk712_io + MK712_STATUS); |
94 | 94 | ||
@@ -100,7 +100,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
100 | if (~status & MK712_STATUS_TOUCH) | 100 | if (~status & MK712_STATUS_TOUCH) |
101 | { | 101 | { |
102 | debounce = 1; | 102 | debounce = 1; |
103 | input_report_key(&mk712_dev, BTN_TOUCH, 0); | 103 | input_report_key(mk712_dev, BTN_TOUCH, 0); |
104 | goto end; | 104 | goto end; |
105 | } | 105 | } |
106 | 106 | ||
@@ -110,15 +110,15 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
110 | goto end; | 110 | goto end; |
111 | } | 111 | } |
112 | 112 | ||
113 | input_report_key(&mk712_dev, BTN_TOUCH, 1); | 113 | input_report_key(mk712_dev, BTN_TOUCH, 1); |
114 | input_report_abs(&mk712_dev, ABS_X, last_x); | 114 | input_report_abs(mk712_dev, ABS_X, last_x); |
115 | input_report_abs(&mk712_dev, ABS_Y, last_y); | 115 | input_report_abs(mk712_dev, ABS_Y, last_y); |
116 | 116 | ||
117 | end: | 117 | end: |
118 | 118 | ||
119 | last_x = inw(mk712_io + MK712_X) & 0x0fff; | 119 | last_x = inw(mk712_io + MK712_X) & 0x0fff; |
120 | last_y = inw(mk712_io + MK712_Y) & 0x0fff; | 120 | last_y = inw(mk712_io + MK712_Y) & 0x0fff; |
121 | input_sync(&mk712_dev); | 121 | input_sync(mk712_dev); |
122 | spin_unlock(&mk712_lock); | 122 | spin_unlock(&mk712_lock); |
123 | return IRQ_HANDLED; | 123 | return IRQ_HANDLED; |
124 | } | 124 | } |
@@ -154,30 +154,11 @@ static void mk712_close(struct input_dev *dev) | |||
154 | spin_unlock_irqrestore(&mk712_lock, flags); | 154 | spin_unlock_irqrestore(&mk712_lock, flags); |
155 | } | 155 | } |
156 | 156 | ||
157 | static struct input_dev mk712_dev = { | ||
158 | .evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, | ||
159 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, | ||
160 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) }, | ||
161 | .open = mk712_open, | ||
162 | .close = mk712_close, | ||
163 | .name = "ICS MicroClock MK712 TouchScreen", | ||
164 | .phys = "isa0260/input0", | ||
165 | .absmin = { [ABS_X] = 0, [ABS_Y] = 0 }, | ||
166 | .absmax = { [ABS_X] = 0xfff, [ABS_Y] = 0xfff }, | ||
167 | .absfuzz = { [ABS_X] = 88, [ABS_Y] = 88 }, | ||
168 | .id = { | ||
169 | .bustype = BUS_ISA, | ||
170 | .vendor = 0x0005, | ||
171 | .product = 0x0001, | ||
172 | .version = 0x0100, | ||
173 | }, | ||
174 | }; | ||
175 | |||
176 | int __init mk712_init(void) | 157 | int __init mk712_init(void) |
177 | { | 158 | { |
159 | int err; | ||
178 | 160 | ||
179 | if(!request_region(mk712_io, 8, "mk712")) | 161 | if (!request_region(mk712_io, 8, "mk712")) { |
180 | { | ||
181 | printk(KERN_WARNING "mk712: unable to get IO region\n"); | 162 | printk(KERN_WARNING "mk712: unable to get IO region\n"); |
182 | return -ENODEV; | 163 | return -ENODEV; |
183 | } | 164 | } |
@@ -188,28 +169,49 @@ int __init mk712_init(void) | |||
188 | (inw(mk712_io + MK712_Y) & 0xf000) || | 169 | (inw(mk712_io + MK712_Y) & 0xf000) || |
189 | (inw(mk712_io + MK712_STATUS) & 0xf333)) { | 170 | (inw(mk712_io + MK712_STATUS) & 0xf333)) { |
190 | printk(KERN_WARNING "mk712: device not present\n"); | 171 | printk(KERN_WARNING "mk712: device not present\n"); |
191 | release_region(mk712_io, 8); | 172 | err = -ENODEV; |
192 | return -ENODEV; | 173 | goto fail; |
193 | } | 174 | } |
194 | 175 | ||
195 | if(request_irq(mk712_irq, mk712_interrupt, 0, "mk712", &mk712_dev)) | 176 | if (!(mk712_dev = input_allocate_device())) { |
196 | { | 177 | printk(KERN_ERR "mk712: not enough memory\n"); |
197 | printk(KERN_WARNING "mk712: unable to get IRQ\n"); | 178 | err = -ENOMEM; |
198 | release_region(mk712_io, 8); | 179 | goto fail; |
199 | return -EBUSY; | ||
200 | } | 180 | } |
201 | 181 | ||
202 | input_register_device(&mk712_dev); | 182 | mk712_dev->name = "ICS MicroClock MK712 TouchScreen"; |
183 | mk712_dev->phys = "isa0260/input0"; | ||
184 | mk712_dev->id.bustype = BUS_ISA; | ||
185 | mk712_dev->id.vendor = 0x0005; | ||
186 | mk712_dev->id.product = 0x0001; | ||
187 | mk712_dev->id.version = 0x0100; | ||
188 | |||
189 | mk712_dev->open = mk712_open; | ||
190 | mk712_dev->close = mk712_close; | ||
203 | 191 | ||
204 | printk(KERN_INFO "input: ICS MicroClock MK712 TouchScreen at %#x irq %d\n", mk712_io, mk712_irq); | 192 | mk712_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
193 | mk712_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
194 | input_set_abs_params(mk712_dev, ABS_X, 0, 0xfff, 88, 0); | ||
195 | input_set_abs_params(mk712_dev, ABS_Y, 0, 0xfff, 88, 0); | ||
205 | 196 | ||
197 | if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) { | ||
198 | printk(KERN_WARNING "mk712: unable to get IRQ\n"); | ||
199 | err = -EBUSY; | ||
200 | goto fail; | ||
201 | } | ||
202 | |||
203 | input_register_device(mk712_dev); | ||
206 | return 0; | 204 | return 0; |
205 | |||
206 | fail: input_free_device(mk712_dev); | ||
207 | release_region(mk712_io, 8); | ||
208 | return err; | ||
207 | } | 209 | } |
208 | 210 | ||
209 | static void __exit mk712_exit(void) | 211 | static void __exit mk712_exit(void) |
210 | { | 212 | { |
211 | input_unregister_device(&mk712_dev); | 213 | input_unregister_device(mk712_dev); |
212 | free_irq(mk712_irq, &mk712_dev); | 214 | free_irq(mk712_irq, mk712_dev); |
213 | release_region(mk712_io, 8); | 215 | release_region(mk712_io, 8); |
214 | } | 216 | } |
215 | 217 | ||