--- sys/arm/at91/at91.c August 2008
+++ sys.new/arm/at91/at91.c August 2008
@@ -304,7 +304,7 @@
 	{
 		"at91_udp", 0,
 		AT91RM92_BASE + AT91RM92_UDP_BASE, AT91RM92_UDP_SIZE,
-		AT91RM92_IRQ_UDP
+		AT91RM92_IRQ_UDP, AT91RM92_IRQ_PIOB
 	},
 	{
 		"at91_mci", 0,
--- sys/arm/at91/at91_piovar.h August 2008
+++ sys.new/arm/at91/at91_piovar.h August 2008
@@ -35,5 +35,9 @@
 	int use_pullup);
 void at91_pio_gpio_set(uint32_t pio, uint32_t data_mask);
 void at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask);
+uint8_t at91_pio_gpio_get(uint32_t pio, uint32_t data_mask);
+void at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch);
+void at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask, int enable_interrupt);
+uint32_t at91_pio_gpio_clear_interrupt(uint32_t pio);
 
 #endif /* ARM_AT91_AT91_PIOVAR_H */
--- sys/arm/at91/at91_pio.c August 2008
+++ sys.new/arm/at91/at91_pio.c August 2008
@@ -349,6 +349,49 @@
 	PIO[PIO_CODR / 4] = data_mask;
 }
 
+uint8_t
+at91_pio_gpio_get(uint32_t pio, uint32_t data_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	data_mask &= PIO[PIO_PDSR / 4];
+
+	return (data_mask ? 1 : 0);
+}
+
+void
+at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	if (use_deglitch)
+		PIO[PIO_IFER / 4] = data_mask;
+	else
+		PIO[PIO_IFDR / 4] = data_mask;
+	return;
+}
+
+void
+at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask, 
+	int enable_interrupt)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	if (enable_interrupt)
+		PIO[PIO_IER / 4] = data_mask;
+	else
+		PIO[PIO_IDR / 4] = data_mask;
+	return;
+}
+
+uint32_t
+at91_pio_gpio_clear_interrupt(uint32_t pio)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+	/* reading this register will clear the interrupts */
+	return (PIO[PIO_ISR / 4]);
+}
+
 static device_method_t at91_pio_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		at91_pio_probe),
--- sys/arm/at91/at91_pmc.c August 2008
+++ sys.new/arm/at91/at91_pmc.c August 2008
@@ -128,7 +128,7 @@
 static struct at91_pmc_clock ohci_clk = {
 	.name = "ohci_clk",
 	.parent = &mck,
-	.pmc_mask = 1 << AT91RM92_IRQ_UDP,
+	.pmc_mask = 1 << AT91RM92_IRQ_UHP,
 	.set_mode = &at91_pmc_set_periph_mode
 };
 
--- sys/arm/conf/KB920X August 2008
+++ sys.new/arm/conf/KB920X August 2008
@@ -92,41 +92,28 @@
 device		icee
 
 device		bpf
+
 # USB support
-device          ohci            # OHCI localbus->USB interface
-device          usb             # USB Bus (required)
-#device         udbp            # USB Double Bulk Pipe devices
-device          ugen            # Generic
-device          uhid            # "Human Interface Devices"
-device          ulpt            # Printer
-device          umass           # Disks/Mass storage - Requires scbus and da
-device          ural            # Ralink Technology RT2500USB wireless NICs
-device          rum             # Ralink Technology RT2501USB wireless NICs
-device          urio            # Diamond Rio 500 MP3 player
-device          uscanner        # Scanners
+device		at91rm9200
+device		usb2_core
+device		usb2_controller		# EHCI/OHCI/UHCI/AT91DCI
+device		usb2_storage		# USB mass storage support
+device		usb2_ethernet		# USB ethernet support
+device		usb2_wlan		# USB wireless LAN support
+device		usb2_serial		# USB serial support
+device		usb2_quirk		# USB quirks
+device		usb2_template		# Device Side Mode USB templates
+device		usb2_image		# USB Scanner support
+
 # USB Ethernet, requires miibus
-device		miibus
-device          aue             # ADMtek USB Ethernet
-device          axe             # ASIX Electronics USB Ethernet
-device          cdce            # Generic USB over Ethernet
-device          cue             # CATC USB Ethernet
-device          kue             # Kawasaki LSI USB Ethernet
-device          rue             # RealTek RTL8150 USB Ethernet
-device		udav
-# usb serial
-device          ucom
-device          uark
-device          ubsa
-device          uftdi
-device          uipaq
-device          uplcom
-device          uvisor
-device          uvscom
+device				miibus
+
 # SCSI peripherals
 device          scbus           # SCSI bus (required for SCSI)
 device          da              # Direct Access (disks)
 device          cd              # CD
 device          pass            # Passthrough device (direct SCSI access)
+
 # Wireless NIC cards
 device          wlan            # 802.11 support
 device          wlan_wep        # 802.11 WEP support
--- sys/compat/ndis/ntoskrnl_var.h August 2008
+++ sys.new/compat/ndis/ntoskrnl_var.h August 2008
@@ -117,6 +117,7 @@
 
 /* Note: assumes x86 page size of 4K. */
 
+#ifndef PAGE_SHIFT
 #if PAGE_SIZE == 4096
 #define PAGE_SHIFT	12
 #elif PAGE_SIZE == 8192
@@ -124,6 +125,7 @@
 #else
 #error PAGE_SHIFT undefined!
 #endif
+#endif
 
 #define SPAN_PAGES(ptr, len)					\
 	((uint32_t)((((uintptr_t)(ptr) & (PAGE_SIZE - 1)) +	\
--- sys/conf/files August 2008
+++ sys.new/conf/files August 2008
@@ -1316,6 +1316,145 @@
 dev/usb/uslcom.c		optional uslcom
 dev/usb/uvisor.c		optional uvisor
 dev/usb/uvscom.c		optional uvscom
+#
+# USB2 controller drivers
+#
+dev/usb2/controller/at91dci.c		optional usb2_core usb2_controller
+dev/usb2/controller/at91dci_atmelarm.c	optional usb2_core usb2_controller at91rm9200
+dev/usb2/controller/ehci2.c		optional usb2_core usb2_controller
+dev/usb2/controller/ehci2_pci.c		optional usb2_core usb2_controller pci
+dev/usb2/controller/ohci2.c		optional usb2_core usb2_controller
+dev/usb2/controller/ohci2_atmelarm.c	optional usb2_core usb2_controller at91rm9200
+dev/usb2/controller/ohci2_pci.c		optional usb2_core usb2_controller pci
+dev/usb2/controller/uhci2.c		optional usb2_core usb2_controller
+dev/usb2/controller/uhci2_pci.c		optional usb2_core usb2_controller pci
+dev/usb2/controller/usb2_controller.c	optional usb2_core usb2_controller
+dev/usb2/controller/uss820dci.c		optional usb2_core usb2_controller
+dev/usb2/controller/uss820dci_pccard.c	optional usb2_core usb2_controller pccard
+#
+# USB2 storage drivers
+#
+# NOTE: ata-usb conflicts with umass
+# dev/usb2/storage/ata-usb2.c		optional usb2_core usb2_storage
+#
+dev/usb2/storage/umass2.c		optional usb2_core usb2_storage
+dev/usb2/storage/urio2.c		optional usb2_core usb2_storage
+dev/usb2/storage/usb2_storage.c		optional usb2_core usb2_storage
+dev/usb2/storage/ustorage2_fs.c		optional usb2_core usb2_storage
+#
+# USB2 NDIS driver
+#
+dev/usb2/ndis/if_ndis_usb2.c		optional usb2_core usb2_ndis
+dev/usb2/ndis/usb2_ndis.c		optional usb2_core usb2_ndis
+#
+# USB2 core
+#
+dev/usb2/core/usb2_busdma.c		optional usb2_core
+dev/usb2/core/usb2_compat_linux.c	optional usb2_core
+dev/usb2/core/usb2_config_td.c		optional usb2_core
+dev/usb2/core/usb2_core.c		optional usb2_core
+dev/usb2/core/usb2_debug.c		optional usb2_core
+dev/usb2/core/usb2_dev.c		optional usb2_core
+dev/usb2/core/usb2_device.c		optional usb2_core
+dev/usb2/core/usb2_dynamic.c		optional usb2_core
+dev/usb2/core/usb2_error.c		optional usb2_core
+dev/usb2/core/usb2_generic.c		optional usb2_core
+dev/usb2/core/usb2_handle_request.c	optional usb2_core
+dev/usb2/core/usb2_hid.c		optional usb2_core
+dev/usb2/core/usb2_hub.c		optional usb2_core
+dev/usb2/core/usb2_if.m			optional usb2_core
+dev/usb2/core/usb2_lookup.c		optional usb2_core
+dev/usb2/core/usb2_mbuf.c		optional usb2_core
+dev/usb2/core/usb2_msctest.c		optional usb2_core
+dev/usb2/core/usb2_parse.c		optional usb2_core
+dev/usb2/core/usb2_process.c		optional usb2_core
+dev/usb2/core/usb2_request.c		optional usb2_core
+dev/usb2/core/usb2_sw_transfer.c	optional usb2_core
+dev/usb2/core/usb2_transfer.c		optional usb2_core
+dev/usb2/core/usb2_util.c		optional usb2_core
+#
+# USB2 ethernet drivers
+#
+dev/usb2/ethernet/if_aue2.c		optional usb2_core usb2_ethernet
+dev/usb2/ethernet/if_axe2.c		optional usb2_core usb2_ethernet
+dev/usb2/ethernet/if_cdce2.c		optional usb2_core usb2_ethernet
+dev/usb2/ethernet/if_cue2.c		optional usb2_core usb2_ethernet
+dev/usb2/ethernet/if_kue2.c		optional usb2_core usb2_ethernet
+dev/usb2/ethernet/if_rue2.c		optional usb2_core usb2_ethernet
+dev/usb2/ethernet/if_udav2.c		optional usb2_core usb2_ethernet
+dev/usb2/ethernet/usb2_ethernet.c	optional usb2_core usb2_ethernet
+#
+# USB2 WLAN drivers
+#
+dev/usb2/wlan/if_rum2.c		optional usb2_core usb2_wlan
+dev/usb2/wlan/if_ural2.c	optional usb2_core usb2_wlan
+dev/usb2/wlan/if_zyd2.c		optional usb2_core usb2_wlan
+dev/usb2/wlan/usb2_wlan.c	optional usb2_core usb2_wlan
+#
+# USB2 serial and parallel port drivers
+#
+dev/usb2/serial/uark2.c		optional usb2_core usb2_serial
+dev/usb2/serial/ubsa2.c		optional usb2_core usb2_serial
+dev/usb2/serial/ubser2.c	optional usb2_core usb2_serial
+dev/usb2/serial/uchcom2.c	optional usb2_core usb2_serial
+dev/usb2/serial/ucycom2.c	optional usb2_core usb2_serial
+dev/usb2/serial/ufoma2.c	optional usb2_core usb2_serial
+dev/usb2/serial/uftdi2.c	optional usb2_core usb2_serial
+dev/usb2/serial/ugensa2.c	optional usb2_core usb2_serial
+dev/usb2/serial/uipaq2.c	optional usb2_core usb2_serial
+dev/usb2/serial/ulpt2.c		optional usb2_core usb2_serial
+dev/usb2/serial/umct2.c		optional usb2_core usb2_serial
+dev/usb2/serial/umodem2.c	optional usb2_core usb2_serial
+dev/usb2/serial/umoscom2.c	optional usb2_core usb2_serial
+dev/usb2/serial/uplcom2.c	optional usb2_core usb2_serial
+dev/usb2/serial/usb2_serial.c	optional usb2_core usb2_serial
+dev/usb2/serial/uvisor2.c	optional usb2_core usb2_serial
+dev/usb2/serial/uvscom2.c	optional usb2_core usb2_serial
+#
+# USB2 bluetooth drivers
+#
+dev/usb2/bluetooth/usb2_bluetooth.c	optional usb2_core usb2_bluetooth
+dev/usb2/bluetooth/ng_ubt2.c		optional usb2_core usb2_bluetooth
+dev/usb2/bluetooth/ubtbcmfw2.c		optional usb2_core usb2_bluetooth
+
+#
+# USB2 misc drivers
+#
+dev/usb2/misc/usb2_misc.c	optional usb2_core usb2_misc
+dev/usb2/misc/ufm2.c		optional usb2_core usb2_misc
+dev/usb2/misc/udbp2.c		optional usb2_core usb2_misc
+#
+# USB2 input drivers
+#
+dev/usb2/input/uhid2.c		optional usb2_core usb2_input
+dev/usb2/input/ukbd2.c		optional usb2_core usb2_input
+dev/usb2/input/ums2.c		optional usb2_core usb2_input
+dev/usb2/input/usb2_input.c	optional usb2_core usb2_input
+#
+# USB2 quirks
+#
+dev/usb2/quirk/usb2_quirk.c	optional usb2_core usb2_quirk
+#
+# USB2 templates
+#
+dev/usb2/template/usb2_template.c	optional usb2_core usb2_template
+dev/usb2/template/usb2_template_cdce.c	optional usb2_core usb2_template
+dev/usb2/template/usb2_template_msc.c	optional usb2_core usb2_template
+dev/usb2/template/usb2_template_mtp.c	optional usb2_core usb2_template
+#
+# USB2 image drivers
+#
+dev/usb2/image/usb2_image.c	optional usb2_core usb2_image
+dev/usb2/image/uscanner2.c	optional usb2_core usb2_image
+#
+# USB2 sound and MIDI drivers
+#
+dev/usb2/sound/usb2_sound.c	optional usb2_core usb2_sound
+dev/usb2/sound/uaudio2.c	optional usb2_core usb2_sound
+dev/usb2/sound/uaudio2_pcm.c	optional usb2_core usb2_sound
+#
+# USB2 END
+#
 dev/utopia/idtphy.c		optional utopia
 dev/utopia/suni.c		optional utopia
 dev/utopia/utopia.c		optional utopia
--- sys/conf/kmod.mk August 2008
+++ sys.new/conf/kmod.mk August 2008
@@ -331,6 +331,7 @@
 	dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
 	dev/sound/midi/mpu_if.m dev/sound/midi/mpufoi_if.m \
 	dev/sound/midi/synth_if.m dev/usb/usb_if.m isa/isa_if.m \
+	dev/usb2/core/usb2_if.m \
 	kern/bus_if.m kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \
 	libkern/iconv_converter_if.m opencrypto/cryptodev_if.m \
 	pc98/pc98/canbus_if.m
--- sys/dev/sound/pcm/channel.c August 2008
+++ sys.new/dev/sound/pcm/channel.c August 2008
@@ -570,13 +570,26 @@
 void
 chn_intr(struct pcm_channel *c)
 {
-	CHN_LOCK(c);
+	uint8_t do_unlock;
+	if (CHN_LOCK_OWNED(c)) {
+		/* 
+		 * Allow sound drivers to call this function with
+		 * "CHN_LOCK()" locked:
+		 */
+		do_unlock = 0;
+	} else {
+		do_unlock = 1;
+		CHN_LOCK(c);
+	}
 	c->interrupts++;
 	if (c->direction == PCMDIR_PLAY)
 		chn_wrintr(c);
 	else
 		chn_rdintr(c);
-	CHN_UNLOCK(c);
+	if (do_unlock) {
+		CHN_UNLOCK(c);
+	}
+	return;
 }
 
 u_int32_t
--- sys/dev/sound/pcm/channel.h August 2008
+++ sys.new/dev/sound/pcm/channel.h August 2008
@@ -258,11 +258,13 @@
 #endif
 
 #ifdef	USING_MUTEX
+#define CHN_LOCK_OWNED(c) mtx_owned((struct mtx *)((c)->lock))
 #define CHN_LOCK(c) mtx_lock((struct mtx *)((c)->lock))
 #define CHN_UNLOCK(c) mtx_unlock((struct mtx *)((c)->lock))
 #define CHN_TRYLOCK(c) mtx_trylock((struct mtx *)((c)->lock))
 #define CHN_LOCKASSERT(c) mtx_assert((struct mtx *)((c)->lock), MA_OWNED)
 #else
+#define CHN_LOCK_OWNED(c) 0
 #define CHN_LOCK(c)
 #define CHN_UNLOCK(c)
 #define CHN_TRYLOCK(c)
--- sys/dev/sound/pcm/mixer.c August 2008
+++ sys.new/dev/sound/pcm/mixer.c August 2008
@@ -589,7 +589,7 @@
 	KASSERT(m->type == MIXER_TYPE_SECONDARY,
 	    ("%s(): illegal mixer type=%d", __func__, m->type));
 
-	snd_mtxlock(m->lock);
+	/* mixer uninit can sleep --hps */
 
 	MIXER_UNINIT(m);
 
@@ -704,14 +704,24 @@
 		return EBUSY;
 	}
 
+	/* destroy dev can sleep --hps */
+
+	snd_mtxunlock(m->lock);
+
 	pdev->si_drv1 = NULL;
 	destroy_dev(pdev);
 
+	snd_mtxlock(m->lock);
+
 	for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
 		mixer_set(m, i, 0);
 
 	mixer_setrecsrc(m, SOUND_MASK_MIC);
 
+	snd_mtxunlock(m->lock);
+
+	/* mixer uninit can sleep --hps */
+
 	MIXER_UNINIT(m);
 
 	snd_mtxfree(m->lock);
@@ -1280,3 +1290,16 @@
 
 	return (EINVAL);
 }
+
+/*
+ * Allow the sound driver to use the mixer lock to protect its mixer
+ * data:
+ */
+struct mtx *
+mixer_get_lock(struct snd_mixer *m)
+{
+	if (m->lock == NULL) {
+		return (&Giant);
+	}
+	return (m->lock);
+}
--- sys/dev/sound/pcm/mixer.h August 2008
+++ sys.new/dev/sound/pcm/mixer.h August 2008
@@ -56,6 +56,7 @@
 u_int32_t mix_getparent(struct snd_mixer *m, u_int32_t dev);
 u_int32_t mix_getchild(struct snd_mixer *m, u_int32_t dev);
 void *mix_getdevinfo(struct snd_mixer *m);
+struct mtx *mixer_get_lock(struct snd_mixer *m);
 
 extern int mixer_count;
 
--- sys/kern/subr_bus.c August 2008
+++ sys.new/kern/subr_bus.c August 2008
@@ -1879,7 +1879,8 @@
 int
 device_get_children(device_t dev, device_t **devlistp, int *devcountp)
 {
-	int count;
+	uint32_t count;
+	uint32_t n;
 	device_t child;
 	device_t *list;
 
@@ -1888,14 +1889,34 @@
 		count++;
 	}
 
-	list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT|M_ZERO);
-	if (!list)
+	if (count == 0) {
+		/* avoid zero size allocation */
+		n = 1 * sizeof(device_t);
+	} else {
+		n = count * sizeof(device_t);
+	}
+
+	list = malloc(n, M_TEMP, M_NOWAIT|M_ZERO);
+	if (!list) {
+		*devlistp = NULL;
+		*devcountp = 0;
 		return (ENOMEM);
+	}
 
-	count = 0;
+	n = 0;
 	TAILQ_FOREACH(child, &dev->children, link) {
-		list[count] = child;
-		count++;
+		if (n < count) {
+			list[n] = child;
+		}
+		n++;
+	}
+
+	if (n != count) {
+		printf("device_get_children: Number of devices changed "
+		       "from %d to %d!\n", count, n);
+		if (n < count) {
+			count = n;
+		}
 	}
 
 	*devlistp = list;
--- sys/modules/Makefile August 2008
+++ sys.new/modules/Makefile August 2008
@@ -289,6 +289,7 @@
 	ural \
 	urio \
 	usb \
+	usb2 \
 	uscanner \
 	uslcom \
 	utopia \
