2008-07-07 20:17:48 +00:00
|
|
|
/*
|
|
|
|
* Xilinx XPS PS/2 device driver
|
|
|
|
*
|
|
|
|
* (c) 2005 MontaVista Software, Inc.
|
|
|
|
* (c) 2008 Xilinx, Inc.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/serio.h>
|
|
|
|
#include <linux/interrupt.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>
|
2008-07-07 20:17:48 +00:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/io.h>
|
2011-07-13 13:46:21 +00:00
|
|
|
#include <linux/of_address.h>
|
2008-07-07 20:17:48 +00:00
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/of_platform.h>
|
|
|
|
|
|
|
|
#define DRIVER_NAME "xilinx_ps2"
|
|
|
|
|
|
|
|
/* Register offsets for the xps2 device */
|
|
|
|
#define XPS2_SRST_OFFSET 0x00000000 /* Software Reset register */
|
|
|
|
#define XPS2_STATUS_OFFSET 0x00000004 /* Status register */
|
|
|
|
#define XPS2_RX_DATA_OFFSET 0x00000008 /* Receive Data register */
|
|
|
|
#define XPS2_TX_DATA_OFFSET 0x0000000C /* Transmit Data register */
|
|
|
|
#define XPS2_GIER_OFFSET 0x0000002C /* Global Interrupt Enable reg */
|
|
|
|
#define XPS2_IPISR_OFFSET 0x00000030 /* Interrupt Status register */
|
|
|
|
#define XPS2_IPIER_OFFSET 0x00000038 /* Interrupt Enable register */
|
|
|
|
|
|
|
|
/* Reset Register Bit Definitions */
|
|
|
|
#define XPS2_SRST_RESET 0x0000000A /* Software Reset */
|
|
|
|
|
|
|
|
/* Status Register Bit Positions */
|
|
|
|
#define XPS2_STATUS_RX_FULL 0x00000001 /* Receive Full */
|
|
|
|
#define XPS2_STATUS_TX_FULL 0x00000002 /* Transmit Full */
|
|
|
|
|
|
|
|
/* Bit definitions for ISR/IER registers. Both the registers have the same bit
|
|
|
|
* definitions and are only defined once. */
|
|
|
|
#define XPS2_IPIXR_WDT_TOUT 0x00000001 /* Watchdog Timeout Interrupt */
|
|
|
|
#define XPS2_IPIXR_TX_NOACK 0x00000002 /* Transmit No ACK Interrupt */
|
|
|
|
#define XPS2_IPIXR_TX_ACK 0x00000004 /* Transmit ACK (Data) Interrupt */
|
|
|
|
#define XPS2_IPIXR_RX_OVF 0x00000008 /* Receive Overflow Interrupt */
|
|
|
|
#define XPS2_IPIXR_RX_ERR 0x00000010 /* Receive Error Interrupt */
|
|
|
|
#define XPS2_IPIXR_RX_FULL 0x00000020 /* Receive Data Interrupt */
|
|
|
|
|
|
|
|
/* Mask for all the Transmit Interrupts */
|
|
|
|
#define XPS2_IPIXR_TX_ALL (XPS2_IPIXR_TX_NOACK | XPS2_IPIXR_TX_ACK)
|
|
|
|
|
|
|
|
/* Mask for all the Receive Interrupts */
|
|
|
|
#define XPS2_IPIXR_RX_ALL (XPS2_IPIXR_RX_OVF | XPS2_IPIXR_RX_ERR | \
|
2008-10-28 02:17:22 +00:00
|
|
|
XPS2_IPIXR_RX_FULL)
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
/* Mask for all the Interrupts */
|
|
|
|
#define XPS2_IPIXR_ALL (XPS2_IPIXR_TX_ALL | XPS2_IPIXR_RX_ALL | \
|
2008-10-28 02:17:22 +00:00
|
|
|
XPS2_IPIXR_WDT_TOUT)
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
/* Global Interrupt Enable mask */
|
|
|
|
#define XPS2_GIER_GIE_MASK 0x80000000
|
|
|
|
|
|
|
|
struct xps2data {
|
|
|
|
int irq;
|
|
|
|
spinlock_t lock;
|
|
|
|
void __iomem *base_address; /* virt. address of control registers */
|
2008-10-28 02:17:22 +00:00
|
|
|
unsigned int flags;
|
2012-03-26 00:23:19 +00:00
|
|
|
struct serio *serio; /* serio */
|
|
|
|
struct device *dev;
|
2008-07-07 20:17:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/************************************/
|
|
|
|
/* XPS PS/2 data transmission calls */
|
|
|
|
/************************************/
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/**
|
|
|
|
* xps2_recv() - attempts to receive a byte from the PS/2 port.
|
|
|
|
* @drvdata: pointer to ps2 device private data structure
|
|
|
|
* @byte: address where the read data will be copied
|
|
|
|
*
|
|
|
|
* If there is any data available in the PS/2 receiver, this functions reads
|
|
|
|
* the data, otherwise it returns error.
|
2008-07-07 20:17:48 +00:00
|
|
|
*/
|
|
|
|
static int xps2_recv(struct xps2data *drvdata, u8 *byte)
|
|
|
|
{
|
|
|
|
u32 sr;
|
|
|
|
int status = -1;
|
|
|
|
|
|
|
|
/* If there is data available in the PS/2 receiver, read it */
|
|
|
|
sr = in_be32(drvdata->base_address + XPS2_STATUS_OFFSET);
|
|
|
|
if (sr & XPS2_STATUS_RX_FULL) {
|
|
|
|
*byte = in_be32(drvdata->base_address + XPS2_RX_DATA_OFFSET);
|
|
|
|
status = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************/
|
|
|
|
/* Interrupt handler */
|
|
|
|
/*********************/
|
|
|
|
static irqreturn_t xps2_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct xps2data *drvdata = dev_id;
|
|
|
|
u32 intr_sr;
|
|
|
|
u8 c;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
/* Get the PS/2 interrupts and clear them */
|
|
|
|
intr_sr = in_be32(drvdata->base_address + XPS2_IPISR_OFFSET);
|
|
|
|
out_be32(drvdata->base_address + XPS2_IPISR_OFFSET, intr_sr);
|
|
|
|
|
|
|
|
/* Check which interrupt is active */
|
|
|
|
if (intr_sr & XPS2_IPIXR_RX_OVF)
|
2012-03-26 00:23:19 +00:00
|
|
|
dev_warn(drvdata->dev, "receive overrun error\n");
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
if (intr_sr & XPS2_IPIXR_RX_ERR)
|
2008-10-28 02:17:22 +00:00
|
|
|
drvdata->flags |= SERIO_PARITY;
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
if (intr_sr & (XPS2_IPIXR_TX_NOACK | XPS2_IPIXR_WDT_TOUT))
|
2008-10-28 02:17:22 +00:00
|
|
|
drvdata->flags |= SERIO_TIMEOUT;
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
if (intr_sr & XPS2_IPIXR_RX_FULL) {
|
2008-10-28 02:17:22 +00:00
|
|
|
status = xps2_recv(drvdata, &c);
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
/* Error, if a byte is not received */
|
|
|
|
if (status) {
|
2012-03-26 00:23:19 +00:00
|
|
|
dev_err(drvdata->dev,
|
2008-10-28 02:17:22 +00:00
|
|
|
"wrong rcvd byte count (%d)\n", status);
|
2008-07-07 20:17:48 +00:00
|
|
|
} else {
|
2012-03-26 00:23:19 +00:00
|
|
|
serio_interrupt(drvdata->serio, c, drvdata->flags);
|
2008-10-28 02:17:22 +00:00
|
|
|
drvdata->flags = 0;
|
2008-07-07 20:17:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************/
|
|
|
|
/* serio callbacks */
|
|
|
|
/*******************/
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/**
|
|
|
|
* sxps2_write() - sends a byte out through the PS/2 port.
|
|
|
|
* @pserio: pointer to the serio structure of the PS/2 port
|
|
|
|
* @c: data that needs to be written to the PS/2 port
|
|
|
|
*
|
|
|
|
* This function checks if the PS/2 transmitter is empty and sends a byte.
|
|
|
|
* Otherwise it returns error. Transmission fails only when nothing is connected
|
|
|
|
* to the PS/2 port. Thats why, we do not try to resend the data in case of a
|
|
|
|
* failure.
|
2008-07-07 20:17:48 +00:00
|
|
|
*/
|
|
|
|
static int sxps2_write(struct serio *pserio, unsigned char c)
|
|
|
|
{
|
|
|
|
struct xps2data *drvdata = pserio->port_data;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 sr;
|
|
|
|
int status = -1;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&drvdata->lock, flags);
|
|
|
|
|
|
|
|
/* If the PS/2 transmitter is empty send a byte of data */
|
|
|
|
sr = in_be32(drvdata->base_address + XPS2_STATUS_OFFSET);
|
|
|
|
if (!(sr & XPS2_STATUS_TX_FULL)) {
|
|
|
|
out_be32(drvdata->base_address + XPS2_TX_DATA_OFFSET, c);
|
|
|
|
status = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&drvdata->lock, flags);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/**
|
|
|
|
* sxps2_open() - called when a port is opened by the higher layer.
|
|
|
|
* @pserio: pointer to the serio structure of the PS/2 device
|
|
|
|
*
|
|
|
|
* This function requests irq and enables interrupts for the PS/2 device.
|
2008-07-07 20:17:48 +00:00
|
|
|
*/
|
|
|
|
static int sxps2_open(struct serio *pserio)
|
|
|
|
{
|
|
|
|
struct xps2data *drvdata = pserio->port_data;
|
2008-10-28 02:17:22 +00:00
|
|
|
int error;
|
|
|
|
u8 c;
|
2008-07-07 20:17:48 +00:00
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
error = request_irq(drvdata->irq, &xps2_interrupt, 0,
|
2008-07-07 20:17:48 +00:00
|
|
|
DRIVER_NAME, drvdata);
|
2008-10-28 02:17:22 +00:00
|
|
|
if (error) {
|
2012-03-26 00:23:19 +00:00
|
|
|
dev_err(drvdata->dev,
|
2008-10-28 02:17:22 +00:00
|
|
|
"Couldn't allocate interrupt %d\n", drvdata->irq);
|
|
|
|
return error;
|
2008-07-07 20:17:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* start reception by enabling the interrupts */
|
|
|
|
out_be32(drvdata->base_address + XPS2_GIER_OFFSET, XPS2_GIER_GIE_MASK);
|
|
|
|
out_be32(drvdata->base_address + XPS2_IPIER_OFFSET, XPS2_IPIXR_RX_ALL);
|
2008-10-28 02:17:22 +00:00
|
|
|
(void)xps2_recv(drvdata, &c);
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
return 0; /* success */
|
|
|
|
}
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/**
|
|
|
|
* sxps2_close() - frees the interrupt.
|
|
|
|
* @pserio: pointer to the serio structure of the PS/2 device
|
|
|
|
*
|
|
|
|
* This function frees the irq and disables interrupts for the PS/2 device.
|
2008-07-07 20:17:48 +00:00
|
|
|
*/
|
|
|
|
static void sxps2_close(struct serio *pserio)
|
|
|
|
{
|
|
|
|
struct xps2data *drvdata = pserio->port_data;
|
|
|
|
|
|
|
|
/* Disable the PS2 interrupts */
|
|
|
|
out_be32(drvdata->base_address + XPS2_GIER_OFFSET, 0x00);
|
|
|
|
out_be32(drvdata->base_address + XPS2_IPIER_OFFSET, 0x00);
|
|
|
|
free_irq(drvdata->irq, drvdata);
|
|
|
|
}
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/**
|
|
|
|
* xps2_of_probe - probe method for the PS/2 device.
|
|
|
|
* @of_dev: pointer to OF device structure
|
2011-03-31 01:57:33 +00:00
|
|
|
* @match: pointer to the structure used for matching a device
|
2008-10-28 02:17:22 +00:00
|
|
|
*
|
|
|
|
* This function probes the PS/2 device in the device tree.
|
|
|
|
* It initializes the driver data structure and the hardware.
|
|
|
|
* It returns 0, if the driver is bound to the PS/2 device, or a negative
|
|
|
|
* value if there is an error.
|
|
|
|
*/
|
2011-02-17 09:43:24 +00:00
|
|
|
static int __devinit xps2_of_probe(struct platform_device *ofdev)
|
2008-07-07 20:17:48 +00:00
|
|
|
{
|
2008-10-28 02:17:22 +00:00
|
|
|
struct resource r_irq; /* Interrupt resources */
|
|
|
|
struct resource r_mem; /* IO mem resources */
|
2008-07-07 20:17:48 +00:00
|
|
|
struct xps2data *drvdata;
|
|
|
|
struct serio *serio;
|
2008-10-28 02:17:22 +00:00
|
|
|
struct device *dev = &ofdev->dev;
|
|
|
|
resource_size_t remap_size, phys_addr;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
dev_info(dev, "Device Tree Probing \'%s\'\n",
|
2010-04-13 23:12:29 +00:00
|
|
|
ofdev->dev.of_node->name);
|
2008-07-07 20:17:48 +00:00
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/* Get iospace for the device */
|
2010-04-13 23:12:29 +00:00
|
|
|
error = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
|
2008-10-28 02:17:22 +00:00
|
|
|
if (error) {
|
|
|
|
dev_err(dev, "invalid address\n");
|
|
|
|
return error;
|
|
|
|
}
|
2008-07-07 20:17:48 +00:00
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/* Get IRQ for the device */
|
2011-12-21 12:28:23 +00:00
|
|
|
if (!of_irq_to_resource(ofdev->dev.of_node, 0, &r_irq)) {
|
2008-10-28 02:17:22 +00:00
|
|
|
dev_err(dev, "no IRQ found\n");
|
|
|
|
return -ENODEV;
|
2008-07-07 20:17:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
drvdata = kzalloc(sizeof(struct xps2data), GFP_KERNEL);
|
2012-03-26 00:23:19 +00:00
|
|
|
serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
|
|
|
|
if (!drvdata || !serio) {
|
|
|
|
error = -ENOMEM;
|
|
|
|
goto failed1;
|
2008-07-07 20:17:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_init(&drvdata->lock);
|
2008-10-28 02:17:22 +00:00
|
|
|
drvdata->irq = r_irq.start;
|
2012-03-26 00:23:19 +00:00
|
|
|
drvdata->serio = serio;
|
|
|
|
drvdata->dev = dev;
|
2008-10-28 02:17:22 +00:00
|
|
|
|
|
|
|
phys_addr = r_mem.start;
|
2010-01-22 07:52:37 +00:00
|
|
|
remap_size = resource_size(&r_mem);
|
2008-10-28 02:17:22 +00:00
|
|
|
if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) {
|
|
|
|
dev_err(dev, "Couldn't lock memory region at 0x%08llX\n",
|
|
|
|
(unsigned long long)phys_addr);
|
|
|
|
error = -EBUSY;
|
2008-07-07 20:17:48 +00:00
|
|
|
goto failed1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in configuration data and add them to the list */
|
2008-10-28 02:17:22 +00:00
|
|
|
drvdata->base_address = ioremap(phys_addr, remap_size);
|
2008-07-07 20:17:48 +00:00
|
|
|
if (drvdata->base_address == NULL) {
|
2008-10-28 02:17:22 +00:00
|
|
|
dev_err(dev, "Couldn't ioremap memory at 0x%08llX\n",
|
|
|
|
(unsigned long long)phys_addr);
|
|
|
|
error = -EFAULT;
|
2008-07-07 20:17:48 +00:00
|
|
|
goto failed2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable all the interrupts, just in case */
|
|
|
|
out_be32(drvdata->base_address + XPS2_IPIER_OFFSET, 0);
|
|
|
|
|
|
|
|
/* Reset the PS2 device and abort any current transaction, to make sure
|
|
|
|
* we have the PS2 in a good state */
|
|
|
|
out_be32(drvdata->base_address + XPS2_SRST_OFFSET, XPS2_SRST_RESET);
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
dev_info(dev, "Xilinx PS2 at 0x%08llX mapped to 0x%p, irq=%d\n",
|
|
|
|
(unsigned long long)phys_addr, drvdata->base_address,
|
|
|
|
drvdata->irq);
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
serio->id.type = SERIO_8042;
|
|
|
|
serio->write = sxps2_write;
|
|
|
|
serio->open = sxps2_open;
|
|
|
|
serio->close = sxps2_close;
|
|
|
|
serio->port_data = drvdata;
|
|
|
|
serio->dev.parent = dev;
|
|
|
|
snprintf(serio->name, sizeof(serio->name),
|
2008-10-28 02:17:22 +00:00
|
|
|
"Xilinx XPS PS/2 at %08llX", (unsigned long long)phys_addr);
|
2008-07-07 20:17:48 +00:00
|
|
|
snprintf(serio->phys, sizeof(serio->phys),
|
2008-10-28 02:17:22 +00:00
|
|
|
"xilinxps2/serio at %08llX", (unsigned long long)phys_addr);
|
|
|
|
|
2008-07-07 20:17:48 +00:00
|
|
|
serio_register_port(serio);
|
|
|
|
|
2012-03-26 00:23:19 +00:00
|
|
|
platform_set_drvdata(ofdev, drvdata);
|
2008-07-07 20:17:48 +00:00
|
|
|
return 0; /* success */
|
|
|
|
|
|
|
|
failed2:
|
2008-10-28 02:17:22 +00:00
|
|
|
release_mem_region(phys_addr, remap_size);
|
2008-07-07 20:17:48 +00:00
|
|
|
failed1:
|
2012-03-26 00:23:19 +00:00
|
|
|
kfree(serio);
|
2008-07-07 20:17:48 +00:00
|
|
|
kfree(drvdata);
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
return error;
|
2008-07-07 20:17:48 +00:00
|
|
|
}
|
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
/**
|
|
|
|
* xps2_of_remove - unbinds the driver from the PS/2 device.
|
|
|
|
* @of_dev: pointer to OF device structure
|
|
|
|
*
|
|
|
|
* This function is called if a device is physically removed from the system or
|
|
|
|
* if the driver module is being unloaded. It frees any resources allocated to
|
|
|
|
* the device.
|
|
|
|
*/
|
2010-08-06 15:25:50 +00:00
|
|
|
static int __devexit xps2_of_remove(struct platform_device *of_dev)
|
2008-07-07 20:17:48 +00:00
|
|
|
{
|
2012-03-26 00:23:19 +00:00
|
|
|
struct xps2data *drvdata = platform_get_drvdata(of_dev);
|
2008-10-28 02:17:22 +00:00
|
|
|
struct resource r_mem; /* IO mem resources */
|
2008-07-07 20:17:48 +00:00
|
|
|
|
2012-03-26 00:23:19 +00:00
|
|
|
serio_unregister_port(drvdata->serio);
|
2008-07-07 20:17:48 +00:00
|
|
|
iounmap(drvdata->base_address);
|
2008-10-28 02:17:22 +00:00
|
|
|
|
|
|
|
/* Get iospace of the device */
|
2010-04-13 23:12:29 +00:00
|
|
|
if (of_address_to_resource(of_dev->dev.of_node, 0, &r_mem))
|
2012-03-26 00:23:19 +00:00
|
|
|
dev_err(drvdata->dev, "invalid address\n");
|
2008-10-28 02:17:22 +00:00
|
|
|
else
|
2010-01-22 07:52:37 +00:00
|
|
|
release_mem_region(r_mem.start, resource_size(&r_mem));
|
2008-10-28 02:17:22 +00:00
|
|
|
|
2008-07-07 20:17:48 +00:00
|
|
|
kfree(drvdata);
|
|
|
|
|
2012-03-26 00:23:19 +00:00
|
|
|
platform_set_drvdata(of_dev, NULL);
|
2008-07-07 20:17:48 +00:00
|
|
|
|
2008-10-28 02:17:22 +00:00
|
|
|
return 0;
|
2008-07-07 20:17:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Match table for of_platform binding */
|
2012-11-24 05:31:00 +00:00
|
|
|
static const struct of_device_id xps2_of_match[] = {
|
2008-07-07 20:17:48 +00:00
|
|
|
{ .compatible = "xlnx,xps-ps2-1.00.a", },
|
|
|
|
{ /* end of list */ },
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, xps2_of_match);
|
|
|
|
|
2011-02-17 09:43:24 +00:00
|
|
|
static struct platform_driver xps2_of_driver = {
|
2010-04-13 23:13:02 +00:00
|
|
|
.driver = {
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.of_match_table = xps2_of_match,
|
|
|
|
},
|
2008-07-07 20:17:48 +00:00
|
|
|
.probe = xps2_of_probe,
|
2012-11-24 05:27:39 +00:00
|
|
|
.remove = xps2_of_remove,
|
2008-07-07 20:17:48 +00:00
|
|
|
};
|
2011-11-29 19:08:43 +00:00
|
|
|
module_platform_driver(xps2_of_driver);
|
2008-07-07 20:17:48 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Xilinx, Inc.");
|
|
|
|
MODULE_DESCRIPTION("Xilinx XPS PS/2 driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|