[Midnightbsd-cvs] src [10033] trunk/sys/dev: sync with freebsd 10 stable

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 18:24:35 EDT 2018


Revision: 10033
          http://svnweb.midnightbsd.org/src/?rev=10033
Author:   laffer1
Date:     2018-05-27 18:24:34 -0400 (Sun, 27 May 2018)
Log Message:
-----------
sync with freebsd 10 stable

Modified Paths:
--------------
    trunk/sys/dev/watchdog/watchdog.c
    trunk/sys/dev/wb/if_wb.c
    trunk/sys/dev/wb/if_wbreg.h
    trunk/sys/dev/wbwd/wbwd.c
    trunk/sys/dev/wds/wd7000.c
    trunk/sys/dev/wl/if_wl.c
    trunk/sys/dev/wl/if_wl.h
    trunk/sys/dev/wl/if_wl_i82586.h

Added Paths:
-----------
    trunk/sys/dev/wi/if_wi_macio.c

Modified: trunk/sys/dev/watchdog/watchdog.c
===================================================================
--- trunk/sys/dev/watchdog/watchdog.c	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/watchdog/watchdog.c	2018-05-27 22:24:34 UTC (rev 10033)
@@ -1,6 +1,9 @@
-/* $MidnightBSD: src/sys/dev/watchdog/watchdog.c,v 1.3 2012/08/06 01:22:10 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Poul-Henning Kamp
+ * Copyright (c) 2013 iXsystems.com,
+ *               author: Alfred Perlstein <alfred at freebsd.org>
+ *
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,25 +29,95 @@
  *
  */
 
+#include "opt_ddb.h"
+
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/watchdog/watchdog.c 287928 2015-09-17 18:19:55Z rstone $");
 
 #include <sys/param.h>
+#include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
 #include <sys/uio.h>
 #include <sys/kernel.h>
+#include <sys/kdb.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/syslog.h>
 #include <sys/watchdog.h>
 #include <sys/bus.h>
 #include <machine/bus.h>
 
+#include <sys/syscallsubr.h> /* kern_clock_gettime() */
+
+static int wd_set_pretimeout(int newtimeout, int disableiftoolong);
+static void wd_timeout_cb(void *arg);
+
+static struct callout wd_pretimeo_handle;
+static int wd_pretimeout;
+static int wd_pretimeout_act = WD_SOFT_LOG;
+
+static struct callout wd_softtimeo_handle;
+static int wd_softtimer;	/* true = use softtimer instead of hardware
+				   watchdog */
+static int wd_softtimeout_act = WD_SOFT_LOG;	/* action for the software timeout */
+
 static struct cdev *wd_dev;
-static volatile u_int wd_last_u;
+static volatile u_int wd_last_u;    /* last timeout value set by kern_do_pat */
+static u_int wd_last_u_sysctl;    /* last timeout value set by kern_do_pat */
+static u_int wd_last_u_sysctl_secs;    /* wd_last_u in seconds */
 
+SYSCTL_NODE(_hw, OID_AUTO, watchdog, CTLFLAG_RD, 0, "Main watchdog device");
+SYSCTL_UINT(_hw_watchdog, OID_AUTO, wd_last_u, CTLFLAG_RD,
+    &wd_last_u_sysctl, 0, "Watchdog last update time");
+SYSCTL_UINT(_hw_watchdog, OID_AUTO, wd_last_u_secs, CTLFLAG_RD,
+    &wd_last_u_sysctl_secs, 0, "Watchdog last update time");
+
+static int wd_lastpat_valid = 0;
+static time_t wd_lastpat = 0;	/* when the watchdog was last patted */
+
+static void
+pow2ns_to_ts(int pow2ns, struct timespec *ts)
+{
+	uint64_t ns;
+
+	ns = 1ULL << pow2ns;
+	ts->tv_sec = ns / 1000000000ULL;
+	ts->tv_nsec = ns % 1000000000ULL;
+}
+
 static int
-kern_do_pat(u_int utim)
+pow2ns_to_ticks(int pow2ns)
 {
+	struct timeval tv;
+	struct timespec ts;
+
+	pow2ns_to_ts(pow2ns, &ts);
+	TIMESPEC_TO_TIMEVAL(&tv, &ts);
+	return (tvtohz(&tv));
+}
+
+static int
+seconds_to_pow2ns(int seconds)
+{
+	uint64_t power;
+	uint64_t ns;
+	uint64_t shifted;
+
+	ns = ((uint64_t)seconds) * 1000000000ULL;
+	power = flsll(ns);
+	shifted = 1ULL << power;
+	if (shifted <= ns) {
+		power++;
+	}
+	return (power);
+}
+
+
+int
+wdog_kern_pat(u_int utim)
+{
 	int error;
 
 	if ((utim & WD_LASTVAL) != 0 && (utim & WD_INTERVAL) > 0)
@@ -51,11 +124,22 @@
 		return (EINVAL);
 
 	if ((utim & WD_LASTVAL) != 0) {
+		/*
+		 * if WD_LASTVAL is set, fill in the bits for timeout
+		 * from the saved value in wd_last_u.
+		 */
 		MPASS((wd_last_u & ~WD_INTERVAL) == 0);
 		utim &= ~WD_LASTVAL;
 		utim |= wd_last_u;
-	} else
+	} else {
+		/*
+		 * Otherwise save the new interval.
+		 * This can be zero (to disable the watchdog)
+		 */
 		wd_last_u = (utim & WD_INTERVAL);
+		wd_last_u_sysctl = wd_last_u;
+		wd_last_u_sysctl_secs = pow2ns_to_ticks(wd_last_u) / hz;
+	}
 	if ((utim & WD_INTERVAL) == WD_TO_NEVER) {
 		utim = 0;
 
@@ -65,18 +149,49 @@
 		/* Assume no watchdog available; watchdog flags success */
 		error = EOPNOTSUPP;
 	}
-	EVENTHANDLER_INVOKE(watchdog_list, utim, &error);
+	if (wd_softtimer) {
+		if (utim == 0) {
+			callout_stop(&wd_softtimeo_handle);
+		} else {
+			(void) callout_reset(&wd_softtimeo_handle,
+			    pow2ns_to_ticks(utim), wd_timeout_cb, "soft");
+		}
+		error = 0;
+	} else {
+		EVENTHANDLER_INVOKE(watchdog_list, utim, &error);
+	}
+	wd_set_pretimeout(wd_pretimeout, true);
+	/*
+	 * If we were able to arm/strobe the watchdog, then
+	 * update the last time it was strobed for WDIOC_GETTIMELEFT
+	 */
+	if (!error) {
+		struct timespec ts;
+
+		error = kern_clock_gettime(curthread /* XXX */,
+		    CLOCK_MONOTONIC_FAST, &ts);
+		if (!error) {
+			wd_lastpat = ts.tv_sec;
+			wd_lastpat_valid = 1;
+		}
+	}
 	return (error);
 }
 
 static int
-wd_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data,
-    int flags __unused, struct thread *td)
+wd_valid_act(int act)
 {
+
+	if ((act & ~(WD_SOFT_MASK)) != 0)
+		return false;
+	return true;
+}
+
+static int
+wd_ioctl_patpat(caddr_t data)
+{
 	u_int u;
 
-	if (cmd != WDIOCPATPAT)
-		return (ENOIOCTL);
 	u = *(u_int *)data;
 	if (u & ~(WD_ACTIVE | WD_PASSIVE | WD_LASTVAL | WD_INTERVAL))
 		return (EINVAL);
@@ -89,26 +204,181 @@
 		return (ENOSYS);	/* XXX Not implemented yet */
 	u &= ~(WD_ACTIVE | WD_PASSIVE);
 
-	return (kern_do_pat(u));
+	return (wdog_kern_pat(u));
 }
 
-u_int
-wdog_kern_last_timeout(void)
+static int
+wd_get_time_left(struct thread *td, time_t *remainp)
 {
+	struct timespec ts;
+	int error;
 
-	return (wd_last_u);
+	error = kern_clock_gettime(td, CLOCK_MONOTONIC_FAST, &ts);
+	if (error)
+		return (error);
+	if (!wd_lastpat_valid)
+		return (ENOENT);
+	*remainp = ts.tv_sec - wd_lastpat;
+	return (0);
 }
 
-int
-wdog_kern_pat(u_int utim)
+static void
+wd_timeout_cb(void *arg)
 {
+	const char *type = arg;
 
-	if (utim & ~(WD_LASTVAL | WD_INTERVAL))
-		return (EINVAL);
+#ifdef DDB
+	if ((wd_pretimeout_act & WD_SOFT_DDB)) {
+		char kdb_why[80];
+		snprintf(kdb_why, sizeof(kdb_why), "watchdog %s timeout", type);
+		kdb_backtrace();
+		kdb_enter(KDB_WHY_WATCHDOG, kdb_why);
+	}
+#endif
+	if ((wd_pretimeout_act & WD_SOFT_LOG))
+		log(LOG_EMERG, "watchdog %s-timeout, WD_SOFT_LOG", type);
+	if ((wd_pretimeout_act & WD_SOFT_PRINTF))
+		printf("watchdog %s-timeout, WD_SOFT_PRINTF\n", type);
+	if ((wd_pretimeout_act & WD_SOFT_PANIC))
+		panic("watchdog %s-timeout, WD_SOFT_PANIC set", type);
+}
 
-	return (kern_do_pat(utim));
+/*
+ * Called to manage timeouts.
+ * newtimeout needs to be in the range of 0 to actual watchdog timeout.
+ * if 0, we disable the pre-timeout.
+ * otherwise we set the pre-timeout provided it's not greater than the
+ * current actual watchdog timeout.
+ */
+static int
+wd_set_pretimeout(int newtimeout, int disableiftoolong)
+{
+	u_int utime;
+	struct timespec utime_ts;
+	int timeout_ticks;
+
+	utime = wdog_kern_last_timeout();
+	pow2ns_to_ts(utime, &utime_ts);
+	/* do not permit a pre-timeout >= than the timeout. */
+	if (newtimeout >= utime_ts.tv_sec) {
+		/*
+		 * If 'disableiftoolong' then just fall through
+		 * so as to disable the pre-watchdog
+		 */
+		if (disableiftoolong)
+			newtimeout = 0;
+		else
+			return EINVAL;
+	}
+
+	/* disable the pre-timeout */
+	if (newtimeout == 0) {
+		wd_pretimeout = 0;
+		callout_stop(&wd_pretimeo_handle);
+		return 0;
+	}
+
+	timeout_ticks = pow2ns_to_ticks(utime) - (hz*newtimeout);
+#if 0
+	printf("wd_set_pretimeout: "
+	    "newtimeout: %d, "
+	    "utime: %d -> utime_ticks: %d, "
+	    "hz*newtimeout: %d, "
+	    "timeout_ticks: %d -> sec: %d\n",
+	    newtimeout,
+	    utime, pow2ns_to_ticks(utime),
+	    hz*newtimeout,
+	    timeout_ticks, timeout_ticks / hz);
+#endif
+
+	/* We determined the value is sane, so reset the callout */
+	(void) callout_reset(&wd_pretimeo_handle,
+	    timeout_ticks,
+	    wd_timeout_cb, "pre-timeout");
+	wd_pretimeout = newtimeout;
+	return 0;
 }
 
+static int
+wd_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data,
+    int flags __unused, struct thread *td)
+{
+	u_int u;
+	time_t timeleft;
+	int error;
+
+	error = 0;
+
+	switch (cmd) {
+	case WDIOC_SETSOFT:
+		u = *(int *)data;
+		/* do nothing? */
+		if (u == wd_softtimer)
+			break;
+		/* If there is a pending timeout disallow this ioctl */
+		if (wd_last_u != 0) {
+			error = EINVAL;
+			break;
+		}
+		wd_softtimer = u;
+		break;
+	case WDIOC_SETSOFTTIMEOUTACT:
+		u = *(int *)data;
+		if (wd_valid_act(u)) {
+			wd_softtimeout_act = u;
+		} else {
+			error = EINVAL;
+		}
+		break;
+	case WDIOC_SETPRETIMEOUTACT:
+		u = *(int *)data;
+		if (wd_valid_act(u)) {
+			wd_pretimeout_act = u;
+		} else {
+			error = EINVAL;
+		}
+		break;
+	case WDIOC_GETPRETIMEOUT:
+		*(int *)data = (int)wd_pretimeout;
+		break;
+	case WDIOC_SETPRETIMEOUT:
+		error = wd_set_pretimeout(*(int *)data, false);
+		break;
+	case WDIOC_GETTIMELEFT:
+		error = wd_get_time_left(td, &timeleft);
+		if (error)
+			break;
+		*(int *)data = (int)timeleft;
+		break;
+	case WDIOC_SETTIMEOUT:
+		u = *(u_int *)data;
+		error = wdog_kern_pat(seconds_to_pow2ns(u));
+		break;
+	case WDIOC_GETTIMEOUT:
+		u = wdog_kern_last_timeout();
+		*(u_int *)data = u;
+		break;
+	case WDIOCPATPAT:
+		error = wd_ioctl_patpat(data);
+		break;
+	default:
+		error = ENOIOCTL;
+		break;
+	}
+	return (error);
+}
+
+/*
+ * Return the last timeout set, this is NOT the seconds from NOW until timeout,
+ * rather it is the amount of seconds passed to WDIOCPATPAT/WDIOC_SETTIMEOUT.
+ */
+u_int
+wdog_kern_last_timeout(void)
+{
+
+	return (wd_last_u);
+}
+
 static struct cdevsw wd_cdevsw = {
 	.d_version =	D_VERSION,
 	.d_ioctl =	wd_ioctl,
@@ -120,10 +390,16 @@
 {
 	switch(type) {
 	case MOD_LOAD:
+		callout_init(&wd_pretimeo_handle, true);
+		callout_init(&wd_softtimeo_handle, true);
 		wd_dev = make_dev(&wd_cdevsw, 0,
 		    UID_ROOT, GID_WHEEL, 0600, _PATH_WATCHDOG);
 		return 0;
 	case MOD_UNLOAD:
+		callout_stop(&wd_pretimeo_handle);
+		callout_stop(&wd_softtimeo_handle);
+		callout_drain(&wd_pretimeo_handle);
+		callout_drain(&wd_softtimeo_handle);
 		destroy_dev(wd_dev);
 		return 0;
 	case MOD_SHUTDOWN:

Modified: trunk/sys/dev/wb/if_wb.c
===================================================================
--- trunk/sys/dev/wb/if_wb.c	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/wb/if_wb.c	2018-05-27 22:24:34 UTC (rev 10033)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997, 1998
  *	Bill Paul <wpaul at ctr.columbia.edu>.  All rights reserved.
@@ -31,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/wb/if_wb.c 254842 2013-08-25 10:57:09Z andre $");
 
 /*
  * Winbond fast ethernet PCI NIC driver
@@ -142,7 +143,7 @@
 static int wb_attach(device_t);
 static int wb_detach(device_t);
 
-static void wb_bfree(void *addr, void *args);
+static int wb_bfree(struct mbuf *, void *addr, void *args);
 static int wb_newbuf(struct wb_softc *, struct wb_chain_onefrag *,
 		struct mbuf *);
 static int wb_encap(struct wb_softc *, struct wb_chain *, struct mbuf *);
@@ -660,7 +661,6 @@
 	}
 	ifp->if_softc = sc;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-	ifp->if_mtu = ETHERMTU;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = wb_ioctl;
 	ifp->if_start = wb_start;
@@ -823,12 +823,11 @@
 	return(0);
 }
 
-static void
-wb_bfree(buf, args)
-	void			*buf;
-	void			*args;
+static int
+wb_bfree(struct mbuf *m, void *buf, void *args)
 {
 
+	return (EXT_FREE_OK);
 }
 
 /*

Modified: trunk/sys/dev/wb/if_wbreg.h
===================================================================
--- trunk/sys/dev/wb/if_wbreg.h	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/wb/if_wbreg.h	2018-05-27 22:24:34 UTC (rev 10033)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997, 1998
  *	Bill Paul <wpaul at ctr.columbia.edu>.  All rights reserved.
@@ -29,7 +30,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/wb/if_wbreg.h 226995 2011-11-01 16:13:59Z marius $
  */
 
 /*

Modified: trunk/sys/dev/wbwd/wbwd.c
===================================================================
--- trunk/sys/dev/wbwd/wbwd.c	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/wbwd/wbwd.c	2018-05-27 22:24:34 UTC (rev 10033)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Sandvine Incorporated ULC.
  * Copyright (c) 2012 iXsystems, Inc.
@@ -38,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/wbwd/wbwd.c 300060 2016-05-17 15:18:01Z pfg $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -91,9 +92,12 @@
 #define	WB_LDN8_CRF7_FORCE	0x20	/* 1: force timeout (self-clear) */
 #define	WB_LDN8_CRF7_TS		0x10	/* 0: counting, 1: fired */
 #define	WB_LDN8_CRF7_IRQS	0x0f	/* irq source for watchdog, 2 == SMI */
-#define	WB_LDN8_CRF7_CLEAR_MASK	\
-    (WB_LDN8_CRF7_MOUSE|WB_LDN8_CRF7_KEYB|WB_LDN8_CRF7_TS|WB_LDN8_CRF7_IRQS)
 
+enum chips { w83627hf, w83627s, w83697hf, w83697ug, w83637hf, w83627thf,
+	     w83687thf, w83627ehf, w83627dhg, w83627uhg, w83667hg,
+	     w83627dhg_p, w83667hg_b, nct6775, nct6776, nct6779, nct6791,
+	     nct6792, nct6102 };
+
 struct wb_softc {
 	device_t		dev;
 	struct resource		*portres;
@@ -103,6 +107,10 @@
 	eventhandler_tag	ev_tag;
 	int			(*ext_cfg_enter_f)(struct wb_softc *, u_short);
 	void			(*ext_cfg_exit_f)(struct wb_softc *, u_short);
+	enum chips		chip;
+	uint8_t			ctl_reg;
+	uint8_t			time_reg;
+	uint8_t			csr_reg;
 	int			debug_verbose;
 
 	/*
@@ -144,47 +152,105 @@
 };
 
 struct winbond_vendor_device_id {
-	uint16_t		vendor_id;
 	uint8_t			device_id;
-	uint8_t			device_rev;
+	enum chips		chip;
 	const char *		descr;
 } wb_devs[] = {
 	{
-		.vendor_id	= 0x5ca3,
 		.device_id	= 0x52,
-		.device_rev	= 0x17,
-		.descr		= "Winbond 83627HF/F/HG/G Rev. G",
+		.chip		= w83627hf,
+		.descr		= "Winbond 83627HF/F/HG/G",
 	},
 	{
-		.vendor_id	= 0x5ca3,
-		.device_id	= 0x52,
-		.device_rev	= 0x3a,
-		.descr		= "Winbond 83627HF/F/HG/G Rev. J",
+		.device_id	= 0x59,
+		.chip		= w83627s,
+		.descr		= "Winbond 83627S",
 	},
 	{
-		.vendor_id	= 0x5ca3,
-		.device_id	= 0x52,
-		.device_rev	= 0x41,
-		.descr		= "Winbond 83627HF/F/HG/G Rev. UD-A",
+		.device_id	= 0x60,
+		.chip		= w83697hf,
+		.descr		= "Winbond 83697HF",
 	},
 	{
-		.vendor_id	= 0x5ca3,
+		.device_id	= 0x68,
+		.chip		= w83697ug,
+		.descr		= "Winbond 83697UG",
+	},
+	{
+		.device_id	= 0x70,
+		.chip		= w83637hf,
+		.descr		= "Winbond 83637HF",
+	},
+	{
+		.device_id	= 0x82,
+		.chip		= w83627thf,
+		.descr		= "Winbond 83627THF",
+	},
+	{
+		.device_id	= 0x85,
+		.chip		= w83687thf,
+		.descr		= "Winbond 83687THF",
+	},
+	{
+		.device_id	= 0x88,
+		.chip		= w83627ehf,
+		.descr		= "Winbond 83627EHF",
+	},
+	{
 		.device_id	= 0xa0,
-		.device_rev	= 0x25,
-		.descr		= "Winbond 83627DHG IC ver. 5",   
+		.chip		= w83627dhg,
+		.descr		= "Winbond 83627DHG",
 	},
 	{
-		.vendor_id	= 0x5ca3,
+		.device_id	= 0xa2,
+		.chip		= w83627uhg,
+		.descr		= "Winbond 83627UHG",
+	},
+	{
+		.device_id	= 0xa5,
+		.chip		= w83667hg,
+		.descr		= "Winbond 83667HG",
+	},
+	{
 		.device_id	= 0xb0,
-		.device_rev	= 0x73,
-		.descr		= "Winbond 83627DHG-P",   
+		.chip		= w83627dhg_p,
+		.descr		= "Winbond 83627DHG-P",
 	},
 	{
-		.vendor_id	= 0x5ca3,
+		.device_id	= 0xb3,
+		.chip		= w83667hg_b,
+		.descr		= "Winbond 83667HG-B",
+	},
+	{
+		.device_id	= 0xb4,
+		.chip		= nct6775,
+		.descr		= "Nuvoton NCT6775",
+	},
+	{
 		.device_id	= 0xc3,
-		.device_rev	= 0x33,
-		.descr		= "Nuvoton WPCM450RA0BX",   
+		.chip		= nct6776,
+		.descr		= "Nuvoton NCT6776",
 	},
+	{
+		.device_id	= 0xc4,
+		.chip		= nct6102,
+		.descr		= "Nuvoton NCT6102",
+	},
+	{
+		.device_id	= 0xc5,
+		.chip		= nct6779,
+		.descr		= "Nuvoton NCT6779",
+	},
+	{
+		.device_id	= 0xc8,
+		.chip		= nct6791,
+		.descr		= "Nuvoton NCT6791",
+	},
+	{
+		.device_id	= 0xc9,
+		.chip		= nct6792,
+		.descr		= "Nuvoton NCT6792",
+	},
 };
 
 static void
@@ -231,6 +297,22 @@
 		return (inb(baseport + 1));
 }
 
+static void
+write_reg(struct wb_softc *sc, uint8_t reg, uint8_t value)
+{
+
+	write_efir_1(sc, 0, reg);
+	write_efdr_1(sc, 0, value);
+}
+
+static uint8_t
+read_reg(struct wb_softc *sc, uint8_t reg)
+{
+
+	write_efir_1(sc, 0, reg);
+	return (read_efdr_1(sc, 0));
+}
+
 /*
  * Return the watchdog related registers as we last read them.  This will
  * usually not give the current timeout or state on whether the watchdog
@@ -248,11 +330,10 @@
 	sbuf_new_for_sysctl(&sb, NULL, 64, req);
 
 	sbuf_printf(&sb, "LDN8 (GPIO2, Watchdog): ");
-	sbuf_printf(&sb, "CRF5 0x%02x ", sc->reg_1);
-	sbuf_printf(&sb, "CRF6 0x%02x ", sc->reg_timeout);
-	sbuf_printf(&sb, "CRF7 0x%02x ", sc->reg_2);
+	sbuf_printf(&sb, "CR%02X 0x%02x ", sc->ctl_reg, sc->reg_1);
+	sbuf_printf(&sb, "CR%02X 0x%02x ", sc->time_reg, sc->reg_timeout);
+	sbuf_printf(&sb, "CR%02X 0x%02x", sc->csr_reg, sc->reg_2);
 
-	sbuf_trim(&sb);
 	error = sbuf_finish(&sb);
 	sbuf_delete(&sb);
 	return (error);
@@ -270,24 +351,18 @@
 
 	sc = arg1;
 
-	/*
-	 * Enter extended function mode in case someone else has been
-	 * poking on the registers.  We will not leave it though.
-	 */
 	if ((*sc->ext_cfg_enter_f)(sc, 0) != 0)
 		return (ENXIO);
 
 	/* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog). */
-	write_efir_1(sc, 0, WB_LDN_REG);
-	write_efdr_1(sc, 0, WB_LDN_REG_LDN8);
+	write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8);
 
-	write_efir_1(sc, 0, WB_LDN8_CRF5);
-	sc->reg_1 = read_efdr_1(sc, 0);
-	write_efir_1(sc, 0, WB_LDN8_CRF6);
-	sc->reg_timeout = read_efdr_1(sc, 0);
-	write_efir_1(sc, 0, WB_LDN8_CRF7);
-	sc->reg_2 = read_efdr_1(sc, 0);
+	sc->reg_1 = read_reg(sc, sc->ctl_reg);
+	sc->reg_timeout = read_reg(sc, sc->time_reg);
+	sc->reg_2 = read_reg(sc, sc->csr_reg);
 
+	(*sc->ext_cfg_exit_f)(sc, 0);
+
 	return (sysctl_wb_debug(oidp, arg1, arg2, req));
 }
 
@@ -327,10 +402,6 @@
 	}
 #endif
 
-	/*
-	 * Enter extended function mode in case someone else has been
-	 * poking on the registers.  We will not leave it though.
-	 */
 	if ((*sc->ext_cfg_enter_f)(sc, 0) != 0)
 		return (ENXIO);
 
@@ -344,16 +415,14 @@
 #endif
 
 	/* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog). */
-	write_efir_1(sc, 0, WB_LDN_REG);
-	write_efdr_1(sc, 0, WB_LDN_REG_LDN8);
+	write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8);
 
 	/* Force watchdog to fire. */
-	write_efir_1(sc, 0, WB_LDN8_CRF7);
-	sc->reg_2 = read_efdr_1(sc, 0);
+	sc->reg_2 = read_reg(sc, sc->csr_reg);
 	sc->reg_2 |= WB_LDN8_CRF7_FORCE;
+	write_reg(sc, sc->csr_reg, sc->reg_2);
 
-	write_efir_1(sc, 0, WB_LDN8_CRF7);
-	write_efdr_1(sc, 0, sc->reg_2);
+	(*sc->ext_cfg_exit_f)(sc, 0);
 
 	return (0);
 }
@@ -415,51 +484,36 @@
 wb_set_watchdog(struct wb_softc *sc, unsigned int timeout)
 {
 
+	if (timeout != 0) {
+		/*
+		 * In case an override is set, let it override.  It may lead
+		 * to strange results as we do not check the input of the sysctl.
+		 */
+		if (sc->timeout_override > 0)
+			timeout = sc->timeout_override;
+
+		/* Make sure we support the requested timeout. */
+		if (timeout > 255 * 60)
+			return (EINVAL);
+	}
+
 	if (sc->debug_verbose)
 		wb_print_state(sc, "Before watchdog counter (re)load");
 
-	/*
-	 * Enter extended function mode in case someone else has been
-	 * poking on the registers.  We will not leave it though.
-	 */
 	if ((*sc->ext_cfg_enter_f)(sc, 0) != 0)
 		return (ENXIO);
 
 	/* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog) */
-	write_efir_1(sc, 0, WB_LDN_REG);
-	write_efdr_1(sc, 0, WB_LDN_REG_LDN8);
+	write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8);
 
-	/* Disable and validate or arm/reset watchdog. */
 	if (timeout == 0) {
 		/* Disable watchdog. */
-		write_efir_1(sc, 0, WB_LDN8_CRF6);
-		write_efdr_1(sc, 0, 0x00);
+		sc->reg_timeout = 0;
+		write_reg(sc, sc->time_reg, sc->reg_timeout);
 
-		/* Re-check. */
-		write_efir_1(sc, 0, WB_LDN8_CRF6);
-		sc->reg_timeout = read_efdr_1(sc, 0);
-		
-		if (sc->reg_timeout != 0x00) {
-			device_printf(sc->dev, "Failed to disable watchdog: "
-			    "0x%02x.\n", sc->reg_timeout);
-			return (EIO);
-		}
-
 	} else {
-		/*
-		 * In case an override is set, let it override.  It may lead
-		 * to strange results as we do not check the input of the sysctl.
-		 */
-		if (sc->timeout_override > 0)
-			timeout = sc->timeout_override;
-
-		/* Make sure we support the requested timeout. */
-		if (timeout > 255 * 60)
-			return (EINVAL);
-
 		/* Read current scaling factor. */
-		write_efir_1(sc, 0, WB_LDN8_CRF5);
-		sc->reg_1 = read_efdr_1(sc, 0);
+		sc->reg_1 = read_reg(sc, sc->ctl_reg);
 
 		if (timeout > 255) {
 			/* Set scaling factor to 60s. */
@@ -474,26 +528,23 @@
 		}
 
 		/* In case we fired before we need to clear to fire again. */
-		write_efir_1(sc, 0, WB_LDN8_CRF7);
-		sc->reg_2 = read_efdr_1(sc, 0);
+		sc->reg_2 = read_reg(sc, sc->csr_reg);
 		if (sc->reg_2 & WB_LDN8_CRF7_TS) {
 			sc->reg_2 &= ~WB_LDN8_CRF7_TS;
-			write_efir_1(sc, 0, WB_LDN8_CRF7);
-			write_efdr_1(sc, 0, sc->reg_2);
+			write_reg(sc, sc->csr_reg, sc->reg_2);
 		}
 
 		/* Write back scaling factor. */
-		write_efir_1(sc, 0, WB_LDN8_CRF5);
-		write_efdr_1(sc, 0, sc->reg_1);
+		write_reg(sc, sc->ctl_reg, sc->reg_1);
 
 		/* Set timer and arm/reset the watchdog. */
-		write_efir_1(sc, 0, WB_LDN8_CRF6);
-		write_efdr_1(sc, 0, sc->reg_timeout);
+		write_reg(sc, sc->time_reg, sc->reg_timeout);
 	}
 
+	(*sc->ext_cfg_exit_f)(sc, 0);
+
 	if (sc->debug_verbose)
 		wb_print_state(sc, "After watchdog counter (re)load");
-
 	return (0);
 }
 
@@ -557,6 +608,7 @@
 	struct wb_softc *sc;
 	int error, found, i, j;
 	uint8_t dev_id, dev_rev, cr26;
+	char buf[128];
 
 	if (dev == NULL)
 		sc = NULL;
@@ -567,6 +619,7 @@
 	}
 
 	error = ENXIO;
+	found = 0;
 	for (i = 0; i < sizeof(probe_addrs) / sizeof(*probe_addrs); i++) {
 
 		if (sc != NULL) {
@@ -579,7 +632,6 @@
 			sc->bsh = rman_get_bushandle(sc->portres);
 		}
 
-		found = 0;
 		error = (*probe_addrs[i].ext_cfg_enter_f)(sc, probe_addrs[i].efer);
 		if (error != 0)
 			goto cleanup;
@@ -592,6 +644,9 @@
 		write_efir_1(sc, probe_addrs[i].efer, WB_CR26);
 		cr26 = read_efdr_1(sc, probe_addrs[i].efer);
 
+		if (dev_id == 0xff && dev_rev == 0xff)
+			goto cleanup;
+
 		/* HEFRAS of 0 means EFER at 0x2e, 1 means EFER at 0x4e. */
 		if (((cr26 & 0x40) == 0x00 && probe_addrs[i].efer != 0x2e) ||
 		    ((cr26 & 0x40) == 0x40 && probe_addrs[i].efer != 0x4e)) {
@@ -603,36 +658,30 @@
 			goto cleanup;
 		}
 
-		if (dev_id == 0xff && dev_rev == 0xff)
-			goto cleanup;
-
 		for (j = 0; j < sizeof(wb_devs) / sizeof(*wb_devs); j++) {
-			if (wb_devs[j].device_id == dev_id &&
-			    wb_devs[j].device_rev == dev_rev) {
-				if (probe && dev != NULL)
-					device_set_desc(dev, wb_devs[j].descr);
-				found++;
+			if (wb_devs[j].device_id == dev_id) {
+				found = 1;
 				break;
 			}
 		}
 
-		if (!found) {
-			if (probe && dev != NULL) {
-				device_set_desc(dev, "Unknown Winbond/Nuvoton model");
-				device_printf(dev, "DevID 0x%02x DevRev 0x%02x, "
-				    "please report this.\n", dev_id, dev_rev);
-			}
-			found++;
+		if (probe && dev != NULL) {
+			snprintf(buf, sizeof(buf),
+			    "%s (0x%02x/0x%02x) Watchdog Timer",
+			    found ? wb_devs[j].descr :
+			     "Unknown Winbond/Nuvoton", dev_id, dev_rev);
+			device_set_desc_copy(dev, buf);
 		}
 
-		if (probe && found && bootverbose && dev != NULL)
-			device_printf(dev, "%s EFER 0x%02x ID 0x%02x Rev 0x%02x"
-			     " CR26 0x%02x (probing)\n", device_get_desc(dev),
-			     probe_addrs[i].efer, dev_id, dev_rev, cr26);
+		/* If this is hinted attach, try to guess the model. */
+		if (dev != NULL && !found) {
+			found = 1;
+			j = 0;
+		}
+
 cleanup:
 		if (probe || !found) {
 			(*probe_addrs[i].ext_cfg_exit_f)(sc, probe_addrs[i].efer);
-
 			if (sc != NULL)
 				(void) bus_release_resource(dev, SYS_RES_IOPORT,
 				    sc->rid, sc->portres);
@@ -647,9 +696,21 @@
 			if (sc != NULL) {
 				sc->ext_cfg_enter_f = probe_addrs[i].ext_cfg_enter_f;
 				sc->ext_cfg_exit_f = probe_addrs[i].ext_cfg_exit_f;
+				sc->chip = wb_devs[j].chip;
+				sc->ctl_reg = 0xf5;
+				sc->time_reg = 0xf6;
+				sc->csr_reg = 0xf7;
+				if (sc->chip == w83697hf ||
+				    sc->chip == w83697ug) {
+					sc->ctl_reg = 0xf3;
+					sc->time_reg = 0xf4;
+				} else if (sc->chip == nct6102) {
+					sc->ctl_reg = 0xf0;
+					sc->time_reg = 0xf1;
+					sc->csr_reg = 0xf2;
+				}
 			}
-			error = BUS_PROBE_DEFAULT;
-			break;
+			return (BUS_PROBE_SPECIFIC);
 		} else
 			error = ENXIO;
 	}
@@ -660,15 +721,10 @@
 static void
 wb_identify(driver_t *driver, device_t parent)
 {
-	device_t dev;
 
-	if ((dev = device_find_child(parent, driver->name, 0)) == NULL) {
-		if (wb_probe_enable(dev, 1) != BUS_PROBE_DEFAULT) {
-			if (bootverbose)
-				device_printf(dev, "can not find compatible Winbond chip.\n");
-		} else
-			dev = BUS_ADD_CHILD(parent, 0, driver->name, 0);
-		return;
+	if (device_find_child(parent, driver->name, 0) == NULL) {
+		if (wb_probe_enable(NULL, 1) <= 0)
+			BUS_ADD_CHILD(parent, 0, driver->name, 0);
 	}
 }
 
@@ -691,6 +747,7 @@
 	struct sysctl_oid *soid;
 	unsigned long timeout;
 	int error;
+	uint8_t t;
 
 	error = wb_probe_enable(dev, 0);
 	if (error > 0)
@@ -698,40 +755,98 @@
 
 	sc = device_get_softc(dev);
 	KASSERT(sc->ext_cfg_enter_f != NULL && sc->ext_cfg_exit_f != NULL,
-	    ("%s: successfull probe result but not setup correctly", __func__));
+	    ("%s: successful probe result but not setup correctly", __func__));
 
 	/* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog). */
-	write_efir_1(sc, 0, WB_LDN_REG);
-	write_efdr_1(sc, 0, WB_LDN_REG_LDN8);
+	write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8);
 
-	/* Make sure LDN8 is enabled (Do we need to? Also affects GPIO). */
-	write_efir_1(sc, 0, WB_LDN8_CR30);
-	write_efdr_1(sc, 0, WB_LDN8_CR30_ACTIVE);
+	/* Make sure WDT is enabled. */
+	write_reg(sc, WB_LDN8_CR30,
+	    read_reg(sc, WB_LDN8_CR30) | WB_LDN8_CR30_ACTIVE);
 
+	switch (sc->chip) {
+	case w83627hf:
+	case w83627s:
+		t = read_reg(sc, 0x2B) & ~0x10;
+		write_reg(sc, 0x2B, t); /* set GPIO24 to WDT0 */
+		break;
+	case w83697hf:
+		/* Set pin 119 to WDTO# mode (= CR29, WDT0) */
+		t = read_reg(sc, 0x29) & ~0x60;
+		t |= 0x20;
+		write_reg(sc, 0x29, t);
+		break;
+	case w83697ug:
+		/* Set pin 118 to WDTO# mode */
+		t = read_reg(sc, 0x2b) & ~0x04;
+		write_reg(sc, 0x2b, t);
+		break;
+	case w83627thf:
+		t = (read_reg(sc, 0x2B) & ~0x08) | 0x04;
+		write_reg(sc, 0x2B, t); /* set GPIO3 to WDT0 */
+		break;
+	case w83627dhg:
+	case w83627dhg_p:
+		t = read_reg(sc, 0x2D) & ~0x01; /* PIN77 -> WDT0# */
+		write_reg(sc, 0x2D, t); /* set GPIO5 to WDT0 */
+		t = read_reg(sc, sc->ctl_reg);
+		t |= 0x02;	/* enable the WDTO# output low pulse
+				 * to the KBRST# pin */
+		write_reg(sc, sc->ctl_reg, t);
+		break;
+	case w83637hf:
+		break;
+	case w83687thf:
+		t = read_reg(sc, 0x2C) & ~0x80; /* PIN47 -> WDT0# */
+		write_reg(sc, 0x2C, t);
+		break;
+	case w83627ehf:
+	case w83627uhg:
+	case w83667hg:
+	case w83667hg_b:
+	case nct6775:
+	case nct6776:
+	case nct6779:
+	case nct6791:
+	case nct6792:
+	case nct6102:
+		/*
+		 * These chips have a fixed WDTO# output pin (W83627UHG),
+		 * or support more than one WDTO# output pin.
+		 * Don't touch its configuration, and hope the BIOS
+		 * does the right thing.
+		 */
+		t = read_reg(sc, sc->ctl_reg);
+		t |= 0x02;	/* enable the WDTO# output low pulse
+				 * to the KBRST# pin */
+		write_reg(sc, sc->ctl_reg, t);
+		break;
+	default:
+		break;
+	}
+
 	/* Read the current watchdog configuration. */
-	write_efir_1(sc, 0, WB_LDN8_CRF5);
-	sc->reg_1 = read_efdr_1(sc, 0);
-	write_efir_1(sc, 0, WB_LDN8_CRF6);
-	sc->reg_timeout = read_efdr_1(sc, 0);
-	write_efir_1(sc, 0, WB_LDN8_CRF7);
-	sc->reg_2 = read_efdr_1(sc, 0);
+	sc->reg_1 = read_reg(sc, sc->ctl_reg);
+	sc->reg_timeout = read_reg(sc, sc->time_reg);
+	sc->reg_2 = read_reg(sc, sc->csr_reg);
 
 	/* Print current state if bootverbose or watchdog already enabled. */
 	if (bootverbose || (sc->reg_timeout > 0x00))
 		wb_print_state(sc, "Before watchdog attach");
 
+	sc->reg_1 &= ~WB_LDN8_CRF5_KEYB_P20;
+	sc->reg_1 |= WB_LDN8_CRF5_KBRST;
+	write_reg(sc, sc->ctl_reg, sc->reg_1);
+
 	/*
-	 * Clear a previous watchdog timeout event (if (still) set).
-	 * Disable all all interrupt reset sources (defaults).
+	 * Clear a previous watchdog timeout event (if still set).
+	 * Disable timer reset on mouse interrupts.  Leave reset on keyboard,
+	 * since one of my boards is getting stuck in reboot without it.
 	 */
-	sc->reg_1 &= ~(WB_LDN8_CRF5_KEYB_P20);
-	sc->reg_1 |= WB_LDN8_CRF5_KBRST;
-	write_efir_1(sc, 0, WB_LDN8_CRF5);
-	write_efdr_1(sc, 0, sc->reg_1);
+	sc->reg_2 &= ~(WB_LDN8_CRF7_MOUSE|WB_LDN8_CRF7_TS);
+	write_reg(sc, sc->csr_reg, sc->reg_2);
 
-	sc->reg_2 &= ~WB_LDN8_CRF7_CLEAR_MASK;
-	write_efir_1(sc, 0, WB_LDN8_CRF7);
-	write_efdr_1(sc, 0, sc->reg_2);
+	(*sc->ext_cfg_exit_f)(sc, 0);
 
 	/* Read global timeout override tunable, Add per device sysctls. */
 	if (TUNABLE_ULONG_FETCH("hw.wbwd.timeout_override", &timeout)) {

Modified: trunk/sys/dev/wds/wd7000.c
===================================================================
--- trunk/sys/dev/wds/wd7000.c	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/wds/wd7000.c	2018-05-27 22:24:34 UTC (rev 10033)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/wds/wd7000.c,v 1.3 2009/01/18 19:29:05 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
  * Copyright (c) 2000 Sergey A. Babkin
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/wds/wd7000.c 246713 2013-02-12 16:57:20Z kib $");
 
 /* All bugs are subject to removal without further notice */
 
@@ -1067,7 +1067,7 @@
 		xpt_done((union ccb *) csio);
 		return;
 	}
-	if (ccb_h->flags & (CAM_CDB_PHYS | CAM_SCATTER_VALID | CAM_DATA_PHYS)) {
+	if ((ccb_h->flags & CAM_DATA_MASK) != CAM_DATA_VADDR) {
 		/* don't support these */
 		ccb_h->status = CAM_REQ_INVALID;
 		xpt_done((union ccb *) csio);
@@ -1225,7 +1225,7 @@
 		cpi->hba_misc = 0;
 		cpi->bus_id = cam_sim_bus(sim);
 		cpi->base_transfer_speed = 3300;
-		strncpy(cpi->sim_vid, "MidnightBSD", SIM_IDLEN);
+		strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
 		strncpy(cpi->hba_vid, "WD/FDC", HBA_IDLEN);
 		strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
 		cpi->unit_number = cam_sim_unit(sim);

Added: trunk/sys/dev/wi/if_wi_macio.c
===================================================================
--- trunk/sys/dev/wi/if_wi_macio.c	                        (rev 0)
+++ trunk/sys/dev/wi/if_wi_macio.c	2018-05-27 22:24:34 UTC (rev 10033)
@@ -0,0 +1,142 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013	Justin Hibbits
+ * All rights reserved.
+ * Copyright (c) 1997, 1998, 1999
+ *	Bill Paul <wpaul at ctr.columbia.edu>.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Lucent WaveLAN/IEEE 802.11 MacIO attachment for FreeBSD.
+ *
+ * Based on the PCMCIA driver
+ * Written by Bill Paul <wpaul at ctr.columbia.edu>
+ * Electrical Engineering Department
+ * Columbia University, New York City
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/wi/if_wi_macio.c 253825 2013-07-31 01:13:29Z jhibbits $");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+
+#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+#include <machine/ofw_machdep.h>
+
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/ethernet.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/wi/if_wavelan_ieee.h>
+#include <dev/wi/if_wireg.h>
+#include <dev/wi/if_wivar.h>
+
+static int wi_macio_probe(device_t);
+static int wi_macio_attach(device_t);
+
+static device_method_t wi_macio_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		wi_macio_probe),
+	DEVMETHOD(device_attach,	wi_macio_attach),
+	DEVMETHOD(device_detach,	wi_detach),
+	DEVMETHOD(device_shutdown,	wi_shutdown),
+
+	{ 0, 0 }
+};
+
+static driver_t wi_macio_driver = {
+	"wi",
+	wi_macio_methods,
+	sizeof(struct wi_softc)
+};
+
+DRIVER_MODULE(wi, macio, wi_macio_driver, wi_devclass, 0, 0);
+MODULE_DEPEND(wi, wlan, 1, 1, 1);
+
+static int
+wi_macio_probe(device_t dev)
+{
+	const char *name, *compat;
+
+	/* Make sure we're a network driver */
+	name = ofw_bus_get_name(dev);
+	if (name == NULL)
+		return (ENXIO);
+
+	if (strcmp(name, "radio") != 0) {
+		return ENXIO;
+	}
+	compat = ofw_bus_get_compat(dev);
+	if (strcmp(compat, "wireless") != 0) {
+		return ENXIO;
+	}
+
+	device_set_desc(dev, "Apple Airport");
+	return 0;
+}
+
+static int
+wi_macio_attach(device_t dev)
+{
+	struct wi_softc	*sc;
+	int error;
+
+	sc = device_get_softc(dev);
+	sc->wi_gone = 0;
+	sc->wi_bus_type = 0;
+
+	error = wi_alloc(dev, 0);
+	if (error == 0) {
+		/* Make sure interrupts are disabled. */
+		CSR_WRITE_2(sc, WI_INT_EN, 0);
+		CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
+
+		error = wi_attach(dev);
+		if (error != 0)
+			wi_free(dev);
+	}
+	return error;
+}


Property changes on: trunk/sys/dev/wi/if_wi_macio.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/dev/wl/if_wl.c
===================================================================
--- trunk/sys/dev/wl/if_wl.c	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/wl/if_wl.c	2018-05-27 22:24:34 UTC (rev 10033)
@@ -174,7 +174,7 @@
 */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/wl/if_wl.c 320923 2017-07-12 22:16:54Z jhb $");
 
 /*
  * NOTE:
@@ -576,6 +576,8 @@
 
     if (bootverbose)
 	wldump(sc);
+    device_printf(device,
+	"WARNING: This driver is deprecated and will be removed.\n");
     return (0);
 }
 

Modified: trunk/sys/dev/wl/if_wl.h
===================================================================
--- trunk/sys/dev/wl/if_wl.h	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/wl/if_wl.h	2018-05-27 22:24:34 UTC (rev 10033)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/wl/if_wl.h,v 1.2 2008/12/02 22:43:17 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -19,7 +19,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * 
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/wl/if_wl.h 139749 2005-01-06 01:43:34Z imp $
  */
 /* Definitions for WaveLAN driver */
 

Modified: trunk/sys/dev/wl/if_wl_i82586.h
===================================================================
--- trunk/sys/dev/wl/if_wl_i82586.h	2018-05-27 22:23:30 UTC (rev 10032)
+++ trunk/sys/dev/wl/if_wl_i82586.h	2018-05-27 22:24:34 UTC (rev 10033)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/wl/if_wl_i82586.h,v 1.2 2008/12/02 22:43:17 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Mach Operating System
  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
@@ -24,7 +24,7 @@
  * any improvements or extensions that they make and grant Carnegie Mellon
  * the rights to redistribute these changes.
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/wl/if_wl_i82586.h 146019 2005-05-09 04:47:58Z nyan $
  */
 /*
   Copyright 1988, 1989 by Olivetti Advanced Technology Center, Inc.,



More information about the Midnightbsd-cvs mailing list