diff options
Diffstat (limited to 'drivers/input/serio/sa1111ps2.c')
-rw-r--r-- | drivers/input/serio/sa1111ps2.c | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c index b3e6889..f9e5c79 100644 --- a/drivers/input/serio/sa1111ps2.c +++ b/drivers/input/serio/sa1111ps2.c @@ -47,6 +47,8 @@ struct ps2if { struct serio *io; struct sa1111_dev *dev; void __iomem *base; + int rx_irq; + int tx_irq; unsigned int open; spinlock_t lock; unsigned int head; @@ -64,22 +66,22 @@ static irqreturn_t ps2_rxint(int irq, void *dev_id) struct ps2if *ps2if = dev_id; unsigned int scancode, flag, status; - status = sa1111_readl(ps2if->base + PS2STAT); + status = readl_relaxed(ps2if->base + PS2STAT); while (status & PS2STAT_RXF) { if (status & PS2STAT_STP) - sa1111_writel(PS2STAT_STP, ps2if->base + PS2STAT); + writel_relaxed(PS2STAT_STP, ps2if->base + PS2STAT); flag = (status & PS2STAT_STP ? SERIO_FRAME : 0) | (status & PS2STAT_RXP ? 0 : SERIO_PARITY); - scancode = sa1111_readl(ps2if->base + PS2DATA) & 0xff; + scancode = readl_relaxed(ps2if->base + PS2DATA) & 0xff; if (hweight8(scancode) & 1) flag ^= SERIO_PARITY; serio_interrupt(ps2if->io, scancode, flag); - status = sa1111_readl(ps2if->base + PS2STAT); + status = readl_relaxed(ps2if->base + PS2STAT); } return IRQ_HANDLED; @@ -94,12 +96,12 @@ static irqreturn_t ps2_txint(int irq, void *dev_id) unsigned int status; spin_lock(&ps2if->lock); - status = sa1111_readl(ps2if->base + PS2STAT); + status = readl_relaxed(ps2if->base + PS2STAT); if (ps2if->head == ps2if->tail) { disable_irq_nosync(irq); /* done */ } else if (status & PS2STAT_TXE) { - sa1111_writel(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA); + writel_relaxed(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA); ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1); } spin_unlock(&ps2if->lock); @@ -122,11 +124,11 @@ static int ps2_write(struct serio *io, unsigned char val) /* * If the TX register is empty, we can go straight out. */ - if (sa1111_readl(ps2if->base + PS2STAT) & PS2STAT_TXE) { - sa1111_writel(val, ps2if->base + PS2DATA); + if (readl_relaxed(ps2if->base + PS2STAT) & PS2STAT_TXE) { + writel_relaxed(val, ps2if->base + PS2DATA); } else { if (ps2if->head == ps2if->tail) - enable_irq(ps2if->dev->irq[1]); + enable_irq(ps2if->tx_irq); head = (ps2if->head + 1) & (sizeof(ps2if->buf) - 1); if (head != ps2if->tail) { ps2if->buf[ps2if->head] = val; @@ -147,30 +149,30 @@ static int ps2_open(struct serio *io) if (ret) return ret; - ret = request_irq(ps2if->dev->irq[0], ps2_rxint, 0, + ret = request_irq(ps2if->rx_irq, ps2_rxint, 0, SA1111_DRIVER_NAME(ps2if->dev), ps2if); if (ret) { printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", - ps2if->dev->irq[0], ret); + ps2if->rx_irq, ret); sa1111_disable_device(ps2if->dev); return ret; } - ret = request_irq(ps2if->dev->irq[1], ps2_txint, 0, + ret = request_irq(ps2if->tx_irq, ps2_txint, 0, SA1111_DRIVER_NAME(ps2if->dev), ps2if); if (ret) { printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", - ps2if->dev->irq[1], ret); - free_irq(ps2if->dev->irq[0], ps2if); + ps2if->tx_irq, ret); + free_irq(ps2if->rx_irq, ps2if); sa1111_disable_device(ps2if->dev); return ret; } ps2if->open = 1; - enable_irq_wake(ps2if->dev->irq[0]); + enable_irq_wake(ps2if->rx_irq); - sa1111_writel(PS2CR_ENA, ps2if->base + PS2CR); + writel_relaxed(PS2CR_ENA, ps2if->base + PS2CR); return 0; } @@ -178,14 +180,14 @@ static void ps2_close(struct serio *io) { struct ps2if *ps2if = io->port_data; - sa1111_writel(0, ps2if->base + PS2CR); + writel_relaxed(0, ps2if->base + PS2CR); - disable_irq_wake(ps2if->dev->irq[0]); + disable_irq_wake(ps2if->rx_irq); ps2if->open = 0; - free_irq(ps2if->dev->irq[1], ps2if); - free_irq(ps2if->dev->irq[0], ps2if); + free_irq(ps2if->tx_irq, ps2if); + free_irq(ps2if->rx_irq, ps2if); sa1111_disable_device(ps2if->dev); } @@ -198,7 +200,7 @@ static void ps2_clear_input(struct ps2if *ps2if) int maxread = 100; while (maxread--) { - if ((sa1111_readl(ps2if->base + PS2DATA) & 0xff) == 0xff) + if ((readl_relaxed(ps2if->base + PS2DATA) & 0xff) == 0xff) break; } } @@ -208,11 +210,11 @@ static unsigned int ps2_test_one(struct ps2if *ps2if, { unsigned int val; - sa1111_writel(PS2CR_ENA | mask, ps2if->base + PS2CR); + writel_relaxed(PS2CR_ENA | mask, ps2if->base + PS2CR); - udelay(2); + udelay(10); - val = sa1111_readl(ps2if->base + PS2STAT); + val = readl_relaxed(ps2if->base + PS2STAT); return val & (PS2STAT_KBC | PS2STAT_KBD); } @@ -243,7 +245,7 @@ static int ps2_test(struct ps2if *ps2if) ret = -ENODEV; } - sa1111_writel(0, ps2if->base + PS2CR); + writel_relaxed(0, ps2if->base + PS2CR); return ret; } @@ -264,7 +266,6 @@ static int ps2_probe(struct sa1111_dev *dev) goto free; } - serio->id.type = SERIO_8042; serio->write = ps2_write; serio->open = ps2_open; @@ -279,6 +280,18 @@ static int ps2_probe(struct sa1111_dev *dev) spin_lock_init(&ps2if->lock); + ps2if->rx_irq = sa1111_get_irq(dev, 0); + if (ps2if->rx_irq <= 0) { + ret = ps2if->rx_irq ? : -ENXIO; + goto free; + } + + ps2if->tx_irq = sa1111_get_irq(dev, 1); + if (ps2if->tx_irq <= 0) { + ret = ps2if->tx_irq ? : -ENXIO; + goto free; + } + /* * Request the physical region for this PS2 port. */ @@ -297,8 +310,8 @@ static int ps2_probe(struct sa1111_dev *dev) sa1111_enable_device(ps2if->dev); /* Incoming clock is 8MHz */ - sa1111_writel(0, ps2if->base + PS2CLKDIV); - sa1111_writel(127, ps2if->base + PS2PRECNT); + writel_relaxed(0, ps2if->base + PS2CLKDIV); + writel_relaxed(127, ps2if->base + PS2PRECNT); /* * Flush any pending input. |