aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2008-04-02 00:42:42 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-04-02 00:42:42 -0400
commite6cdd15629a5a99d805fa3cbf0f5174bcfc685bb (patch)
tree7776d522648ad053ca62587dfc5f0d373ddad1c5 /drivers/input
parent3797fec17193e05dee9666b990d6c84e16b188b3 (diff)
Input: locomokbd - add 'off' button support for Sharp Collie/Poodle
Enables the Sharp Zaurus Collie and Poodle devices to be turned off by pressing the "Cancel" button for a few seconds (as designed by Sharp). Additional small cleanups: - removal of unused #defines and variables - add missing __devinit/__devexit/__devinitconst annotations - reorganized copyright notice Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/locomokbd.c73
1 files changed, 48 insertions, 25 deletions
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index 5a0ca18d6755..9caed30f3bbb 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -1,14 +1,12 @@
1/* 1/*
2 * Copyright (c) 2005 John Lenz 2 * LoCoMo keyboard driver for Linux-based ARM PDAs:
3 * - SHARP Zaurus Collie (SL-5500)
4 * - SHARP Zaurus Poodle (SL-5600)
3 * 5 *
6 * Copyright (c) 2005 John Lenz
4 * Based on from xtkbd.c 7 * Based on from xtkbd.c
5 */ 8 *
6 9 *
7/*
8 * LoCoMo keyboard driver for Linux/ARM
9 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
@@ -47,7 +45,8 @@ MODULE_LICENSE("GPL");
47#define KEY_CONTACT KEY_F18 45#define KEY_CONTACT KEY_F18
48#define KEY_CENTER KEY_F15 46#define KEY_CENTER KEY_F15
49 47
50static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = { 48static const unsigned char
49locomokbd_keycode[LOCOMOKBD_NUMKEYS] __devinitconst = {
51 0, KEY_ESC, KEY_ACTIVITY, 0, 0, 0, 0, 0, 0, 0, /* 0 - 9 */ 50 0, KEY_ESC, KEY_ACTIVITY, 0, 0, 0, 0, 0, 0, 0, /* 0 - 9 */
52 0, 0, 0, 0, 0, 0, 0, KEY_MENU, KEY_HOME, KEY_CONTACT, /* 10 - 19 */ 51 0, 0, 0, 0, 0, 0, 0, KEY_MENU, KEY_HOME, KEY_CONTACT, /* 10 - 19 */
53 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20 - 29 */ 52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20 - 29 */
@@ -67,22 +66,21 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
67#define KB_COLS 8 66#define KB_COLS 8
68#define KB_ROWMASK(r) (1 << (r)) 67#define KB_ROWMASK(r) (1 << (r))
69#define SCANCODE(c,r) ( ((c)<<4) + (r) + 1 ) 68#define SCANCODE(c,r) ( ((c)<<4) + (r) + 1 )
70#define NR_SCANCODES 128
71 69
72#define KB_DELAY 8 70#define KB_DELAY 8
73#define SCAN_INTERVAL (HZ/10) 71#define SCAN_INTERVAL (HZ/10)
74#define LOCOMOKBD_PRESSED 1
75 72
76struct locomokbd { 73struct locomokbd {
77 unsigned char keycode[LOCOMOKBD_NUMKEYS]; 74 unsigned char keycode[LOCOMOKBD_NUMKEYS];
78 struct input_dev *input; 75 struct input_dev *input;
79 char phys[32]; 76 char phys[32];
80 77
81 struct locomo_dev *ldev;
82 unsigned long base; 78 unsigned long base;
83 spinlock_t lock; 79 spinlock_t lock;
84 80
85 struct timer_list timer; 81 struct timer_list timer;
82 unsigned long suspend_jiffies;
83 unsigned int count_cancel;
86}; 84};
87 85
88/* helper functions for reading the keyboard matrix */ 86/* helper functions for reading the keyboard matrix */
@@ -128,7 +126,7 @@ static inline void locomokbd_reset_col(unsigned long membase, int col)
128/* Scan the hardware keyboard and push any changes up through the input layer */ 126/* Scan the hardware keyboard and push any changes up through the input layer */
129static void locomokbd_scankeyboard(struct locomokbd *locomokbd) 127static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
130{ 128{
131 unsigned int row, col, rowd, scancode; 129 unsigned int row, col, rowd;
132 unsigned long flags; 130 unsigned long flags;
133 unsigned int num_pressed; 131 unsigned int num_pressed;
134 unsigned long membase = locomokbd->base; 132 unsigned long membase = locomokbd->base;
@@ -145,13 +143,33 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
145 143
146 rowd = ~locomo_readl(membase + LOCOMO_KIB); 144 rowd = ~locomo_readl(membase + LOCOMO_KIB);
147 for (row = 0; row < KB_ROWS; row++) { 145 for (row = 0; row < KB_ROWS; row++) {
146 unsigned int scancode, pressed, key;
147
148 scancode = SCANCODE(col, row); 148 scancode = SCANCODE(col, row);
149 if (rowd & KB_ROWMASK(row)) { 149 pressed = rowd & KB_ROWMASK(row);
150 num_pressed += 1; 150 key = locomokbd->keycode[scancode];
151 input_report_key(locomokbd->input, locomokbd->keycode[scancode], 1); 151
152 } else { 152 input_report_key(locomokbd->input, key, pressed);
153 input_report_key(locomokbd->input, locomokbd->keycode[scancode], 0); 153 if (likely(!pressed))
154 } 154 continue;
155
156 num_pressed++;
157
158 /* The "Cancel/ESC" key is labeled "On/Off" on
159 * Collie and Poodle and should suspend the device
160 * if it was pressed for more than a second. */
161 if (unlikely(key == KEY_ESC)) {
162 if (!time_after(jiffies,
163 locomokbd->suspend_jiffies + HZ))
164 continue;
165 if (locomokbd->count_cancel++
166 != (HZ/SCAN_INTERVAL + 1))
167 continue;
168 input_event(locomokbd->input, EV_PWR,
169 KEY_SUSPEND, 1);
170 locomokbd->suspend_jiffies = jiffies;
171 } else
172 locomokbd->count_cancel = 0;
155 } 173 }
156 locomokbd_reset_col(membase, col); 174 locomokbd_reset_col(membase, col);
157 } 175 }
@@ -162,6 +180,8 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
162 /* if any keys are pressed, enable the timer */ 180 /* if any keys are pressed, enable the timer */
163 if (num_pressed) 181 if (num_pressed)
164 mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL); 182 mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL);
183 else
184 locomokbd->count_cancel = 0;
165 185
166 spin_unlock_irqrestore(&locomokbd->lock, flags); 186 spin_unlock_irqrestore(&locomokbd->lock, flags);
167} 187}
@@ -186,10 +206,11 @@ static irqreturn_t locomokbd_interrupt(int irq, void *dev_id)
186static void locomokbd_timer_callback(unsigned long data) 206static void locomokbd_timer_callback(unsigned long data)
187{ 207{
188 struct locomokbd *locomokbd = (struct locomokbd *) data; 208 struct locomokbd *locomokbd = (struct locomokbd *) data;
209
189 locomokbd_scankeyboard(locomokbd); 210 locomokbd_scankeyboard(locomokbd);
190} 211}
191 212
192static int locomokbd_probe(struct locomo_dev *dev) 213static int __devinit locomokbd_probe(struct locomo_dev *dev)
193{ 214{
194 struct locomokbd *locomokbd; 215 struct locomokbd *locomokbd;
195 struct input_dev *input_dev; 216 struct input_dev *input_dev;
@@ -211,7 +232,6 @@ static int locomokbd_probe(struct locomo_dev *dev)
211 goto err_free_mem; 232 goto err_free_mem;
212 } 233 }
213 234
214 locomokbd->ldev = dev;
215 locomo_set_drvdata(dev, locomokbd); 235 locomo_set_drvdata(dev, locomokbd);
216 236
217 locomokbd->base = (unsigned long) dev->mapbase; 237 locomokbd->base = (unsigned long) dev->mapbase;
@@ -222,6 +242,8 @@ static int locomokbd_probe(struct locomo_dev *dev)
222 locomokbd->timer.function = locomokbd_timer_callback; 242 locomokbd->timer.function = locomokbd_timer_callback;
223 locomokbd->timer.data = (unsigned long) locomokbd; 243 locomokbd->timer.data = (unsigned long) locomokbd;
224 244
245 locomokbd->suspend_jiffies = jiffies;
246
225 locomokbd->input = input_dev; 247 locomokbd->input = input_dev;
226 strcpy(locomokbd->phys, "locomokbd/input0"); 248 strcpy(locomokbd->phys, "locomokbd/input0");
227 249
@@ -233,9 +255,10 @@ static int locomokbd_probe(struct locomo_dev *dev)
233 input_dev->id.version = 0x0100; 255 input_dev->id.version = 0x0100;
234 input_dev->dev.parent = &dev->dev; 256 input_dev->dev.parent = &dev->dev;
235 257
236 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 258 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
259 BIT_MASK(EV_PWR);
237 input_dev->keycode = locomokbd->keycode; 260 input_dev->keycode = locomokbd->keycode;
238 input_dev->keycodesize = sizeof(unsigned char); 261 input_dev->keycodesize = sizeof(locomokbd_keycode[0]);
239 input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); 262 input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode);
240 263
241 memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); 264 memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode));
@@ -268,7 +291,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
268 return err; 291 return err;
269} 292}
270 293
271static int locomokbd_remove(struct locomo_dev *dev) 294static int __devexit locomokbd_remove(struct locomo_dev *dev)
272{ 295{
273 struct locomokbd *locomokbd = locomo_get_drvdata(dev); 296 struct locomokbd *locomokbd = locomo_get_drvdata(dev);
274 297
@@ -292,7 +315,7 @@ static struct locomo_driver keyboard_driver = {
292 }, 315 },
293 .devid = LOCOMO_DEVID_KEYBOARD, 316 .devid = LOCOMO_DEVID_KEYBOARD,
294 .probe = locomokbd_probe, 317 .probe = locomokbd_probe,
295 .remove = locomokbd_remove, 318 .remove = __devexit_p(locomokbd_remove),
296}; 319};
297 320
298static int __init locomokbd_init(void) 321static int __init locomokbd_init(void)