diff options
author | marius <marius@FreeBSD.org> | 2005-06-10 20:56:38 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2005-06-10 20:56:38 +0000 |
commit | 9afc57a1d6b7a82c8cce67a9b6da734e64da5fef (patch) | |
tree | 73faadc85aaf50514c90a2b39f6e6c558347a47d /sys/dev/atkbdc/atkbdc.c | |
parent | a23214e059e07a8642c27d57c541ce60479d3d53 (diff) | |
download | FreeBSD-src-9afc57a1d6b7a82c8cce67a9b6da734e64da5fef.zip FreeBSD-src-9afc57a1d6b7a82c8cce67a9b6da734e64da5fef.tar.gz |
- Hook up the new locations of the atkbdc(4), atkbd(4) and psm(4) source
files after they were repo-copied to sys/dev/atkbdc. The sources of
atkbdc(4) and its children were moved to the new location in preparation
for adding an EBus front-end to atkbdc(4) for use on sparc64; i.e. in
order to not further scatter them over the whole tree which would have
been the result of adding atkbdc_ebus.c in e.g. sys/sparc64/ebus. Another
reason for the repo-copies was that some of the sources were misfiled,
e.g. sys/isa/atkbd_isa.c wasn't ISA-specific at all but for hanging
atkbd(4) off of atkbdc(4) and was renamed to atkbd_atkbdc.c accordingly.
Most of sys/isa/psm.c, i.e. expect for its PSMC PNP part, also isn't
ISA-specific.
- Separate the parts of atkbdc_isa.c which aren't actually ISA-specific
but are shareable between different atkbdc(4) bus front-ends into
atkbdc_subr.c (repo-copied from atkbdc_isa.c). While here use
bus_generic_rl_alloc_resource() and bus_generic_rl_release_resource()
respectively in atkbdc_isa.c instead of rolling own versions.
- Add sparc64 MD bits to atkbdc(4) and atkbd(4) and an EBus front-end for
atkbdc(4). PS/2 controllers and input devices are used on a couple of
Sun OEM boards and occur on either the EBus or the ISA bus. Depending on
the board it's either the only on-board mean to connect a keyboard and
mouse or an alternative to either RS232 or USB devices.
- Wrap the PSMC PNP part of psm.c in #ifdef DEV_ISA so it can be compiled
without isa(4) (e.g. for EBus-only machines). This ISA-specific part
isn't separated into its own source file, yet, as it requires more work
than was feasible for 6.0 in order to do it in a clean way. Actually
philip@ is working on a rewrite of psm(4) so a more comprehensive
clean-up and separation of hardware dependent and independent parts is
expected to happen after 6.0.
Tested on: i386, sparc64 (AX1105, AXe and AXi boards)
Reviewed by: philip
Diffstat (limited to 'sys/dev/atkbdc/atkbdc.c')
-rw-r--r-- | sys/dev/atkbdc/atkbdc.c | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c index c0cee01..6889e1e 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); } |