wbsio(4) && lm(4): add support for `kldload lm.ko wbsio.ko`
authorConstantine A. Murenin <cnst+dfly@bugmail.mojo.ru>
Thu, 18 Mar 2010 19:34:54 +0000 (15:34 -0400)
committerConstantine A. Murenin <cnst+dfly@bugmail.mojo.ru>
Thu, 18 Mar 2010 19:52:16 +0000 (15:52 -0400)
share/man/man4/wbsio.4
sys/dev/powermng/Makefile
sys/dev/powermng/lm/Makefile [new file with mode: 0644]
sys/dev/powermng/wbsio/wbsio.c

index f4e9bb0..652f43f 100644 (file)
 .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
index 6659aef..f95e6f4 100644 (file)
@@ -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 (file)
index 0000000..3397a46
--- /dev/null
@@ -0,0 +1,5 @@
+KMOD=          lm
+SRCS=          lm78.c lm78_isa.c
+SRCS+=         isa_if.h bus_if.h device_if.h
+
+.include <bsd.kmod.mk>
index bfcdc93..acca7db 100644 (file)
@@ -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)
 {