From fa130c0230f70153612043d6fbb47d9cf50af78f Mon Sep 17 00:00:00 2001 From: "Constantine A. Murenin" Date: Thu, 18 Mar 2010 15:34:54 -0400 Subject: [PATCH] wbsio(4) && lm(4): add support for `kldload lm.ko wbsio.ko` --- share/man/man4/wbsio.4 | 14 ++++++++++++++ sys/dev/powermng/Makefile | 2 +- sys/dev/powermng/lm/Makefile | 5 +++++ sys/dev/powermng/wbsio/wbsio.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 sys/dev/powermng/lm/Makefile diff --git a/share/man/man4/wbsio.4 b/share/man/man4/wbsio.4 index f4e9bb0fb5..652f43f34e 100644 --- a/share/man/man4/wbsio.4 +++ b/share/man/man4/wbsio.4 @@ -22,9 +22,23 @@ .Nm wbsio .Nd Winbond LPC Super I/O .Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device isa" .Cd "device wbsio0 at isa? port 0x2e" .Cd "device wbsio1 at isa? port 0x4e" .Cd "device lm" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following lines in +.Xr loader.conf 5 : +.Bd -literal -offset indent +lm_load="YES" +wbsio_load="YES" +.Ed .Sh DESCRIPTION The .Nm diff --git a/sys/dev/powermng/Makefile b/sys/dev/powermng/Makefile index 6659aefd72..f95e6f462c 100644 --- a/sys/dev/powermng/Makefile +++ b/sys/dev/powermng/Makefile @@ -1,4 +1,4 @@ -SUBDIR= aps coretemp kate km +SUBDIR= aps coretemp kate km lm wbsio .if ${MACHINE_ARCH} == "i386" SUBDIR+= powernow .endif diff --git a/sys/dev/powermng/lm/Makefile b/sys/dev/powermng/lm/Makefile new file mode 100644 index 0000000000..3397a46d76 --- /dev/null +++ b/sys/dev/powermng/lm/Makefile @@ -0,0 +1,5 @@ +KMOD= lm +SRCS= lm78.c lm78_isa.c +SRCS+= isa_if.h bus_if.h device_if.h + +.include diff --git a/sys/dev/powermng/wbsio/wbsio.c b/sys/dev/powermng/wbsio/wbsio.c index bfcdc9351f..acca7dba6f 100644 --- a/sys/dev/powermng/wbsio/wbsio.c +++ b/sys/dev/powermng/wbsio/wbsio.c @@ -70,11 +70,13 @@ struct wbsio_softc { bus_space_handle_t sc_ioh; }; +static void wbsio_identify(driver_t *, struct device *); static int wbsio_probe(struct device *); static int wbsio_attach(struct device *); static int wbsio_detach(struct device *); static device_method_t wbsio_methods[] = { + DEVMETHOD(device_identify, wbsio_identify), DEVMETHOD(device_probe, wbsio_probe), DEVMETHOD(device_attach, wbsio_attach), DEVMETHOD(device_detach, wbsio_detach), @@ -121,6 +123,33 @@ wbsio_conf_write(bus_space_tag_t iot, bus_space_handle_t ioh, u_int8_t index, bus_space_write_1(iot, ioh, WBSIO_DATA, data); } +static void +wbsio_identify(driver_t *driver, struct device *parent) +{ +#ifdef KLD_MODULE + struct device *child[2]; + const int port[2] = { 0x2e, 0x4e }; + + for (int i = 0; i < 2; i++) { + child[i] = device_find_child(parent, driver->name, i); + if (child[i] == NULL) { + child[i] = BUS_ADD_CHILD(parent, parent, ISA_ORDER_PNP, + driver->name, i); + if (child[i] == NULL) { + kprintf("%s: cannot add child[%i]\n", + __func__, i); + continue; + } + } else + continue; + if (bus_set_resource(child[i], SYS_RES_IOPORT, 0, + port[i], WBSIO_IOSIZE)) + kprintf("%s: cannot set resource for child[%i]\n", + __func__, i); + } +#endif +} + static int wbsio_probe(struct device *dev) { -- 2.41.0