/* * Read all bytes waiting in the PS2 port. There should be * at the most one, but we loop for safety. If there was a * framing error, we have to manually clear the status.
*/ static irqreturn_t ps2_rxint(int irq, void *dev_id)
{ struct ps2if *ps2if = dev_id; unsignedint scancode, flag, status;
status = readl_relaxed(ps2if->base + PS2STAT); while (status & PS2STAT_RXF) { if (status & PS2STAT_STP)
writel_relaxed(PS2STAT_STP, ps2if->base + PS2STAT);
/* * Write a byte to the PS2 port. We have to wait for the * port to indicate that the transmitter is empty.
*/ staticint ps2_write(struct serio *io, unsignedchar val)
{ struct ps2if *ps2if = io->port_data; unsignedint head;
guard(spinlock_irqsave)(&ps2if->lock);
/* * If the TX register is empty, we can go straight out.
*/ if (readl_relaxed(ps2if->base + PS2STAT) & PS2STAT_TXE) {
writel_relaxed(val, ps2if->base + PS2DATA);
} else { if (ps2if->head == ps2if->tail)
enable_irq(ps2if->tx_irq);
head = (ps2if->head + 1) & (sizeof(ps2if->buf) - 1); if (head != ps2if->tail) {
ps2if->buf[ps2if->head] = val;
ps2if->head = head;
}
}
val = readl_relaxed(ps2if->base + PS2STAT); return val & (PS2STAT_KBC | PS2STAT_KBD);
}
/* * Test the keyboard interface. We basically check to make sure that * we can drive each line to the keyboard independently of each other.
*/ staticint ps2_test(struct ps2if *ps2if)
{ unsignedint stat; int ret = 0;
stat = ps2_test_one(ps2if, PS2CR_FKC); if (stat != PS2STAT_KBD) {
printk("PS/2 interface test failed[1]: %02x\n", stat);
ret = -ENODEV;
}
stat = ps2_test_one(ps2if, 0); if (stat != (PS2STAT_KBC | PS2STAT_KBD)) {
printk("PS/2 interface test failed[2]: %02x\n", stat);
ret = -ENODEV;
}
stat = ps2_test_one(ps2if, PS2CR_FKD); if (stat != PS2STAT_KBC) {
printk("PS/2 interface test failed[3]: %02x\n", stat);
ret = -ENODEV;
}
writel_relaxed(0, ps2if->base + PS2CR);
return ret;
}
/* * Add one device to this driver.
*/ staticint ps2_probe(struct sa1111_dev *dev)
{ struct ps2if *ps2if; struct serio *serio; int ret;
ps2if = kzalloc(sizeof(*ps2if), GFP_KERNEL);
serio = kzalloc(sizeof(*serio), GFP_KERNEL); if (!ps2if || !serio) {
ret = -ENOMEM; goto free;
}
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.
*/ if (!request_mem_region(dev->res.start,
dev->res.end - dev->res.start + 1,
SA1111_DRIVER_NAME(dev))) {
ret = -EBUSY; goto free;
}
/* * Our parent device has already mapped the region.
*/
ps2if->base = dev->mapbase;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.