2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Keyboard driver for Sharp Corgi models (SL-C7xx)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004-2005 Richard Purdie
|
|
|
|
*
|
|
|
|
* Based on xtkbd.c/locomkbd.c
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/delay.h>
|
2005-10-29 20:07:23 +02:00
|
|
|
#include <linux/platform_device.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/interrupt.h>
|
2005-09-07 00:18:59 +02:00
|
|
|
#include <linux/jiffies.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
|
|
|
#include <asm/arch/corgi.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
|
|
|
#include <asm/arch/pxa-regs.h>
|
|
|
|
#include <asm/hardware/scoop.h>
|
|
|
|
|
|
|
|
#define KB_ROWS 8
|
|
|
|
#define KB_COLS 12
|
|
|
|
#define KB_ROWMASK(r) (1 << (r))
|
|
|
|
#define SCANCODE(r,c) ( ((r)<<4) + (c) + 1 )
|
2006-03-14 06:12:32 +01:00
|
|
|
/* zero code, 124 scancodes */
|
|
|
|
#define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 )
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-03-14 06:12:32 +01:00
|
|
|
#define SCAN_INTERVAL (50) /* ms */
|
|
|
|
#define HINGE_SCAN_INTERVAL (250) /* ms */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#define CORGI_KEY_CALENDER KEY_F1
|
|
|
|
#define CORGI_KEY_ADDRESS KEY_F2
|
|
|
|
#define CORGI_KEY_FN KEY_F3
|
2005-05-29 09:27:06 +02:00
|
|
|
#define CORGI_KEY_CANCEL KEY_F4
|
2005-04-17 00:20:36 +02:00
|
|
|
#define CORGI_KEY_OFF KEY_SUSPEND
|
|
|
|
#define CORGI_KEY_EXOK KEY_F5
|
|
|
|
#define CORGI_KEY_EXCANCEL KEY_F6
|
|
|
|
#define CORGI_KEY_EXJOGDOWN KEY_F7
|
|
|
|
#define CORGI_KEY_EXJOGUP KEY_F8
|
|
|
|
#define CORGI_KEY_JAP1 KEY_LEFTCTRL
|
|
|
|
#define CORGI_KEY_JAP2 KEY_LEFTALT
|
2005-05-29 09:27:06 +02:00
|
|
|
#define CORGI_KEY_MAIL KEY_F10
|
2005-04-17 00:20:36 +02:00
|
|
|
#define CORGI_KEY_OK KEY_F11
|
|
|
|
#define CORGI_KEY_MENU KEY_F12
|
|
|
|
|
|
|
|
static unsigned char corgikbd_keycode[NR_SCANCODES] = {
|
|
|
|
0, /* 0 */
|
|
|
|
0, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, 0, 0, 0, 0, 0, 0, 0, /* 1-16 */
|
|
|
|
0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, 0, 0, 0, 0, 0, 0, 0, /* 17-32 */
|
|
|
|
KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */
|
|
|
|
CORGI_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */
|
|
|
|
CORGI_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, 0, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, /* 65-80 */
|
2005-05-29 09:27:06 +02:00
|
|
|
CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */
|
|
|
|
KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */
|
2005-04-17 00:20:36 +02:00
|
|
|
CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct corgikbd {
|
|
|
|
unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)];
|
2005-09-15 09:01:45 +02:00
|
|
|
struct input_dev *input;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spinlock_t lock;
|
|
|
|
struct timer_list timer;
|
|
|
|
struct timer_list htimer;
|
2005-09-07 00:18:59 +02:00
|
|
|
|
|
|
|
unsigned int suspended;
|
|
|
|
unsigned long suspend_jiffies;
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define KB_DISCHARGE_DELAY 10
|
|
|
|
#define KB_ACTIVATE_DELAY 10
|
|
|
|
|
|
|
|
/* Helper functions for reading the keyboard matrix
|
|
|
|
* Note: We should really be using pxa_gpio_mode to alter GPDR but it
|
|
|
|
* requires a function call per GPIO bit which is excessive
|
|
|
|
* when we need to access 12 bits at once multiple times.
|
|
|
|
* These functions must be called within local_irq_save()/local_irq_restore()
|
|
|
|
* or similar.
|
|
|
|
*/
|
|
|
|
static inline void corgikbd_discharge_all(void)
|
|
|
|
{
|
2005-09-07 00:19:00 +02:00
|
|
|
/* STROBE All HiZ */
|
2005-04-17 00:20:36 +02:00
|
|
|
GPCR2 = CORGI_GPIO_ALL_STROBE_BIT;
|
|
|
|
GPDR2 &= ~CORGI_GPIO_ALL_STROBE_BIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void corgikbd_activate_all(void)
|
|
|
|
{
|
2005-09-07 00:19:00 +02:00
|
|
|
/* STROBE ALL -> High */
|
2005-04-17 00:20:36 +02:00
|
|
|
GPSR2 = CORGI_GPIO_ALL_STROBE_BIT;
|
|
|
|
GPDR2 |= CORGI_GPIO_ALL_STROBE_BIT;
|
|
|
|
|
|
|
|
udelay(KB_DISCHARGE_DELAY);
|
|
|
|
|
2005-09-07 00:19:00 +02:00
|
|
|
/* Clear any interrupts we may have triggered when altering the GPIO lines */
|
2005-04-17 00:20:36 +02:00
|
|
|
GEDR1 = CORGI_GPIO_HIGH_SENSE_BIT;
|
|
|
|
GEDR2 = CORGI_GPIO_LOW_SENSE_BIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void corgikbd_activate_col(int col)
|
|
|
|
{
|
2005-09-07 00:19:00 +02:00
|
|
|
/* STROBE col -> High, not col -> HiZ */
|
2005-04-17 00:20:36 +02:00
|
|
|
GPSR2 = CORGI_GPIO_STROBE_BIT(col);
|
|
|
|
GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void corgikbd_reset_col(int col)
|
|
|
|
{
|
2005-09-07 00:19:00 +02:00
|
|
|
/* STROBE col -> Low */
|
2005-04-17 00:20:36 +02:00
|
|
|
GPCR2 = CORGI_GPIO_STROBE_BIT(col);
|
2005-09-07 00:19:00 +02:00
|
|
|
/* STROBE col -> out, not col -> HiZ */
|
2005-04-17 00:20:36 +02:00
|
|
|
GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GET_ROWS_STATUS(c) (((GPLR1 & CORGI_GPIO_HIGH_SENSE_BIT) >> CORGI_GPIO_HIGH_SENSE_RSHIFT) | ((GPLR2 & CORGI_GPIO_LOW_SENSE_BIT) << CORGI_GPIO_LOW_SENSE_LSHIFT))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The corgi keyboard only generates interrupts when a key is pressed.
|
|
|
|
* When a key is pressed, we enable a timer which then scans the
|
|
|
|
* keyboard to detect when the key is released.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Scan the hardware keyboard and push any changes up through the input layer */
|
|
|
|
static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs *regs)
|
|
|
|
{
|
2005-09-07 00:19:00 +02:00
|
|
|
unsigned int row, col, rowd;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
unsigned int num_pressed;
|
|
|
|
|
2005-09-07 00:18:59 +02:00
|
|
|
if (corgikbd_data->suspended)
|
|
|
|
return;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&corgikbd_data->lock, flags);
|
|
|
|
|
|
|
|
if (regs)
|
2005-09-15 09:01:45 +02:00
|
|
|
input_regs(corgikbd_data->input, regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
num_pressed = 0;
|
|
|
|
for (col = 0; col < KB_COLS; col++) {
|
|
|
|
/*
|
|
|
|
* Discharge the output driver capacitatance
|
|
|
|
* in the keyboard matrix. (Yes it is significant..)
|
|
|
|
*/
|
|
|
|
|
|
|
|
corgikbd_discharge_all();
|
|
|
|
udelay(KB_DISCHARGE_DELAY);
|
|
|
|
|
|
|
|
corgikbd_activate_col(col);
|
|
|
|
udelay(KB_ACTIVATE_DELAY);
|
|
|
|
|
|
|
|
rowd = GET_ROWS_STATUS(col);
|
|
|
|
for (row = 0; row < KB_ROWS; row++) {
|
2005-09-07 00:19:00 +02:00
|
|
|
unsigned int scancode, pressed;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
scancode = SCANCODE(row, col);
|
2005-09-07 00:19:00 +02:00
|
|
|
pressed = rowd & KB_ROWMASK(row);
|
|
|
|
|
2005-09-15 09:01:45 +02:00
|
|
|
input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed);
|
2005-09-07 00:19:00 +02:00
|
|
|
|
|
|
|
if (pressed)
|
2005-04-17 00:20:36 +02:00
|
|
|
num_pressed++;
|
2005-09-07 00:19:00 +02:00
|
|
|
|
|
|
|
if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF)
|
|
|
|
&& time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) {
|
2005-09-15 09:01:45 +02:00
|
|
|
input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1);
|
2005-09-07 00:19:00 +02:00
|
|
|
corgikbd_data->suspend_jiffies=jiffies;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
corgikbd_reset_col(col);
|
|
|
|
}
|
|
|
|
|
|
|
|
corgikbd_activate_all();
|
|
|
|
|
2005-09-15 09:01:45 +02:00
|
|
|
input_sync(corgikbd_data->input);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* if any keys are pressed, enable the timer */
|
|
|
|
if (num_pressed)
|
2006-03-14 06:12:32 +01:00
|
|
|
mod_timer(&corgikbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&corgikbd_data->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* corgi keyboard interrupt handler.
|
|
|
|
*/
|
|
|
|
static irqreturn_t corgikbd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
struct corgikbd *corgikbd_data = dev_id;
|
|
|
|
|
|
|
|
if (!timer_pending(&corgikbd_data->timer)) {
|
|
|
|
/** wait chattering delay **/
|
|
|
|
udelay(20);
|
|
|
|
corgikbd_scankeyboard(corgikbd_data, regs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* corgi timer checking for released keys
|
|
|
|
*/
|
|
|
|
static void corgikbd_timer_callback(unsigned long data)
|
|
|
|
{
|
|
|
|
struct corgikbd *corgikbd_data = (struct corgikbd *) data;
|
|
|
|
corgikbd_scankeyboard(corgikbd_data, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The hinge switches generate no interrupt so they need to be
|
|
|
|
* monitored by a timer.
|
|
|
|
*
|
2005-09-07 00:19:00 +02:00
|
|
|
* We debounce the switches and pass them to the input system.
|
|
|
|
*
|
|
|
|
* gprr == 0x00 - Keyboard with Landscape Screen
|
|
|
|
* 0x08 - No Keyboard with Portrait Screen
|
|
|
|
* 0x0c - Keyboard and Screen Closed
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
|
2006-03-14 06:12:32 +01:00
|
|
|
#define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x))
|
2005-04-17 00:20:36 +02:00
|
|
|
#define HINGE_STABLE_COUNT 2
|
|
|
|
static int sharpsl_hinge_state;
|
|
|
|
static int hinge_count;
|
|
|
|
|
|
|
|
static void corgikbd_hinge_timer(unsigned long data)
|
|
|
|
{
|
|
|
|
struct corgikbd *corgikbd_data = (struct corgikbd *) data;
|
|
|
|
unsigned long gprr;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2005-09-07 00:18:59 +02:00
|
|
|
gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB);
|
2006-03-14 06:12:32 +01:00
|
|
|
gprr |= (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (gprr != sharpsl_hinge_state) {
|
|
|
|
hinge_count = 0;
|
|
|
|
sharpsl_hinge_state = gprr;
|
|
|
|
} else if (hinge_count < HINGE_STABLE_COUNT) {
|
|
|
|
hinge_count++;
|
|
|
|
if (hinge_count >= HINGE_STABLE_COUNT) {
|
|
|
|
spin_lock_irqsave(&corgikbd_data->lock, flags);
|
|
|
|
|
2005-09-15 09:01:45 +02:00
|
|
|
input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0));
|
|
|
|
input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0));
|
2006-03-14 06:12:32 +01:00
|
|
|
input_report_switch(corgikbd_data->input, SW_2, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0));
|
2005-09-15 09:01:45 +02:00
|
|
|
input_sync(corgikbd_data->input);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&corgikbd_data->lock, flags);
|
|
|
|
}
|
|
|
|
}
|
2006-03-14 06:12:32 +01:00
|
|
|
mod_timer(&corgikbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-09-07 00:18:59 +02:00
|
|
|
#ifdef CONFIG_PM
|
2005-11-09 23:32:44 +01:00
|
|
|
static int corgikbd_suspend(struct platform_device *dev, pm_message_t state)
|
2005-09-07 00:18:59 +02:00
|
|
|
{
|
2006-03-14 06:12:32 +01:00
|
|
|
int i;
|
2005-11-09 23:32:44 +01:00
|
|
|
struct corgikbd *corgikbd = platform_get_drvdata(dev);
|
2006-03-14 06:12:32 +01:00
|
|
|
|
2005-10-28 18:52:56 +02:00
|
|
|
corgikbd->suspended = 1;
|
2006-03-14 06:12:32 +01:00
|
|
|
/* strobe 0 is the power key so this can't be made an input for
|
|
|
|
powersaving therefore i = 1 */
|
|
|
|
for (i = 1; i < CORGI_KEY_STROBE_NUM; i++)
|
|
|
|
pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_IN);
|
2005-10-28 18:52:56 +02:00
|
|
|
|
2005-09-07 00:18:59 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-09 23:32:44 +01:00
|
|
|
static int corgikbd_resume(struct platform_device *dev)
|
2005-09-07 00:18:59 +02:00
|
|
|
{
|
2006-03-14 06:12:32 +01:00
|
|
|
int i;
|
2005-11-09 23:32:44 +01:00
|
|
|
struct corgikbd *corgikbd = platform_get_drvdata(dev);
|
2005-10-28 18:52:56 +02:00
|
|
|
|
2006-03-14 06:12:32 +01:00
|
|
|
for (i = 1; i < CORGI_KEY_STROBE_NUM; i++)
|
|
|
|
pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
|
|
|
|
|
2005-10-28 18:52:56 +02:00
|
|
|
/* Upon resume, ignore the suspend key for a short while */
|
|
|
|
corgikbd->suspend_jiffies=jiffies;
|
|
|
|
corgikbd->suspended = 0;
|
2005-09-07 00:18:59 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define corgikbd_suspend NULL
|
|
|
|
#define corgikbd_resume NULL
|
|
|
|
#endif
|
|
|
|
|
2005-11-09 23:32:44 +01:00
|
|
|
static int __init corgikbd_probe(struct platform_device *pdev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct corgikbd *corgikbd;
|
2005-09-15 09:01:45 +02:00
|
|
|
struct input_dev *input_dev;
|
|
|
|
int i;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-09-07 00:18:33 +02:00
|
|
|
corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL);
|
2005-09-15 09:01:45 +02:00
|
|
|
input_dev = input_allocate_device();
|
|
|
|
if (!corgikbd || !input_dev) {
|
|
|
|
kfree(corgikbd);
|
|
|
|
input_free_device(input_dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -ENOMEM;
|
2005-09-15 09:01:45 +02:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-11-09 23:32:44 +01:00
|
|
|
platform_set_drvdata(pdev, corgikbd);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-09-15 09:01:45 +02:00
|
|
|
corgikbd->input = input_dev;
|
2005-09-07 00:18:59 +02:00
|
|
|
spin_lock_init(&corgikbd->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Init Keyboard rescan timer */
|
|
|
|
init_timer(&corgikbd->timer);
|
|
|
|
corgikbd->timer.function = corgikbd_timer_callback;
|
|
|
|
corgikbd->timer.data = (unsigned long) corgikbd;
|
|
|
|
|
|
|
|
/* Init Hinge Timer */
|
|
|
|
init_timer(&corgikbd->htimer);
|
|
|
|
corgikbd->htimer.function = corgikbd_hinge_timer;
|
|
|
|
corgikbd->htimer.data = (unsigned long) corgikbd;
|
|
|
|
|
2005-09-07 00:18:59 +02:00
|
|
|
corgikbd->suspend_jiffies=jiffies;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode));
|
2005-09-15 09:01:45 +02:00
|
|
|
|
|
|
|
input_dev->name = "Corgi Keyboard";
|
|
|
|
input_dev->phys = "corgikbd/input0";
|
|
|
|
input_dev->id.bustype = BUS_HOST;
|
|
|
|
input_dev->id.vendor = 0x0001;
|
|
|
|
input_dev->id.product = 0x0001;
|
|
|
|
input_dev->id.version = 0x0100;
|
2005-11-09 23:32:44 +01:00
|
|
|
input_dev->cdev.dev = &pdev->dev;
|
2005-09-15 09:01:45 +02:00
|
|
|
input_dev->private = corgikbd;
|
|
|
|
|
|
|
|
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
|
|
|
|
input_dev->keycode = corgikbd->keycode;
|
|
|
|
input_dev->keycodesize = sizeof(unsigned char);
|
|
|
|
input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++)
|
2005-09-15 09:01:45 +02:00
|
|
|
set_bit(corgikbd->keycode[i], input_dev->keybit);
|
|
|
|
clear_bit(0, input_dev->keybit);
|
|
|
|
set_bit(SW_0, input_dev->swbit);
|
|
|
|
set_bit(SW_1, input_dev->swbit);
|
2006-03-14 06:12:32 +01:00
|
|
|
set_bit(SW_2, input_dev->swbit);
|
2005-09-15 09:01:45 +02:00
|
|
|
|
|
|
|
input_register_device(corgikbd->input);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-03-14 06:12:32 +01:00
|
|
|
mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
|
|
|
|
for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) {
|
|
|
|
pxa_gpio_mode(CORGI_GPIO_KEY_SENSE(i) | GPIO_IN);
|
|
|
|
if (request_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd_interrupt,
|
[PATCH] IRQ type flags
Some ARM platforms have the ability to program the interrupt controller to
detect various interrupt edges and/or levels. For some platforms, this is
critical to setup correctly, particularly those which the setting is dependent
on the device.
Currently, ARM drivers do (eg) the following:
err = request_irq(irq, ...);
set_irq_type(irq, IRQT_RISING);
However, if the interrupt has previously been programmed to be level sensitive
(for whatever reason) then this will cause an interrupt storm.
Hence, if we combine set_irq_type() with request_irq(), we can then safely set
the type prior to unmasking the interrupt. The unfortunate problem is that in
order to support this, these flags need to be visible outside of the ARM
architecture - drivers such as smc91x need these flags and they're
cross-architecture.
Finally, the SA_TRIGGER_* flag passed to request_irq() should reflect the
property that the device would like. The IRQ controller code should do its
best to select the most appropriate supported mode.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-08 10:02:07 +01:00
|
|
|
SA_INTERRUPT | SA_TRIGGER_RISING,
|
|
|
|
"corgikbd", corgikbd))
|
2005-04-17 00:20:36 +02:00
|
|
|
printk(KERN_WARNING "corgikbd: Can't get IRQ: %d!\n", i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Strobe lines as outputs - set high */
|
|
|
|
for (i = 0; i < CORGI_KEY_STROBE_NUM; i++)
|
|
|
|
pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
|
|
|
|
|
2006-03-14 06:12:32 +01:00
|
|
|
/* Setup the headphone jack as an input */
|
|
|
|
pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-09 23:32:44 +01:00
|
|
|
static int corgikbd_remove(struct platform_device *pdev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 23:32:44 +01:00
|
|
|
struct corgikbd *corgikbd = platform_get_drvdata(pdev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
for (i = 0; i < CORGI_KEY_SENSE_NUM; i++)
|
|
|
|
free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd);
|
|
|
|
|
|
|
|
del_timer_sync(&corgikbd->htimer);
|
|
|
|
del_timer_sync(&corgikbd->timer);
|
|
|
|
|
2005-09-15 09:01:45 +02:00
|
|
|
input_unregister_device(corgikbd->input);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
kfree(corgikbd);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-09 23:32:44 +01:00
|
|
|
static struct platform_driver corgikbd_driver = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.probe = corgikbd_probe,
|
|
|
|
.remove = corgikbd_remove,
|
2005-09-07 00:18:59 +02:00
|
|
|
.suspend = corgikbd_suspend,
|
|
|
|
.resume = corgikbd_resume,
|
2005-11-09 23:32:44 +01:00
|
|
|
.driver = {
|
|
|
|
.name = "corgi-keyboard",
|
|
|
|
},
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __devinit corgikbd_init(void)
|
|
|
|
{
|
2005-11-09 23:32:44 +01:00
|
|
|
return platform_driver_register(&corgikbd_driver);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit corgikbd_exit(void)
|
|
|
|
{
|
2005-11-09 23:32:44 +01:00
|
|
|
platform_driver_unregister(&corgikbd_driver);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(corgikbd_init);
|
|
|
|
module_exit(corgikbd_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
|
|
|
|
MODULE_DESCRIPTION("Corgi Keyboard Driver");
|
|
|
|
MODULE_LICENSE("GPLv2");
|