Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Jan 2009 00:12:02 +0000 (UTC)
From:      Alfred Perlstein <alfred@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r186730 - in head: lib/libusb20 sys/dev/usb2/controller sys/dev/usb2/core sys/dev/usb2/ethernet sys/dev/usb2/image sys/dev/usb2/include sys/dev/usb2/serial sys/dev/usb2/sound sys/dev/us...
Message-ID:  <200901040012.n040C2gH040928@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alfred
Date: Sun Jan  4 00:12:01 2009
New Revision: 186730
URL: http://svn.freebsd.org/changeset/base/186730

Log:
  Sync with usb4bsd:
  
  src/lib/libusb20/libusb20_desc.c
  
  Make "libusb20_desc_foreach()" more readable.
  
  src/sys/dev/usb2/controller/*.[ch]
  src/sys/dev/usb2/core/*.[ch]
  
  Implement support for USB power save for all HC's.
  
  Implement support for Big-endian EHCI.
  
  Move Huawei quirks back into "u3g" driver.
  
  Improve device enumeration.
  
  src/sys/dev/usb2/ethernet/*[ch]
  
  Patches for supporting new AXE Gigabit chipset.
  
  src/sys/dev/usb2/serial/*[ch]
  
  Fix IOCTL return code.
  
  src/sys/dev/usb2/wlan/*[ch]
  
  Sync with old USB stack.
  
  Submitted by: hps

Added:
  head/sys/modules/usb2/serial_3g/
  head/sys/modules/usb2/serial_3g/Makefile   (contents, props changed)
Modified:
  head/lib/libusb20/libusb20_desc.c
  head/sys/dev/usb2/controller/at91dci.c
  head/sys/dev/usb2/controller/ehci2.c
  head/sys/dev/usb2/controller/ehci2.h
  head/sys/dev/usb2/controller/musb2_otg.c
  head/sys/dev/usb2/controller/ohci2.c
  head/sys/dev/usb2/controller/uhci2.c
  head/sys/dev/usb2/controller/uhci2.h
  head/sys/dev/usb2/controller/usb2_bus.h
  head/sys/dev/usb2/controller/usb2_controller.c
  head/sys/dev/usb2/controller/usb2_controller.h
  head/sys/dev/usb2/controller/uss820dci.c
  head/sys/dev/usb2/core/usb2_busdma.c
  head/sys/dev/usb2/core/usb2_core.h
  head/sys/dev/usb2/core/usb2_device.c
  head/sys/dev/usb2/core/usb2_device.h
  head/sys/dev/usb2/core/usb2_dynamic.c
  head/sys/dev/usb2/core/usb2_dynamic.h
  head/sys/dev/usb2/core/usb2_generic.c
  head/sys/dev/usb2/core/usb2_handle_request.c
  head/sys/dev/usb2/core/usb2_hub.c
  head/sys/dev/usb2/core/usb2_hub.h
  head/sys/dev/usb2/core/usb2_msctest.c
  head/sys/dev/usb2/core/usb2_msctest.h
  head/sys/dev/usb2/core/usb2_request.c
  head/sys/dev/usb2/core/usb2_request.h
  head/sys/dev/usb2/core/usb2_transfer.c
  head/sys/dev/usb2/core/usb2_transfer.h
  head/sys/dev/usb2/ethernet/if_axe2.c
  head/sys/dev/usb2/ethernet/if_axe2_reg.h
  head/sys/dev/usb2/image/uscanner2.c
  head/sys/dev/usb2/include/usb2_devid.h
  head/sys/dev/usb2/include/usb2_devtable.h
  head/sys/dev/usb2/include/usb2_ioctl.h
  head/sys/dev/usb2/include/usb2_standard.h
  head/sys/dev/usb2/serial/u3g2.c
  head/sys/dev/usb2/serial/uchcom2.c
  head/sys/dev/usb2/serial/uftdi2.c
  head/sys/dev/usb2/serial/uplcom2.c
  head/sys/dev/usb2/serial/uvscom2.c
  head/sys/dev/usb2/sound/uaudio2.c
  head/sys/dev/usb2/storage/umass2.c
  head/sys/dev/usb2/storage/ustorage2_fs.c
  head/sys/dev/usb2/wlan/if_ural2.c
  head/sys/dev/usb2/wlan/if_zyd2.c
  head/sys/dev/usb2/wlan/if_zyd2_reg.h
  head/sys/modules/usb2/Makefile

Modified: head/lib/libusb20/libusb20_desc.c
==============================================================================
--- head/lib/libusb20/libusb20_desc.c	Sat Jan  3 22:51:54 2009	(r186729)
+++ head/lib/libusb20/libusb20_desc.c	Sun Jan  4 00:12:01 2009	(r186730)
@@ -238,23 +238,37 @@ const uint8_t *
 libusb20_desc_foreach(const struct libusb20_me_struct *pdesc,
     const uint8_t *psubdesc)
 {
-	const void *end;
+	const uint8_t *start;
+	const uint8_t *end;
+	const uint8_t *desc_next;
 
-	if (pdesc == NULL) {
+	/* be NULL safe */
+	if (pdesc == NULL)
 		return (NULL);
-	}
-	end = LIBUSB20_ADD_BYTES(pdesc->ptr, pdesc->len);
 
-	if (psubdesc == NULL) {
-		psubdesc = LIBUSB20_ADD_BYTES(pdesc->ptr, 0);
-	} else {
-		psubdesc = LIBUSB20_ADD_BYTES(psubdesc, psubdesc[0]);
-	}
-	return (((((const void *)psubdesc) >= ((void *)(pdesc->ptr))) &&
-	    (((const void *)psubdesc) < end) &&
-	    (LIBUSB20_ADD_BYTES(psubdesc, psubdesc[0]) >= ((void *)(pdesc->ptr))) &&
-	    (LIBUSB20_ADD_BYTES(psubdesc, psubdesc[0]) <= end) &&
-	    (psubdesc[0] >= 3)) ? psubdesc : NULL);
+	start = (const uint8_t *)pdesc->ptr;
+	end = LIBUSB20_ADD_BYTES(start, pdesc->len);
+
+	/* get start of next descriptor */
+	if (psubdesc == NULL)
+		psubdesc = start;
+	else
+		psubdesc = psubdesc + psubdesc[0];
+
+	/* check that the next USB descriptor is within the range */
+	if ((psubdesc < start) || (psubdesc >= end))
+		return (NULL);		/* out of range, or EOD */
+
+	/* check start of the second next USB descriptor, if any */
+	desc_next = psubdesc + psubdesc[0];
+	if ((desc_next < start) || (desc_next > end))
+		return (NULL);		/* out of range */
+
+	/* check minimum descriptor length */
+	if (psubdesc[0] < 3)
+		return (NULL);		/* too short descriptor */
+
+	return (psubdesc);		/* return start of next descriptor */
 }
 
 /*------------------------------------------------------------------------*

Modified: head/sys/dev/usb2/controller/at91dci.c
==============================================================================
--- head/sys/dev/usb2/controller/at91dci.c	Sat Jan  3 22:51:54 2009	(r186729)
+++ head/sys/dev/usb2/controller/at91dci.c	Sun Jan  4 00:12:01 2009	(r186730)
@@ -261,42 +261,28 @@ at91dci_pull_down(struct at91dci_softc *
 }
 
 static void
-at91dci_wakeup_peer(struct at91dci_softc *sc)
+at91dci_wakeup_peer(struct usb2_xfer *xfer)
 {
-	uint32_t temp;
+	struct at91dci_softc *sc = xfer->usb2_sc;
+	uint8_t use_polling;
 
 	if (!(sc->sc_flags.status_suspend)) {
 		return;
 	}
-	temp = AT91_UDP_READ_4(sc, AT91_UDP_GSTATE);
-
-	if (!(temp & AT91_UDP_GSTATE_ESR)) {
-		return;
-	}
-	AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, temp);
-}
-
-static void
-at91dci_rem_wakeup_set(struct usb2_device *udev, uint8_t is_on)
-{
-	struct at91dci_softc *sc;
-	uint32_t temp;
-
-	DPRINTFN(5, "is_on=%u\n", is_on);
-
-	USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
-
-	sc = AT9100_DCI_BUS2SC(udev->bus);
+	use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
 
-	temp = AT91_UDP_READ_4(sc, AT91_UDP_GSTATE);
+	AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, AT91_UDP_GSTATE_ESR);
 
-	if (is_on) {
-		temp |= AT91_UDP_GSTATE_ESR;
+	/* wait 8 milliseconds */
+	if (use_polling) {
+		/* polling */
+		DELAY(8000);
 	} else {
-		temp &= ~AT91_UDP_GSTATE_ESR;
+		/* Wait for reset to complete. */
+		usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8);
 	}
 
-	AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, temp);
+	AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, 0);
 }
 
 static void
@@ -2120,7 +2106,7 @@ tr_handle_clear_port_feature:
 
 	switch (value) {
 	case UHF_PORT_SUSPEND:
-		at91dci_wakeup_peer(sc);
+		at91dci_wakeup_peer(xfer);
 		break;
 
 	case UHF_PORT_ENABLE:
@@ -2492,5 +2478,4 @@ struct usb2_bus_methods at91dci_bus_meth
 	.set_stall = &at91dci_set_stall,
 	.clear_stall = &at91dci_clear_stall,
 	.vbus_interrupt = &at91dci_vbus_interrupt,
-	.rem_wakeup_set = &at91dci_rem_wakeup_set,
 };

Modified: head/sys/dev/usb2/controller/ehci2.c
==============================================================================
--- head/sys/dev/usb2/controller/ehci2.c	Sat Jan  3 22:51:54 2009	(r186729)
+++ head/sys/dev/usb2/controller/ehci2.c	Sun Jan  4 00:12:01 2009	(r186730)
@@ -84,7 +84,7 @@ SYSCTL_INT(_hw_usb2_ehci, OID_AUTO, no_h
     &ehcinohighspeed, 0, "Disable High Speed USB");
 
 static void ehci_dump_regs(ehci_softc_t *sc);
-static void ehci_dump_sqh(ehci_qh_t *sqh);
+static void ehci_dump_sqh(ehci_softc_t *sc, ehci_qh_t *sqh);
 
 #endif
 
@@ -101,7 +101,7 @@ extern struct usb2_pipe_methods ehci_roo
 
 static usb2_config_td_command_t ehci_root_ctrl_task;
 static void ehci_do_poll(struct usb2_bus *bus);
-static void ehci_root_ctrl_poll(struct ehci_softc *sc);
+static void ehci_root_ctrl_poll(ehci_softc_t *sc);
 static void ehci_device_done(struct usb2_xfer *xfer, usb2_error_t error);
 static uint8_t ehci_check_transfer(struct usb2_xfer *xfer);
 static void ehci_timeout(void *arg);
@@ -110,6 +110,7 @@ static usb2_sw_transfer_func_t ehci_root
 static usb2_sw_transfer_func_t ehci_root_ctrl_done;
 
 struct ehci_std_temp {
+	ehci_softc_t *sc;
 	struct usb2_page_cache *pc;
 	ehci_qtd_t *td;
 	ehci_qtd_t *td_next;
@@ -123,10 +124,27 @@ struct ehci_std_temp {
 	uint8_t	short_frames_ok;
 };
 
+/*
+ * Byte-order conversion functions.
+ */
+static uint32_t
+htoehci32(ehci_softc_t *sc, const uint32_t v)
+{
+	return ((sc->sc_flags & EHCI_SCFLG_BIGEDESC) ?
+	    htobe32(v) : htole32(v));
+}
+
+static uint32_t
+ehci32toh(ehci_softc_t *sc, const uint32_t v)
+{
+	return ((sc->sc_flags & EHCI_SCFLG_BIGEDESC) ?
+	    be32toh(v) : le32toh(v));
+}
+
 void
 ehci_iterate_hw_softc(struct usb2_bus *bus, usb2_bus_mem_sub_cb_t *cb)
 {
-	struct ehci_softc *sc = EHCI_BUS2SC(bus);
+	ehci_softc_t *sc = EHCI_BUS2SC(bus);
 	uint32_t i;
 
 	cb(bus, &sc->sc_hw.pframes_pc, &sc->sc_hw.pframes_pg,
@@ -280,21 +298,21 @@ ehci_init(ehci_softc_t *sc)
 		sc->sc_intr_p_last[i] = qh;
 
 		qh->qh_self =
-		    htole32(buf_res.physaddr) |
-		    htole32(EHCI_LINK_QH);
+		    htoehci32(sc, buf_res.physaddr) |
+		    htoehci32(sc, EHCI_LINK_QH);
 
 		qh->qh_endp =
-		    htole32(EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH));
+		    htoehci32(sc, EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH));
 		qh->qh_endphub =
-		    htole32(EHCI_QH_SET_MULT(1));
+		    htoehci32(sc, EHCI_QH_SET_MULT(1));
 		qh->qh_curqtd = 0;
 
 		qh->qh_qtd.qtd_next =
-		    htole32(EHCI_LINK_TERMINATE);
+		    htoehci32(sc, EHCI_LINK_TERMINATE);
 		qh->qh_qtd.qtd_altnext =
-		    htole32(EHCI_LINK_TERMINATE);
+		    htoehci32(sc, EHCI_LINK_TERMINATE);
 		qh->qh_qtd.qtd_status =
-		    htole32(EHCI_QTD_HALTED);
+		    htoehci32(sc, EHCI_QTD_HALTED);
 	}
 
 	/*
@@ -329,7 +347,7 @@ ehci_init(ehci_softc_t *sc)
 		qh = sc->sc_intr_p_last[0];
 
 		/* the last (1ms) QH terminates */
-		qh->qh_link = htole32(EHCI_LINK_TERMINATE);
+		qh->qh_link = htoehci32(sc, EHCI_LINK_TERMINATE);
 	}
 	for (i = 0; i < EHCI_VIRTUAL_FRAMELIST_COUNT; i++) {
 		ehci_sitd_t *sitd;
@@ -350,11 +368,11 @@ ehci_init(ehci_softc_t *sc)
 		/* initialize full speed isochronous */
 
 		sitd->sitd_self =
-		    htole32(buf_res.physaddr) |
-		    htole32(EHCI_LINK_SITD);
+		    htoehci32(sc, buf_res.physaddr) |
+		    htoehci32(sc, EHCI_LINK_SITD);
 
 		sitd->sitd_back =
-		    htole32(EHCI_LINK_TERMINATE);
+		    htoehci32(sc, EHCI_LINK_TERMINATE);
 
 		sitd->sitd_next =
 		    sc->sc_intr_p_last[i | (EHCI_VIRTUAL_FRAMELIST_COUNT / 2)]->qh_self;
@@ -375,8 +393,8 @@ ehci_init(ehci_softc_t *sc)
 		/* initialize high speed isochronous */
 
 		itd->itd_self =
-		    htole32(buf_res.physaddr) |
-		    htole32(EHCI_LINK_ITD);
+		    htoehci32(sc, buf_res.physaddr) |
+		    htoehci32(sc, EHCI_LINK_ITD);
 
 		itd->itd_next =
 		    sitd->sitd_self;
@@ -421,20 +439,20 @@ ehci_init(ehci_softc_t *sc)
 		/* init dummy QH that starts the async list */
 
 		qh->qh_self =
-		    htole32(buf_res.physaddr) |
-		    htole32(EHCI_LINK_QH);
+		    htoehci32(sc, buf_res.physaddr) |
+		    htoehci32(sc, EHCI_LINK_QH);
 
 		/* fill the QH */
 		qh->qh_endp =
-		    htole32(EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH) | EHCI_QH_HRECL);
-		qh->qh_endphub = htole32(EHCI_QH_SET_MULT(1));
+		    htoehci32(sc, EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH) | EHCI_QH_HRECL);
+		qh->qh_endphub = htoehci32(sc, EHCI_QH_SET_MULT(1));
 		qh->qh_link = qh->qh_self;
 		qh->qh_curqtd = 0;
 
 		/* fill the overlay qTD */
-		qh->qh_qtd.qtd_next = htole32(EHCI_LINK_TERMINATE);
-		qh->qh_qtd.qtd_altnext = htole32(EHCI_LINK_TERMINATE);
-		qh->qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
+		qh->qh_qtd.qtd_next = htoehci32(sc, EHCI_LINK_TERMINATE);
+		qh->qh_qtd.qtd_altnext = htoehci32(sc, EHCI_LINK_TERMINATE);
+		qh->qh_qtd.qtd_status = htoehci32(sc, EHCI_QTD_HALTED);
 	}
 	/* flush all cache into memory */
 
@@ -442,7 +460,7 @@ ehci_init(ehci_softc_t *sc)
 
 #if USB_DEBUG
 	if (ehcidebug) {
-		ehci_dump_sqh(sc->sc_async_p_last);
+		ehci_dump_sqh(sc, sc->sc_async_p_last);
 	}
 #endif
 
@@ -490,7 +508,7 @@ done:
  * shut down the controller when the system is going down
  */
 void
-ehci_detach(struct ehci_softc *sc)
+ehci_detach(ehci_softc_t *sc)
 {
 	USB_BUS_LOCK(&sc->sc_bus);
 
@@ -510,7 +528,7 @@ ehci_detach(struct ehci_softc *sc)
 }
 
 void
-ehci_suspend(struct ehci_softc *sc)
+ehci_suspend(ehci_softc_t *sc)
 {
 	uint32_t cmd;
 	uint32_t hcr;
@@ -564,7 +582,7 @@ ehci_suspend(struct ehci_softc *sc)
 }
 
 void
-ehci_resume(struct ehci_softc *sc)
+ehci_resume(ehci_softc_t *sc)
 {
 	struct usb2_page_search buf_res;
 	uint32_t cmd;
@@ -723,9 +741,9 @@ ehci_dump_regs(ehci_softc_t *sc)
 }
 
 static void
-ehci_dump_link(uint32_t link, int type)
+ehci_dump_link(ehci_softc_t *sc, uint32_t link, int type)
 {
-	link = le32toh(link);
+	link = ehci32toh(sc, link);
 	printf("0x%08x", link);
 	if (link & EHCI_LINK_TERMINATE)
 		printf("<T>");
@@ -752,16 +770,16 @@ ehci_dump_link(uint32_t link, int type)
 }
 
 static void
-ehci_dump_qtd(ehci_qtd_t *qtd)
+ehci_dump_qtd(ehci_softc_t *sc, ehci_qtd_t *qtd)
 {
 	uint32_t s;
 
 	printf("  next=");
-	ehci_dump_link(qtd->qtd_next, 0);
+	ehci_dump_link(sc, qtd->qtd_next, 0);
 	printf(" altnext=");
-	ehci_dump_link(qtd->qtd_altnext, 0);
+	ehci_dump_link(sc, qtd->qtd_altnext, 0);
 	printf("\n");
-	s = le32toh(qtd->qtd_status);
+	s = ehci32toh(sc, qtd->qtd_status);
 	printf("  status=0x%08x: toggle=%d bytes=0x%x ioc=%d c_page=0x%x\n",
 	    s, EHCI_QTD_GET_TOGGLE(s), EHCI_QTD_GET_BYTES(s),
 	    EHCI_QTD_GET_IOC(s), EHCI_QTD_GET_C_PAGE(s));
@@ -778,35 +796,35 @@ ehci_dump_qtd(ehci_qtd_t *qtd)
 
 	for (s = 0; s < 5; s++) {
 		printf("  buffer[%d]=0x%08x\n", s,
-		    le32toh(qtd->qtd_buffer[s]));
+		    ehci32toh(sc, qtd->qtd_buffer[s]));
 	}
 	for (s = 0; s < 5; s++) {
 		printf("  buffer_hi[%d]=0x%08x\n", s,
-		    le32toh(qtd->qtd_buffer_hi[s]));
+		    ehci32toh(sc, qtd->qtd_buffer_hi[s]));
 	}
 }
 
 static uint8_t
-ehci_dump_sqtd(ehci_qtd_t *sqtd)
+ehci_dump_sqtd(ehci_softc_t *sc, ehci_qtd_t *sqtd)
 {
 	uint8_t temp;
 
 	usb2_pc_cpu_invalidate(sqtd->page_cache);
-	printf("QTD(%p) at 0x%08x:\n", sqtd, le32toh(sqtd->qtd_self));
-	ehci_dump_qtd(sqtd);
-	temp = (sqtd->qtd_next & htole32(EHCI_LINK_TERMINATE)) ? 1 : 0;
+	printf("QTD(%p) at 0x%08x:\n", sqtd, ehci32toh(sc, sqtd->qtd_self));
+	ehci_dump_qtd(sc, sqtd);
+	temp = (sqtd->qtd_next & htoehci32(sc, EHCI_LINK_TERMINATE)) ? 1 : 0;
 	return (temp);
 }
 
 static void
-ehci_dump_sqtds(ehci_qtd_t *sqtd)
+ehci_dump_sqtds(ehci_softc_t *sc, ehci_qtd_t *sqtd)
 {
 	uint16_t i;
 	uint8_t stop;
 
 	stop = 0;
 	for (i = 0; sqtd && (i < 20) && !stop; sqtd = sqtd->obj_next, i++) {
-		stop = ehci_dump_sqtd(sqtd);
+		stop = ehci_dump_sqtd(sc, sqtd);
 	}
 	if (sqtd) {
 		printf("dump aborted, too many TDs\n");
@@ -814,16 +832,17 @@ ehci_dump_sqtds(ehci_qtd_t *sqtd)
 }
 
 static void
-ehci_dump_sqh(ehci_qh_t *qh)
+ehci_dump_sqh(ehci_softc_t *sc, ehci_qh_t *qh)
 {
-	uint32_t endp, endphub;
+	uint32_t endp;
+	uint32_t endphub;
 
 	usb2_pc_cpu_invalidate(qh->page_cache);
-	printf("QH(%p) at 0x%08x:\n", qh, le32toh(qh->qh_self) & ~0x1F);
+	printf("QH(%p) at 0x%08x:\n", qh, ehci32toh(sc, qh->qh_self) & ~0x1F);
 	printf("  link=");
-	ehci_dump_link(qh->qh_link, 1);
+	ehci_dump_link(sc, qh->qh_link, 1);
 	printf("\n");
-	endp = le32toh(qh->qh_endp);
+	endp = ehci32toh(sc, qh->qh_endp);
 	printf("  endp=0x%08x\n", endp);
 	printf("    addr=0x%02x inact=%d endpt=%d eps=%d dtc=%d hrecl=%d\n",
 	    EHCI_QH_GET_ADDR(endp), EHCI_QH_GET_INACT(endp),
@@ -832,90 +851,90 @@ ehci_dump_sqh(ehci_qh_t *qh)
 	printf("    mpl=0x%x ctl=%d nrl=%d\n",
 	    EHCI_QH_GET_MPL(endp), EHCI_QH_GET_CTL(endp),
 	    EHCI_QH_GET_NRL(endp));
-	endphub = le32toh(qh->qh_endphub);
+	endphub = ehci32toh(sc, qh->qh_endphub);
 	printf("  endphub=0x%08x\n", endphub);
 	printf("    smask=0x%02x cmask=0x%02x huba=0x%02x port=%d mult=%d\n",
 	    EHCI_QH_GET_SMASK(endphub), EHCI_QH_GET_CMASK(endphub),
 	    EHCI_QH_GET_HUBA(endphub), EHCI_QH_GET_PORT(endphub),
 	    EHCI_QH_GET_MULT(endphub));
 	printf("  curqtd=");
-	ehci_dump_link(qh->qh_curqtd, 0);
+	ehci_dump_link(sc, qh->qh_curqtd, 0);
 	printf("\n");
 	printf("Overlay qTD:\n");
-	ehci_dump_qtd((void *)&qh->qh_qtd);
+	ehci_dump_qtd(sc, (void *)&qh->qh_qtd);
 }
 
 static void
-ehci_dump_sitd(ehci_sitd_t *sitd)
+ehci_dump_sitd(ehci_softc_t *sc, ehci_sitd_t *sitd)
 {
 	usb2_pc_cpu_invalidate(sitd->page_cache);
-	printf("SITD(%p) at 0x%08x\n", sitd, le32toh(sitd->sitd_self) & ~0x1F);
-	printf(" next=0x%08x\n", le32toh(sitd->sitd_next));
+	printf("SITD(%p) at 0x%08x\n", sitd, ehci32toh(sc, sitd->sitd_self) & ~0x1F);
+	printf(" next=0x%08x\n", ehci32toh(sc, sitd->sitd_next));
 	printf(" portaddr=0x%08x dir=%s addr=%d endpt=0x%x port=0x%x huba=0x%x\n",
-	    le32toh(sitd->sitd_portaddr),
-	    (sitd->sitd_portaddr & htole32(EHCI_SITD_SET_DIR_IN))
+	    ehci32toh(sc, sitd->sitd_portaddr),
+	    (sitd->sitd_portaddr & htoehci32(sc, EHCI_SITD_SET_DIR_IN))
 	    ? "in" : "out",
-	    EHCI_SITD_GET_ADDR(le32toh(sitd->sitd_portaddr)),
-	    EHCI_SITD_GET_ENDPT(le32toh(sitd->sitd_portaddr)),
-	    EHCI_SITD_GET_PORT(le32toh(sitd->sitd_portaddr)),
-	    EHCI_SITD_GET_HUBA(le32toh(sitd->sitd_portaddr)));
-	printf(" mask=0x%08x\n", le32toh(sitd->sitd_mask));
-	printf(" status=0x%08x <%s> len=0x%x\n", le32toh(sitd->sitd_status),
-	    (sitd->sitd_status & htole32(EHCI_SITD_ACTIVE)) ? "ACTIVE" : "",
-	    EHCI_SITD_GET_LEN(le32toh(sitd->sitd_status)));
+	    EHCI_SITD_GET_ADDR(ehci32toh(sc, sitd->sitd_portaddr)),
+	    EHCI_SITD_GET_ENDPT(ehci32toh(sc, sitd->sitd_portaddr)),
+	    EHCI_SITD_GET_PORT(ehci32toh(sc, sitd->sitd_portaddr)),
+	    EHCI_SITD_GET_HUBA(ehci32toh(sc, sitd->sitd_portaddr)));
+	printf(" mask=0x%08x\n", ehci32toh(sc, sitd->sitd_mask));
+	printf(" status=0x%08x <%s> len=0x%x\n", ehci32toh(sc, sitd->sitd_status),
+	    (sitd->sitd_status & htoehci32(sc, EHCI_SITD_ACTIVE)) ? "ACTIVE" : "",
+	    EHCI_SITD_GET_LEN(ehci32toh(sc, sitd->sitd_status)));
 	printf(" back=0x%08x, bp=0x%08x,0x%08x,0x%08x,0x%08x\n",
-	    le32toh(sitd->sitd_back),
-	    le32toh(sitd->sitd_bp[0]),
-	    le32toh(sitd->sitd_bp[1]),
-	    le32toh(sitd->sitd_bp_hi[0]),
-	    le32toh(sitd->sitd_bp_hi[1]));
+	    ehci32toh(sc, sitd->sitd_back),
+	    ehci32toh(sc, sitd->sitd_bp[0]),
+	    ehci32toh(sc, sitd->sitd_bp[1]),
+	    ehci32toh(sc, sitd->sitd_bp_hi[0]),
+	    ehci32toh(sc, sitd->sitd_bp_hi[1]));
 }
 
 static void
-ehci_dump_itd(ehci_itd_t *itd)
+ehci_dump_itd(ehci_softc_t *sc, ehci_itd_t *itd)
 {
 	usb2_pc_cpu_invalidate(itd->page_cache);
-	printf("ITD(%p) at 0x%08x\n", itd, le32toh(itd->itd_self) & ~0x1F);
-	printf(" next=0x%08x\n", le32toh(itd->itd_next));
-	printf(" status[0]=0x%08x; <%s>\n", le32toh(itd->itd_status[0]),
-	    (itd->itd_status[0] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" status[1]=0x%08x; <%s>\n", le32toh(itd->itd_status[1]),
-	    (itd->itd_status[1] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" status[2]=0x%08x; <%s>\n", le32toh(itd->itd_status[2]),
-	    (itd->itd_status[2] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" status[3]=0x%08x; <%s>\n", le32toh(itd->itd_status[3]),
-	    (itd->itd_status[3] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" status[4]=0x%08x; <%s>\n", le32toh(itd->itd_status[4]),
-	    (itd->itd_status[4] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" status[5]=0x%08x; <%s>\n", le32toh(itd->itd_status[5]),
-	    (itd->itd_status[5] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" status[6]=0x%08x; <%s>\n", le32toh(itd->itd_status[6]),
-	    (itd->itd_status[6] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" status[7]=0x%08x; <%s>\n", le32toh(itd->itd_status[7]),
-	    (itd->itd_status[7] & htole32(EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
-	printf(" bp[0]=0x%08x\n", le32toh(itd->itd_bp[0]));
+	printf("ITD(%p) at 0x%08x\n", itd, ehci32toh(sc, itd->itd_self) & ~0x1F);
+	printf(" next=0x%08x\n", ehci32toh(sc, itd->itd_next));
+	printf(" status[0]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[0]),
+	    (itd->itd_status[0] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" status[1]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[1]),
+	    (itd->itd_status[1] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" status[2]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[2]),
+	    (itd->itd_status[2] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" status[3]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[3]),
+	    (itd->itd_status[3] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" status[4]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[4]),
+	    (itd->itd_status[4] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" status[5]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[5]),
+	    (itd->itd_status[5] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" status[6]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[6]),
+	    (itd->itd_status[6] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" status[7]=0x%08x; <%s>\n", ehci32toh(sc, itd->itd_status[7]),
+	    (itd->itd_status[7] & htoehci32(sc, EHCI_ITD_ACTIVE)) ? "ACTIVE" : "");
+	printf(" bp[0]=0x%08x\n", ehci32toh(sc, itd->itd_bp[0]));
 	printf("  addr=0x%02x; endpt=0x%01x\n",
-	    EHCI_ITD_GET_ADDR(le32toh(itd->itd_bp[0])),
-	    EHCI_ITD_GET_ENDPT(le32toh(itd->itd_bp[0])));
-	printf(" bp[1]=0x%08x\n", le32toh(itd->itd_bp[1]));
+	    EHCI_ITD_GET_ADDR(ehci32toh(sc, itd->itd_bp[0])),
+	    EHCI_ITD_GET_ENDPT(ehci32toh(sc, itd->itd_bp[0])));
+	printf(" bp[1]=0x%08x\n", ehci32toh(sc, itd->itd_bp[1]));
 	printf(" dir=%s; mpl=0x%02x\n",
-	    (le32toh(itd->itd_bp[1]) & EHCI_ITD_SET_DIR_IN) ? "in" : "out",
-	    EHCI_ITD_GET_MPL(le32toh(itd->itd_bp[1])));
+	    (ehci32toh(sc, itd->itd_bp[1]) & EHCI_ITD_SET_DIR_IN) ? "in" : "out",
+	    EHCI_ITD_GET_MPL(ehci32toh(sc, itd->itd_bp[1])));
 	printf(" bp[2..6]=0x%08x,0x%08x,0x%08x,0x%08x,0x%08x\n",
-	    le32toh(itd->itd_bp[2]),
-	    le32toh(itd->itd_bp[3]),
-	    le32toh(itd->itd_bp[4]),
-	    le32toh(itd->itd_bp[5]),
-	    le32toh(itd->itd_bp[6]));
+	    ehci32toh(sc, itd->itd_bp[2]),
+	    ehci32toh(sc, itd->itd_bp[3]),
+	    ehci32toh(sc, itd->itd_bp[4]),
+	    ehci32toh(sc, itd->itd_bp[5]),
+	    ehci32toh(sc, itd->itd_bp[6]));
 	printf(" bp_hi=0x%08x,0x%08x,0x%08x,0x%08x,\n"
 	    "       0x%08x,0x%08x,0x%08x\n",
-	    le32toh(itd->itd_bp_hi[0]),
-	    le32toh(itd->itd_bp_hi[1]),
-	    le32toh(itd->itd_bp_hi[2]),
-	    le32toh(itd->itd_bp_hi[3]),
-	    le32toh(itd->itd_bp_hi[4]),
-	    le32toh(itd->itd_bp_hi[5]),
-	    le32toh(itd->itd_bp_hi[6]));
+	    ehci32toh(sc, itd->itd_bp_hi[0]),
+	    ehci32toh(sc, itd->itd_bp_hi[1]),
+	    ehci32toh(sc, itd->itd_bp_hi[2]),
+	    ehci32toh(sc, itd->itd_bp_hi[3]),
+	    ehci32toh(sc, itd->itd_bp_hi[4]),
+	    ehci32toh(sc, itd->itd_bp_hi[5]),
+	    ehci32toh(sc, itd->itd_bp_hi[6]));
 }
 
 static void
@@ -936,12 +955,12 @@ ehci_dump_isoc(ehci_softc_t *sc)
 	sitd = sc->sc_isoc_fs_p_last[pos];
 
 	while (itd && max && max--) {
-		ehci_dump_itd(itd);
+		ehci_dump_itd(sc, itd);
 		itd = itd->prev;
 	}
 
 	while (sitd && max && max--) {
-		ehci_dump_sitd(sitd);
+		ehci_dump_sitd(sc, sitd);
 		sitd = sitd->prev;
 	}
 }
@@ -1022,6 +1041,11 @@ _ehci_append_qh(ehci_qh_t *sqh, ehci_qh_
 {
 	DPRINTFN(11, "%p to %p\n", sqh, last);
 
+	if (sqh->prev != NULL) {
+		/* should not happen */
+		DPRINTFN(0, "QH already linked!\n");
+		return (last);
+	}
 	/* (sc->sc_bus.mtx) must be locked */
 
 	sqh->next = last->next;
@@ -1040,12 +1064,6 @@ _ehci_append_qh(ehci_qh_t *sqh, ehci_qh_
 
 	usb2_pc_cpu_flush(last->page_cache);
 
-#if USB_DEBUG
-	if (ehcidebug > 5) {
-		printf("%s:\n", __FUNCTION__);
-		ehci_dump_sqh(sqh);
-	}
-#endif
 	return (sqh);
 }
 
@@ -1109,14 +1127,6 @@ _ehci_remove_qh(ehci_qh_t *sqh, ehci_qh_
 			sqh->next->prev = sqh->prev;
 			usb2_pc_cpu_flush(sqh->next->page_cache);
 		}
-		/*
-		 * set the Terminate-bit in the e_next of the QH, in case
-		 * the transferred packet was short so that the QH still
-		 * points at the last used TD
-		 */
-
-		sqh->qh_qtd.qtd_next = htole32(EHCI_LINK_TERMINATE);
-
 		last = ((last == sqh) ? sqh->prev : last);
 
 		sqh->prev = 0;
@@ -1129,6 +1139,7 @@ _ehci_remove_qh(ehci_qh_t *sqh, ehci_qh_
 static usb2_error_t
 ehci_non_isoc_done_sub(struct usb2_xfer *xfer)
 {
+	ehci_softc_t *sc = xfer->usb2_sc;
 	ehci_qtd_t *td;
 	ehci_qtd_t *td_alt_next;
 	uint32_t status;
@@ -1140,7 +1151,7 @@ ehci_non_isoc_done_sub(struct usb2_xfer 
 	while (1) {
 
 		usb2_pc_cpu_invalidate(td->page_cache);
-		status = le32toh(td->qtd_status);
+		status = ehci32toh(sc, td->qtd_status);
 
 		len = EHCI_QTD_GET_BYTES(status);
 
@@ -1232,7 +1243,9 @@ ehci_non_isoc_done(struct usb2_xfer *xfe
 
 #if USB_DEBUG
 	if (ehcidebug > 10) {
-		ehci_dump_sqtds(xfer->td_transfer_first);
+		ehci_softc_t *sc = xfer->usb2_sc;
+
+		ehci_dump_sqtds(sc, xfer->td_transfer_first);
 	}
 #endif
 
@@ -1282,6 +1295,7 @@ static uint8_t
 ehci_check_transfer(struct usb2_xfer *xfer)
 {
 	struct usb2_pipe_methods *methods = xfer->pipe->methods;
+	ehci_softc_t *sc = xfer->usb2_sc;
 
 	uint32_t status;
 
@@ -1294,13 +1308,13 @@ ehci_check_transfer(struct usb2_xfer *xf
 
 		td = xfer->td_transfer_last;
 		usb2_pc_cpu_invalidate(td->page_cache);
-		status = le32toh(td->sitd_status);
+		status = ehci32toh(sc, td->sitd_status);
 
 		/* also check if first is complete */
 
 		td = xfer->td_transfer_first;
 		usb2_pc_cpu_invalidate(td->page_cache);
-		status |= le32toh(td->sitd_status);
+		status |= ehci32toh(sc, td->sitd_status);
 
 		if (!(status & EHCI_SITD_ACTIVE)) {
 			ehci_device_done(xfer, USB_ERR_NORMAL_COMPLETION);
@@ -1329,7 +1343,7 @@ ehci_check_transfer(struct usb2_xfer *xf
 		    td->itd_status[6] | td->itd_status[7];
 
 		/* if no transactions are active we continue */
-		if (!(status & htole32(EHCI_ITD_ACTIVE))) {
+		if (!(status & htoehci32(sc, EHCI_ITD_ACTIVE))) {
 			ehci_device_done(xfer, USB_ERR_NORMAL_COMPLETION);
 			goto transferred;
 		}
@@ -1346,7 +1360,7 @@ ehci_check_transfer(struct usb2_xfer *xf
 
 		while (1) {
 			usb2_pc_cpu_invalidate(td->page_cache);
-			status = le32toh(td->qtd_status);
+			status = ehci32toh(sc, td->qtd_status);
 
 			/*
 			 * if there is an active TD the transfer isn't done
@@ -1520,7 +1534,7 @@ ehci_timeout(void *arg)
 static void
 ehci_do_poll(struct usb2_bus *bus)
 {
-	struct ehci_softc *sc = EHCI_BUS2SC(bus);
+	ehci_softc_t *sc = EHCI_BUS2SC(bus);
 
 	USB_BUS_LOCK(&sc->sc_bus);
 	ehci_interrupt_poll(sc);
@@ -1542,7 +1556,7 @@ ehci_setup_standard_chain_sub(struct ehc
 	uint8_t shortpkt_old;
 	uint8_t precompute;
 
-	qtd_altnext = htole32(EHCI_LINK_TERMINATE);
+	qtd_altnext = htoehci32(temp->sc, EHCI_LINK_TERMINATE);
 	td_alt_next = NULL;
 	buf_offset = 0;
 	shortpkt_old = temp->shortpkt;
@@ -1599,7 +1613,8 @@ restart:
 		/* fill out current TD */
 
 		td->qtd_status =
-		    temp->qtd_status | htole32(EHCI_QTD_SET_BYTES(average));
+		    temp->qtd_status |
+		    htoehci32(temp->sc, EHCI_QTD_SET_BYTES(average));
 
 		if (average == 0) {
 
@@ -1607,7 +1622,8 @@ restart:
 
 				/* update data toggle, ZLP case */
 
-				temp->qtd_status ^= htole32(EHCI_QTD_TOGGLE_MASK);
+				temp->qtd_status ^=
+				    htoehci32(temp->sc, EHCI_QTD_TOGGLE_MASK);
 			}
 			td->len = 0;
 
@@ -1627,7 +1643,8 @@ restart:
 
 				if (((average + temp->max_frame_size - 1) /
 				    temp->max_frame_size) & 1) {
-					temp->qtd_status ^= htole32(EHCI_QTD_TOGGLE_MASK);
+					temp->qtd_status ^=
+					    htoehci32(temp->sc, EHCI_QTD_TOGGLE_MASK);
 				}
 			}
 			td->len = average;
@@ -1639,7 +1656,8 @@ restart:
 			/* fill out buffer pointers */
 
 			usb2_get_page(temp->pc, buf_offset, &buf_res);
-			td->qtd_buffer[0] = htole32(buf_res.physaddr);
+			td->qtd_buffer[0] =
+			    htoehci32(temp->sc, buf_res.physaddr);
 			td->qtd_buffer_hi[0] = 0;
 
 			x = 1;
@@ -1648,7 +1666,9 @@ restart:
 				average -= EHCI_PAGE_SIZE;
 				buf_offset += EHCI_PAGE_SIZE;
 				usb2_get_page(temp->pc, buf_offset, &buf_res);
-				td->qtd_buffer[x] = htole32(buf_res.physaddr & (~0xFFF));
+				td->qtd_buffer[x] =
+				    htoehci32(temp->sc,
+				    buf_res.physaddr & (~0xFFF));
 				td->qtd_buffer_hi[x] = 0;
 				x++;
 			}
@@ -1663,7 +1683,9 @@ restart:
 			 */
 			buf_offset += average;
 			usb2_get_page(temp->pc, buf_offset - 1, &buf_res);
-			td->qtd_buffer[x] = htole32(buf_res.physaddr & (~0xFFF));
+			td->qtd_buffer[x] =
+			    htoehci32(temp->sc,
+			    buf_res.physaddr & (~0xFFF));
 			td->qtd_buffer_hi[x] = 0;
 		}
 
@@ -1717,6 +1739,7 @@ ehci_setup_standard_chain(struct usb2_xf
 
 	temp.average = xfer->max_usb2_frame_size;
 	temp.max_frame_size = xfer->max_frame_size;
+	temp.sc = xfer->usb2_sc;
 
 	/* toggle the DMA set we are using */
 	xfer->flags_int.curr_dma_set ^= 1;
@@ -1736,7 +1759,8 @@ ehci_setup_standard_chain(struct usb2_xf
 	if (xfer->flags_int.control_xfr) {
 		if (xfer->pipe->toggle_next) {
 			/* DATA1 is next */
-			temp.qtd_status |= htole32(EHCI_QTD_SET_TOGGLE(1));
+			temp.qtd_status |=
+			    htoehci32(temp.sc, EHCI_QTD_SET_TOGGLE(1));
 		}
 		temp.auto_data_toggle = 0;
 	} else {
@@ -1745,14 +1769,16 @@ ehci_setup_standard_chain(struct usb2_xf
 
 	if (usb2_get_speed(xfer->udev) != USB_SPEED_HIGH) {
 		/* max 3 retries */
-		temp.qtd_status |= htole32(EHCI_QTD_SET_CERR(3));
+		temp.qtd_status |=
+		    htoehci32(temp.sc, EHCI_QTD_SET_CERR(3));
 	}
 	/* check if we should prepend a setup message */
 
 	if (xfer->flags_int.control_xfr) {
 		if (xfer->flags_int.control_hdr) {
 
-			temp.qtd_status &= htole32(EHCI_QTD_SET_CERR(3));
+			temp.qtd_status &=
+			    htoehci32(temp.sc, EHCI_QTD_SET_CERR(3));
 			temp.qtd_status |= htole32
 			    (EHCI_QTD_ACTIVE |
 			    EHCI_QTD_SET_PID(EHCI_QTD_PID_SETUP) |
@@ -1783,7 +1809,8 @@ ehci_setup_standard_chain(struct usb2_xf
 		}
 		/* keep previous data toggle and error count */
 
-		temp.qtd_status &= htole32(EHCI_QTD_SET_CERR(3) |
+		temp.qtd_status &=
+		    htoehci32(temp.sc, EHCI_QTD_SET_CERR(3) |
 		    EHCI_QTD_SET_TOGGLE(1));
 
 		if (temp.len == 0) {
@@ -1803,9 +1830,9 @@ ehci_setup_standard_chain(struct usb2_xf
 
 		temp.qtd_status |=
 		    (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN) ?
-		    htole32(EHCI_QTD_ACTIVE |
+		    htoehci32(temp.sc, EHCI_QTD_ACTIVE |
 		    EHCI_QTD_SET_PID(EHCI_QTD_PID_IN)) :
-		    htole32(EHCI_QTD_ACTIVE |
+		    htoehci32(temp.sc, EHCI_QTD_ACTIVE |
 		    EHCI_QTD_SET_PID(EHCI_QTD_PID_OUT));
 
 		ehci_setup_standard_chain_sub(&temp);
@@ -1821,14 +1848,14 @@ ehci_setup_standard_chain(struct usb2_xf
 		 * direction.
 		 */
 
-		temp.qtd_status &= htole32(EHCI_QTD_SET_CERR(3) |
+		temp.qtd_status &= htoehci32(temp.sc, EHCI_QTD_SET_CERR(3) |
 		    EHCI_QTD_SET_TOGGLE(1));
 		temp.qtd_status |=
 		    (UE_GET_DIR(xfer->endpoint) == UE_DIR_OUT) ?
-		    htole32(EHCI_QTD_ACTIVE |
+		    htoehci32(temp.sc, EHCI_QTD_ACTIVE |
 		    EHCI_QTD_SET_PID(EHCI_QTD_PID_IN) |
 		    EHCI_QTD_SET_TOGGLE(1)) :
-		    htole32(EHCI_QTD_ACTIVE |
+		    htoehci32(temp.sc, EHCI_QTD_ACTIVE |
 		    EHCI_QTD_SET_PID(EHCI_QTD_PID_OUT) |
 		    EHCI_QTD_SET_TOGGLE(1));
 
@@ -1841,9 +1868,9 @@ ehci_setup_standard_chain(struct usb2_xf
 	td = temp.td;
 
 	/* the last TD terminates the transfer: */
-	td->qtd_next = htole32(EHCI_LINK_TERMINATE);
-	td->qtd_altnext = htole32(EHCI_LINK_TERMINATE);
-	td->qtd_status |= htole32(EHCI_QTD_IOC);
+	td->qtd_next = htoehci32(temp.sc, EHCI_LINK_TERMINATE);
+	td->qtd_altnext = htoehci32(temp.sc, EHCI_LINK_TERMINATE);
+	td->qtd_status |= htoehci32(temp.sc, EHCI_QTD_IOC);
 
 	usb2_pc_cpu_flush(td->page_cache);
 
@@ -1855,7 +1882,8 @@ ehci_setup_standard_chain(struct usb2_xf
 	if (ehcidebug > 8) {
 		DPRINTF("nexttog=%d; data before transfer:\n",
 		    xfer->pipe->toggle_next);
-		ehci_dump_sqtds(xfer->td_transfer_first);
+		ehci_dump_sqtds(temp.sc,
+		    xfer->td_transfer_first);
 	}
 #endif
 
@@ -1892,7 +1920,7 @@ ehci_setup_standard_chain(struct usb2_xf
 		}
 	}
 
-	qh->qh_endp = htole32(qh_endp);
+	qh->qh_endp = htoehci32(temp.sc, qh_endp);
 
 	qh_endphub =
 	    (EHCI_QH_SET_MULT(xfer->max_packet_count & 3) |
@@ -1901,38 +1929,42 @@ ehci_setup_standard_chain(struct usb2_xf
 	    EHCI_QH_SET_HUBA(xfer->udev->hs_hub_addr) |
 	    EHCI_QH_SET_PORT(xfer->udev->hs_port_no));
 
-	qh->qh_endphub = htole32(qh_endphub);
-	qh->qh_curqtd = htole32(0);
+	qh->qh_endphub = htoehci32(temp.sc, qh_endphub);
+	qh->qh_curqtd = htoehci32(temp.sc, 0);
 
 	/* fill the overlay qTD */
-	qh->qh_qtd.qtd_status = htole32(0);
+	qh->qh_qtd.qtd_status = htoehci32(temp.sc, 0);
 
 	if (temp.auto_data_toggle) {
 
 		/* let the hardware compute the data toggle */
 
-		qh->qh_endp &= ~htole32(EHCI_QH_DTC);
+		qh->qh_endp &= htoehci32(temp.sc, ~EHCI_QH_DTC);
 
 		if (xfer->pipe->toggle_next) {
 			/* DATA1 is next */
-			qh->qh_qtd.qtd_status |= htole32(EHCI_QTD_SET_TOGGLE(1));
+			qh->qh_qtd.qtd_status |=
+			    htoehci32(temp.sc, EHCI_QTD_SET_TOGGLE(1));
 		}
 	}
 	td = xfer->td_transfer_first;
 
 	qh->qh_qtd.qtd_next = td->qtd_self;
-	qh->qh_qtd.qtd_altnext = htole32(EHCI_LINK_TERMINATE);
+	qh->qh_qtd.qtd_altnext =
+	    htoehci32(temp.sc, EHCI_LINK_TERMINATE);
 
 	usb2_pc_cpu_flush(qh->page_cache);
 
-	EHCI_APPEND_QH(qh, *qh_last);
+	if (xfer->udev->pwr_save.suspended == 0) {
+		EHCI_APPEND_QH(qh, *qh_last);
+	}
 }
 
 static void
 ehci_root_intr_done(struct usb2_xfer *xfer,
     struct usb2_sw_transfer *std)
 {
-	struct ehci_softc *sc = xfer->usb2_sc;
+	ehci_softc_t *sc = xfer->usb2_sc;
 	uint16_t i;
 	uint16_t m;
 
@@ -1992,11 +2024,11 @@ ehci_isoc_fs_done(ehci_softc_t *sc, stru
 #if USB_DEBUG
 		if (ehcidebug > 15) {
 			DPRINTF("isoc FS-TD\n");
-			ehci_dump_sitd(td);
+			ehci_dump_sitd(sc, td);
 		}
 #endif
 		usb2_pc_cpu_invalidate(td->page_cache);
-		status = le32toh(td->sitd_status);
+		status = ehci32toh(sc, td->sitd_status);
 
 		len = EHCI_SITD_GET_LEN(status);
 
@@ -2044,12 +2076,12 @@ ehci_isoc_hs_done(ehci_softc_t *sc, stru
 #if USB_DEBUG
 		if (ehcidebug > 15) {
 			DPRINTF("isoc HS-TD\n");
-			ehci_dump_itd(td);
+			ehci_dump_itd(sc, td);
 		}
 #endif
 
 		usb2_pc_cpu_invalidate(td->page_cache);
-		status = le32toh(td->itd_status[td_no]);
+		status = ehci32toh(sc, td->itd_status[td_no]);
 
 		len = EHCI_ITD_GET_LEN(status);
 
@@ -2102,7 +2134,8 @@ ehci_device_done(struct usb2_xfer *xfer,
 		if (ehcidebug > 8) {
 			DPRINTF("nexttog=%d; data after transfer:\n",
 			    xfer->pipe->toggle_next);
-			ehci_dump_sqtds(xfer->td_transfer_first);
+			ehci_dump_sqtds(xfer->usb2_sc,
+			    xfer->td_transfer_first);
 		}
 #endif
 
@@ -2322,6 +2355,7 @@ struct usb2_pipe_methods ehci_device_int
 static void
 ehci_device_isoc_fs_open(struct usb2_xfer *xfer)
 {
+	ehci_softc_t *sc = xfer->usb2_sc;
 	ehci_sitd_t *td;
 	uint32_t sitd_portaddr;
 	uint8_t ds;
@@ -2335,7 +2369,7 @@ ehci_device_isoc_fs_open(struct usb2_xfe
 	if (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN) {
 		sitd_portaddr |= EHCI_SITD_SET_DIR_IN;
 	}
-	sitd_portaddr = htole32(sitd_portaddr);
+	sitd_portaddr = htoehci32(sc, sitd_portaddr);
 
 	/* initialize all TD's */
 
@@ -2352,7 +2386,7 @@ ehci_device_isoc_fs_open(struct usb2_xfe
 			 *
 			 * micro-frame usage (8 microframes per 1ms)
 			 */
-			td->sitd_back = htole32(EHCI_LINK_TERMINATE);
+			td->sitd_back = htoehci32(sc, EHCI_LINK_TERMINATE);
 
 			usb2_pc_cpu_flush(td->page_cache);
 		}
@@ -2499,7 +2533,7 @@ ehci_device_isoc_fs_enter(struct usb2_xf
 			 * non-zero length
 			 */
 			usb2_get_page(xfer->frbuffers, buf_offset, &buf_res);
-			td->sitd_bp[0] = htole32(buf_res.physaddr);
+			td->sitd_bp[0] = htoehci32(sc, buf_res.physaddr);
 			buf_offset += *plen;
 			/*
 			 * NOTE: We need to subtract one from the offset so
@@ -2544,9 +2578,9 @@ ehci_device_isoc_fs_enter(struct usb2_xf

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901040012.n040C2gH040928>