Blame view

drivers/input/keyboard/omap-keypad.c 12 KB
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
1
2
3
4
5
6
  /*
   * linux/drivers/input/keyboard/omap-keypad.c
   *
   * OMAP Keypad Driver
   *
   * Copyright (C) 2003 Nokia Corporation
96de0e252   Jan Engelhardt   Convert files to ...
7
   * Written by Timo Teräs <ext-timo.teras@nokia.com>
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
   *
   * Added support for H2 & H3 Keypad
   * Copyright (C) 2004 Texas Instruments
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   */
  
  #include <linux/module.h>
  #include <linux/init.h>
  #include <linux/interrupt.h>
  #include <linux/types.h>
  #include <linux/input.h>
  #include <linux/kernel.h>
  #include <linux/delay.h>
  #include <linux/platform_device.h>
  #include <linux/mutex.h>
  #include <linux/errno.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
37
  #include <linux/slab.h>
1bc857f70   Russell King   ARM: gpio: omap: ...
38
  #include <asm/gpio.h>
ce491cf85   Tony Lindgren   omap: headers: Mo...
39
40
  #include <plat/keypad.h>
  #include <plat/menelaus.h>
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
41
  #include <asm/irq.h>
a09e64fbc   Russell King   [ARM] Move includ...
42
  #include <mach/hardware.h>
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
43
  #include <asm/io.h>
ce491cf85   Tony Lindgren   omap: headers: Mo...
44
  #include <plat/mux.h>
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  
  #undef NEW_BOARD_LEARNING_MODE
  
  static void omap_kp_tasklet(unsigned long);
  static void omap_kp_timer(unsigned long);
  
  static unsigned char keypad_state[8];
  static DEFINE_MUTEX(kp_enable_mutex);
  static int kp_enable = 1;
  static int kp_cur_group = -1;
  
  struct omap_kp {
  	struct input_dev *input;
  	struct timer_list timer;
  	int irq;
  	unsigned int rows;
  	unsigned int cols;
  	unsigned long delay;
  	unsigned int debounce;
  };
7c8ad9828   Russell King   [ARM] omap: fix a...
65
  static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
66

ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
67
68
69
70
71
72
73
  static unsigned int *row_gpios;
  static unsigned int *col_gpios;
  
  #ifdef CONFIG_ARCH_OMAP2
  static void set_col_gpio_val(struct omap_kp *omap_kp, u8 value)
  {
  	int col;
93a22f8b9   David Brownell   omap drivers: swi...
74
75
76
  
  	for (col = 0; col < omap_kp->cols; col++)
  		gpio_set_value(col_gpios[col], value & (1 << col));
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
77
78
79
80
81
82
83
84
  }
  
  static u8 get_row_gpio_val(struct omap_kp *omap_kp)
  {
  	int row;
  	u8 value = 0;
  
  	for (row = 0; row < omap_kp->rows; row++) {
93a22f8b9   David Brownell   omap drivers: swi...
85
  		if (gpio_get_value(row_gpios[row]))
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
86
87
88
89
90
91
92
93
  			value |= (1 << row);
  	}
  	return value;
  }
  #else
  #define		set_col_gpio_val(x, y)	do {} while (0)
  #define		get_row_gpio_val(x)	0
  #endif
7d12e780e   David Howells   IRQ: Maintain reg...
94
  static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
95
96
97
98
99
100
  {
  	struct omap_kp *omap_kp = dev_id;
  
  	/* disable keyboard interrupt and schedule for handling */
  	if (cpu_is_omap24xx()) {
  		int i;
0f751719e   Ben Nizette   Input: omap-keypa...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  
  		for (i = 0; i < omap_kp->rows; i++) {
  			int gpio_irq = gpio_to_irq(row_gpios[i]);
  			/*
  			 * The interrupt which we're currently handling should
  			 * be disabled _nosync() to avoid deadlocks waiting
  			 * for this handler to complete.  All others should
  			 * be disabled the regular way for SMP safety.
  			 */
  			if (gpio_irq == irq)
  				disable_irq_nosync(gpio_irq);
  			else
  				disable_irq(gpio_irq);
  		}
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
115
116
  	} else
  		/* disable keyboard interrupt and schedule for handling */
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
117
  		omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  
  	tasklet_schedule(&kp_tasklet);
  
  	return IRQ_HANDLED;
  }
  
  static void omap_kp_timer(unsigned long data)
  {
  	tasklet_schedule(&kp_tasklet);
  }
  
  static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
  {
  	int col = 0;
  
  	/* read the keypad status */
  	if (cpu_is_omap24xx()) {
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
135
136
137
  		/* read the keypad status */
  		for (col = 0; col < omap_kp->cols; col++) {
  			set_col_gpio_val(omap_kp, ~(1 << col));
dde4ac072   Peter Ujfalusi   Input: omap-keypa...
138
  			state[col] = ~(get_row_gpio_val(omap_kp)) & 0xff;
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
139
140
141
142
143
  		}
  		set_col_gpio_val(omap_kp, 0);
  
  	} else {
  		/* disable keyboard interrupt and schedule for handling */
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
144
  		omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
145
146
  
  		/* read the keypad status */
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
147
  		omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
148
149
  		for (col = 0; col < omap_kp->cols; col++) {
  			omap_writew(~(1 << col) & 0xff,
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
150
  				    OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
151
152
  
  			udelay(omap_kp->delay);
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
153
  			state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
154
155
  						 OMAP_MPUIO_KBR_LATCH) & 0xff;
  		}
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
156
  		omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
157
158
159
  		udelay(2);
  	}
  }
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
160
161
162
  static void omap_kp_tasklet(unsigned long data)
  {
  	struct omap_kp *omap_kp_data = (struct omap_kp *) data;
da1f026b5   Janusz Krzysztofik   Keyboard: omap-ke...
163
164
  	unsigned short *keycodes = omap_kp_data->input->keycode;
  	unsigned int row_shift = get_count_order(omap_kp_data->cols);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  	unsigned char new_state[8], changed, key_down = 0;
  	int col, row;
  	int spurious = 0;
  
  	/* check for any changes */
  	omap_kp_scan_keypad(omap_kp_data, new_state);
  
  	/* check for changes and print those */
  	for (col = 0; col < omap_kp_data->cols; col++) {
  		changed = new_state[col] ^ keypad_state[col];
  		key_down |= new_state[col];
  		if (changed == 0)
  			continue;
  
  		for (row = 0; row < omap_kp_data->rows; row++) {
  			int key;
  			if (!(changed & (1 << row)))
  				continue;
  #ifdef NEW_BOARD_LEARNING_MODE
  			printk(KERN_INFO "omap-keypad: key %d-%d %s
  ", col,
  			       row, (new_state[col] & (1 << row)) ?
  			       "pressed" : "released");
  #else
da1f026b5   Janusz Krzysztofik   Keyboard: omap-ke...
189
  			key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)];
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  			if (key < 0) {
  				printk(KERN_WARNING
  				      "omap-keypad: Spurious key event %d-%d
  ",
  				       col, row);
  				/* We scan again after a couple of seconds */
  				spurious = 1;
  				continue;
  			}
  
  			if (!(kp_cur_group == (key & GROUP_MASK) ||
  			      kp_cur_group == -1))
  				continue;
  
  			kp_cur_group = key & GROUP_MASK;
  			input_report_key(omap_kp_data->input, key & ~GROUP_MASK,
  					 new_state[col] & (1 << row));
  #endif
  		}
  	}
b27af563b   Janusz Krzysztofik   Input: omap-keypa...
210
  	input_sync(omap_kp_data->input);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
211
212
213
214
215
216
217
218
219
220
221
222
223
224
  	memcpy(keypad_state, new_state, sizeof(keypad_state));
  
  	if (key_down) {
                  int delay = HZ / 20;
  		/* some key is pressed - keep irq disabled and use timer
  		 * to poll the keypad */
  		if (spurious)
  			delay = 2 * HZ;
  		mod_timer(&omap_kp_data->timer, jiffies + delay);
  	} else {
  		/* enable interrupts */
  		if (cpu_is_omap24xx()) {
  			int i;
  			for (i = 0; i < omap_kp_data->rows; i++)
15f74b033   David Brownell   ARM: OMAP: use gp...
225
  				enable_irq(gpio_to_irq(row_gpios[i]));
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
226
  		} else {
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
227
  			omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
228
229
  			kp_cur_group = -1;
  		}
9360353f4   Dmitry Torokhov   Input: omap-keybo...
230
  	}
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
  }
  
  static ssize_t omap_kp_enable_show(struct device *dev,
  				   struct device_attribute *attr, char *buf)
  {
  	return sprintf(buf, "%u
  ", kp_enable);
  }
  
  static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute *attr,
  				    const char *buf, size_t count)
  {
  	int state;
  
  	if (sscanf(buf, "%u", &state) != 1)
  		return -EINVAL;
  
  	if ((state != 1) && (state != 0))
  		return -EINVAL;
  
  	mutex_lock(&kp_enable_mutex);
  	if (state != kp_enable) {
  		if (state)
  			enable_irq(INT_KEYBOARD);
  		else
  			disable_irq(INT_KEYBOARD);
  		kp_enable = state;
  	}
  	mutex_unlock(&kp_enable_mutex);
  
  	return strnlen(buf, count);
  }
  
  static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store);
  
  #ifdef CONFIG_PM
  static int omap_kp_suspend(struct platform_device *dev, pm_message_t state)
  {
  	/* Nothing yet */
  
  	return 0;
  }
  
  static int omap_kp_resume(struct platform_device *dev)
  {
  	/* Nothing yet */
  
  	return 0;
  }
  #else
  #define omap_kp_suspend	NULL
  #define omap_kp_resume	NULL
  #endif
d63dab00e   Uwe Kleine-König   Input: omap-keypa...
284
  static int __devinit omap_kp_probe(struct platform_device *pdev)
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
285
286
287
288
289
  {
  	struct omap_kp *omap_kp;
  	struct input_dev *input_dev;
  	struct omap_kp_platform_data *pdata =  pdev->dev.platform_data;
  	int i, col_idx, row_idx, irq_idx, ret;
da1f026b5   Janusz Krzysztofik   Keyboard: omap-ke...
290
  	unsigned int row_shift, keycodemax;
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
291

da1f026b5   Janusz Krzysztofik   Keyboard: omap-ke...
292
293
294
  	if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
  		printk(KERN_ERR "No rows, cols or keymap_data from pdata
  ");
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
295
296
  		return -EINVAL;
  	}
da1f026b5   Janusz Krzysztofik   Keyboard: omap-ke...
297
298
299
300
301
  	row_shift = get_count_order(pdata->cols);
  	keycodemax = pdata->rows << row_shift;
  
  	omap_kp = kzalloc(sizeof(struct omap_kp) +
  			keycodemax * sizeof(unsigned short), GFP_KERNEL);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
302
303
304
305
306
307
308
309
310
311
312
313
314
  	input_dev = input_allocate_device();
  	if (!omap_kp || !input_dev) {
  		kfree(omap_kp);
  		input_free_device(input_dev);
  		return -ENOMEM;
  	}
  
  	platform_set_drvdata(pdev, omap_kp);
  
  	omap_kp->input = input_dev;
  
  	/* Disable the interrupt for the MPUIO keyboard */
  	if (!cpu_is_omap24xx())
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
315
  		omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
316

da1f026b5   Janusz Krzysztofik   Keyboard: omap-ke...
317
318
319
  	input_dev->keycode      = &omap_kp[1];
  	input_dev->keycodesize  = sizeof(unsigned short);
  	input_dev->keycodemax   = keycodemax;
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
320
321
  
  	if (pdata->rep)
9360353f4   Dmitry Torokhov   Input: omap-keybo...
322
  		__set_bit(EV_REP, input_dev->evbit);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
  
  	if (pdata->delay)
  		omap_kp->delay = pdata->delay;
  
  	if (pdata->row_gpios && pdata->col_gpios) {
  		row_gpios = pdata->row_gpios;
  		col_gpios = pdata->col_gpios;
  	}
  
  	omap_kp->rows = pdata->rows;
  	omap_kp->cols = pdata->cols;
  
  	if (cpu_is_omap24xx()) {
  		/* Cols: outputs */
  		for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
93a22f8b9   David Brownell   omap drivers: swi...
338
  			if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
339
340
341
342
343
344
  				printk(KERN_ERR "Failed to request"
  				       "GPIO%d for keypad
  ",
  				       col_gpios[col_idx]);
  				goto err1;
  			}
93a22f8b9   David Brownell   omap drivers: swi...
345
  			gpio_direction_output(col_gpios[col_idx], 0);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
346
347
348
  		}
  		/* Rows: inputs */
  		for (row_idx = 0; row_idx < omap_kp->rows; row_idx++) {
93a22f8b9   David Brownell   omap drivers: swi...
349
  			if (gpio_request(row_gpios[row_idx], "omap_kp_row") < 0) {
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
350
351
352
353
354
355
  				printk(KERN_ERR "Failed to request"
  				       "GPIO%d for keypad
  ",
  				       row_gpios[row_idx]);
  				goto err2;
  			}
93a22f8b9   David Brownell   omap drivers: swi...
356
  			gpio_direction_input(row_gpios[row_idx]);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
357
  		}
da3e4c885   David Brownell   Input: omap-keypa...
358
359
360
  	} else {
  		col_idx = 0;
  		row_idx = 0;
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
361
362
363
364
365
366
367
368
369
370
371
372
373
  	}
  
  	setup_timer(&omap_kp->timer, omap_kp_timer, (unsigned long)omap_kp);
  
  	/* get the irq and init timer*/
  	tasklet_enable(&kp_tasklet);
  	kp_tasklet.data = (unsigned long) omap_kp;
  
  	ret = device_create_file(&pdev->dev, &dev_attr_enable);
  	if (ret < 0)
  		goto err2;
  
  	/* setup input device */
9360353f4   Dmitry Torokhov   Input: omap-keybo...
374
  	__set_bit(EV_KEY, input_dev->evbit);
da1f026b5   Janusz Krzysztofik   Keyboard: omap-ke...
375
376
  	matrix_keypad_build_keymap(pdata->keymap_data, row_shift,
  			input_dev->keycode, input_dev->keybit);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
377
378
  	input_dev->name = "omap-keypad";
  	input_dev->phys = "omap-keypad/input0";
469ba4dff   Dmitry Torokhov   Input: keyboards ...
379
  	input_dev->dev.parent = &pdev->dev;
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
380
381
382
383
384
  
  	input_dev->id.bustype = BUS_HOST;
  	input_dev->id.vendor = 0x0001;
  	input_dev->id.product = 0x0001;
  	input_dev->id.version = 0x0100;
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
385
386
387
388
389
390
391
392
  	ret = input_register_device(omap_kp->input);
  	if (ret < 0) {
  		printk(KERN_ERR "Unable to register omap-keypad input device
  ");
  		goto err3;
  	}
  
  	if (pdata->dbounce)
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
393
  		omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_GPIO_DEBOUNCING);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
394
395
396
397
398
399
400
401
402
403
  
  	/* scan current status and enable interrupt */
  	omap_kp_scan_keypad(omap_kp, keypad_state);
  	if (!cpu_is_omap24xx()) {
  		omap_kp->irq = platform_get_irq(pdev, 0);
  		if (omap_kp->irq >= 0) {
  			if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
  					"omap-keypad", omap_kp) < 0)
  				goto err4;
  		}
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
404
  		omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
405
406
  	} else {
  		for (irq_idx = 0; irq_idx < omap_kp->rows; irq_idx++) {
15f74b033   David Brownell   ARM: OMAP: use gp...
407
  			if (request_irq(gpio_to_irq(row_gpios[irq_idx]),
9360353f4   Dmitry Torokhov   Input: omap-keybo...
408
  					omap_kp_interrupt,
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
409
  					IRQF_TRIGGER_FALLING,
9360353f4   Dmitry Torokhov   Input: omap-keybo...
410
  					"omap-keypad", omap_kp) < 0)
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
411
412
413
414
415
  				goto err5;
  		}
  	}
  	return 0;
  err5:
9360353f4   Dmitry Torokhov   Input: omap-keybo...
416
  	for (i = irq_idx - 1; i >=0; i--)
60c8ba647   Axel Lin   Input: omap-keypa...
417
  		free_irq(row_gpios[i], omap_kp);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
418
419
420
421
422
423
  err4:
  	input_unregister_device(omap_kp->input);
  	input_dev = NULL;
  err3:
  	device_remove_file(&pdev->dev, &dev_attr_enable);
  err2:
da3e4c885   David Brownell   Input: omap-keypa...
424
  	for (i = row_idx - 1; i >=0; i--)
93a22f8b9   David Brownell   omap drivers: swi...
425
  		gpio_free(row_gpios[i]);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
426
  err1:
da3e4c885   David Brownell   Input: omap-keypa...
427
  	for (i = col_idx - 1; i >=0; i--)
93a22f8b9   David Brownell   omap drivers: swi...
428
  		gpio_free(col_gpios[i]);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
429
430
431
432
433
434
  
  	kfree(omap_kp);
  	input_free_device(input_dev);
  
  	return -EINVAL;
  }
d63dab00e   Uwe Kleine-König   Input: omap-keypa...
435
  static int __devexit omap_kp_remove(struct platform_device *pdev)
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
436
437
438
439
440
441
442
443
  {
  	struct omap_kp *omap_kp = platform_get_drvdata(pdev);
  
  	/* disable keypad interrupt handling */
  	tasklet_disable(&kp_tasklet);
  	if (cpu_is_omap24xx()) {
  		int i;
  		for (i = 0; i < omap_kp->cols; i++)
93a22f8b9   David Brownell   omap drivers: swi...
444
  			gpio_free(col_gpios[i]);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
445
  		for (i = 0; i < omap_kp->rows; i++) {
93a22f8b9   David Brownell   omap drivers: swi...
446
  			gpio_free(row_gpios[i]);
60c8ba647   Axel Lin   Input: omap-keypa...
447
  			free_irq(gpio_to_irq(row_gpios[i]), omap_kp);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
448
449
  		}
  	} else {
6175556fd   Tony Lindgren   OMAP: Rename OMAP...
450
  		omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
60c8ba647   Axel Lin   Input: omap-keypa...
451
  		free_irq(omap_kp->irq, omap_kp);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
  	}
  
  	del_timer_sync(&omap_kp->timer);
  	tasklet_kill(&kp_tasklet);
  
  	/* unregister everything */
  	input_unregister_device(omap_kp->input);
  
  	kfree(omap_kp);
  
  	return 0;
  }
  
  static struct platform_driver omap_kp_driver = {
  	.probe		= omap_kp_probe,
d63dab00e   Uwe Kleine-König   Input: omap-keypa...
467
  	.remove		= __devexit_p(omap_kp_remove),
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
468
469
470
471
  	.suspend	= omap_kp_suspend,
  	.resume		= omap_kp_resume,
  	.driver		= {
  		.name	= "omap-keypad",
d7b5247bb   Kay Sievers   Input: add MODULE...
472
  		.owner	= THIS_MODULE,
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
473
474
  	},
  };
5146c84f8   JJ Ding   Input: keyboard -...
475
  module_platform_driver(omap_kp_driver);
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
476

96de0e252   Jan Engelhardt   Convert files to ...
477
  MODULE_AUTHOR("Timo Teräs");
ad4e09b16   Komal Shah   [PATCH] OMAP: Add...
478
479
  MODULE_DESCRIPTION("OMAP Keypad Driver");
  MODULE_LICENSE("GPL");
d7b5247bb   Kay Sievers   Input: add MODULE...
480
  MODULE_ALIAS("platform:omap-keypad");