Commit 88a94ded authored by Russell King's avatar Russell King Committed by Vojtech Pavlik

Here's a patch that makes the RiscPC input bits work in 2.5:

- Call the RiscPC mouse "CONFIG_MOUSE_RISCPC" not "CONFIG_MOUSE_ACORN"
- Remember the last state of the buttons so we're not continuously
  reporting this to the core input subsystem.
- Correct mapping of bits to buttons
- Correct button sense (1 = released)
- Always pass a dev_id when requesting an IRQ.  Required for SA_SHIRQ
  shared interrupts.
- Merge ARM keyboard controller config options
- General update for rpckbd.c
parent 98170900
......@@ -77,7 +77,7 @@ CONFIG_MOUSE_AMIGA
The module will be called amimouse.o. If you want to compile it as a
module, say M here and read <file.:Documentation/modules.txt>.
CONFIG_MOUSE_ACORN
CONFIG_MOUSE_RISCPC
Say Y here if you have the Acorn RiscPC computer and want its
native mouse supported.
......
......@@ -20,5 +20,5 @@ if [ "$CONFIG_AMIGA" = "y" ]; then
dep_tristate ' Amiga mouse' CONFIG_MOUSE_AMIGA $CONFIG_INPUT $CONFIG_INPUT_MOUSE
fi
if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
dep_tristate ' Acorn RiscPC mouse' CONFIG_MOUSE_ACORN $CONFIG_INPUT $CONFIG_INPUT_MOUSE
dep_tristate ' Acorn RiscPC mouse' CONFIG_MOUSE_RISCPC $CONFIG_INPUT $CONFIG_INPUT_MOUSE
fi
......@@ -5,7 +5,7 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o
obj-$(CONFIG_MOUSE_ACORN) += rpcmouse.o
obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o
obj-$(CONFIG_MOUSE_INPORT) += inport.o
obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
obj-$(CONFIG_MOUSE_MAPLE) += maplemouse.o
......
......@@ -34,6 +34,7 @@ MODULE_DESCRIPTION("Acorn RiscPC mouse driver");
MODULE_LICENSE("GPL");
static short rpcmouse_lastx, rpcmouse_lasty;
static unsigned int rpcmouse_lastb;
static struct input_dev rpcmouse_dev = {
.evbit = { BIT(EV_KEY) | BIT(EV_REL) },
......@@ -51,11 +52,12 @@ static struct input_dev rpcmouse_dev = {
static void rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
{
short x, y, dx, dy, b;
struct input_dev *dev = dev_id;
short x, y, dx, dy;
unsigned int b;
x = (short) iomd_readl(IOMD_MOUSEX);
y = (short) iomd_readl(IOMD_MOUSEY);
b = (short) (__raw_readl(0xe0310000) >> 4) & 7;
dx = x - rpcmouse_lastx;
dy = y - rpcmouse_lasty;
......@@ -63,14 +65,22 @@ static void rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
rpcmouse_lastx = x;
rpcmouse_lasty = y;
input_report_rel(&rpcmouse_dev, REL_X, dx);
input_report_rel(&rpcmouse_dev, REL_Y, dy);
if (dx)
input_report_rel(dev, REL_X, dx);
if (dy)
input_report_rel(dev, REL_Y, -dy);
input_report_key(&rpcmouse_dev, BTN_LEFT, b & 0x10);
input_report_key(&rpcmouse_dev, BTN_MIDDLE, b & 0x20);
input_report_key(&rpcmouse_dev, BTN_RIGHT, b & 0x40);
b = __raw_readl(0xe0310000) ^ 0x70;
if (b != rpcmouse_lastb) {
input_report_key(dev, BTN_LEFT, b & 0x40);
input_report_key(dev, BTN_MIDDLE, b & 0x20);
input_report_key(dev, BTN_RIGHT, b & 0x10);
}
if (b != rpcmouse_lastb || dx || dy)
input_sync(dev);
input_sync(&rpcmouse_dev);
rpcmouse_lastb = b;
}
static int __init rpcmouse_init(void)
......@@ -80,7 +90,7 @@ static int __init rpcmouse_init(void)
rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX);
rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY);
if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", NULL)) {
if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", &rpcmouse_dev)) {
printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n");
return -1;
}
......
......@@ -12,12 +12,8 @@ if [ "$CONFIG_Q40" = "y" ]; then
fi
dep_tristate ' Parallel port keyboard adapter' CONFIG_SERIO_PARKBD $CONFIG_SERIO $CONFIG_PARPORT
if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
dep_tristate ' Acorn RiscPC keyboard controller' CONFIG_SERIO_ACORN $CONFIG_SERIO
fi
if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
dep_tristate ' AMBA KMI keyboard controller' CONFIG_SERIO_AMBAKMI $CONFIG_SERIO
fi
if [ "$CONFIG_SA1111" = "y" ]; then
dep_tristate ' Intel SA1111 keyboard controller' CONFIG_SERIO_SA1111 $CONFIG_SERIO
if [ "$CONFIG_ARM" = "y" ]; then
dep_tristate ' Acorn RiscPC keyboard controller' CONFIG_SERIO_RPCKBD $CONFIG_SERIO $CONFIG_ARCH_RPC
dep_tristate ' AMBA KMI keyboard controller' CONFIG_SERIO_AMBAKMI $CONFIG_SERIO $CONFIG_ARCH_INTEGRATOR
dep_tristate ' Intel SA1111 keyboard controller' CONFIG_SERIO_SA1111 $CONFIG_SERIO $CONFIG_SA1111
fi
......@@ -4,7 +4,9 @@
* Copyright (c) 2000-2001 Vojtech Pavlik
*
* Based on the work of:
* unknown author
* Russell King (thanks)
*
* Fixes by Russell King.
*/
/*
......@@ -32,44 +34,42 @@
*/
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/serio.h>
#include <asm/irq.h>
#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/iomd.h>
#include <asm/hardware/iomd.h>
#include <asm/system.h>
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Acorn RiscPC PS/2 keyboard controller driver");
MODULE_LICENSE("GPL");
static inline void rpckbd_write(unsigned char val)
extern struct pt_regs *kbd_pt_regs;
static int rpckbd_write(struct serio *port, unsigned char val)
{
while (!(iomd_readb(IOMD_KCTRL) & (1 << 7)))
cpu_relax();
iomd_writeb(val, IOMD_KARTTX);
}
static struct serio rpckbd_port =
{
.type = SERIO_8042,
.write = rpckbd_write,
.name = "RiscPC PS/2 kbd port",
.phys = "rpckbd/serio0",
};
return 0;
}
static void rpckbd_rx(int irq, void *dev_id, struct pt_regs *regs)
{
struct serio *port = dev_id;
unsigned int byte;
kbd_pt_regs = regs;
while (iomd_readb(IOMD_KCTRL) & (1 << 5)) {
byte = iomd_readb(IOMD_KARTRX);
serio_interrupt(&rpckbd_port, byte, 0);
serio_interrupt(port, byte, 0);
}
}
......@@ -77,34 +77,52 @@ static void rpckbd_tx(int irq, void *dev_id, struct pt_regs *regs)
{
}
static int __init rpckbd_init(void)
static int rpckbd_open(struct serio *port)
{
/* Reset the keyboard state machine. */
iomd_writeb(0, IOMD_KCTRL);
iomd_writeb(8, IOMD_KCTRL);
iomd_readb(IOMD_KARTRX);
if (request_irq(IRQ_KEYBOARDRX, rpckbd_rx, 0, "rpckbd", NULL) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ!\n")
if (request_irq(IRQ_KEYBOARDRX, rpckbd_rx, 0, "rpckbd", port) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ!\n");
return -EBUSY;
}
if (request_irq(IRQ_KEYBOARDTX, rpckbd_tx, 0, "rpckbd", NULL) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ!\n")
if (request_irq(IRQ_KEYBOARDTX, rpckbd_tx, 0, "rpckbd", port) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ!\n");
free_irq(IRQ_KEYBOARDRX, NULL);
return -EBUSY;
}
register_serio_port(&rpckbd_port);
return 0;
}
static void __exit rpckbd_exit(void)
static void rpckbd_close(struct serio *port)
{
free_irq(IRQ_KEYBOARDRX, port);
free_irq(IRQ_KEYBOARDTX, port);
}
static struct serio rpckbd_port =
{
.type = SERIO_8042,
.open = rpckbd_open,
.close = rpckbd_close,
.write = rpckbd_write,
.name = "RiscPC PS/2 kbd port",
.phys = "rpckbd/serio0",
};
static int __init rpckbd_init(void)
{
free_irq(IRQ_KEYBOARDRX, NULL);
free_irq(IRQ_KEYBOARDTX, NULL);
serio_register_port(&rpckbd_port);
return 0;
}
unregister_serio_port(&rpckbd_port);
static void __exit rpckbd_exit(void)
{
serio_unregister_port(&rpckbd_port);
}
module_init(rpckbd_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment