aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/atkbdc/atkbdc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/atkbdc/atkbdc.c')
-rw-r--r--sys/dev/atkbdc/atkbdc.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c
index c0cee013e6c1..6889e1ebbfd3 100644
--- a/sys/dev/atkbdc/atkbdc.c
+++ b/sys/dev/atkbdc/atkbdc.c
@@ -44,10 +44,15 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
+#include <dev/atkbdc/atkbdcreg.h>
-#include <dev/kbd/atkbdcreg.h>
-
+#ifdef __sparc64__
+#include <dev/ofw/openfirm.h>
+#include <machine/bus_private.h>
+#include <machine/ofw_machdep.h>
+#else
#include <isa/isareg.h>
+#endif
/* constants */
@@ -88,6 +93,10 @@ static atkbdc_softc_t *atkbdc_softc[MAXKBDC] = { &default_kbdc };
static int verbose = KBDIO_DEBUG;
+#ifdef __sparc64__
+static struct bus_space_tag atkbdc_bst_store[MAXKBDC];
+#endif
+
/* function prototypes */
static int atkbdc_setup(atkbdc_softc_t *sc, bus_space_tag_t tag,
@@ -144,14 +153,16 @@ atkbdc_configure(void)
bus_space_tag_t tag;
bus_space_handle_t h0;
bus_space_handle_t h1;
+#ifdef __sparc64__
+ char name[32];
+ phandle_t chosen, node;
+ ihandle_t stdin;
+ bus_addr_t port0;
+ bus_addr_t port1;
+ int space;
+#else
int port0;
int port1;
-
- port0 = IO_KBD;
- resource_int_value("atkbdc", 0, "port", &port0);
- port1 = IO_KBD + KBD_STATUS_PORT;
-#if 0
- resource_int_value("atkbdc", 0, "port", &port0);
#endif
/* XXX: tag should be passed from the caller */
@@ -163,10 +174,43 @@ atkbdc_configure(void)
tag = busspace_isa_io;
#elif defined(__ia64__)
tag = IA64_BUS_SPACE_IO;
+#elif defined(__sparc64__)
+ tag = &atkbdc_bst_store[0];
#else
#error "define tag!"
#endif
+#ifdef __sparc64__
+ if ((chosen = OF_finddevice("/chosen")) == -1)
+ return 0;
+ if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1)
+ return 0;
+ if ((node = OF_instance_to_package(stdin)) == -1)
+ return 0;
+ if (OF_getprop(node, "name", name, sizeof(name)) == -1)
+ return 0;
+ name[sizeof(name) - 1] = '\0';
+ if (strcmp(name, "kb_ps2") != 0)
+ return 0;
+ /*
+ * The stdin handle points to an instance of a PS/2 keyboard
+ * package but we want the 8042 controller, which is the parent
+ * of that keyboard node.
+ */
+ if ((node = OF_parent(node)) == 0)
+ return 0;
+ if (OF_decode_addr(node, 0, &space, &port0) != 0)
+ return 0;
+ h0 = sparc64_fake_bustag(space, port0, tag);
+ bus_space_subregion(tag, h0, KBD_DATA_PORT, 1, &h0);
+ if (OF_decode_addr(node, 1, &space, &port1) != 0)
+ return 0;
+ h1 = sparc64_fake_bustag(space, port1, tag);
+ bus_space_subregion(tag, h1, KBD_STATUS_PORT, 1, &h1);
+#else
+ port0 = IO_KBD;
+ resource_int_value("atkbdc", 0, "port", &port0);
+ port1 = IO_KBD + KBD_STATUS_PORT;
#if notyet
bus_space_map(tag, port0, IO_KBDSIZE, 0, &h0);
bus_space_map(tag, port1, IO_KBDSIZE, 0, &h1);
@@ -174,6 +218,7 @@ atkbdc_configure(void)
h0 = (bus_space_handle_t)port0;
h1 = (bus_space_handle_t)port1;
#endif
+#endif
return atkbdc_setup(atkbdc_softc[0], tag, h0, h1);
}