2006-09-29 08:59:19 +00:00
|
|
|
/*
|
|
|
|
* linux/drivers/input/keyboard/omap-keypad.c
|
|
|
|
*
|
|
|
|
* OMAP Keypad Driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Nokia Corporation
|
2007-10-19 21:21:04 +00:00
|
|
|
* Written by Timo Teräs <ext-timo.teras@nokia.com>
|
2006-09-29 08:59:19 +00:00
|
|
|
*
|
|
|
|
* 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/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>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2012-09-07 20:27:58 +00:00
|
|
|
#include <linux/gpio.h>
|
|
|
|
#include <linux/platform_data/gpio-omap.h>
|
2012-08-24 13:21:06 +00:00
|
|
|
#include <linux/platform_data/keypad-omap.h>
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
#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;
|
2012-05-11 05:37:08 +00:00
|
|
|
unsigned short keymap[];
|
2006-09-29 08:59:19 +00:00
|
|
|
};
|
|
|
|
|
2008-09-05 14:13:24 +00:00
|
|
|
static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
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;
|
2008-10-16 05:03:15 +00:00
|
|
|
|
|
|
|
for (col = 0; col < omap_kp->cols; col++)
|
|
|
|
gpio_set_value(col_gpios[col], value & (1 << col));
|
2006-09-29 08:59:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 get_row_gpio_val(struct omap_kp *omap_kp)
|
|
|
|
{
|
|
|
|
int row;
|
|
|
|
u8 value = 0;
|
|
|
|
|
|
|
|
for (row = 0; row < omap_kp->rows; row++) {
|
2008-10-16 05:03:15 +00:00
|
|
|
if (gpio_get_value(row_gpios[row]))
|
2006-09-29 08:59:19 +00:00
|
|
|
value |= (1 << row);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define set_col_gpio_val(x, y) do {} while (0)
|
|
|
|
#define get_row_gpio_val(x) 0
|
|
|
|
#endif
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
|
2006-09-29 08:59:19 +00:00
|
|
|
{
|
|
|
|
/* disable keyboard interrupt and schedule for handling */
|
2012-09-07 20:27:58 +00:00
|
|
|
omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2012-09-07 20:27:58 +00:00
|
|
|
/* disable keyboard interrupt and schedule for handling */
|
|
|
|
omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
2012-09-07 20:27:58 +00:00
|
|
|
/* read the keypad status */
|
|
|
|
omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
|
|
|
|
for (col = 0; col < omap_kp->cols; col++) {
|
|
|
|
omap_writew(~(1 << col) & 0xff,
|
|
|
|
OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
2012-09-07 20:27:58 +00:00
|
|
|
udelay(omap_kp->delay);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
2012-09-07 20:27:58 +00:00
|
|
|
state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
|
|
|
|
OMAP_MPUIO_KBR_LATCH) & 0xff;
|
2006-09-29 08:59:19 +00:00
|
|
|
}
|
2012-09-07 20:27:58 +00:00
|
|
|
omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
|
|
|
|
udelay(2);
|
2006-09-29 08:59:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_kp_tasklet(unsigned long data)
|
|
|
|
{
|
|
|
|
struct omap_kp *omap_kp_data = (struct omap_kp *) data;
|
2010-12-20 21:09:22 +00:00
|
|
|
unsigned short *keycodes = omap_kp_data->input->keycode;
|
|
|
|
unsigned int row_shift = get_count_order(omap_kp_data->cols);
|
2006-09-29 08:59:19 +00:00
|
|
|
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\n", col,
|
|
|
|
row, (new_state[col] & (1 << row)) ?
|
|
|
|
"pressed" : "released");
|
|
|
|
#else
|
2010-12-20 21:09:22 +00:00
|
|
|
key = keycodes[MATRIX_SCAN_CODE(row, col, row_shift)];
|
2006-09-29 08:59:19 +00:00
|
|
|
if (key < 0) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"omap-keypad: Spurious key event %d-%d\n",
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 04:13:55 +00:00
|
|
|
input_sync(omap_kp_data->input);
|
2006-09-29 08:59:19 +00:00
|
|
|
memcpy(keypad_state, new_state, sizeof(keypad_state));
|
|
|
|
|
|
|
|
if (key_down) {
|
2012-09-05 06:10:50 +00:00
|
|
|
int delay = HZ / 20;
|
2006-09-29 08:59:19 +00:00
|
|
|
/* 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 */
|
2012-09-07 20:27:58 +00:00
|
|
|
omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
|
|
|
|
kp_cur_group = -1;
|
2007-10-12 18:20:00 +00:00
|
|
|
}
|
2006-09-29 08:59:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t omap_kp_enable_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
return sprintf(buf, "%u\n", kp_enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2012-09-07 20:27:58 +00:00
|
|
|
struct omap_kp *omap_kp = dev_get_drvdata(dev);
|
2006-09-29 08:59:19 +00:00
|
|
|
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)
|
2012-09-07 20:27:58 +00:00
|
|
|
enable_irq(omap_kp->irq);
|
2006-09-29 08:59:19 +00:00
|
|
|
else
|
2012-09-07 20:27:58 +00:00
|
|
|
disable_irq(omap_kp->irq);
|
2006-09-29 08:59:19 +00:00
|
|
|
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
|
|
|
|
|
2012-11-24 05:38:25 +00:00
|
|
|
static int omap_kp_probe(struct platform_device *pdev)
|
2006-09-29 08:59:19 +00:00
|
|
|
{
|
|
|
|
struct omap_kp *omap_kp;
|
|
|
|
struct input_dev *input_dev;
|
2013-12-06 03:21:10 +00:00
|
|
|
struct omap_kp_platform_data *pdata = dev_get_platdata(&pdev->dev);
|
2012-09-07 20:27:58 +00:00
|
|
|
int i, col_idx, row_idx, ret;
|
2010-12-20 21:09:22 +00:00
|
|
|
unsigned int row_shift, keycodemax;
|
2006-09-29 08:59:19 +00:00
|
|
|
|
2010-12-20 21:09:22 +00:00
|
|
|
if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
|
|
|
|
printk(KERN_ERR "No rows, cols or keymap_data from pdata\n");
|
2006-09-29 08:59:19 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-12-20 21:09:22 +00:00
|
|
|
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);
|
2006-09-29 08:59:19 +00:00
|
|
|
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 */
|
2012-09-07 20:27:58 +00:00
|
|
|
omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2012-09-07 20:27:58 +00:00
|
|
|
col_idx = 0;
|
|
|
|
row_idx = 0;
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
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 */
|
|
|
|
input_dev->name = "omap-keypad";
|
|
|
|
input_dev->phys = "omap-keypad/input0";
|
2007-04-12 05:34:58 +00:00
|
|
|
input_dev->dev.parent = &pdev->dev;
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
input_dev->id.bustype = BUS_HOST;
|
|
|
|
input_dev->id.vendor = 0x0001;
|
|
|
|
input_dev->id.product = 0x0001;
|
|
|
|
input_dev->id.version = 0x0100;
|
|
|
|
|
2012-05-11 05:37:08 +00:00
|
|
|
if (pdata->rep)
|
|
|
|
__set_bit(EV_REP, input_dev->evbit);
|
|
|
|
|
|
|
|
ret = matrix_keypad_build_keymap(pdata->keymap_data, NULL,
|
|
|
|
pdata->rows, pdata->cols,
|
|
|
|
omap_kp->keymap, input_dev);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err3;
|
|
|
|
|
2006-09-29 08:59:19 +00:00
|
|
|
ret = input_register_device(omap_kp->input);
|
|
|
|
if (ret < 0) {
|
|
|
|
printk(KERN_ERR "Unable to register omap-keypad input device\n");
|
|
|
|
goto err3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdata->dbounce)
|
2009-08-28 17:50:34 +00:00
|
|
|
omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_GPIO_DEBOUNCING);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
/* scan current status and enable interrupt */
|
|
|
|
omap_kp_scan_keypad(omap_kp, keypad_state);
|
2012-09-07 20:27:58 +00:00
|
|
|
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;
|
2006-09-29 08:59:19 +00:00
|
|
|
}
|
2012-09-07 20:27:58 +00:00
|
|
|
omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
|
|
|
|
|
2006-09-29 08:59:19 +00:00
|
|
|
return 0;
|
2012-09-07 20:27:58 +00:00
|
|
|
|
2006-09-29 08:59:19 +00:00
|
|
|
err4:
|
|
|
|
input_unregister_device(omap_kp->input);
|
|
|
|
input_dev = NULL;
|
|
|
|
err3:
|
|
|
|
device_remove_file(&pdev->dev, &dev_attr_enable);
|
|
|
|
err2:
|
2012-09-05 06:10:50 +00:00
|
|
|
for (i = row_idx - 1; i >= 0; i--)
|
2008-10-16 05:03:15 +00:00
|
|
|
gpio_free(row_gpios[i]);
|
2012-09-05 06:10:50 +00:00
|
|
|
for (i = col_idx - 1; i >= 0; i--)
|
2008-10-16 05:03:15 +00:00
|
|
|
gpio_free(col_gpios[i]);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
kfree(omap_kp);
|
|
|
|
input_free_device(input_dev);
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2012-11-24 05:50:47 +00:00
|
|
|
static int omap_kp_remove(struct platform_device *pdev)
|
2006-09-29 08:59:19 +00:00
|
|
|
{
|
|
|
|
struct omap_kp *omap_kp = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
/* disable keypad interrupt handling */
|
|
|
|
tasklet_disable(&kp_tasklet);
|
2012-09-07 20:27:58 +00:00
|
|
|
omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
|
|
|
|
free_irq(omap_kp->irq, omap_kp);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
|
|
|
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,
|
2012-11-24 05:27:39 +00:00
|
|
|
.remove = omap_kp_remove,
|
2006-09-29 08:59:19 +00:00
|
|
|
.suspend = omap_kp_suspend,
|
|
|
|
.resume = omap_kp_resume,
|
|
|
|
.driver = {
|
|
|
|
.name = "omap-keypad",
|
2008-04-18 04:24:42 +00:00
|
|
|
.owner = THIS_MODULE,
|
2006-09-29 08:59:19 +00:00
|
|
|
},
|
|
|
|
};
|
2011-11-29 19:08:39 +00:00
|
|
|
module_platform_driver(omap_kp_driver);
|
2006-09-29 08:59:19 +00:00
|
|
|
|
2007-10-19 21:21:04 +00:00
|
|
|
MODULE_AUTHOR("Timo Teräs");
|
2006-09-29 08:59:19 +00:00
|
|
|
MODULE_DESCRIPTION("OMAP Keypad Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-18 04:24:42 +00:00
|
|
|
MODULE_ALIAS("platform:omap-keypad");
|