2005-04-17 05:20:36 +07:00
|
|
|
#ifndef _SERIO_H
|
|
|
|
#define _SERIO_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1999-2002 Vojtech Pavlik
|
|
|
|
*
|
|
|
|
* 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/ioctl.h>
|
|
|
|
|
|
|
|
#define SPIOCSTYPE _IOW('q', 0x01, unsigned long)
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2009-05-10 06:08:05 +07:00
|
|
|
#include <linux/types.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/spinlock.h>
|
2006-02-19 12:21:55 +07:00
|
|
|
#include <linux/mutex.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
|
|
|
|
struct serio {
|
|
|
|
void *port_data;
|
|
|
|
|
|
|
|
char name[32];
|
|
|
|
char phys[32];
|
|
|
|
|
2009-05-10 06:08:05 +07:00
|
|
|
bool manual_bind;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
struct serio_device_id id;
|
|
|
|
|
|
|
|
spinlock_t lock; /* protects critical sections from port's interrupt handler */
|
|
|
|
|
|
|
|
int (*write)(struct serio *, unsigned char);
|
|
|
|
int (*open)(struct serio *);
|
|
|
|
void (*close)(struct serio *);
|
|
|
|
int (*start)(struct serio *);
|
|
|
|
void (*stop)(struct serio *);
|
|
|
|
|
2010-10-05 11:46:10 +07:00
|
|
|
struct serio *parent;
|
|
|
|
struct list_head child_node; /* Entry in parent->children list */
|
|
|
|
struct list_head children;
|
2006-10-11 12:45:31 +07:00
|
|
|
unsigned int depth; /* level of nesting in serio hierarchy */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
|
2006-02-19 12:21:55 +07:00
|
|
|
struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
struct device dev;
|
|
|
|
|
|
|
|
struct list_head node;
|
|
|
|
};
|
|
|
|
#define to_serio_port(d) container_of(d, struct serio, dev)
|
|
|
|
|
|
|
|
struct serio_driver {
|
2010-09-14 13:53:55 +07:00
|
|
|
const char *description;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-14 13:53:55 +07:00
|
|
|
const struct serio_device_id *id_table;
|
2009-05-10 06:08:05 +07:00
|
|
|
bool manual_bind;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
void (*write_wakeup)(struct serio *);
|
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 20:55:46 +07:00
|
|
|
irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
|
2005-04-17 05:20:36 +07:00
|
|
|
int (*connect)(struct serio *, struct serio_driver *drv);
|
|
|
|
int (*reconnect)(struct serio *);
|
|
|
|
void (*disconnect)(struct serio *);
|
|
|
|
void (*cleanup)(struct serio *);
|
|
|
|
|
|
|
|
struct device_driver driver;
|
|
|
|
};
|
|
|
|
#define to_serio_driver(d) container_of(d, struct serio_driver, driver)
|
|
|
|
|
|
|
|
int serio_open(struct serio *serio, struct serio_driver *drv);
|
|
|
|
void serio_close(struct serio *serio);
|
|
|
|
void serio_rescan(struct serio *serio);
|
|
|
|
void serio_reconnect(struct serio *serio);
|
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 20:55:46 +07:00
|
|
|
irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
void __serio_register_port(struct serio *serio, struct module *owner);
|
2011-05-27 20:02:11 +07:00
|
|
|
|
|
|
|
/* use a define to avoid include chaining to get THIS_MODULE */
|
|
|
|
#define serio_register_port(serio) \
|
|
|
|
__serio_register_port(serio, THIS_MODULE)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
void serio_unregister_port(struct serio *serio);
|
2005-06-01 14:40:01 +07:00
|
|
|
void serio_unregister_child_port(struct serio *serio);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-05-27 20:02:11 +07:00
|
|
|
int __must_check __serio_register_driver(struct serio_driver *drv,
|
|
|
|
struct module *owner, const char *mod_name);
|
|
|
|
|
|
|
|
/* use a define to avoid include chaining to get THIS_MODULE & friends */
|
|
|
|
#define serio_register_driver(drv) \
|
|
|
|
__serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
void serio_unregister_driver(struct serio_driver *drv);
|
|
|
|
|
2012-04-04 13:50:15 +07:00
|
|
|
/**
|
|
|
|
* module_serio_driver() - Helper macro for registering a serio driver
|
|
|
|
* @__serio_driver: serio_driver struct
|
|
|
|
*
|
|
|
|
* Helper macro for serio drivers which do not do anything special in
|
|
|
|
* module init/exit. This eliminates a lot of boilerplate. Each module
|
|
|
|
* may only use this macro once, and calling it replaces module_init()
|
|
|
|
* and module_exit().
|
|
|
|
*/
|
|
|
|
#define module_serio_driver(__serio_driver) \
|
|
|
|
module_driver(__serio_driver, serio_register_driver, \
|
|
|
|
serio_unregister_driver)
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline int serio_write(struct serio *serio, unsigned char data)
|
|
|
|
{
|
|
|
|
if (serio->write)
|
|
|
|
return serio->write(serio, data);
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void serio_drv_write_wakeup(struct serio *serio)
|
|
|
|
{
|
|
|
|
if (serio->drv && serio->drv->write_wakeup)
|
|
|
|
serio->drv->write_wakeup(serio);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-03-26 16:38:58 +07:00
|
|
|
* Use the following functions to manipulate serio's per-port
|
2005-04-17 05:20:36 +07:00
|
|
|
* driver-specific data.
|
|
|
|
*/
|
|
|
|
static inline void *serio_get_drvdata(struct serio *serio)
|
|
|
|
{
|
|
|
|
return dev_get_drvdata(&serio->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void serio_set_drvdata(struct serio *serio, void *data)
|
|
|
|
{
|
|
|
|
dev_set_drvdata(&serio->dev, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-03-26 16:38:58 +07:00
|
|
|
* Use the following functions to protect critical sections in
|
2005-04-17 05:20:36 +07:00
|
|
|
* driver code from port's interrupt handler
|
|
|
|
*/
|
|
|
|
static inline void serio_pause_rx(struct serio *serio)
|
|
|
|
{
|
|
|
|
spin_lock_irq(&serio->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void serio_continue_rx(struct serio *serio)
|
|
|
|
{
|
|
|
|
spin_unlock_irq(&serio->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* bit masks for use in "interrupt" flags (3rd argument)
|
|
|
|
*/
|
|
|
|
#define SERIO_TIMEOUT 1
|
|
|
|
#define SERIO_PARITY 2
|
|
|
|
#define SERIO_FRAME 4
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Serio types
|
|
|
|
*/
|
|
|
|
#define SERIO_XT 0x00
|
|
|
|
#define SERIO_8042 0x01
|
|
|
|
#define SERIO_RS232 0x02
|
|
|
|
#define SERIO_HIL_MLC 0x03
|
|
|
|
#define SERIO_PS_PSTHRU 0x05
|
|
|
|
#define SERIO_8042_XL 0x06
|
|
|
|
|
|
|
|
/*
|
2008-07-08 21:30:27 +07:00
|
|
|
* Serio protocols
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
#define SERIO_UNKNOWN 0x00
|
|
|
|
#define SERIO_MSC 0x01
|
|
|
|
#define SERIO_SUN 0x02
|
|
|
|
#define SERIO_MS 0x03
|
|
|
|
#define SERIO_MP 0x04
|
|
|
|
#define SERIO_MZ 0x05
|
|
|
|
#define SERIO_MZP 0x06
|
|
|
|
#define SERIO_MZPP 0x07
|
|
|
|
#define SERIO_VSXXXAA 0x08
|
|
|
|
#define SERIO_SUNKBD 0x10
|
|
|
|
#define SERIO_WARRIOR 0x18
|
|
|
|
#define SERIO_SPACEORB 0x19
|
|
|
|
#define SERIO_MAGELLAN 0x1a
|
|
|
|
#define SERIO_SPACEBALL 0x1b
|
|
|
|
#define SERIO_GUNZE 0x1c
|
|
|
|
#define SERIO_IFORCE 0x1d
|
|
|
|
#define SERIO_STINGER 0x1e
|
|
|
|
#define SERIO_NEWTON 0x1f
|
|
|
|
#define SERIO_STOWAWAY 0x20
|
|
|
|
#define SERIO_H3600 0x21
|
|
|
|
#define SERIO_PS2SER 0x22
|
|
|
|
#define SERIO_TWIDKBD 0x23
|
|
|
|
#define SERIO_TWIDJOY 0x24
|
|
|
|
#define SERIO_HIL 0x25
|
|
|
|
#define SERIO_SNES232 0x26
|
|
|
|
#define SERIO_SEMTECH 0x27
|
|
|
|
#define SERIO_LKKBD 0x28
|
|
|
|
#define SERIO_ELO 0x29
|
|
|
|
#define SERIO_MICROTOUCH 0x30
|
2006-08-05 11:32:18 +07:00
|
|
|
#define SERIO_PENMOUNT 0x31
|
2006-08-05 11:32:24 +07:00
|
|
|
#define SERIO_TOUCHRIGHT 0x32
|
2006-08-05 11:32:30 +07:00
|
|
|
#define SERIO_TOUCHWIN 0x33
|
2007-07-12 19:12:31 +07:00
|
|
|
#define SERIO_TAOSEVM 0x34
|
2007-07-18 11:37:01 +07:00
|
|
|
#define SERIO_FUJITSU 0x35
|
2008-03-10 19:40:36 +07:00
|
|
|
#define SERIO_ZHENHUA 0x36
|
2008-06-26 21:10:41 +07:00
|
|
|
#define SERIO_INEXIO 0x37
|
2009-03-08 04:39:22 +07:00
|
|
|
#define SERIO_TOUCHIT213 0x38
|
2008-11-20 04:58:50 +07:00
|
|
|
#define SERIO_W8001 0x39
|
2009-10-26 02:13:58 +07:00
|
|
|
#define SERIO_DYNAPRO 0x3a
|
2010-04-13 09:54:38 +07:00
|
|
|
#define SERIO_HAMPSHIRE 0x3b
|
2010-10-18 23:18:13 +07:00
|
|
|
#define SERIO_PS2MULT 0x3c
|
2011-09-29 00:04:21 +07:00
|
|
|
#define SERIO_TSC40 0x3d
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#endif
|