Commit 8c6d9d0a authored by Russell King's avatar Russell King

ARM: riscpc: pass IRQ resources into keyboard driver

Rather than including asm/irq.h into the keyboard driver, pass the
IRQ numbers via the platform device instead.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent a1be5d64
...@@ -134,12 +134,19 @@ static struct platform_device iomd_device = { ...@@ -134,12 +134,19 @@ static struct platform_device iomd_device = {
.resource = iomd_resources, .resource = iomd_resources,
}; };
static struct resource iomd_kart_resources[] = {
DEFINE_RES_IRQ(IRQ_KEYBOARDRX),
DEFINE_RES_IRQ(IRQ_KEYBOARDTX),
};
static struct platform_device kbd_device = { static struct platform_device kbd_device = {
.name = "kart", .name = "kart",
.id = -1, .id = -1,
.dev = { .dev = {
.parent = &iomd_device.dev, .parent = &iomd_device.dev,
}, },
.num_resources = ARRAY_SIZE(iomd_kart_resources),
.resource = iomd_kart_resources,
}; };
static struct plat_serial8250_port serial_platform_data[] = { static struct plat_serial8250_port serial_platform_data[] = {
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/irq.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <asm/hardware/iomd.h> #include <asm/hardware/iomd.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -46,6 +45,11 @@ MODULE_DESCRIPTION("Acorn RiscPC PS/2 keyboard controller driver"); ...@@ -46,6 +45,11 @@ MODULE_DESCRIPTION("Acorn RiscPC PS/2 keyboard controller driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:kart"); MODULE_ALIAS("platform:kart");
struct rpckbd_data {
int tx_irq;
int rx_irq;
};
static int rpckbd_write(struct serio *port, unsigned char val) static int rpckbd_write(struct serio *port, unsigned char val)
{ {
while (!(iomd_readb(IOMD_KCTRL) & (1 << 7))) while (!(iomd_readb(IOMD_KCTRL) & (1 << 7)))
...@@ -78,19 +82,21 @@ static irqreturn_t rpckbd_tx(int irq, void *dev_id) ...@@ -78,19 +82,21 @@ static irqreturn_t rpckbd_tx(int irq, void *dev_id)
static int rpckbd_open(struct serio *port) static int rpckbd_open(struct serio *port)
{ {
struct rpckbd_data *rpckbd = port->port_data;
/* Reset the keyboard state machine. */ /* Reset the keyboard state machine. */
iomd_writeb(0, IOMD_KCTRL); iomd_writeb(0, IOMD_KCTRL);
iomd_writeb(8, IOMD_KCTRL); iomd_writeb(8, IOMD_KCTRL);
iomd_readb(IOMD_KARTRX); iomd_readb(IOMD_KARTRX);
if (request_irq(IRQ_KEYBOARDRX, rpckbd_rx, 0, "rpckbd", port) != 0) { if (request_irq(rpckbd->rx_irq, rpckbd_rx, 0, "rpckbd", port) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ\n"); printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ\n");
return -EBUSY; return -EBUSY;
} }
if (request_irq(IRQ_KEYBOARDTX, rpckbd_tx, 0, "rpckbd", port) != 0) { if (request_irq(rpckbd->tx_irq, rpckbd_tx, 0, "rpckbd", port) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n"); printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n");
free_irq(IRQ_KEYBOARDRX, port); free_irq(rpckbd->rx_irq, port);
return -EBUSY; return -EBUSY;
} }
...@@ -99,8 +105,10 @@ static int rpckbd_open(struct serio *port) ...@@ -99,8 +105,10 @@ static int rpckbd_open(struct serio *port)
static void rpckbd_close(struct serio *port) static void rpckbd_close(struct serio *port)
{ {
free_irq(IRQ_KEYBOARDRX, port); struct rpckbd_data *rpckbd = port->port_data;
free_irq(IRQ_KEYBOARDTX, port);
free_irq(rpckbd->rx_irq, port);
free_irq(rpckbd->tx_irq, port);
} }
/* /*
...@@ -109,17 +117,35 @@ static void rpckbd_close(struct serio *port) ...@@ -109,17 +117,35 @@ static void rpckbd_close(struct serio *port)
*/ */
static int __devinit rpckbd_probe(struct platform_device *dev) static int __devinit rpckbd_probe(struct platform_device *dev)
{ {
struct rpckbd_data *rpckbd;
struct serio *serio; struct serio *serio;
int tx_irq, rx_irq;
rx_irq = platform_get_irq(dev, 0);
if (rx_irq <= 0)
return rx_irq < 0 ? rx_irq : -ENXIO;
tx_irq = platform_get_irq(dev, 1);
if (tx_irq <= 0)
return tx_irq < 0 ? tx_irq : -ENXIO;
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
if (!serio) rpckbd = kzalloc(sizeof(*rpckbd), GFP_KERNEL);
if (!serio || !rpckbd) {
kfree(rpckbd);
kfree(serio);
return -ENOMEM; return -ENOMEM;
}
rpckbd->rx_irq = rx_irq;
rpckbd->tx_irq = tx_irq;
serio->id.type = SERIO_8042; serio->id.type = SERIO_8042;
serio->write = rpckbd_write; serio->write = rpckbd_write;
serio->open = rpckbd_open; serio->open = rpckbd_open;
serio->close = rpckbd_close; serio->close = rpckbd_close;
serio->dev.parent = &dev->dev; serio->dev.parent = &dev->dev;
serio->port_data = rpckbd;
strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name)); strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name));
strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys)); strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys));
...@@ -131,7 +157,11 @@ static int __devinit rpckbd_probe(struct platform_device *dev) ...@@ -131,7 +157,11 @@ static int __devinit rpckbd_probe(struct platform_device *dev)
static int __devexit rpckbd_remove(struct platform_device *dev) static int __devexit rpckbd_remove(struct platform_device *dev)
{ {
struct serio *serio = platform_get_drvdata(dev); struct serio *serio = platform_get_drvdata(dev);
struct rpckbd_data *rpckbd = serio->port_data;
serio_unregister_port(serio); serio_unregister_port(serio);
kfree(rpckbd);
return 0; return 0;
} }
......
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