[OpenBIOS] [PATCH 2/2] pc_kbd: add optional mouse device support for 8042 devices
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Sat Jul 8 21:25:51 CEST 2017
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
drivers/pc_kbd.c | 63 +++++++++++++++++++++++++++++++++++++++++----
drivers/pci.c | 4 +--
include/drivers/drivers.h | 4 +--
3 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/drivers/pc_kbd.c b/drivers/pc_kbd.c
index 3e366c5..51b7a1f 100644
--- a/drivers/pc_kbd.c
+++ b/drivers/pc_kbd.c
@@ -185,8 +185,8 @@ NODE_METHODS(pc_kbd) = {
};
void
-ob_pc_kbd_init(const char *path, const char *dev_name, uint64_t base,
- uint64_t offset, int intr)
+ob_pc_kbd_init(const char *path, const char *kdev_name, const char *mdev_name,
+ uint64_t base, uint64_t offset, int kintr, int mintr)
{
phandle_t chosen, aliases;
char nodebuff[128];
@@ -210,6 +210,19 @@ ob_pc_kbd_init(const char *path, const char *dev_name, uint64_t base,
PUSH(SER_SIZE);
fword("encode-int");
fword("encode+");
+
+ if (mdev_name != NULL) {
+ PUSH((base + offset) >> 32);
+ fword("encode-int");
+ fword("encode+");
+ PUSH((base + offset) & 0xffffffff);
+ fword("encode-int");
+ fword("encode+");
+ PUSH(SER_SIZE);
+ fword("encode-int");
+ fword("encode+");
+ }
+
push_str("reg");
fword("property");
@@ -217,20 +230,28 @@ ob_pc_kbd_init(const char *path, const char *dev_name, uint64_t base,
set_int_property(chosen, "#address-cells", 1);
set_int_property(chosen, "#size-cells", 0);
- PUSH(intr);
+ PUSH(kintr);
fword("encode-int");
+
+ if (mdev_name != NULL) {
+ PUSH(mintr);
+ fword("encode-int");
+ fword("encode+");
+ }
+
push_str("interrupts");
fword("property");
fword("finish-device");
- snprintf(nodebuff, sizeof(nodebuff), "%s/8042/%s", path, dev_name);
+ /* Keyboard */
+ snprintf(nodebuff, sizeof(nodebuff), "%s/8042/%s", path, kdev_name);
REGISTER_NAMED_NODE(pc_kbd, nodebuff);
push_str(nodebuff);
fword("find-device");
- push_str(dev_name);
+ push_str(kdev_name);
fword("device-name");
push_str("serial");
@@ -260,4 +281,36 @@ ob_pc_kbd_init(const char *path, const char *dev_name, uint64_t base,
set_property(aliases, "keyboard", nodebuff, strlen(nodebuff) + 1);
pc_kbd_controller_cmd(0x60, 0x40); // Write mode command, translated mode
+
+ /* Mouse (optional) */
+ if (mdev_name != NULL) {
+ snprintf(nodebuff, sizeof(nodebuff), "%s/8042", path);
+ push_str(nodebuff);
+ fword("find-device");
+
+ fword("new-device");
+
+ push_str(mdev_name);
+ fword("device-name");
+
+ push_str("mouse");
+ fword("device-type");
+
+ PUSH(1);
+ fword("encode-int");
+ push_str("reg");
+ fword("property");
+
+ PUSH(-1);
+ fword("encode-int");
+ push_str("mouse");
+ fword("property");
+
+ PUSH(offset);
+ fword("encode-int");
+ push_str("address");
+ fword("property");
+
+ fword("finish-device");
+ }
}
diff --git a/drivers/pci.c b/drivers/pci.c
index e803ab2..d506a50 100644
--- a/drivers/pci.c
+++ b/drivers/pci.c
@@ -949,7 +949,7 @@ int ebus_config_cb(const pci_config_t *config)
ob_pc_serial_init(config->path, "su", (PCI_BASE_ADDR_1 | 0ULL) << 32, 0x3f8ULL, 0);
#endif
#ifdef CONFIG_DRIVER_PC_KBD
- ob_pc_kbd_init(config->path, "kb_ps2", (PCI_BASE_ADDR_1 | 0ULL) << 32, 0x60ULL, 1);
+ ob_pc_kbd_init(config->path, "kb_ps2", NULL, (PCI_BASE_ADDR_1 | 0ULL) << 32, 0x60ULL, 1, 0);
#endif
#endif
return 0;
@@ -961,7 +961,7 @@ int i82378_config_cb(const pci_config_t *config)
ob_pc_serial_init(config->path, "serial", arch->io_base, 0x3f8ULL, 0);
#endif
#ifdef CONFIG_DRIVER_PC_KBD
- ob_pc_kbd_init(config->path, "8042", arch->io_base, 0x60ULL, 0);
+ ob_pc_kbd_init(config->path, "8042", NULL, arch->io_base, 0x60ULL, 0, 0);
#endif
#ifdef CONFIG_DRIVER_IDE
ob_ide_init(config->path, 0x1f0, 0x3f6, 0x170, 0x376);
diff --git a/include/drivers/drivers.h b/include/drivers/drivers.h
index 9ea1c6a..59ee436 100644
--- a/include/drivers/drivers.h
+++ b/include/drivers/drivers.h
@@ -99,8 +99,8 @@ int ob_floppy_init(const char *path, const char *dev_name,
unsigned long io_base, unsigned long mmio_base);
#endif
#ifdef CONFIG_DRIVER_PC_KBD
-void ob_pc_kbd_init(const char *path, const char *dev_name, uint64_t base,
- uint64_t offset, int intr);
+void ob_pc_kbd_init(const char *path, const char *kdev_name, const char *mdev_name,
+ uint64_t base, uint64_t offset, int kintr, int mintr);
int pc_kbd_dataready(void);
unsigned char pc_kbd_readdata(void);
#endif
--
1.7.10.4
More information about the OpenBIOS
mailing list