diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-08-07 04:55:03 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-08-07 04:55:03 -0400 |
commit | 4fb8af10d0fd09372d52966b76922b9e82bbc950 (patch) | |
tree | d240e4d40357583e3f3eb228dccf20122a5b31ed /drivers/input | |
parent | f44f82e8a20b98558486eb14497b2f71c78fa325 (diff) | |
parent | 64a99d2a8c3ed5c4e39f3ae1cc682aa8fd3977fc (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/maple_keyb.c | 173 | ||||
-rw-r--r-- | drivers/input/keyboard/sh_keysc.c | 27 | ||||
-rw-r--r-- | drivers/input/misc/uinput.c | 1 | ||||
-rw-r--r-- | drivers/input/serio/serio.c | 55 | ||||
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 12 | ||||
-rw-r--r-- | drivers/input/touchscreen/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/ads7846.c | 16 | ||||
-rw-r--r-- | drivers/input/touchscreen/atmel_tsadcc.c | 332 |
8 files changed, 483 insertions, 134 deletions
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index 2b404284c28a..22f17a593be7 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * SEGA Dreamcast keyboard driver | 2 | * SEGA Dreamcast keyboard driver |
3 | * Based on drivers/usb/usbkbd.c | 3 | * Based on drivers/usb/usbkbd.c |
4 | * Copyright YAEGASHI Takeshi, 2001 | 4 | * Copyright YAEGASHI Takeshi, 2001 |
5 | * Porting to 2.6 Copyright Adrian McMenamin, 2007 | 5 | * Porting to 2.6 Copyright Adrian McMenamin, 2007, 2008 |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
29 | #include <linux/maple.h> | 29 | #include <linux/maple.h> |
30 | #include <asm/mach/maple.h> | ||
31 | 30 | ||
32 | /* Very simple mutex to ensure proper cleanup */ | 31 | /* Very simple mutex to ensure proper cleanup */ |
33 | static DEFINE_MUTEX(maple_keyb_mutex); | 32 | static DEFINE_MUTEX(maple_keyb_mutex); |
@@ -46,39 +45,51 @@ struct dc_kbd { | |||
46 | }; | 45 | }; |
47 | 46 | ||
48 | static const unsigned short dc_kbd_keycode[NR_SCANCODES] = { | 47 | static const unsigned short dc_kbd_keycode[NR_SCANCODES] = { |
49 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B, KEY_C, KEY_D, | 48 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B, |
50 | KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, | 49 | KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, |
51 | KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, | 50 | KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, |
52 | KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, | 51 | KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, |
53 | KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, | 52 | KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, |
54 | KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE, | 53 | KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE, |
55 | KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, | 54 | KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON, |
56 | KEY_DOT, KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, | 55 | KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, KEY_DOT, KEY_SLASH, |
56 | KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, | ||
57 | KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_SYSRQ, | 57 | KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_SYSRQ, |
58 | KEY_SCROLLLOCK, KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, | 58 | KEY_SCROLLLOCK, KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP, |
59 | KEY_END, KEY_PAGEDOWN, KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP, | 59 | KEY_DELETE, KEY_END, KEY_PAGEDOWN, KEY_RIGHT, KEY_LEFT, KEY_DOWN, |
60 | KEY_NUMLOCK, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS, KEY_KPENTER, KEY_KP1, KEY_KP2, | 60 | KEY_UP, KEY_NUMLOCK, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, |
61 | KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KP0, KEY_KPDOT, | 61 | KEY_KPPLUS, KEY_KPENTER, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, |
62 | KEY_102ND, KEY_COMPOSE, KEY_POWER, KEY_KPEQUAL, KEY_F13, KEY_F14, KEY_F15, | 62 | KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KP0, KEY_KPDOT, KEY_102ND, |
63 | KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20, | 63 | KEY_COMPOSE, KEY_POWER, KEY_KPEQUAL, KEY_F13, KEY_F14, KEY_F15, |
64 | KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_OPEN, KEY_HELP, KEY_PROPS, KEY_FRONT, | 64 | KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20, KEY_F21, KEY_F22, |
65 | KEY_STOP, KEY_AGAIN, KEY_UNDO, KEY_CUT, KEY_COPY, KEY_PASTE, KEY_FIND, KEY_MUTE, | 65 | KEY_F23, KEY_F24, KEY_OPEN, KEY_HELP, KEY_PROPS, KEY_FRONT, KEY_STOP, |
66 | KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_KPCOMMA, KEY_RESERVED, KEY_RO, KEY_KATAKANAHIRAGANA , KEY_YEN, | 66 | KEY_AGAIN, KEY_UNDO, KEY_CUT, KEY_COPY, KEY_PASTE, KEY_FIND, KEY_MUTE, |
67 | KEY_HENKAN, KEY_MUHENKAN, KEY_KPJPCOMMA, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 67 | KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
68 | KEY_HANGEUL, KEY_HANJA, KEY_KATAKANA, KEY_HIRAGANA, KEY_ZENKAKUHANKAKU, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 68 | KEY_KPCOMMA, KEY_RESERVED, KEY_RO, KEY_KATAKANAHIRAGANA , KEY_YEN, |
69 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 69 | KEY_HENKAN, KEY_MUHENKAN, KEY_KPJPCOMMA, KEY_RESERVED, KEY_RESERVED, |
70 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 70 | KEY_RESERVED, KEY_HANGEUL, KEY_HANJA, KEY_KATAKANA, KEY_HIRAGANA, |
71 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 71 | KEY_ZENKAKUHANKAKU, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
72 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 72 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
73 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 73 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
74 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 74 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
75 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 75 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
76 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 76 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
77 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | 77 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
78 | KEY_LEFTCTRL, KEY_LEFTSHIFT, KEY_LEFTALT, KEY_LEFTMETA, KEY_RIGHTCTRL, KEY_RIGHTSHIFT, KEY_RIGHTALT, KEY_RIGHTMETA, | 78 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
79 | KEY_PLAYPAUSE, KEY_STOPCD, KEY_PREVIOUSSONG, KEY_NEXTSONG, KEY_EJECTCD, KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_MUTE, | 79 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
80 | KEY_WWW, KEY_BACK, KEY_FORWARD, KEY_STOP, KEY_FIND, KEY_SCROLLUP, KEY_SCROLLDOWN, KEY_EDIT, KEY_SLEEP, | 80 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
81 | KEY_SCREENLOCK, KEY_REFRESH, KEY_CALC, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED | 81 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, |
82 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | ||
83 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | ||
84 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | ||
85 | KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, | ||
86 | KEY_RESERVED, KEY_RESERVED, KEY_LEFTCTRL, KEY_LEFTSHIFT, KEY_LEFTALT, | ||
87 | KEY_LEFTMETA, KEY_RIGHTCTRL, KEY_RIGHTSHIFT, KEY_RIGHTALT, | ||
88 | KEY_RIGHTMETA, KEY_PLAYPAUSE, KEY_STOPCD, KEY_PREVIOUSSONG, | ||
89 | KEY_NEXTSONG, KEY_EJECTCD, KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_MUTE, | ||
90 | KEY_WWW, KEY_BACK, KEY_FORWARD, KEY_STOP, KEY_FIND, KEY_SCROLLUP, | ||
91 | KEY_SCROLLDOWN, KEY_EDIT, KEY_SLEEP, KEY_SCREENLOCK, KEY_REFRESH, | ||
92 | KEY_CALC, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED | ||
82 | }; | 93 | }; |
83 | 94 | ||
84 | static void dc_scan_kbd(struct dc_kbd *kbd) | 95 | static void dc_scan_kbd(struct dc_kbd *kbd) |
@@ -128,12 +139,12 @@ static void dc_scan_kbd(struct dc_kbd *kbd) | |||
128 | static void dc_kbd_callback(struct mapleq *mq) | 139 | static void dc_kbd_callback(struct mapleq *mq) |
129 | { | 140 | { |
130 | struct maple_device *mapledev = mq->dev; | 141 | struct maple_device *mapledev = mq->dev; |
131 | struct dc_kbd *kbd = mapledev->private_data; | 142 | struct dc_kbd *kbd = maple_get_drvdata(mapledev); |
132 | unsigned long *buf = mq->recvbuf; | 143 | unsigned long *buf = mq->recvbuf; |
133 | 144 | ||
134 | /* | 145 | /* |
135 | * We should always be getting the lock because the only | 146 | * We should always get the lock because the only |
136 | * time it may be locked if driver is in cleanup phase. | 147 | * time it may be locked is if the driver is in the cleanup phase. |
137 | */ | 148 | */ |
138 | if (likely(mutex_trylock(&maple_keyb_mutex))) { | 149 | if (likely(mutex_trylock(&maple_keyb_mutex))) { |
139 | 150 | ||
@@ -146,106 +157,96 @@ static void dc_kbd_callback(struct mapleq *mq) | |||
146 | } | 157 | } |
147 | } | 158 | } |
148 | 159 | ||
149 | static int dc_kbd_connect(struct maple_device *mdev) | 160 | static int probe_maple_kbd(struct device *dev) |
150 | { | 161 | { |
162 | struct maple_device *mdev = to_maple_dev(dev); | ||
163 | struct maple_driver *mdrv = to_maple_driver(dev->driver); | ||
151 | int i, error; | 164 | int i, error; |
152 | struct dc_kbd *kbd; | 165 | struct dc_kbd *kbd; |
153 | struct input_dev *dev; | 166 | struct input_dev *idev; |
154 | 167 | ||
155 | if (!(mdev->function & MAPLE_FUNC_KEYBOARD)) | 168 | if (!(mdev->function & MAPLE_FUNC_KEYBOARD)) |
156 | return -EINVAL; | 169 | return -EINVAL; |
157 | 170 | ||
158 | kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); | 171 | kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); |
159 | dev = input_allocate_device(); | 172 | idev = input_allocate_device(); |
160 | if (!kbd || !dev) { | 173 | if (!kbd || !idev) { |
161 | error = -ENOMEM; | 174 | error = -ENOMEM; |
162 | goto fail; | 175 | goto fail; |
163 | } | 176 | } |
164 | 177 | ||
165 | mdev->private_data = kbd; | 178 | kbd->dev = idev; |
166 | |||
167 | kbd->dev = dev; | ||
168 | memcpy(kbd->keycode, dc_kbd_keycode, sizeof(kbd->keycode)); | 179 | memcpy(kbd->keycode, dc_kbd_keycode, sizeof(kbd->keycode)); |
169 | 180 | ||
170 | dev->name = mdev->product_name; | 181 | idev->name = mdev->product_name; |
171 | dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 182 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
172 | dev->keycode = kbd->keycode; | 183 | idev->keycode = kbd->keycode; |
173 | dev->keycodesize = sizeof (unsigned short); | 184 | idev->keycodesize = sizeof(unsigned short); |
174 | dev->keycodemax = ARRAY_SIZE(kbd->keycode); | 185 | idev->keycodemax = ARRAY_SIZE(kbd->keycode); |
175 | dev->id.bustype = BUS_HOST; | 186 | idev->id.bustype = BUS_HOST; |
176 | dev->dev.parent = &mdev->dev; | 187 | idev->dev.parent = &mdev->dev; |
177 | 188 | ||
178 | for (i = 0; i < NR_SCANCODES; i++) | 189 | for (i = 0; i < NR_SCANCODES; i++) |
179 | __set_bit(dc_kbd_keycode[i], dev->keybit); | 190 | __set_bit(dc_kbd_keycode[i], idev->keybit); |
180 | __clear_bit(KEY_RESERVED, dev->keybit); | 191 | __clear_bit(KEY_RESERVED, idev->keybit); |
181 | 192 | ||
182 | input_set_capability(dev, EV_MSC, MSC_SCAN); | 193 | input_set_capability(idev, EV_MSC, MSC_SCAN); |
183 | input_set_drvdata(dev, kbd); | 194 | input_set_drvdata(idev, kbd); |
184 | 195 | ||
185 | error = input_register_device(dev); | 196 | error = input_register_device(idev); |
186 | if (error) | 197 | if (error) |
187 | goto fail; | 198 | goto fail; |
188 | 199 | ||
189 | /* Maple polling is locked to VBLANK - which may be just 50/s */ | 200 | /* Maple polling is locked to VBLANK - which may be just 50/s */ |
190 | maple_getcond_callback(mdev, dc_kbd_callback, HZ/50, MAPLE_FUNC_KEYBOARD); | 201 | maple_getcond_callback(mdev, dc_kbd_callback, HZ/50, |
191 | return 0; | 202 | MAPLE_FUNC_KEYBOARD); |
192 | 203 | ||
193 | fail: | 204 | mdev->driver = mdrv; |
194 | input_free_device(dev); | 205 | |
206 | maple_set_drvdata(mdev, kbd); | ||
207 | |||
208 | return error; | ||
209 | |||
210 | fail: | ||
211 | input_free_device(idev); | ||
195 | kfree(kbd); | 212 | kfree(kbd); |
196 | mdev->private_data = NULL; | 213 | maple_set_drvdata(mdev, NULL); |
197 | return error; | 214 | return error; |
198 | } | 215 | } |
199 | 216 | ||
200 | static void dc_kbd_disconnect(struct maple_device *mdev) | 217 | static int remove_maple_kbd(struct device *dev) |
201 | { | 218 | { |
202 | struct dc_kbd *kbd; | 219 | struct maple_device *mdev = to_maple_dev(dev); |
220 | struct dc_kbd *kbd = maple_get_drvdata(mdev); | ||
203 | 221 | ||
204 | mutex_lock(&maple_keyb_mutex); | 222 | mutex_lock(&maple_keyb_mutex); |
205 | 223 | ||
206 | kbd = mdev->private_data; | ||
207 | mdev->private_data = NULL; | ||
208 | input_unregister_device(kbd->dev); | 224 | input_unregister_device(kbd->dev); |
209 | kfree(kbd); | 225 | kfree(kbd); |
210 | 226 | ||
211 | mutex_unlock(&maple_keyb_mutex); | 227 | maple_set_drvdata(mdev, NULL); |
212 | } | ||
213 | |||
214 | /* allow the keyboard to be used */ | ||
215 | static int probe_maple_kbd(struct device *dev) | ||
216 | { | ||
217 | struct maple_device *mdev = to_maple_dev(dev); | ||
218 | struct maple_driver *mdrv = to_maple_driver(dev->driver); | ||
219 | int error; | ||
220 | |||
221 | error = dc_kbd_connect(mdev); | ||
222 | if (error) | ||
223 | return error; | ||
224 | |||
225 | mdev->driver = mdrv; | ||
226 | mdev->registered = 1; | ||
227 | 228 | ||
229 | mutex_unlock(&maple_keyb_mutex); | ||
228 | return 0; | 230 | return 0; |
229 | } | 231 | } |
230 | 232 | ||
231 | static struct maple_driver dc_kbd_driver = { | 233 | static struct maple_driver dc_kbd_driver = { |
232 | .function = MAPLE_FUNC_KEYBOARD, | 234 | .function = MAPLE_FUNC_KEYBOARD, |
233 | .connect = dc_kbd_connect, | ||
234 | .disconnect = dc_kbd_disconnect, | ||
235 | .drv = { | 235 | .drv = { |
236 | .name = "Dreamcast_keyboard", | 236 | .name = "Dreamcast_keyboard", |
237 | .probe = probe_maple_kbd, | 237 | .probe = probe_maple_kbd, |
238 | }, | 238 | .remove = remove_maple_kbd, |
239 | }, | ||
239 | }; | 240 | }; |
240 | 241 | ||
241 | static int __init dc_kbd_init(void) | 242 | static int __init dc_kbd_init(void) |
242 | { | 243 | { |
243 | return maple_driver_register(&dc_kbd_driver.drv); | 244 | return maple_driver_register(&dc_kbd_driver); |
244 | } | 245 | } |
245 | 246 | ||
246 | static void __exit dc_kbd_exit(void) | 247 | static void __exit dc_kbd_exit(void) |
247 | { | 248 | { |
248 | driver_unregister(&dc_kbd_driver.drv); | 249 | maple_driver_unregister(&dc_kbd_driver); |
249 | } | 250 | } |
250 | 251 | ||
251 | module_init(dc_kbd_init); | 252 | module_init(dc_kbd_init); |
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c index 8486abc457ed..c600ab7f93e8 100644 --- a/drivers/input/keyboard/sh_keysc.c +++ b/drivers/input/keyboard/sh_keysc.c | |||
@@ -158,25 +158,18 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
158 | memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); | 158 | memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); |
159 | pdata = &priv->pdata; | 159 | pdata = &priv->pdata; |
160 | 160 | ||
161 | res = request_mem_region(res->start, res_size(res), pdev->name); | ||
162 | if (res == NULL) { | ||
163 | dev_err(&pdev->dev, "failed to request I/O memory\n"); | ||
164 | error = -EBUSY; | ||
165 | goto err1; | ||
166 | } | ||
167 | |||
168 | priv->iomem_base = ioremap_nocache(res->start, res_size(res)); | 161 | priv->iomem_base = ioremap_nocache(res->start, res_size(res)); |
169 | if (priv->iomem_base == NULL) { | 162 | if (priv->iomem_base == NULL) { |
170 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); | 163 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); |
171 | error = -ENXIO; | 164 | error = -ENXIO; |
172 | goto err2; | 165 | goto err1; |
173 | } | 166 | } |
174 | 167 | ||
175 | priv->input = input_allocate_device(); | 168 | priv->input = input_allocate_device(); |
176 | if (!priv->input) { | 169 | if (!priv->input) { |
177 | dev_err(&pdev->dev, "failed to allocate input device\n"); | 170 | dev_err(&pdev->dev, "failed to allocate input device\n"); |
178 | error = -ENOMEM; | 171 | error = -ENOMEM; |
179 | goto err3; | 172 | goto err2; |
180 | } | 173 | } |
181 | 174 | ||
182 | input = priv->input; | 175 | input = priv->input; |
@@ -194,7 +187,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
194 | error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); | 187 | error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); |
195 | if (error) { | 188 | if (error) { |
196 | dev_err(&pdev->dev, "failed to request IRQ\n"); | 189 | dev_err(&pdev->dev, "failed to request IRQ\n"); |
197 | goto err4; | 190 | goto err3; |
198 | } | 191 | } |
199 | 192 | ||
200 | for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { | 193 | for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { |
@@ -206,7 +199,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
206 | error = input_register_device(input); | 199 | error = input_register_device(input); |
207 | if (error) { | 200 | if (error) { |
208 | dev_err(&pdev->dev, "failed to register input device\n"); | 201 | dev_err(&pdev->dev, "failed to register input device\n"); |
209 | goto err5; | 202 | goto err4; |
210 | } | 203 | } |
211 | 204 | ||
212 | iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | | 205 | iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | |
@@ -214,14 +207,12 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
214 | iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); | 207 | iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); |
215 | iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); | 208 | iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); |
216 | return 0; | 209 | return 0; |
217 | err5: | ||
218 | free_irq(irq, pdev); | ||
219 | err4: | 210 | err4: |
220 | input_free_device(input); | 211 | free_irq(irq, pdev); |
221 | err3: | 212 | err3: |
222 | iounmap(priv->iomem_base); | 213 | input_free_device(input); |
223 | err2: | 214 | err2: |
224 | release_mem_region(res->start, res_size(res)); | 215 | iounmap(priv->iomem_base); |
225 | err1: | 216 | err1: |
226 | platform_set_drvdata(pdev, NULL); | 217 | platform_set_drvdata(pdev, NULL); |
227 | kfree(priv); | 218 | kfree(priv); |
@@ -232,7 +223,6 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
232 | static int __devexit sh_keysc_remove(struct platform_device *pdev) | 223 | static int __devexit sh_keysc_remove(struct platform_device *pdev) |
233 | { | 224 | { |
234 | struct sh_keysc_priv *priv = platform_get_drvdata(pdev); | 225 | struct sh_keysc_priv *priv = platform_get_drvdata(pdev); |
235 | struct resource *res; | ||
236 | 226 | ||
237 | iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); | 227 | iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); |
238 | 228 | ||
@@ -240,9 +230,6 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev) | |||
240 | free_irq(platform_get_irq(pdev, 0), pdev); | 230 | free_irq(platform_get_irq(pdev, 0), pdev); |
241 | iounmap(priv->iomem_base); | 231 | iounmap(priv->iomem_base); |
242 | 232 | ||
243 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
244 | release_mem_region(res->start, res_size(res)); | ||
245 | |||
246 | platform_set_drvdata(pdev, NULL); | 233 | platform_set_drvdata(pdev, NULL); |
247 | kfree(priv); | 234 | kfree(priv); |
248 | return 0; | 235 | return 0; |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 2bcfa0b35061..223d56d5555b 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/fs.h> | 37 | #include <linux/fs.h> |
38 | #include <linux/miscdevice.h> | 38 | #include <linux/miscdevice.h> |
39 | #include <linux/uinput.h> | 39 | #include <linux/uinput.h> |
40 | #include <linux/smp_lock.h> | ||
41 | 40 | ||
42 | static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 41 | static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
43 | { | 42 | { |
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 78f2abb5c11b..2f12d60eee3b 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
@@ -63,8 +63,9 @@ static LIST_HEAD(serio_list); | |||
63 | static struct bus_type serio_bus; | 63 | static struct bus_type serio_bus; |
64 | 64 | ||
65 | static void serio_add_port(struct serio *serio); | 65 | static void serio_add_port(struct serio *serio); |
66 | static void serio_reconnect_port(struct serio *serio); | 66 | static int serio_reconnect_port(struct serio *serio); |
67 | static void serio_disconnect_port(struct serio *serio); | 67 | static void serio_disconnect_port(struct serio *serio); |
68 | static void serio_reconnect_chain(struct serio *serio); | ||
68 | static void serio_attach_driver(struct serio_driver *drv); | 69 | static void serio_attach_driver(struct serio_driver *drv); |
69 | 70 | ||
70 | static int serio_connect_driver(struct serio *serio, struct serio_driver *drv) | 71 | static int serio_connect_driver(struct serio *serio, struct serio_driver *drv) |
@@ -161,6 +162,7 @@ static void serio_find_driver(struct serio *serio) | |||
161 | enum serio_event_type { | 162 | enum serio_event_type { |
162 | SERIO_RESCAN_PORT, | 163 | SERIO_RESCAN_PORT, |
163 | SERIO_RECONNECT_PORT, | 164 | SERIO_RECONNECT_PORT, |
165 | SERIO_RECONNECT_CHAIN, | ||
164 | SERIO_REGISTER_PORT, | 166 | SERIO_REGISTER_PORT, |
165 | SERIO_ATTACH_DRIVER, | 167 | SERIO_ATTACH_DRIVER, |
166 | }; | 168 | }; |
@@ -315,6 +317,10 @@ static void serio_handle_event(void) | |||
315 | serio_find_driver(event->object); | 317 | serio_find_driver(event->object); |
316 | break; | 318 | break; |
317 | 319 | ||
320 | case SERIO_RECONNECT_CHAIN: | ||
321 | serio_reconnect_chain(event->object); | ||
322 | break; | ||
323 | |||
318 | case SERIO_ATTACH_DRIVER: | 324 | case SERIO_ATTACH_DRIVER: |
319 | serio_attach_driver(event->object); | 325 | serio_attach_driver(event->object); |
320 | break; | 326 | break; |
@@ -470,7 +476,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute * | |||
470 | if (!strncmp(buf, "none", count)) { | 476 | if (!strncmp(buf, "none", count)) { |
471 | serio_disconnect_port(serio); | 477 | serio_disconnect_port(serio); |
472 | } else if (!strncmp(buf, "reconnect", count)) { | 478 | } else if (!strncmp(buf, "reconnect", count)) { |
473 | serio_reconnect_port(serio); | 479 | serio_reconnect_chain(serio); |
474 | } else if (!strncmp(buf, "rescan", count)) { | 480 | } else if (!strncmp(buf, "rescan", count)) { |
475 | serio_disconnect_port(serio); | 481 | serio_disconnect_port(serio); |
476 | serio_find_driver(serio); | 482 | serio_find_driver(serio); |
@@ -620,14 +626,30 @@ static void serio_destroy_port(struct serio *serio) | |||
620 | } | 626 | } |
621 | 627 | ||
622 | /* | 628 | /* |
629 | * Reconnect serio port (re-initialize attached device). | ||
630 | * If reconnect fails (old device is no longer attached or | ||
631 | * there was no device to begin with) we do full rescan in | ||
632 | * hope of finding a driver for the port. | ||
633 | */ | ||
634 | static int serio_reconnect_port(struct serio *serio) | ||
635 | { | ||
636 | int error = serio_reconnect_driver(serio); | ||
637 | |||
638 | if (error) { | ||
639 | serio_disconnect_port(serio); | ||
640 | serio_find_driver(serio); | ||
641 | } | ||
642 | |||
643 | return error; | ||
644 | } | ||
645 | |||
646 | /* | ||
623 | * Reconnect serio port and all its children (re-initialize attached devices) | 647 | * Reconnect serio port and all its children (re-initialize attached devices) |
624 | */ | 648 | */ |
625 | static void serio_reconnect_port(struct serio *serio) | 649 | static void serio_reconnect_chain(struct serio *serio) |
626 | { | 650 | { |
627 | do { | 651 | do { |
628 | if (serio_reconnect_driver(serio)) { | 652 | if (serio_reconnect_port(serio)) { |
629 | serio_disconnect_port(serio); | ||
630 | serio_find_driver(serio); | ||
631 | /* Ok, old children are now gone, we are done */ | 653 | /* Ok, old children are now gone, we are done */ |
632 | break; | 654 | break; |
633 | } | 655 | } |
@@ -673,7 +695,7 @@ void serio_rescan(struct serio *serio) | |||
673 | 695 | ||
674 | void serio_reconnect(struct serio *serio) | 696 | void serio_reconnect(struct serio *serio) |
675 | { | 697 | { |
676 | serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT); | 698 | serio_queue_event(serio, NULL, SERIO_RECONNECT_CHAIN); |
677 | } | 699 | } |
678 | 700 | ||
679 | /* | 701 | /* |
@@ -927,19 +949,16 @@ static int serio_suspend(struct device *dev, pm_message_t state) | |||
927 | 949 | ||
928 | static int serio_resume(struct device *dev) | 950 | static int serio_resume(struct device *dev) |
929 | { | 951 | { |
930 | struct serio *serio = to_serio_port(dev); | 952 | /* |
931 | 953 | * Driver reconnect can take a while, so better let kseriod | |
932 | if (dev->power.power_state.event != PM_EVENT_ON && | 954 | * deal with it. |
933 | serio_reconnect_driver(serio)) { | 955 | */ |
934 | /* | 956 | if (dev->power.power_state.event != PM_EVENT_ON) { |
935 | * Driver re-probing can take a while, so better let kseriod | 957 | dev->power.power_state = PMSG_ON; |
936 | * deal with it. | 958 | serio_queue_event(to_serio_port(dev), NULL, |
937 | */ | 959 | SERIO_RECONNECT_PORT); |
938 | serio_rescan(serio); | ||
939 | } | 960 | } |
940 | 961 | ||
941 | dev->power.power_state = PMSG_ON; | ||
942 | |||
943 | return 0; | 962 | return 0; |
944 | } | 963 | } |
945 | #endif /* CONFIG_PM */ | 964 | #endif /* CONFIG_PM */ |
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index e57366521572..6e60a97a234c 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -205,6 +205,18 @@ config TOUCHSCREEN_TOUCHWIN | |||
205 | To compile this driver as a module, choose M here: the | 205 | To compile this driver as a module, choose M here: the |
206 | module will be called touchwin. | 206 | module will be called touchwin. |
207 | 207 | ||
208 | config TOUCHSCREEN_ATMEL_TSADCC | ||
209 | tristate "Atmel Touchscreen Interface" | ||
210 | depends on ARCH_AT91SAM9RL | ||
211 | help | ||
212 | Say Y here if you have a 4-wire touchscreen connected to the | ||
213 | ADC Controller on your Atmel SoC (such as the AT91SAM9RL). | ||
214 | |||
215 | If unsure, say N. | ||
216 | |||
217 | To compile this driver as a module, choose M here: the | ||
218 | module will be called atmel_tsadcc. | ||
219 | |||
208 | config TOUCHSCREEN_UCB1400 | 220 | config TOUCHSCREEN_UCB1400 |
209 | tristate "Philips UCB1400 touchscreen" | 221 | tristate "Philips UCB1400 touchscreen" |
210 | select AC97_BUS | 222 | select AC97_BUS |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 39a804cd80f1..15cf29079489 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -7,6 +7,7 @@ | |||
7 | wm97xx-ts-y := wm97xx-core.o | 7 | wm97xx-ts-y := wm97xx-core.o |
8 | 8 | ||
9 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o | 9 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o |
10 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o | ||
10 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o | 11 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o |
11 | obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o | 12 | obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o |
12 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o | 13 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 907a45fe9d40..ce6f48c695f5 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -517,7 +517,9 @@ static void ads7846_rx(void *ads) | |||
517 | if (x == MAX_12BIT) | 517 | if (x == MAX_12BIT) |
518 | x = 0; | 518 | x = 0; |
519 | 519 | ||
520 | if (likely(x && z1)) { | 520 | if (ts->model == 7843) { |
521 | Rt = ts->pressure_max / 2; | ||
522 | } else if (likely(x && z1)) { | ||
521 | /* compute touch pressure resistance using equation #2 */ | 523 | /* compute touch pressure resistance using equation #2 */ |
522 | Rt = z2; | 524 | Rt = z2; |
523 | Rt -= z1; | 525 | Rt -= z1; |
@@ -525,11 +527,9 @@ static void ads7846_rx(void *ads) | |||
525 | Rt *= ts->x_plate_ohms; | 527 | Rt *= ts->x_plate_ohms; |
526 | Rt /= z1; | 528 | Rt /= z1; |
527 | Rt = (Rt + 2047) >> 12; | 529 | Rt = (Rt + 2047) >> 12; |
528 | } else | 530 | } else { |
529 | Rt = 0; | 531 | Rt = 0; |
530 | 532 | } | |
531 | if (ts->model == 7843) | ||
532 | Rt = ts->pressure_max / 2; | ||
533 | 533 | ||
534 | /* Sample found inconsistent by debouncing or pressure is beyond | 534 | /* Sample found inconsistent by debouncing or pressure is beyond |
535 | * the maximum. Don't report it to user space, repeat at least | 535 | * the maximum. Don't report it to user space, repeat at least |
@@ -633,19 +633,17 @@ static void ads7846_rx_val(void *ads) | |||
633 | struct ads7846 *ts = ads; | 633 | struct ads7846 *ts = ads; |
634 | struct spi_message *m; | 634 | struct spi_message *m; |
635 | struct spi_transfer *t; | 635 | struct spi_transfer *t; |
636 | u16 *rx_val; | ||
637 | int val; | 636 | int val; |
638 | int action; | 637 | int action; |
639 | int status; | 638 | int status; |
640 | 639 | ||
641 | m = &ts->msg[ts->msg_idx]; | 640 | m = &ts->msg[ts->msg_idx]; |
642 | t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list); | 641 | t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list); |
643 | rx_val = t->rx_buf; | ||
644 | 642 | ||
645 | /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding; | 643 | /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding; |
646 | * built from two 8 bit values written msb-first. | 644 | * built from two 8 bit values written msb-first. |
647 | */ | 645 | */ |
648 | val = be16_to_cpu(*rx_val) >> 3; | 646 | val = be16_to_cpup((__be16 *)t->rx_buf) >> 3; |
649 | 647 | ||
650 | action = ts->filter(ts->filter_data, ts->msg_idx, &val); | 648 | action = ts->filter(ts->filter_data, ts->msg_idx, &val); |
651 | switch (action) { | 649 | switch (action) { |
@@ -659,7 +657,7 @@ static void ads7846_rx_val(void *ads) | |||
659 | m = ts->last_msg; | 657 | m = ts->last_msg; |
660 | break; | 658 | break; |
661 | case ADS7846_FILTER_OK: | 659 | case ADS7846_FILTER_OK: |
662 | *rx_val = val; | 660 | *(u16 *)t->rx_buf = val; |
663 | ts->tc.ignore = 0; | 661 | ts->tc.ignore = 0; |
664 | m = &ts->msg[++ts->msg_idx]; | 662 | m = &ts->msg[++ts->msg_idx]; |
665 | break; | 663 | break; |
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c new file mode 100644 index 000000000000..eee126b19e8b --- /dev/null +++ b/drivers/input/touchscreen/atmel_tsadcc.c | |||
@@ -0,0 +1,332 @@ | |||
1 | /* | ||
2 | * Atmel Touch Screen Driver | ||
3 | * | ||
4 | * Copyright (c) 2008 ATMEL | ||
5 | * Copyright (c) 2008 Dan Liang | ||
6 | * Copyright (c) 2008 TimeSys Corporation | ||
7 | * Copyright (c) 2008 Justin Waters | ||
8 | * | ||
9 | * Based on touchscreen code from Atmel Corporation. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/input.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/io.h> | ||
25 | |||
26 | /* Register definitions based on AT91SAM9RL64 preliminary draft datasheet */ | ||
27 | |||
28 | #define ATMEL_TSADCC_CR 0x00 /* Control register */ | ||
29 | #define ATMEL_TSADCC_SWRST (1 << 0) /* Software Reset*/ | ||
30 | #define ATMEL_TSADCC_START (1 << 1) /* Start conversion */ | ||
31 | |||
32 | #define ATMEL_TSADCC_MR 0x04 /* Mode register */ | ||
33 | #define ATMEL_TSADCC_TSAMOD (3 << 0) /* ADC mode */ | ||
34 | #define ATMEL_TSADCC_TSAMOD_ADC_ONLY_MODE (0x0) /* ADC Mode */ | ||
35 | #define ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE (0x1) /* Touch Screen Only Mode */ | ||
36 | #define ATMEL_TSADCC_LOWRES (1 << 4) /* Resolution selection */ | ||
37 | #define ATMEL_TSADCC_SLEEP (1 << 5) /* Sleep mode */ | ||
38 | #define ATMEL_TSADCC_PENDET (1 << 6) /* Pen Detect selection */ | ||
39 | #define ATMEL_TSADCC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */ | ||
40 | #define ATMEL_TSADCC_STARTUP (0x7f << 16) /* Start Up time */ | ||
41 | #define ATMEL_TSADCC_SHTIM (0xf << 24) /* Sample & Hold time */ | ||
42 | #define ATMEL_TSADCC_PENDBC (0xf << 28) /* Pen Detect debouncing time */ | ||
43 | |||
44 | #define ATMEL_TSADCC_TRGR 0x08 /* Trigger register */ | ||
45 | #define ATMEL_TSADCC_TRGMOD (7 << 0) /* Trigger mode */ | ||
46 | #define ATMEL_TSADCC_TRGMOD_NONE (0 << 0) | ||
47 | #define ATMEL_TSADCC_TRGMOD_EXT_RISING (1 << 0) | ||
48 | #define ATMEL_TSADCC_TRGMOD_EXT_FALLING (2 << 0) | ||
49 | #define ATMEL_TSADCC_TRGMOD_EXT_ANY (3 << 0) | ||
50 | #define ATMEL_TSADCC_TRGMOD_PENDET (4 << 0) | ||
51 | #define ATMEL_TSADCC_TRGMOD_PERIOD (5 << 0) | ||
52 | #define ATMEL_TSADCC_TRGMOD_CONTINUOUS (6 << 0) | ||
53 | #define ATMEL_TSADCC_TRGPER (0xffff << 16) /* Trigger period */ | ||
54 | |||
55 | #define ATMEL_TSADCC_TSR 0x0C /* Touch Screen register */ | ||
56 | #define ATMEL_TSADCC_TSFREQ (0xf << 0) /* TS Frequency in Interleaved mode */ | ||
57 | #define ATMEL_TSADCC_TSSHTIM (0xf << 24) /* Sample & Hold time */ | ||
58 | |||
59 | #define ATMEL_TSADCC_CHER 0x10 /* Channel Enable register */ | ||
60 | #define ATMEL_TSADCC_CHDR 0x14 /* Channel Disable register */ | ||
61 | #define ATMEL_TSADCC_CHSR 0x18 /* Channel Status register */ | ||
62 | #define ATMEL_TSADCC_CH(n) (1 << (n)) /* Channel number */ | ||
63 | |||
64 | #define ATMEL_TSADCC_SR 0x1C /* Status register */ | ||
65 | #define ATMEL_TSADCC_EOC(n) (1 << ((n)+0)) /* End of conversion for channel N */ | ||
66 | #define ATMEL_TSADCC_OVRE(n) (1 << ((n)+8)) /* Overrun error for channel N */ | ||
67 | #define ATMEL_TSADCC_DRDY (1 << 16) /* Data Ready */ | ||
68 | #define ATMEL_TSADCC_GOVRE (1 << 17) /* General Overrun Error */ | ||
69 | #define ATMEL_TSADCC_ENDRX (1 << 18) /* End of RX Buffer */ | ||
70 | #define ATMEL_TSADCC_RXBUFF (1 << 19) /* TX Buffer full */ | ||
71 | #define ATMEL_TSADCC_PENCNT (1 << 20) /* Pen contact */ | ||
72 | #define ATMEL_TSADCC_NOCNT (1 << 21) /* No contact */ | ||
73 | |||
74 | #define ATMEL_TSADCC_LCDR 0x20 /* Last Converted Data register */ | ||
75 | #define ATMEL_TSADCC_DATA (0x3ff << 0) /* Channel data */ | ||
76 | |||
77 | #define ATMEL_TSADCC_IER 0x24 /* Interrupt Enable register */ | ||
78 | #define ATMEL_TSADCC_IDR 0x28 /* Interrupt Disable register */ | ||
79 | #define ATMEL_TSADCC_IMR 0x2C /* Interrupt Mask register */ | ||
80 | #define ATMEL_TSADCC_CDR0 0x30 /* Channel Data 0 */ | ||
81 | #define ATMEL_TSADCC_CDR1 0x34 /* Channel Data 1 */ | ||
82 | #define ATMEL_TSADCC_CDR2 0x38 /* Channel Data 2 */ | ||
83 | #define ATMEL_TSADCC_CDR3 0x3C /* Channel Data 3 */ | ||
84 | #define ATMEL_TSADCC_CDR4 0x40 /* Channel Data 4 */ | ||
85 | #define ATMEL_TSADCC_CDR5 0x44 /* Channel Data 5 */ | ||
86 | |||
87 | #define ADC_CLOCK 1000000 | ||
88 | |||
89 | struct atmel_tsadcc { | ||
90 | struct input_dev *input; | ||
91 | char phys[32]; | ||
92 | struct clk *clk; | ||
93 | int irq; | ||
94 | }; | ||
95 | |||
96 | static void __iomem *tsc_base; | ||
97 | |||
98 | #define atmel_tsadcc_read(reg) __raw_readl(tsc_base + (reg)) | ||
99 | #define atmel_tsadcc_write(reg, val) __raw_writel((val), tsc_base + (reg)) | ||
100 | |||
101 | static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev) | ||
102 | { | ||
103 | struct input_dev *input_dev = ((struct atmel_tsadcc *)dev)->input; | ||
104 | |||
105 | unsigned int absx; | ||
106 | unsigned int absy; | ||
107 | unsigned int status; | ||
108 | unsigned int reg; | ||
109 | |||
110 | status = atmel_tsadcc_read(ATMEL_TSADCC_SR); | ||
111 | status &= atmel_tsadcc_read(ATMEL_TSADCC_IMR); | ||
112 | |||
113 | if (status & ATMEL_TSADCC_NOCNT) { | ||
114 | /* Contact lost */ | ||
115 | reg = atmel_tsadcc_read(ATMEL_TSADCC_MR) | ATMEL_TSADCC_PENDBC; | ||
116 | |||
117 | atmel_tsadcc_write(ATMEL_TSADCC_MR, reg); | ||
118 | atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE); | ||
119 | atmel_tsadcc_write(ATMEL_TSADCC_IDR, | ||
120 | ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT); | ||
121 | atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); | ||
122 | |||
123 | input_report_key(input_dev, BTN_TOUCH, 0); | ||
124 | input_sync(input_dev); | ||
125 | |||
126 | } else if (status & ATMEL_TSADCC_PENCNT) { | ||
127 | /* Pen detected */ | ||
128 | reg = atmel_tsadcc_read(ATMEL_TSADCC_MR); | ||
129 | reg &= ~ATMEL_TSADCC_PENDBC; | ||
130 | |||
131 | atmel_tsadcc_write(ATMEL_TSADCC_IDR, ATMEL_TSADCC_PENCNT); | ||
132 | atmel_tsadcc_write(ATMEL_TSADCC_MR, reg); | ||
133 | atmel_tsadcc_write(ATMEL_TSADCC_IER, | ||
134 | ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT); | ||
135 | atmel_tsadcc_write(ATMEL_TSADCC_TRGR, | ||
136 | ATMEL_TSADCC_TRGMOD_PERIOD | (0x0FFF << 16)); | ||
137 | |||
138 | } else if (status & ATMEL_TSADCC_EOC(3)) { | ||
139 | /* Conversion finished */ | ||
140 | |||
141 | absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10; | ||
142 | absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2); | ||
143 | |||
144 | absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10; | ||
145 | absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0); | ||
146 | |||
147 | input_report_abs(input_dev, ABS_X, absx); | ||
148 | input_report_abs(input_dev, ABS_Y, absy); | ||
149 | input_report_key(input_dev, BTN_TOUCH, 1); | ||
150 | input_sync(input_dev); | ||
151 | } | ||
152 | |||
153 | return IRQ_HANDLED; | ||
154 | } | ||
155 | |||
156 | /* | ||
157 | * The functions for inserting/removing us as a module. | ||
158 | */ | ||
159 | |||
160 | static int __devinit atmel_tsadcc_probe(struct platform_device *pdev) | ||
161 | { | ||
162 | struct atmel_tsadcc *ts_dev; | ||
163 | struct input_dev *input_dev; | ||
164 | struct resource *res; | ||
165 | int err = 0; | ||
166 | unsigned int prsc; | ||
167 | unsigned int reg; | ||
168 | |||
169 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
170 | if (!res) { | ||
171 | dev_err(&pdev->dev, "no mmio resource defined.\n"); | ||
172 | return -ENXIO; | ||
173 | } | ||
174 | |||
175 | /* Allocate memory for device */ | ||
176 | ts_dev = kzalloc(sizeof(struct atmel_tsadcc), GFP_KERNEL); | ||
177 | if (!ts_dev) { | ||
178 | dev_err(&pdev->dev, "failed to allocate memory.\n"); | ||
179 | return -ENOMEM; | ||
180 | } | ||
181 | platform_set_drvdata(pdev, ts_dev); | ||
182 | |||
183 | input_dev = input_allocate_device(); | ||
184 | if (!input_dev) { | ||
185 | dev_err(&pdev->dev, "failed to allocate input device.\n"); | ||
186 | err = -EBUSY; | ||
187 | goto err_free_mem; | ||
188 | } | ||
189 | |||
190 | ts_dev->irq = platform_get_irq(pdev, 0); | ||
191 | if (ts_dev->irq < 0) { | ||
192 | dev_err(&pdev->dev, "no irq ID is designated.\n"); | ||
193 | err = -ENODEV; | ||
194 | goto err_free_dev; | ||
195 | } | ||
196 | |||
197 | if (!request_mem_region(res->start, res->end - res->start + 1, | ||
198 | "atmel tsadcc regs")) { | ||
199 | dev_err(&pdev->dev, "resources is unavailable.\n"); | ||
200 | err = -EBUSY; | ||
201 | goto err_free_dev; | ||
202 | } | ||
203 | |||
204 | tsc_base = ioremap(res->start, res->end - res->start + 1); | ||
205 | if (!tsc_base) { | ||
206 | dev_err(&pdev->dev, "failed to map registers.\n"); | ||
207 | err = -ENOMEM; | ||
208 | goto err_release_mem; | ||
209 | } | ||
210 | |||
211 | err = request_irq(ts_dev->irq, atmel_tsadcc_interrupt, IRQF_DISABLED, | ||
212 | pdev->dev.driver->name, ts_dev); | ||
213 | if (err) { | ||
214 | dev_err(&pdev->dev, "failed to allocate irq.\n"); | ||
215 | goto err_unmap_regs; | ||
216 | } | ||
217 | |||
218 | ts_dev->clk = clk_get(&pdev->dev, "tsc_clk"); | ||
219 | if (IS_ERR(ts_dev->clk)) { | ||
220 | dev_err(&pdev->dev, "failed to get ts_clk\n"); | ||
221 | err = PTR_ERR(ts_dev->clk); | ||
222 | goto err_free_irq; | ||
223 | } | ||
224 | |||
225 | ts_dev->input = input_dev; | ||
226 | |||
227 | snprintf(ts_dev->phys, sizeof(ts_dev->phys), | ||
228 | "%s/input0", pdev->dev.bus_id); | ||
229 | |||
230 | input_dev->name = "atmel touch screen controller"; | ||
231 | input_dev->phys = ts_dev->phys; | ||
232 | input_dev->dev.parent = &pdev->dev; | ||
233 | |||
234 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
235 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
236 | |||
237 | input_set_abs_params(input_dev, ABS_X, 0, 0x3FF, 0, 0); | ||
238 | input_set_abs_params(input_dev, ABS_Y, 0, 0x3FF, 0, 0); | ||
239 | |||
240 | /* clk_enable() always returns 0, no need to check it */ | ||
241 | clk_enable(ts_dev->clk); | ||
242 | |||
243 | prsc = clk_get_rate(ts_dev->clk); | ||
244 | dev_info(&pdev->dev, "Master clock is set at: %d Hz\n", prsc); | ||
245 | |||
246 | prsc = prsc / ADC_CLOCK / 2 - 1; | ||
247 | |||
248 | reg = ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE | | ||
249 | ((0x00 << 5) & ATMEL_TSADCC_SLEEP) | /* Normal Mode */ | ||
250 | ((0x01 << 6) & ATMEL_TSADCC_PENDET) | /* Enable Pen Detect */ | ||
251 | ((prsc << 8) & ATMEL_TSADCC_PRESCAL) | /* PRESCAL */ | ||
252 | ((0x13 << 16) & ATMEL_TSADCC_STARTUP) | /* STARTUP */ | ||
253 | ((0x0F << 28) & ATMEL_TSADCC_PENDBC); /* PENDBC */ | ||
254 | |||
255 | atmel_tsadcc_write(ATMEL_TSADCC_CR, ATMEL_TSADCC_SWRST); | ||
256 | atmel_tsadcc_write(ATMEL_TSADCC_MR, reg); | ||
257 | atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE); | ||
258 | atmel_tsadcc_write(ATMEL_TSADCC_TSR, (0x3 << 24) & ATMEL_TSADCC_TSSHTIM); | ||
259 | |||
260 | atmel_tsadcc_read(ATMEL_TSADCC_SR); | ||
261 | atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); | ||
262 | |||
263 | /* All went ok, so register to the input system */ | ||
264 | err = input_register_device(input_dev); | ||
265 | if (err) | ||
266 | goto err_fail; | ||
267 | |||
268 | return 0; | ||
269 | |||
270 | err_fail: | ||
271 | clk_disable(ts_dev->clk); | ||
272 | clk_put(ts_dev->clk); | ||
273 | err_free_irq: | ||
274 | free_irq(ts_dev->irq, ts_dev); | ||
275 | err_unmap_regs: | ||
276 | iounmap(tsc_base); | ||
277 | err_release_mem: | ||
278 | release_mem_region(res->start, res->end - res->start + 1); | ||
279 | err_free_dev: | ||
280 | input_free_device(ts_dev->input); | ||
281 | err_free_mem: | ||
282 | kfree(ts_dev); | ||
283 | return err; | ||
284 | } | ||
285 | |||
286 | static int __devexit atmel_tsadcc_remove(struct platform_device *pdev) | ||
287 | { | ||
288 | struct atmel_tsadcc *ts_dev = dev_get_drvdata(&pdev->dev); | ||
289 | struct resource *res; | ||
290 | |||
291 | free_irq(ts_dev->irq, ts_dev); | ||
292 | |||
293 | input_unregister_device(ts_dev->input); | ||
294 | |||
295 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
296 | iounmap(tsc_base); | ||
297 | release_mem_region(res->start, res->end - res->start + 1); | ||
298 | |||
299 | clk_disable(ts_dev->clk); | ||
300 | clk_put(ts_dev->clk); | ||
301 | |||
302 | kfree(ts_dev); | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static struct platform_driver atmel_tsadcc_driver = { | ||
308 | .probe = atmel_tsadcc_probe, | ||
309 | .remove = __devexit_p(atmel_tsadcc_remove), | ||
310 | .driver = { | ||
311 | .name = "atmel_tsadcc", | ||
312 | }, | ||
313 | }; | ||
314 | |||
315 | static int __init atmel_tsadcc_init(void) | ||
316 | { | ||
317 | return platform_driver_register(&atmel_tsadcc_driver); | ||
318 | } | ||
319 | |||
320 | static void __exit atmel_tsadcc_exit(void) | ||
321 | { | ||
322 | platform_driver_unregister(&atmel_tsadcc_driver); | ||
323 | } | ||
324 | |||
325 | module_init(atmel_tsadcc_init); | ||
326 | module_exit(atmel_tsadcc_exit); | ||
327 | |||
328 | |||
329 | MODULE_LICENSE("GPL"); | ||
330 | MODULE_DESCRIPTION("Atmel TouchScreen Driver"); | ||
331 | MODULE_AUTHOR("Dan Liang <dan.liang@atmel.com>"); | ||
332 | |||