2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* drivers/input/serio/gscps2.c
|
|
|
|
*
|
2006-03-28 03:52:15 +08:00
|
|
|
* Copyright (c) 2004-2006 Helge Deller <deller@gmx.de>
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (c) 2002 Laurent Canet <canetl@esiee.fr>
|
|
|
|
* Copyright (c) 2002 Thibaut Varene <varenet@parisc-linux.org>
|
|
|
|
*
|
|
|
|
* Pieces of code based on linux-2.4's hp_mouse.c & hp_keyb.c
|
2009-12-12 13:50:47 +08:00
|
|
|
* Copyright (c) 1999 Alex deVries <alex@onefishtwo.ca>
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (c) 1999-2000 Philipp Rumpf <prumpf@tux.org>
|
|
|
|
* Copyright (c) 2000 Xavier Debacker <debackex@esiee.fr>
|
|
|
|
* Copyright (c) 2000-2001 Thomas Marteau <marteaut@esiee.fr>
|
|
|
|
*
|
|
|
|
* HP GSC PS/2 port driver, found in PA/RISC Workstations
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* - Dino testing (did HP ever shipped a machine on which this port
|
|
|
|
* was usable/enabled ?)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.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 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/serio.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/parisc-device.h>
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Laurent Canet <canetl@esiee.fr>, Thibaut Varene <varenet@parisc-linux.org>, Helge Deller <deller@gmx.de>");
|
|
|
|
MODULE_DESCRIPTION("HP GSC PS2 port driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
#define PFX "gscps2.c: "
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Driver constants
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* various constants */
|
|
|
|
#define ENABLE 1
|
|
|
|
#define DISABLE 0
|
|
|
|
|
|
|
|
#define GSC_DINO_OFFSET 0x0800 /* offset for DINO controller versus LASI one */
|
|
|
|
|
|
|
|
/* PS/2 IO port offsets */
|
|
|
|
#define GSC_ID 0x00 /* device ID offset (see: GSC_ID_XXX) */
|
|
|
|
#define GSC_RESET 0x00 /* reset port offset */
|
|
|
|
#define GSC_RCVDATA 0x04 /* receive port offset */
|
|
|
|
#define GSC_XMTDATA 0x04 /* transmit port offset */
|
|
|
|
#define GSC_CONTROL 0x08 /* see: Control register bits */
|
|
|
|
#define GSC_STATUS 0x0C /* see: Status register bits */
|
|
|
|
|
|
|
|
/* Control register bits */
|
|
|
|
#define GSC_CTRL_ENBL 0x01 /* enable interface */
|
|
|
|
#define GSC_CTRL_LPBXR 0x02 /* loopback operation */
|
|
|
|
#define GSC_CTRL_DIAG 0x20 /* directly control clock/data line */
|
|
|
|
#define GSC_CTRL_DATDIR 0x40 /* data line direct control */
|
|
|
|
#define GSC_CTRL_CLKDIR 0x80 /* clock line direct control */
|
|
|
|
|
|
|
|
/* Status register bits */
|
|
|
|
#define GSC_STAT_RBNE 0x01 /* Receive Buffer Not Empty */
|
|
|
|
#define GSC_STAT_TBNE 0x02 /* Transmit Buffer Not Empty */
|
|
|
|
#define GSC_STAT_TERR 0x04 /* Timeout Error */
|
|
|
|
#define GSC_STAT_PERR 0x08 /* Parity Error */
|
|
|
|
#define GSC_STAT_CMPINTR 0x10 /* Composite Interrupt = irq on any port */
|
|
|
|
#define GSC_STAT_DATSHD 0x40 /* Data Line Shadow */
|
|
|
|
#define GSC_STAT_CLKSHD 0x80 /* Clock Line Shadow */
|
|
|
|
|
|
|
|
/* IDs returned by GSC_ID port register */
|
|
|
|
#define GSC_ID_KEYBOARD 0 /* device ID values */
|
|
|
|
#define GSC_ID_MOUSE 1
|
|
|
|
|
|
|
|
|
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 21:55:46 +08:00
|
|
|
static irqreturn_t gscps2_interrupt(int irq, void *dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define BUFFER_SIZE 0x0f
|
|
|
|
|
|
|
|
/* GSC PS/2 port device struct */
|
|
|
|
struct gscps2port {
|
|
|
|
struct list_head node;
|
|
|
|
struct parisc_device *padev;
|
|
|
|
struct serio *port;
|
|
|
|
spinlock_t lock;
|
|
|
|
char *addr;
|
|
|
|
u8 act, append; /* position in buffer[] */
|
|
|
|
struct {
|
|
|
|
u8 data;
|
|
|
|
u8 str;
|
|
|
|
} buffer[BUFFER_SIZE+1];
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Various HW level routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define gscps2_readb_input(x) readb((x)+GSC_RCVDATA)
|
|
|
|
#define gscps2_readb_control(x) readb((x)+GSC_CONTROL)
|
|
|
|
#define gscps2_readb_status(x) readb((x)+GSC_STATUS)
|
|
|
|
#define gscps2_writeb_control(x, y) writeb((x), (y)+GSC_CONTROL)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wait_TBE() - wait for Transmit Buffer Empty
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int wait_TBE(char *addr)
|
|
|
|
{
|
|
|
|
int timeout = 25000; /* device is expected to react within 250 msec */
|
|
|
|
while (gscps2_readb_status(addr) & GSC_STAT_TBNE) {
|
|
|
|
if (!--timeout)
|
|
|
|
return 0; /* This should not happen */
|
|
|
|
udelay(10);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gscps2_flush() - flush the receive buffer
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void gscps2_flush(struct gscps2port *ps2port)
|
|
|
|
{
|
|
|
|
while (gscps2_readb_status(ps2port->addr) & GSC_STAT_RBNE)
|
|
|
|
gscps2_readb_input(ps2port->addr);
|
|
|
|
ps2port->act = ps2port->append = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gscps2_writeb_output() - write a byte to the port
|
|
|
|
*
|
2008-02-03 23:15:20 +08:00
|
|
|
* returns 1 on success, 0 on error
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
char *addr = ps2port->addr;
|
|
|
|
|
|
|
|
if (!wait_TBE(addr)) {
|
|
|
|
printk(KERN_DEBUG PFX "timeout - could not write byte %#x\n", data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (gscps2_readb_status(ps2port->addr) & GSC_STAT_RBNE)
|
|
|
|
/* wait */;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ps2port->lock, flags);
|
|
|
|
writeb(data, addr+GSC_XMTDATA);
|
|
|
|
spin_unlock_irqrestore(&ps2port->lock, flags);
|
|
|
|
|
|
|
|
/* this is ugly, but due to timing of the port it seems to be necessary. */
|
|
|
|
mdelay(6);
|
|
|
|
|
|
|
|
/* make sure any received data is returned as fast as possible */
|
|
|
|
/* this is important e.g. when we set the LEDs on the keyboard */
|
2006-10-07 10:47:23 +08:00
|
|
|
gscps2_interrupt(0, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gscps2_enable() - enables or disables the port
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void gscps2_enable(struct gscps2port *ps2port, int enable)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
u8 data;
|
|
|
|
|
|
|
|
/* now enable/disable the port */
|
|
|
|
spin_lock_irqsave(&ps2port->lock, flags);
|
|
|
|
gscps2_flush(ps2port);
|
|
|
|
data = gscps2_readb_control(ps2port->addr);
|
|
|
|
if (enable)
|
|
|
|
data |= GSC_CTRL_ENBL;
|
|
|
|
else
|
|
|
|
data &= ~GSC_CTRL_ENBL;
|
|
|
|
gscps2_writeb_control(data, ps2port->addr);
|
|
|
|
spin_unlock_irqrestore(&ps2port->lock, flags);
|
|
|
|
wait_TBE(ps2port->addr);
|
|
|
|
gscps2_flush(ps2port);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gscps2_reset() - resets the PS/2 port
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void gscps2_reset(struct gscps2port *ps2port)
|
|
|
|
{
|
|
|
|
char *addr = ps2port->addr;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/* reset the interface */
|
|
|
|
spin_lock_irqsave(&ps2port->lock, flags);
|
|
|
|
gscps2_flush(ps2port);
|
|
|
|
writeb(0xff, addr+GSC_RESET);
|
|
|
|
gscps2_flush(ps2port);
|
|
|
|
spin_unlock_irqrestore(&ps2port->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LIST_HEAD(ps2port_list);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gscps2_interrupt() - Interruption service routine
|
|
|
|
*
|
|
|
|
* This function reads received PS/2 bytes and processes them on
|
|
|
|
* all interfaces.
|
|
|
|
* The problematic part here is, that the keyboard and mouse PS/2 port
|
|
|
|
* share the same interrupt and it's not possible to send data if any
|
|
|
|
* one of them holds input data. To solve this problem we try to receive
|
|
|
|
* the data as fast as possible and handle the reporting to the upper layer
|
|
|
|
* later.
|
|
|
|
*/
|
|
|
|
|
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 21:55:46 +08:00
|
|
|
static irqreturn_t gscps2_interrupt(int irq, void *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct gscps2port *ps2port;
|
|
|
|
|
|
|
|
list_for_each_entry(ps2port, &ps2port_list, node) {
|
|
|
|
|
|
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&ps2port->lock, flags);
|
|
|
|
|
|
|
|
while ( (ps2port->buffer[ps2port->append].str =
|
|
|
|
gscps2_readb_status(ps2port->addr)) & GSC_STAT_RBNE ) {
|
|
|
|
ps2port->buffer[ps2port->append].data =
|
|
|
|
gscps2_readb_input(ps2port->addr);
|
|
|
|
ps2port->append = ((ps2port->append+1) & BUFFER_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ps2port->lock, flags);
|
|
|
|
|
|
|
|
} /* list_for_each_entry */
|
|
|
|
|
|
|
|
/* all data was read from the ports - now report the data to upper layer */
|
|
|
|
|
|
|
|
list_for_each_entry(ps2port, &ps2port_list, node) {
|
|
|
|
|
|
|
|
while (ps2port->act != ps2port->append) {
|
|
|
|
|
|
|
|
unsigned int rxflags;
|
|
|
|
u8 data, status;
|
|
|
|
|
|
|
|
/* Did new data arrived while we read existing data ?
|
|
|
|
If yes, exit now and let the new irq handler start over again */
|
|
|
|
if (gscps2_readb_status(ps2port->addr) & GSC_STAT_CMPINTR)
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
|
|
|
|
status = ps2port->buffer[ps2port->act].str;
|
|
|
|
data = ps2port->buffer[ps2port->act].data;
|
|
|
|
|
|
|
|
ps2port->act = ((ps2port->act+1) & BUFFER_SIZE);
|
|
|
|
rxflags = ((status & GSC_STAT_TERR) ? SERIO_TIMEOUT : 0 ) |
|
|
|
|
((status & GSC_STAT_PERR) ? SERIO_PARITY : 0 );
|
|
|
|
|
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 21:55:46 +08:00
|
|
|
serio_interrupt(ps2port->port, data, rxflags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
} /* while() */
|
|
|
|
|
|
|
|
} /* list_for_each_entry */
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gscps2_write() - send a byte out through the aux interface.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int gscps2_write(struct serio *port, unsigned char data)
|
|
|
|
{
|
|
|
|
struct gscps2port *ps2port = port->port_data;
|
|
|
|
|
|
|
|
if (!gscps2_writeb_output(ps2port, data)) {
|
|
|
|
printk(KERN_DEBUG PFX "sending byte %#x failed.\n", data);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gscps2_open() is called when a port is opened by the higher layer.
|
|
|
|
* It resets and enables the port.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int gscps2_open(struct serio *port)
|
|
|
|
{
|
|
|
|
struct gscps2port *ps2port = port->port_data;
|
|
|
|
|
|
|
|
gscps2_reset(ps2port);
|
|
|
|
|
2005-10-22 10:58:51 +08:00
|
|
|
/* enable it */
|
|
|
|
gscps2_enable(ps2port, ENABLE);
|
|
|
|
|
2006-10-07 10:47:23 +08:00
|
|
|
gscps2_interrupt(0, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gscps2_close() disables the port
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void gscps2_close(struct serio *port)
|
|
|
|
{
|
|
|
|
struct gscps2port *ps2port = port->port_data;
|
|
|
|
gscps2_enable(ps2port, DISABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gscps2_probe() - Probes PS2 devices
|
|
|
|
* @return: success/error report
|
|
|
|
*/
|
|
|
|
|
2012-11-24 13:38:25 +08:00
|
|
|
static int gscps2_probe(struct parisc_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct gscps2port *ps2port;
|
|
|
|
struct serio *serio;
|
2005-10-22 10:36:40 +08:00
|
|
|
unsigned long hpa = dev->hpa.start;
|
2005-04-17 06:20:36 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!dev->irq)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* Offset for DINO PS/2. Works with LASI even */
|
|
|
|
if (dev->id.sversion == 0x96)
|
|
|
|
hpa += GSC_DINO_OFFSET;
|
|
|
|
|
2007-08-30 12:18:00 +08:00
|
|
|
ps2port = kzalloc(sizeof(struct gscps2port), GFP_KERNEL);
|
|
|
|
serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ps2port || !serio) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail_nomem;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_set_drvdata(&dev->dev, ps2port);
|
|
|
|
|
|
|
|
ps2port->port = serio;
|
|
|
|
ps2port->padev = dev;
|
2006-03-28 03:52:15 +08:00
|
|
|
ps2port->addr = ioremap_nocache(hpa, GSC_STATUS + 4);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_init(&ps2port->lock);
|
|
|
|
|
|
|
|
gscps2_reset(ps2port);
|
|
|
|
ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f;
|
|
|
|
|
2010-11-02 23:23:08 +08:00
|
|
|
snprintf(serio->name, sizeof(serio->name), "gsc-ps2-%s",
|
2005-04-17 06:20:36 +08:00
|
|
|
(ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse");
|
2009-01-30 14:56:08 +08:00
|
|
|
strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys));
|
2005-04-17 06:20:36 +08:00
|
|
|
serio->id.type = SERIO_8042;
|
|
|
|
serio->write = gscps2_write;
|
|
|
|
serio->open = gscps2_open;
|
|
|
|
serio->close = gscps2_close;
|
|
|
|
serio->port_data = ps2port;
|
|
|
|
serio->dev.parent = &dev->dev;
|
|
|
|
|
|
|
|
ret = -EBUSY;
|
2006-07-02 10:29:38 +08:00
|
|
|
if (request_irq(dev->irq, gscps2_interrupt, IRQF_SHARED, ps2port->port->name, ps2port))
|
2005-04-17 06:20:36 +08:00
|
|
|
goto fail_miserably;
|
|
|
|
|
|
|
|
if (ps2port->id != GSC_ID_KEYBOARD && ps2port->id != GSC_ID_MOUSE) {
|
|
|
|
printk(KERN_WARNING PFX "Unsupported PS/2 port at 0x%08lx (id=%d) ignored\n",
|
|
|
|
hpa, ps2port->id);
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (!request_mem_region(hpa, GSC_STATUS + 4, ps2port->port.name))
|
|
|
|
goto fail;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
printk(KERN_INFO "serio: %s port at 0x%p irq %d @ %s\n",
|
|
|
|
ps2port->port->name,
|
|
|
|
ps2port->addr,
|
|
|
|
ps2port->padev->irq,
|
|
|
|
ps2port->port->phys);
|
|
|
|
|
|
|
|
serio_register_port(ps2port->port);
|
|
|
|
|
2005-10-22 10:58:51 +08:00
|
|
|
list_add_tail(&ps2port->node, &ps2port_list);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
free_irq(dev->irq, ps2port);
|
|
|
|
|
|
|
|
fail_miserably:
|
|
|
|
iounmap(ps2port->addr);
|
2005-10-22 10:58:51 +08:00
|
|
|
release_mem_region(dev->hpa.start, GSC_STATUS + 4);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
fail_nomem:
|
|
|
|
kfree(ps2port);
|
|
|
|
kfree(serio);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gscps2_remove() - Removes PS2 devices
|
|
|
|
* @return: success/error report
|
|
|
|
*/
|
|
|
|
|
2012-11-24 13:50:47 +08:00
|
|
|
static int gscps2_remove(struct parisc_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct gscps2port *ps2port = dev_get_drvdata(&dev->dev);
|
|
|
|
|
|
|
|
serio_unregister_port(ps2port->port);
|
|
|
|
free_irq(dev->irq, ps2port);
|
|
|
|
gscps2_flush(ps2port);
|
|
|
|
list_del(&ps2port->node);
|
|
|
|
iounmap(ps2port->addr);
|
|
|
|
#if 0
|
|
|
|
release_mem_region(dev->hpa, GSC_STATUS + 4);
|
|
|
|
#endif
|
|
|
|
dev_set_drvdata(&dev->dev, NULL);
|
|
|
|
kfree(ps2port);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct parisc_device_id gscps2_device_tbl[] = {
|
|
|
|
{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00084 }, /* LASI PS/2 */
|
|
|
|
#ifdef DINO_TESTED
|
|
|
|
{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00096 }, /* DINO PS/2 */
|
|
|
|
#endif
|
|
|
|
{ 0, } /* 0 terminated list */
|
|
|
|
};
|
2015-02-05 02:59:25 +08:00
|
|
|
MODULE_DEVICE_TABLE(parisc, gscps2_device_tbl);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static struct parisc_driver parisc_ps2_driver = {
|
2005-10-22 10:36:23 +08:00
|
|
|
.name = "gsc_ps2",
|
2005-04-17 06:20:36 +08:00
|
|
|
.id_table = gscps2_device_tbl,
|
|
|
|
.probe = gscps2_probe,
|
2012-11-24 13:27:39 +08:00
|
|
|
.remove = gscps2_remove,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init gscps2_init(void)
|
|
|
|
{
|
|
|
|
register_parisc_driver(&parisc_ps2_driver);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit gscps2_exit(void)
|
|
|
|
{
|
|
|
|
unregister_parisc_driver(&parisc_ps2_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module_init(gscps2_init);
|
|
|
|
module_exit(gscps2_exit);
|
|
|
|
|