[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Thu Aug 30 21:23:20 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/a6db8cab5676
changeset: 528:a6db8cab5676
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Fri Aug 31 00:23:32 2012 +0300
description:
Update dwc_otg device mode driver to r239922.

diffstat:

 head/sys/dev/usb/controller/dwc_otg.c |  467 +++++++++++++++++----------------
 head/sys/dev/usb/controller/dwc_otg.h |  286 +--------------------
 2 files changed, 235 insertions(+), 518 deletions(-)

diffs (1298 lines):

diff -r 00e5fe011396 -r a6db8cab5676 head/sys/dev/usb/controller/dwc_otg.c
--- a/head/sys/dev/usb/controller/dwc_otg.c	Thu Aug 16 21:15:49 2012 +0300
+++ b/head/sys/dev/usb/controller/dwc_otg.c	Fri Aug 31 00:23:32 2012 +0300
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/controller/dwc_otg.c 239214 2012-08-12 17:53:06Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/controller/dwc_otg.c 239909 2012-08-30 16:19:05Z hselasky $");
 
 #include <sys/stdint.h>
 #include <sys/stddef.h>
@@ -81,6 +81,7 @@
 #include <dev/usb/usb_bus.h>
 
 #include <dev/usb/controller/dwc_otg.h>
+#include <dev/usb/controller/dwc_otgreg.h>
 
 #define	DWC_OTG_BUS2SC(bus) \
    ((struct dwc_otg_softc *)(((uint8_t *)(bus)) - \
@@ -90,12 +91,12 @@
    DWC_OTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
 #define	DWC_OTG_MSK_GINT_ENABLED	\
-   (DWC_OTG_MSK_GINT_ENUM_DONE |	\
-   DWC_OTG_MSK_GINT_USB_RESET |		\
-   DWC_OTG_MSK_GINT_USB_SUSPEND |	\
-   DWC_OTG_MSK_GINT_INEP |		\
-   DWC_OTG_MSK_GINT_RXFLVL |		\
-   DWC_OTG_MSK_GINT_SESSREQINT)
+   (GINTSTS_ENUMDONE |	\
+   GINTSTS_USBRST |		\
+   GINTSTS_USBSUSP |	\
+   GINTSTS_IEPINT |		\
+   GINTSTS_RXFLVL |		\
+   GINTSTS_SESSREQINT)
 
 #define DWC_OTG_USE_HSIC 0
 
@@ -172,7 +173,7 @@
 	/* split equally for IN and OUT */
 	fifo_size /= 2;
 
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GRXFSIZ, fifo_size / 4);
+	DWC_OTG_WRITE_4(sc, DOTG_GRXFSIZ, fifo_size / 4);
 
 	/* align to 4-bytes */
 	fifo_size &= ~3;
@@ -185,7 +186,7 @@
 		return (EINVAL);
 	}
 
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GNPTXFSIZ, (0x10 << 16) | (tx_start / 4));
+	DWC_OTG_WRITE_4(sc, DOTG_GNPTXFSIZ, (0x10 << 16) | (tx_start / 4));
 	fifo_size -= 0x40;
 	tx_start += 0x40;
 
@@ -210,7 +211,7 @@
 			    (DWC_OTG_MAX_TXN / 2);
 
 			if (fifo_size >= limit) {
-				DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPTXF(x),
+				DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
 				    ((limit / 4) << 16) |
 				    (tx_start / 4));
 				tx_start += limit;
@@ -220,7 +221,7 @@
 				pf->max_buffer = limit;
 
 			} else if (fifo_size >= 0x80) {
-				DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPTXF(x),
+				DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
 				    ((0x80 / 4) << 16) | (tx_start / 4));
 				tx_start += 0x80;
 				fifo_size -= 0x80;
@@ -229,7 +230,7 @@
 
 			} else {
 				pf->usb.is_simplex = 1;
-				DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPTXF(x),
+				DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
 				    (0x0 << 16) | (tx_start / 4));
 			}
 		} else {
@@ -242,13 +243,13 @@
 	}
 
 	/* reset RX FIFO */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GRSTCTL,
-	    DWC_OTG_MSK_GRSTCTL_RXFFLUSH);
+	DWC_OTG_WRITE_4(sc, DOTG_GRSTCTL,
+	    GRSTCTL_RXFFLSH);
 
 	/* reset all TX FIFOs */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GRSTCTL,
-	   DWC_OTG_MSK_GRSTCTL_TXFIFO(0x10) |
-	   DWC_OTG_MSK_GRSTCTL_TXFFLUSH);
+	DWC_OTG_WRITE_4(sc, DOTG_GRSTCTL,
+	   GRSTCTL_TXFIFO(0x10) |
+	   GRSTCTL_TXFFLSH);
 
 	return (0);
 }
@@ -291,9 +292,9 @@
 	    sc->sc_flags.port_powered) {
 		sc->sc_flags.d_pulled_up = 1;
 
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DCTL);
-		temp &= ~DWC_OTG_MSK_DCTL_SOFT_DISC;
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCTL, temp);
+		temp = DWC_OTG_READ_4(sc, DOTG_DCTL);
+		temp &= ~DCTL_SFTDISCON;
+		DWC_OTG_WRITE_4(sc, DOTG_DCTL, temp);
 	}
 }
 
@@ -307,9 +308,9 @@
 	if (sc->sc_flags.d_pulled_up) {
 		sc->sc_flags.d_pulled_up = 0;
 
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DCTL);
-		temp |= DWC_OTG_MSK_DCTL_SOFT_DISC;
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCTL, temp);
+		temp = DWC_OTG_READ_4(sc, DOTG_DCTL);
+		temp |= DCTL_SFTDISCON;
+		DWC_OTG_WRITE_4(sc, DOTG_DCTL, temp);
 	}
 }
 
@@ -325,9 +326,9 @@
 		 * Disable resume interrupt and enable suspend
 		 * interrupt:
 		 */
-		sc->sc_irq_mask &= ~DWC_OTG_MSK_GINT_WKUPINT;
-		sc->sc_irq_mask |= DWC_OTG_MSK_GINT_USB_SUSPEND;
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GINTMSK, sc->sc_irq_mask);
+		sc->sc_irq_mask &= ~GINTSTS_WKUPINT;
+		sc->sc_irq_mask |= GINTSTS_USBSUSP;
+		DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask);
 
 		/* complete root HUB interrupt endpoint */
 		dwc_otg_root_intr(sc);
@@ -345,15 +346,15 @@
 	DPRINTFN(5, "Remote wakeup\n");
 
 	/* enable remote wakeup signalling */
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DCTL);
-	temp |= DWC_OTG_MSK_DCTL_REMOTE_WAKEUP;
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCTL, temp);
+	temp = DWC_OTG_READ_4(sc, DOTG_DCTL);
+	temp |= DCTL_RMTWKUPSIG;
+	DWC_OTG_WRITE_4(sc, DOTG_DCTL, temp);
 
 	/* Wait 8ms for remote wakeup to complete. */
 	usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125);
 
-	temp &= ~DWC_OTG_MSK_DCTL_REMOTE_WAKEUP;
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCTL, temp);
+	temp &= ~DCTL_RMTWKUPSIG;
+	DWC_OTG_WRITE_4(sc, DOTG_DCTL, temp);
 
 	/* need to fake resume IRQ */
 	dwc_otg_resume_irq(sc);
@@ -366,10 +367,10 @@
 
 	DPRINTFN(5, "addr=%d\n", addr);
 
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DCFG);
-	temp &= ~DWC_OTG_MSK_DCFG_SET_DEV_ADDR(0x7F);
-	temp |= DWC_OTG_MSK_DCFG_SET_DEV_ADDR(addr);
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCFG, temp);
+	temp = DWC_OTG_READ_4(sc, DOTG_DCFG);
+	temp &= ~DCFG_DEVADDR_SET(0x7F);
+	temp |= DCFG_DEVADDR_SET(addr);
+	DWC_OTG_WRITE_4(sc, DOTG_DCFG, temp);
 }
 
 static void
@@ -378,8 +379,8 @@
 	DPRINTFN(5, "RX status clear\n");
 
 	/* enable RX FIFO level interrupt */
-	sc->sc_irq_mask |= DWC_OTG_MSK_GINT_RXFLVL;
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GINTMSK, sc->sc_irq_mask);
+	sc->sc_irq_mask |= GINTSTS_RXFLVL;
+	DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask);
 
 	/* clear cached status */
 	sc->sc_last_rx_status = 0;
@@ -401,18 +402,18 @@
 	if (sc->sc_last_rx_status == 0)
 		goto not_complete;
 
-	if (DWC_OTG_MSK_GRXSTS_GET_CHANNEL(sc->sc_last_rx_status) != 0)
+	if (GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status) != 0)
 		goto not_complete;
 
-	if ((sc->sc_last_rx_status & DWC_OTG_MSK_GRXSTS_PID) !=
-	    DWC_OTG_MSK_GRXSTS_PID_DATA0) {
+	if ((sc->sc_last_rx_status & GRXSTSRD_DPID_MASK) !=
+	    GRXSTSRD_DPID_DATA0) {
 		/* release FIFO */
 		dwc_otg_common_rx_ack(sc);
 		goto not_complete;
 	}
 
-	if ((sc->sc_last_rx_status & DWC_OTG_MSK_GRXSTS_PACKET_STS) !=
-	    DWC_OTG_MSK_GRXSTS_DEV_STP_DATA) {
+	if ((sc->sc_last_rx_status & GRXSTSRD_PKTSTS_MASK) !=
+	    GRXSTSRD_STP_DATA) {
 		/* release FIFO */
 		dwc_otg_common_rx_ack(sc);
 		goto not_complete;
@@ -424,7 +425,7 @@
 	td->did_stall = 0;
 
 	/* get the packet byte count */
-	count = DWC_OTG_MSK_GRXSTS_GET_BYTE_CNT(sc->sc_last_rx_status);
+	count = GRXSTSRD_BCNT_GET(sc->sc_last_rx_status);
 
 	/* verify data length */
 	if (count != td->remainder) {
@@ -459,22 +460,22 @@
 	}
 
 	/* don't send any data by default */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPTSIZ(0),
-	    DWC_OTG_MSK_DXEPTSIZ_SET_NPKT(0) | 
-	    DWC_OTG_MSK_DXEPTSIZ_SET_NBYTES(0));
+	DWC_OTG_WRITE_4(sc, DOTG_DIEPTSIZ(0),
+	    DXEPTSIZ_SET_NPKT(0) | 
+	    DXEPTSIZ_SET_NBYTES(0));
 
 	temp = sc->sc_in_ctl[0];
 
 	/* enable IN endpoint */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPCTL(0),
-	    temp | DWC_OTG_MSK_DIEPCTL_ENABLE);
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPCTL(0),
-	    temp | DWC_OTG_MSK_DIEPCTL_SET_NAK);
+	DWC_OTG_WRITE_4(sc, DOTG_DIEPCTL(0),
+	    temp | DIEPCTL_EPENA);
+	DWC_OTG_WRITE_4(sc, DOTG_DIEPCTL(0),
+	    temp | DIEPCTL_SNAK);
 
 	/* reset IN endpoint buffer */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GRSTCTL,
-	    DWC_OTG_MSK_GRSTCTL_TXFIFO(0) |
-	    DWC_OTG_MSK_GRSTCTL_TXFFLUSH);
+	DWC_OTG_WRITE_4(sc, DOTG_GRSTCTL,
+	    GRSTCTL_TXFIFO(0) |
+	    GRSTCTL_TXFFLSH);
 
 	/* acknowledge RX status */
 	dwc_otg_common_rx_ack(sc);
@@ -485,11 +486,11 @@
 
 	temp = sc->sc_out_ctl[0];
 
-	temp |= DWC_OTG_MSK_DOEPCTL_ENABLE |
-	    DWC_OTG_MSK_DOEPCTL_SET_NAK;
+	temp |= DOEPCTL_EPENA |
+	    DOEPCTL_SNAK;
 
 	/* enable OUT endpoint */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPCTL(0), temp);
+	DWC_OTG_WRITE_4(sc, DOTG_DOEPCTL(0), temp);
 
 	if (!td->did_stall) {
 		td->did_stall = 1;
@@ -497,21 +498,21 @@
 		DPRINTFN(5, "stalling IN and OUT direction\n");
 
 		/* set stall after enabling endpoint */
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPCTL(0),
-		    temp | DWC_OTG_MSK_DOEPCTL_STALL);
+		DWC_OTG_WRITE_4(sc, DOTG_DOEPCTL(0),
+		    temp | DOEPCTL_STALL);
 
 		temp = sc->sc_in_ctl[0];
 
 		/* set stall assuming endpoint is enabled */
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPCTL(0),
-		    temp | DWC_OTG_MSK_DIEPCTL_STALL);
+		DWC_OTG_WRITE_4(sc, DOTG_DIEPCTL(0),
+		    temp | DIEPCTL_STALL);
 	}
 
 	/* setup number of buffers to receive */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPTSIZ(0),
-	    DWC_OTG_MSK_DXEPTSIZ_SET_MULTI(3) |
-	    DWC_OTG_MSK_DXEPTSIZ_SET_NPKT(1) | 
-	    DWC_OTG_MSK_DXEPTSIZ_SET_NBYTES(sizeof(req)));
+	DWC_OTG_WRITE_4(sc, DOTG_DOEPTSIZ(0),
+	    DXEPTSIZ_SET_MULTI(3) |
+	    DXEPTSIZ_SET_NPKT(1) | 
+	    DXEPTSIZ_SET_NBYTES(sizeof(req)));
 
 	return (1);			/* not complete */
 }
@@ -533,12 +534,12 @@
 	if (sc->sc_last_rx_status == 0)
 		goto not_complete;
 
-	if (DWC_OTG_MSK_GRXSTS_GET_CHANNEL(sc->sc_last_rx_status) != td->ep_no)
+	if (GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status) != td->ep_no)
 		goto not_complete;
 
 	/* check for SETUP packet */
-	if ((sc->sc_last_rx_status & DWC_OTG_MSK_GRXSTS_PACKET_STS) ==
-	    DWC_OTG_MSK_GRXSTS_DEV_STP_DATA) {
+	if ((sc->sc_last_rx_status & GRXSTSRD_PKTSTS_MASK) ==
+	    GRXSTSRD_STP_DATA) {
 		if (td->remainder == 0) {
 			/*
 			 * We are actually complete and have
@@ -554,15 +555,15 @@
 		return (0);		/* complete */
 	}
 
-	if ((sc->sc_last_rx_status & DWC_OTG_MSK_GRXSTS_PACKET_STS) !=
-	    DWC_OTG_MSK_GRXSTS_DEV_OUT_DATA) {
+	if ((sc->sc_last_rx_status & GRXSTSRD_PKTSTS_MASK) !=
+	    GRXSTSRD_OUT_DATA) {
 		/* release FIFO */
 		dwc_otg_common_rx_ack(sc);
 		goto not_complete;
 	}
 
 	/* get the packet byte count */
-	count = DWC_OTG_MSK_GRXSTS_GET_BYTE_CNT(sc->sc_last_rx_status);
+	count = GRXSTSRD_BCNT_GET(sc->sc_last_rx_status);
 
 	/* verify the packet byte count */
 	if (count != td->max_packet_size) {
@@ -609,22 +610,22 @@
 
 	temp = sc->sc_out_ctl[td->ep_no];
 
-	temp |= DWC_OTG_MSK_DOEPCTL_ENABLE |
-	    DWC_OTG_MSK_DOEPCTL_CLR_NAK;
-
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPCTL(td->ep_no), temp);
+	temp |= DOEPCTL_EPENA |
+	    DOEPCTL_CNAK;
+
+	DWC_OTG_WRITE_4(sc, DOTG_DOEPCTL(td->ep_no), temp);
 
 	/* enable SETUP and transfer complete interrupt */
 	if (td->ep_no == 0) {
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPTSIZ(0),
-		    DWC_OTG_MSK_DXEPTSIZ_SET_NPKT(1) | 
-		    DWC_OTG_MSK_DXEPTSIZ_SET_NBYTES(td->max_packet_size));
+		DWC_OTG_WRITE_4(sc, DOTG_DOEPTSIZ(0),
+		    DXEPTSIZ_SET_NPKT(1) | 
+		    DXEPTSIZ_SET_NBYTES(td->max_packet_size));
 	} else {
 		/* allow reception of multiple packets */
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPTSIZ(td->ep_no),
-		    DWC_OTG_MSK_DXEPTSIZ_SET_MULTI(1) |
-		    DWC_OTG_MSK_DXEPTSIZ_SET_NPKT(4) | 
-		    DWC_OTG_MSK_DXEPTSIZ_SET_NBYTES(4 *
+		DWC_OTG_WRITE_4(sc, DOTG_DOEPTSIZ(td->ep_no),
+		    DXEPTSIZ_SET_MULTI(1) |
+		    DXEPTSIZ_SET_NPKT(4) | 
+		    DXEPTSIZ_SET_NBYTES(4 *
 		    ((td->max_packet_size + 3) & ~3)));
 	}
 	return (1);			/* not complete */
@@ -654,10 +655,10 @@
 	temp = sc->sc_last_rx_status;
 
 	if ((td->ep_no == 0) && (temp != 0) &&
-	    (DWC_OTG_MSK_GRXSTS_GET_CHANNEL(temp) == 0)) {
-
-		if ((temp & DWC_OTG_MSK_GRXSTS_PACKET_STS) !=
-		    DWC_OTG_MSK_GRXSTS_DEV_STP_DATA) {
+	    (GRXSTSRD_CHNUM_GET(temp) == 0)) {
+
+		if ((temp & GRXSTSRD_PKTSTS_MASK) !=
+		    GRXSTSRD_STP_DATA) {
 
 			/* dump data - wrong direction */
 			dwc_otg_common_rx_ack(sc);
@@ -677,10 +678,10 @@
 		uint16_t cpkt;
 
 		/* check if packets have been transferred */
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DIEPTSIZ(td->ep_no));
+		temp = DWC_OTG_READ_4(sc, DOTG_DIEPTSIZ(td->ep_no));
 
 		/* get current packet number */
-		cpkt = DWC_OTG_MSK_DXEPTSIZ_GET_NPKT(temp);
+		cpkt = DXEPTSIZ_GET_NPKT(temp);
 
 		if (cpkt >= td->npkt) {
 			fifo_left = 0;
@@ -711,7 +712,7 @@
 
 			/* transfer data into FIFO */
 			bus_space_write_region_4(sc->sc_io_tag, sc->sc_io_hdl,
-			    DWC_OTG_REG_DFIFO(td->ep_no),
+			    DOTG_DFIFO(td->ep_no),
 			    sc->sc_tx_bounce_buffer, (count + 3) / 4);
 
 			td->tx_bytes -= count;
@@ -735,14 +736,14 @@
 		goto not_complete;
 
 	/* check if not all packets have been transferred */
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DIEPTSIZ(td->ep_no));
-
-	if (DWC_OTG_MSK_DXEPTSIZ_GET_NPKT(temp) != 0) {
+	temp = DWC_OTG_READ_4(sc, DOTG_DIEPTSIZ(td->ep_no));
+
+	if (DXEPTSIZ_GET_NPKT(temp) != 0) {
 
 		DPRINTFN(5, "busy ep=%d npkt=%d DIEPTSIZ=0x%08x "
 		    "DIEPCTL=0x%08x\n", td->ep_no,
-		    DWC_OTG_MSK_DXEPTSIZ_GET_NPKT(temp),
-		    temp, DWC_OTG_READ_4(sc, DWC_OTG_REG_DIEPCTL(td->ep_no)));
+		    DXEPTSIZ_GET_NPKT(temp),
+		    temp, DWC_OTG_READ_4(sc, DOTG_DIEPCTL(td->ep_no)));
 
 		goto not_complete;
 	}
@@ -791,10 +792,10 @@
 		}
 		td->npkt = 1;
 	}
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPTSIZ(td->ep_no),
-	    DWC_OTG_MSK_DXEPTSIZ_SET_MULTI(1) |
-	    DWC_OTG_MSK_DXEPTSIZ_SET_NPKT(td->npkt) | 
-	    DWC_OTG_MSK_DXEPTSIZ_SET_NBYTES(count));
+	DWC_OTG_WRITE_4(sc, DOTG_DIEPTSIZ(td->ep_no),
+	    DXEPTSIZ_SET_MULTI(1) |
+	    DXEPTSIZ_SET_NPKT(td->npkt) | 
+	    DXEPTSIZ_SET_NBYTES(count));
 
 	/* make room for buffering */
 	td->npkt += mpkt;
@@ -802,9 +803,9 @@
 	temp = sc->sc_in_ctl[td->ep_no];
 
 	/* must enable before writing data to FIFO */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPCTL(td->ep_no), temp |
-	    DWC_OTG_MSK_DIEPCTL_ENABLE |
-	    DWC_OTG_MSK_DIEPCTL_CLR_NAK);
+	DWC_OTG_WRITE_4(sc, DOTG_DIEPCTL(td->ep_no), temp |
+	    DIEPCTL_EPENA |
+	    DIEPCTL_CNAK);
 
 	td->tx_bytes = count;
 
@@ -834,10 +835,10 @@
 	/*
 	 * If all packets are transferred we are complete:
 	 */
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DIEPTSIZ(td->ep_no));
+	temp = DWC_OTG_READ_4(sc, DOTG_DIEPTSIZ(td->ep_no));
 
 	/* check that all packets have been transferred */
-	if (DWC_OTG_MSK_DXEPTSIZ_GET_NPKT(temp) != 0) {
+	if (DXEPTSIZ_GET_NPKT(temp) != 0) {
 		DPRINTFN(5, "busy ep=%d\n", td->ep_no);
 		goto not_complete;
 	}
@@ -850,10 +851,10 @@
 	temp = sc->sc_last_rx_status;
 
 	if ((td->ep_no == 0) && (temp != 0) &&
-	    (DWC_OTG_MSK_GRXSTS_GET_CHANNEL(temp) == 0)) {
-
-		if ((temp & DWC_OTG_MSK_GRXSTS_PACKET_STS) ==
-		    DWC_OTG_MSK_GRXSTS_DEV_STP_DATA) {
+	    (GRXSTSRD_CHNUM_GET(temp) == 0)) {
+
+		if ((temp & GRXSTSRD_PKTSTS_MASK) ==
+		    GRXSTSRD_STP_DATA) {
 			DPRINTFN(5, "faking complete\n");
 			/*
 			 * Race condition: We are complete!
@@ -920,36 +921,36 @@
 repeat:
 	if (sc->sc_last_rx_status == 0) {
 
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GINTSTS);
-		if (temp & DWC_OTG_MSK_GINT_RXFLVL) {
+		temp = DWC_OTG_READ_4(sc, DOTG_GINTSTS);
+		if (temp & GINTSTS_RXFLVL) {
 			/* pop current status */
 			sc->sc_last_rx_status =
-			    DWC_OTG_READ_4(sc, DWC_OTG_REG_GRXSTSP);
+			    DWC_OTG_READ_4(sc, DOTG_GRXSTSPD);
 		}
 
 		if (sc->sc_last_rx_status != 0) {
 
 			uint8_t ep_no;
 
-			temp = DWC_OTG_MSK_GRXSTS_GET_BYTE_CNT(
+			temp = GRXSTSRD_BCNT_GET(
 			    sc->sc_last_rx_status);
-			ep_no = DWC_OTG_MSK_GRXSTS_GET_CHANNEL(
+			ep_no = GRXSTSRD_CHNUM_GET(
 			    sc->sc_last_rx_status);
 
 			/* receive data, if any */
 			if (temp != 0) {
 				DPRINTF("Reading %d bytes from ep %d\n", temp, ep_no);
 				bus_space_read_region_4(sc->sc_io_tag, sc->sc_io_hdl,
-				    DWC_OTG_REG_DFIFO(ep_no),
+				    DOTG_DFIFO(ep_no),
 				    sc->sc_rx_bounce_buffer, (temp + 3) / 4);
 			}
 
 			temp = sc->sc_last_rx_status &
-			    DWC_OTG_MSK_GRXSTS_PACKET_STS;
+			    GRXSTSRD_PKTSTS_MASK;
 
 			/* non-data messages we simply skip */
-			if (temp != DWC_OTG_MSK_GRXSTS_DEV_STP_DATA &&
-			    temp != DWC_OTG_MSK_GRXSTS_DEV_OUT_DATA) {
+			if (temp != GRXSTSRD_STP_DATA &&
+			    temp != GRXSTSRD_OUT_DATA) {
 				dwc_otg_common_rx_ack(sc);
 				goto repeat;
 			}
@@ -965,7 +966,7 @@
 			DPRINTFN(5, "RX status = 0x%08x: ch=%d pid=%d bytes=%d sts=%d\n",
 			    sc->sc_last_rx_status, ep_no,
 			    (sc->sc_last_rx_status >> 15) & 3,
-			    DWC_OTG_MSK_GRXSTS_GET_BYTE_CNT(sc->sc_last_rx_status),
+			    GRXSTSRD_BCNT_GET(sc->sc_last_rx_status),
 			    (sc->sc_last_rx_status >> 17) & 15);
 		} else {
 			got_rx_status = 0;
@@ -973,7 +974,7 @@
 	} else {
 		uint8_t ep_no;
 
-		ep_no = DWC_OTG_MSK_GRXSTS_GET_CHANNEL(
+		ep_no = GRXSTSRD_CHNUM_GET(
 		    sc->sc_last_rx_status);
 
 		/* check if we should dump the data */
@@ -997,8 +998,8 @@
 			goto repeat;
 
 		/* disable RX FIFO level interrupt */
-		sc->sc_irq_mask &= ~DWC_OTG_MSK_GINT_RXFLVL;
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GINTMSK, sc->sc_irq_mask);
+		sc->sc_irq_mask &= ~GINTSTS_RXFLVL;
+		DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask);
 	}
 }
 
@@ -1038,12 +1039,12 @@
 	USB_BUS_LOCK(&sc->sc_bus);
 
 	/* read and clear interrupt status */
-	status = DWC_OTG_READ_4(sc, DWC_OTG_REG_GINTSTS);
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GINTSTS, status);
+	status = DWC_OTG_READ_4(sc, DOTG_GINTSTS);
+	DWC_OTG_WRITE_4(sc, DOTG_GINTSTS, status);
 
 	DPRINTFN(14, "GINTSTS=0x%08x\n", status);
 
-	if (status & DWC_OTG_MSK_GINT_USB_RESET) {
+	if (status & GINTSTS_USBRST) {
 
 		/* set correct state */
 		sc->sc_flags.status_bus_reset = 0;
@@ -1056,7 +1057,7 @@
 	}
 
 	/* check for any bus state change interrupts */
-	if (status & DWC_OTG_MSK_GINT_ENUM_DONE) {
+	if (status & GINTSTS_ENUMDONE) {
 
 		uint32_t temp;
 
@@ -1078,18 +1079,18 @@
 		sc->sc_active_out_ep = 1;
 
 		/* figure out enumeration speed */
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DSTS);
-		if (DWC_OTG_MSK_DSTS_GET_ENUM_SPEED(temp) ==
-		    DWC_OTG_MSK_DSTS_ENUM_SPEED_HI)
+		temp = DWC_OTG_READ_4(sc, DOTG_DSTS);
+		if (DSTS_ENUMSPD_GET(temp) ==
+		    DSTS_ENUMSPD_HI)
 			sc->sc_flags.status_high_speed = 1;
 		else
 			sc->sc_flags.status_high_speed = 0;
 
 		/* disable resume interrupt and enable suspend interrupt */
 		
-		sc->sc_irq_mask &= ~DWC_OTG_MSK_GINT_WKUPINT;
-		sc->sc_irq_mask |= DWC_OTG_MSK_GINT_USB_SUSPEND;
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GINTMSK, sc->sc_irq_mask);
+		sc->sc_irq_mask &= ~GINTSTS_WKUPINT;
+		sc->sc_irq_mask |= GINTSTS_USBSUSP;
+		DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask);
 
 		/* complete root HUB interrupt endpoint */
 		dwc_otg_root_intr(sc);
@@ -1099,13 +1100,13 @@
 	 * that like RESUME. Resume is set when there is at least 3
 	 * milliseconds of inactivity on the USB BUS.
 	 */
-	if (status & DWC_OTG_MSK_GINT_WKUPINT) {
+	if (status & GINTSTS_WKUPINT) {
 
 		DPRINTFN(5, "resume interrupt\n");
 
 		dwc_otg_resume_irq(sc);
 
-	} else if (status & DWC_OTG_MSK_GINT_USB_SUSPEND) {
+	} else if (status & GINTSTS_USBSUSP) {
 
 		DPRINTFN(5, "suspend interrupt\n");
 
@@ -1118,45 +1119,45 @@
 			 * Disable suspend interrupt and enable resume
 			 * interrupt:
 			 */
-			sc->sc_irq_mask &= ~DWC_OTG_MSK_GINT_USB_SUSPEND;
-			sc->sc_irq_mask |= DWC_OTG_MSK_GINT_WKUPINT;
-			DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GINTMSK, sc->sc_irq_mask);
+			sc->sc_irq_mask &= ~GINTSTS_USBSUSP;
+			sc->sc_irq_mask |= GINTSTS_WKUPINT;
+			DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask);
 
 			/* complete root HUB interrupt endpoint */
 			dwc_otg_root_intr(sc);
 		}
 	}
 	/* check VBUS */
-	if (status & (DWC_OTG_MSK_GINT_USB_SUSPEND |
-	    DWC_OTG_MSK_GINT_USB_RESET |
-	    DWC_OTG_MSK_GINT_SESSREQINT)) {
+	if (status & (GINTSTS_USBSUSP |
+	    GINTSTS_USBRST |
+	    GINTSTS_SESSREQINT)) {
 		uint32_t temp;
 
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GOTGCTL);
+		temp = DWC_OTG_READ_4(sc, DOTG_GOTGCTL);
 
 		DPRINTFN(5, "GOTGCTL=0x%08x\n", temp);
 
 		dwc_otg_vbus_interrupt(sc,
-		    (temp & DWC_OTG_MSK_GOTGCTL_BSESS_VALID) ? 1 : 0);
+		    (temp & GOTGCTL_BSESVLD) ? 1 : 0);
 	}
 
 	/* clear all IN endpoint interrupts */
-	if (status & DWC_OTG_MSK_GINT_INEP) {
+	if (status & GINTSTS_IEPINT) {
 		uint32_t temp;
 		uint8_t x;
 
 		for (x = 0; x != sc->sc_dev_in_ep_max; x++) {
-			temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DIEPINT(x));
-			if (temp & DWC_OTG_MSK_DIEP_XFER_COMPLETE) {
-				DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPINT(x),
-				    DWC_OTG_MSK_DIEP_XFER_COMPLETE);
+			temp = DWC_OTG_READ_4(sc, DOTG_DIEPINT(x));
+			if (temp & DIEPMSK_XFERCOMPLMSK) {
+				DWC_OTG_WRITE_4(sc, DOTG_DIEPINT(x),
+				    DIEPMSK_XFERCOMPLMSK);
 			}
 		}
 	}
 
 #if 0
 	/* check if we should poll the FIFOs */
-	if (status & (DWC_OTG_MSK_GINT_RXFLVL | DWC_OTG_MSK_GINT_INEP))
+	if (status & (GINTSTS_RXFLVL | GINTSTS_IEPINT))
 #endif
 		/* poll FIFO(s) */
 		dwc_otg_interrupt_poll(sc);
@@ -1548,16 +1549,16 @@
 	DPRINTFN(5, "endpoint=0x%x\n", ep_no);
 
 	if (ep_no & UE_DIR_IN) {
-		reg = DWC_OTG_REG_DIEPCTL(ep_no & UE_ADDR);
+		reg = DOTG_DIEPCTL(ep_no & UE_ADDR);
 		temp = sc->sc_in_ctl[ep_no & UE_ADDR];
 	} else {
-		reg = DWC_OTG_REG_DOEPCTL(ep_no & UE_ADDR);
+		reg = DOTG_DOEPCTL(ep_no & UE_ADDR);
 		temp = sc->sc_out_ctl[ep_no & UE_ADDR];
 	}
 
 	/* disable and stall endpoint */
-	DWC_OTG_WRITE_4(sc, reg, temp | DWC_OTG_MSK_DOEPCTL_DISABLE);
-	DWC_OTG_WRITE_4(sc, reg, temp | DWC_OTG_MSK_DOEPCTL_STALL);
+	DWC_OTG_WRITE_4(sc, reg, temp | DOEPCTL_EPDIS);
+	DWC_OTG_WRITE_4(sc, reg, temp | DOEPCTL_STALL);
 
 	/* clear active OUT ep */
 	if (!(ep_no & UE_DIR_IN)) {
@@ -1565,7 +1566,7 @@
 		sc->sc_active_out_ep &= ~(1U << (ep_no & UE_ADDR));
 
 		if (sc->sc_last_rx_status != 0 &&
-		    (ep_no & UE_ADDR) == DWC_OTG_MSK_GRXSTS_GET_CHANNEL(
+		    (ep_no & UE_ADDR) == GRXSTSRD_CHNUM_GET(
 		    sc->sc_last_rx_status)) {
 			/* dump data */
 			dwc_otg_common_rx_ack(sc);
@@ -1588,9 +1589,9 @@
 	}
 
 	if (ep_dir) {
-		reg = DWC_OTG_REG_DIEPCTL(ep_no);
+		reg = DOTG_DIEPCTL(ep_no);
 	} else {
-		reg = DWC_OTG_REG_DOEPCTL(ep_no);
+		reg = DOTG_DOEPCTL(ep_no);
 		sc->sc_active_out_ep |= (1U << ep_no);
 	}
 
@@ -1598,39 +1599,39 @@
 	mps = (mps + 3) & 0x7FC;
 
 	if (ep_type == UE_BULK) {
-		temp = DWC_OTG_MSK_EP_SET_TYPE(
-		    DWC_OTG_MSK_EP_TYPE_BULK) |
-		    DWC_OTG_MSK_DIEPCTL_USB_AEP;
+		temp = DIEPCTL_EPTYPE_SET(
+		    DIEPCTL_EPTYPE_BULK) |
+		    DIEPCTL_USBACTEP;
 	} else if (ep_type == UE_INTERRUPT) {
-		temp = DWC_OTG_MSK_EP_SET_TYPE(
-		    DWC_OTG_MSK_EP_TYPE_INTERRUPT) |
-		    DWC_OTG_MSK_DIEPCTL_USB_AEP;
+		temp = DIEPCTL_EPTYPE_SET(
+		    DIEPCTL_EPTYPE_INTERRUPT) |
+		    DIEPCTL_USBACTEP;
 	} else {
-		temp = DWC_OTG_MSK_EP_SET_TYPE(
-		    DWC_OTG_MSK_EP_TYPE_ISOC) |
-		    DWC_OTG_MSK_DIEPCTL_USB_AEP;
+		temp = DIEPCTL_EPTYPE_SET(
+		    DIEPCTL_EPTYPE_ISOC) |
+		    DIEPCTL_USBACTEP;
 	}
 
-	temp |= DWC_OTG_MSK_DIEPCTL_MPS(mps);
-	temp |= DWC_OTG_MSK_DIEPCTL_FNUM(ep_no);
+	temp |= DIEPCTL_MPS_SET(mps);
+	temp |= DIEPCTL_TXFNUM_SET(ep_no);
 
 	if (ep_dir)
 		sc->sc_in_ctl[ep_no] = temp;
 	else
 		sc->sc_out_ctl[ep_no] = temp;
 
-	DWC_OTG_WRITE_4(sc, reg, temp | DWC_OTG_MSK_DOEPCTL_DISABLE);
-	DWC_OTG_WRITE_4(sc, reg, temp | DWC_OTG_MSK_DOEPCTL_SET_DATA0);
-	DWC_OTG_WRITE_4(sc, reg, temp | DWC_OTG_MSK_DIEPCTL_SET_NAK);
+	DWC_OTG_WRITE_4(sc, reg, temp | DOEPCTL_EPDIS);
+	DWC_OTG_WRITE_4(sc, reg, temp | DOEPCTL_SETD0PID);
+	DWC_OTG_WRITE_4(sc, reg, temp | DIEPCTL_SNAK);
 
 	/* we only reset the transmit FIFO */
 	if (ep_dir) {
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GRSTCTL,
-		    DWC_OTG_MSK_GRSTCTL_TXFIFO(ep_no) |
-		    DWC_OTG_MSK_GRSTCTL_TXFFLUSH);
+		DWC_OTG_WRITE_4(sc, DOTG_GRSTCTL,
+		    GRSTCTL_TXFIFO(ep_no) |
+		    GRSTCTL_TXFFLSH);
 
 		DWC_OTG_WRITE_4(sc,
-		    DWC_OTG_REG_DIEPTSIZ(ep_no), 0);
+		    DOTG_DIEPTSIZ(ep_no), 0);
 	}
 
 	/* poll interrupt */
@@ -1684,14 +1685,14 @@
 		for (x = 1; x != sc->sc_dev_ep_max; x++) {
 
 			if (x < sc->sc_dev_in_ep_max) {
-				DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPCTL(x),
-				    DWC_OTG_MSK_DIEPCTL_DISABLE);
-				DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPCTL(x), 0);
+				DWC_OTG_WRITE_4(sc, DOTG_DIEPCTL(x),
+				    DIEPCTL_EPDIS);
+				DWC_OTG_WRITE_4(sc, DOTG_DIEPCTL(x), 0);
 			}
 
-			DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPCTL(x),
-			    DWC_OTG_MSK_DOEPCTL_DISABLE);
-			DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPCTL(x), 0);
+			DWC_OTG_WRITE_4(sc, DOTG_DOEPCTL(x),
+			    DOEPCTL_EPDIS);
+			DWC_OTG_WRITE_4(sc, DOTG_DOEPCTL(x), 0);
 		}
 		USB_BUS_UNLOCK(&sc->sc_bus);
 	}
@@ -1716,68 +1717,68 @@
 	/* turn on clocks */
 	dwc_otg_clocks_on(sc);
 
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GSNPSID);
+	temp = DWC_OTG_READ_4(sc, DOTG_GSNPSID);
 	DPRINTF("Version = 0x%08x\n", temp);
 
 	/* disconnect */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCTL,
-	    DWC_OTG_MSK_DCTL_SOFT_DISC);
+	DWC_OTG_WRITE_4(sc, DOTG_DCTL,
+	    DCTL_SFTDISCON);
 
 	/* wait for host to detect disconnect */
 	usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 32);
 
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GRSTCTL,
-	    DWC_OTG_MSK_GRSTCTL_CSFTRST);
+	DWC_OTG_WRITE_4(sc, DOTG_GRSTCTL,
+	    GRSTCTL_CSFTRST);
 
 	/* wait a little bit for block to reset */
 	usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 128);
 
 	/* select HSIC or non-HSIC mode */
 	if (DWC_OTG_USE_HSIC) {
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GUSBCFG,
-		    DWC_OTG_MSK_GUSBCFG_PHY_INTF |
-		    DWC_OTG_MSK_GUSBCFG_TRD_TIM(5));
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GOTGCTL,
+		DWC_OTG_WRITE_4(sc, DOTG_GUSBCFG,
+		    GUSBCFG_PHYIF |
+		    GUSBCFG_TRD_TIM_SET(5));
+		DWC_OTG_WRITE_4(sc, DOTG_GOTGCTL,
 		    0x000000EC);
 
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GLPMCFG);
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GLPMCFG,
-		    temp & ~DWC_OTG_MSK_GLPMCFG_HSIC_CONN);
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GLPMCFG,
-		    temp | DWC_OTG_MSK_GLPMCFG_HSIC_CONN);
+		temp = DWC_OTG_READ_4(sc, DOTG_GLPMCFG);
+		DWC_OTG_WRITE_4(sc, DOTG_GLPMCFG,
+		    temp & ~GLPMCFG_HSIC_CONN);
+		DWC_OTG_WRITE_4(sc, DOTG_GLPMCFG,
+		    temp | GLPMCFG_HSIC_CONN);
 	} else {
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GUSBCFG,
-		    DWC_OTG_MSK_GUSBCFG_ULPI_UMTI_SEL |
-		    DWC_OTG_MSK_GUSBCFG_TRD_TIM(5));
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GOTGCTL, 0);
-
-		temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GLPMCFG);
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GLPMCFG,
-		    temp & ~DWC_OTG_MSK_GLPMCFG_HSIC_CONN);
+		DWC_OTG_WRITE_4(sc, DOTG_GUSBCFG,
+		    GUSBCFG_ULPI_UTMI_SEL |
+		    GUSBCFG_TRD_TIM_SET(5));
+		DWC_OTG_WRITE_4(sc, DOTG_GOTGCTL, 0);
+
+		temp = DWC_OTG_READ_4(sc, DOTG_GLPMCFG);
+		DWC_OTG_WRITE_4(sc, DOTG_GLPMCFG,
+		    temp & ~GLPMCFG_HSIC_CONN);
 	}
 
 	/* clear global nak */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCTL,
-	    DWC_OTG_MSK_DCTL_CGOUT_NAK |
-	    DWC_OTG_MSK_DCTL_CGNPIN_NAK);
+	DWC_OTG_WRITE_4(sc, DOTG_DCTL,
+	    DCTL_CGOUTNAK |
+	    DCTL_CGNPINNAK);
 
 	/* enable USB port */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_PCGCCTL, 0);
+	DWC_OTG_WRITE_4(sc, DOTG_PCGCCTL, 0);
 
 	/* pull up D+ */
 	dwc_otg_pull_up(sc);
 
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GHWCFG3);
-
-	sc->sc_fifo_size = 4 * DWC_OTG_MSK_GHWCFG3_GET_DFIFO(temp);
-
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GHWCFG2);
-
-	sc->sc_dev_ep_max = DWC_OTG_MSK_GHWCFG2_NUM_DEV_EP(temp);
-
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GHWCFG4);
-
-	sc->sc_dev_in_ep_max = DWC_OTG_MSK_GHWCFG4_NUM_IN_EPS(temp);
+	temp = DWC_OTG_READ_4(sc, DOTG_GHWCFG3);
+
+	sc->sc_fifo_size = 4 * GHWCFG3_DFIFODEPTH_GET(temp);
+
+	temp = DWC_OTG_READ_4(sc, DOTG_GHWCFG2);
+
+	sc->sc_dev_ep_max = GHWCFG2_NUMDEVEPS_GET(temp);
+
+	temp = DWC_OTG_READ_4(sc, DOTG_GHWCFG4);
+
+	sc->sc_dev_in_ep_max = GHWCFG4_NUM_IN_EP_GET(temp);
 
 	DPRINTF("Total FIFO size = %d bytes, Device EPs = %d/%d\n",
 	    sc->sc_fifo_size, sc->sc_dev_ep_max, sc->sc_dev_in_ep_max);
@@ -1788,43 +1789,43 @@
 
 	/* enable interrupts */
 	sc->sc_irq_mask = DWC_OTG_MSK_GINT_ENABLED;
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GINTMSK, sc->sc_irq_mask);
+	DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask);
 
 	/* enable all endpoint interrupts */
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GHWCFG2);
-	if (temp & DWC_OTG_MSK_GHWCFG2_MPI) {
+	temp = DWC_OTG_READ_4(sc, DOTG_GHWCFG2);
+	if (temp & GHWCFG2_MPI) {
 		uint8_t x;
 
 		DPRINTF("Multi Process Interrupts\n");
 
 		for (x = 0; x != sc->sc_dev_in_ep_max; x++) {
-			DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPEACHMSK(x),
-			    DWC_OTG_MSK_DIEP_XFER_COMPLETE);
-			DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPEACHMSK(x), 0);
+			DWC_OTG_WRITE_4(sc, DOTG_DIEPEACHINTMSK(x),
+			    DIEPMSK_XFERCOMPLMSK);
+			DWC_OTG_WRITE_4(sc, DOTG_DOEPEACHINTMSK(x), 0);
 		}
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DEACHINTMSK, 0xFFFF);
+		DWC_OTG_WRITE_4(sc, DOTG_DEACHINTMSK, 0xFFFF);
 	} else {
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DIEPMSK,
-		    DWC_OTG_MSK_DIEP_XFER_COMPLETE);
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DOEPMSK, 0);
-		DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DAINTMSK, 0xFFFF);
+		DWC_OTG_WRITE_4(sc, DOTG_DIEPMSK,
+		    DIEPMSK_XFERCOMPLMSK);
+		DWC_OTG_WRITE_4(sc, DOTG_DOEPMSK, 0);
+		DWC_OTG_WRITE_4(sc, DOTG_DAINTMSK, 0xFFFF);
 	}
 
 	/* enable global IRQ */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GAHBCFG,
-	    DWC_OTG_MSK_GAHBCFG_GLOBAL_IRQ);
+	DWC_OTG_WRITE_4(sc, DOTG_GAHBCFG,
+	    GAHBCFG_GLBLINTRMSK);
 
 	/* turn off clocks */
 	dwc_otg_clocks_off(sc);
 
 	/* read initial VBUS state */
 
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_GOTGCTL);
+	temp = DWC_OTG_READ_4(sc, DOTG_GOTGCTL);
 
 	DPRINTFN(5, "GOTCTL=0x%08x\n", temp);
 
 	dwc_otg_vbus_interrupt(sc,
-	    (temp & DWC_OTG_MSK_GOTGCTL_BSESS_VALID) ? 1 : 0);
+	    (temp & GOTGCTL_BSESVLD) ? 1 : 0);
 
 	USB_BUS_UNLOCK(&sc->sc_bus);
 
@@ -1841,11 +1842,11 @@
 	USB_BUS_LOCK(&sc->sc_bus);
 
 	/* set disconnect */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_DCTL,
-	    DWC_OTG_MSK_DCTL_SOFT_DISC);
+	DWC_OTG_WRITE_4(sc, DOTG_DCTL,
+	    DCTL_SFTDISCON);
 
 	/* turn off global IRQ */
-	DWC_OTG_WRITE_4(sc, DWC_OTG_REG_GAHBCFG, 0);
+	DWC_OTG_WRITE_4(sc, DOTG_GAHBCFG, 0);
 
 	sc->sc_flags.port_powered = 0;
 	sc->sc_flags.status_vbus = 0;
@@ -1946,11 +1947,11 @@
 	DPRINTFN(6, "xfer=%p next=%d nframes=%d\n",
 	    xfer, xfer->endpoint->isoc_next, xfer->nframes);
 
-	temp = DWC_OTG_READ_4(sc, DWC_OTG_REG_DSTS);
+	temp = DWC_OTG_READ_4(sc, DOTG_DSTS);
 
 	/* get the current frame index */
 
-	nframes = DWC_OTG_MSK_DSTS_GET_FNUM(temp);
+	nframes = DSTS_SOFFN_GET(temp);
 
 	if (sc->sc_flags.status_high_speed)
 		nframes /= 8;
diff -r 00e5fe011396 -r a6db8cab5676 head/sys/dev/usb/controller/dwc_otg.h
--- a/head/sys/dev/usb/controller/dwc_otg.h	Thu Aug 16 21:15:49 2012 +0300
+++ b/head/sys/dev/usb/controller/dwc_otg.h	Fri Aug 31 00:23:32 2012 +0300
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/dev/usb/controller/dwc_otg.h 232539 2012-03-05 06:41:44Z hselasky $ */
+/* $FreeBSD: head/sys/dev/usb/controller/dwc_otg.h 239909 2012-08-30 16:19:05Z hselasky $ */
 /*-
  * Copyright (c) 2012 Hans Petter Selasky. All rights reserved.
  *
@@ -32,290 +32,6 @@
 #define	DWC_OTG_MAX_TXP 4
 #define	DWC_OTG_MAX_TXN (0x200 * DWC_OTG_MAX_TXP)
 
-/* Global CSR registers */
-
-#define	DWC_OTG_REG_GOTGCTL		0x0000
-#define	DWC_OTG_MSK_GOTGCTL_CHIRP_ON		(1U << 27)
-#define	DWC_OTG_MSK_GOTGCTL_BSESS_VALID		(1U << 19)
-#define	DWC_OTG_MSK_GOTGCTL_ASESS_VALID		(1U << 18)
-#define	DWC_OTG_MSK_GOTGCTL_CONN_ID_STATUS	(1U << 16)
-#define	DWC_OTG_MSK_GOTGCTL_SESS_REQ		(1U << 1)
-#define	DWC_OTG_MSK_GOTGCTL_SESS_VALID		(1U << 0)
-
-#define	DWC_OTG_REG_GOTGINT		0x0004
-#define	DWC_OTG_REG_GAHBCFG		0x0008
-#define	DWC_OTG_MSK_GAHBCFG_GLOBAL_IRQ		(1U << 0)
-
-#define	DWC_OTG_REG_GUSBCFG		0x000C
-#define	DWC_OTG_MSK_GUSBCFG_FORCE_DEVICE	(1U << 30)
-#define	DWC_OTG_MSK_GUSBCFG_FORCE_HOST		(1U << 29)
-#define	DWC_OTG_MSK_GUSBCFG_NO_PULLUP		(1U << 27)
-#define	DWC_OTG_MSK_GUSBCFG_NO_PULLUP		(1U << 27)
-#define	DWC_OTG_MSK_GUSBCFG_IC_USB_CAP		(1U << 26)
-#define	DWC_OTG_MSK_GUSBCFG_ULPI_FS_LS		(1U << 17)
-#define	DWC_OTG_MSK_GUSBCFG_TRD_TIM(x)		(((x) & 15U) << 10)
-#define	DWC_OTG_MSK_GUSBCFG_HRP			(1U << 9)
-#define	DWC_OTG_MSK_GUSBCFG_SRP			(1U << 8)
-#define	DWC_OTG_MSK_GUSBCFG_HS_PHY		(1U << 6)
-#define	DWC_OTG_MSK_GUSBCFG_FS_INTF		(1U << 5)
-#define	DWC_OTG_MSK_GUSBCFG_ULPI_UMTI_SEL	(1U << 4)
-#define	DWC_OTG_MSK_GUSBCFG_PHY_INTF		(1U << 3)
-
-#define	DWC_OTG_REG_GRSTCTL		0x0010
-#define	DWC_OTG_MSK_GRSTCTL_TXFIFO(n)		(((n) & 31U) << 6)
-#define	DWC_OTG_MSK_GRSTCTL_TXFFLUSH		(1U << 5)
-#define	DWC_OTG_MSK_GRSTCTL_RXFFLUSH		(1U << 4)
-#define	DWC_OTG_MSK_GRSTCTL_FRMCNTRRST		(1U << 2)
-#define	DWC_OTG_MSK_GRSTCTL_CSFTRST		(1U << 0)
-
-#define	DWC_OTG_REG_GINTSTS		0x0014
-#define	DWC_OTG_REG_GINTMSK		0x0018
-#define	DWC_OTG_MSK_GINT_WKUPINT		(1U << 31)
-#define	DWC_OTG_MSK_GINT_SESSREQINT		(1U << 30)
-#define	DWC_OTG_MSK_GINT_DISCONNINT		(1U << 29)
-#define	DWC_OTG_MSK_GINT_CONNIDSTSCHNG		(1U << 28)
-#define	DWC_OTG_MSK_GINT_LPM			(1U << 27)
-#define	DWC_OTG_MSK_GINT_PTXFEMP		(1U << 26)
-#define	DWC_OTG_MSK_GINT_HCHINT			(1U << 25)
-#define	DWC_OTG_MSK_GINT_PRTINT			(1U << 24)
-#define	DWC_OTG_MSK_GINT_RESETDET		(1U << 23)
-#define	DWC_OTG_MSK_GINT_FETSUSP		(1U << 22)
-#define	DWC_OTG_MSK_GINT_INCOMPL_P		(1U << 21)
-#define	DWC_OTG_MSK_GINT_INCOMPL_ISO_IN		(1U << 20)
-#define	DWC_OTG_MSK_GINT_OUTEP			(1U << 19)
-#define	DWC_OTG_MSK_GINT_INEP			(1U << 18)
-#define	DWC_OTG_MSK_GINT_EP_MISMATCH		(1U << 17)
-#define	DWC_OTG_MSK_GINT_RESTORE_DONE		(1U << 16)
-#define	DWC_OTG_MSK_GINT_EOP_FRAME		(1U << 15)
-#define	DWC_OTG_MSK_GINT_ISO_OUT_DROP		(1U << 14)
-#define	DWC_OTG_MSK_GINT_ENUM_DONE		(1U << 13)
-#define	DWC_OTG_MSK_GINT_USB_RESET		(1U << 12)
-#define	DWC_OTG_MSK_GINT_USB_SUSPEND		(1U << 11)
-#define	DWC_OTG_MSK_GINT_EARLY_SUSPEND		(1U << 10)
-#define	DWC_OTG_MSK_GINT_I2C_INT		(1U << 9)
-#define	DWC_OTG_MSK_GINT_ULPI_CARKIT		(1U << 8)
-#define	DWC_OTG_MSK_GINT_GLOBAL_OUT_NAK		(1U << 7)
-#define	DWC_OTG_MSK_GINT_GLOBAL_IN_NAK		(1U << 6)
-#define	DWC_OTG_MSK_GINT_NPTXFEMP		(1U << 5)
-#define	DWC_OTG_MSK_GINT_RXFLVL			(1U << 4)
-#define	DWC_OTG_MSK_GINT_SOF			(1U << 3)
-#define	DWC_OTG_MSK_GINT_OTG			(1U << 2)
-#define	DWC_OTG_MSK_GINT_MODE_MISMATCH		(1U << 1)
-#define	DWC_OTG_MSK_GINT_CUR_MODE		(1U << 0)
-
-#define	DWC_OTG_REG_GRXSTSR		0x001C
-#define	DWC_OTG_REG_GRXSTSP		0x0020
-#define	DWC_OTG_MSK_GRXSTS_PACKET_STS		(15U << 17)
-#define	DWC_OTG_MSK_GRXSTS_HST_IN_DATA		(2U << 17)
-#define	DWC_OTG_MSK_GRXSTS_HST_IN_COMPLETE	(3U << 17)
-#define	DWC_OTG_MSK_GRXSTS_HST_DT_ERROR		(5U << 17)
-#define	DWC_OTG_MSK_GRXSTS_HST_HALTED		(7U << 17)
-#define	DWC_OTG_MSK_GRXSTS_DEV_GLOB_OUT_NAK	(1U << 17)
-#define	DWC_OTG_MSK_GRXSTS_DEV_OUT_DATA		(2U << 17)
-#define	DWC_OTG_MSK_GRXSTS_DEV_OUT_COMPLETE	(3U << 17)
-#define	DWC_OTG_MSK_GRXSTS_DEV_STP_COMPLETE	(4U << 17)
-#define	DWC_OTG_MSK_GRXSTS_DEV_STP_DATA		(6U << 17)
-#define	DWC_OTG_MSK_GRXSTS_PID			(3U << 15)
-#define	DWC_OTG_MSK_GRXSTS_PID_DATA0		(0U << 15)
-#define	DWC_OTG_MSK_GRXSTS_PID_DATA1		(2U << 15)
-#define	DWC_OTG_MSK_GRXSTS_PID_DATA2		(1U << 15)
-#define	DWC_OTG_MSK_GRXSTS_PID_MDATA		(3U << 15)
-#define	DWC_OTG_MSK_GRXSTS_GET_BYTE_CNT(x)	(((x) >> 4) & 0x7FFU)
-#define	DWC_OTG_MSK_GRXSTS_GET_CHANNEL(x)	((x) & 15U)
-#define	DWC_OTG_MSK_GRXSTS_GET_FRNUM	(x)	(((x) >> 21) & 15U)
-
-#define	DWC_OTG_REG_GRXFSIZ		0x0024
-#define	DWC_OTG_REG_GNPTXFSIZ		0x0028
-#define	DWC_OTG_REG_GNPTXSTS		0x002C
-#define	DWC_OTG_REG_GI2CCTL		0x0030
-#define	DWC_OTG_REG_GPVNDCTL		0x0034
-#define	DWC_OTG_REG_GGPIO		0x0038
-#define	DWC_OTG_REG_GUID		0x003C
-#define	DWC_OTG_REG_GSNPSID		0x0040
-#define	DWC_OTG_REG_GHWCFG1		0x0044
-#define	DWC_OTG_MSK_GHWCFG1_GET_DIR(x, n)	(((x) >> (2 * (n))) & 3U)
-#define	DWC_OTG_MSK_GHWCFG1_BIDIR		(0U)
-#define	DWC_OTG_MSK_GHWCFG1_IN			(1U)
-#define	DWC_OTG_MSK_GHWCFG1_OUT			(2U)
-#define	DWC_OTG_REG_GHWCFG2		0x0048
-#define	DWC_OTG_MSK_GHWCFG2_NUM_DEV_EP(x)	((((x) >> 10) & 15) + 1)
-#define	DWC_OTG_MSK_GHWCFG2_NUM_HOST_EP(x)	((((x) >> 14) & 15) + 1)
-#define	DWC_OTG_MSK_GHWCFG2_DYN_FIFO		(1U << 19)
-#define	DWC_OTG_MSK_GHWCFG2_MPI			(1U << 20)
-#define	DWC_OTG_REG_GHWCFG3		0x004C
-#define	DWC_OTG_MSK_GHWCFG3_GET_DFIFO(x)	((x) >> 16)
-#define	DWC_OTG_MSK_GHWCFG3_PKT_SIZE		(0x10U << (((x) >> 4) & 7))
-#define	DWC_OTG_MSK_GHWCFG3_XFR_SIZE		(0x400U << (((x) >> 0) & 15))
-
-#define	DWC_OTG_REG_GHWCFG4		0x0050
-#define	DWC_OTG_MSK_GHWCFG4_NUM_IN_EPS(x)	((((x) >> 26) & 15U) + 1U)
-#define	DWC_OTG_MSK_GHWCFG4_NUM_CTRL_EPS(x)	(((x) >> 16) & 15U)
-#define	DWC_OTG_MSK_GHWCFG4_NUM_IN_PERIODIC_EPS(x)	(((x) >> 0) & 15U)
-
-#define	DWC_OTG_REG_GLPMCFG		0x0054
-#define	DWC_OTG_MSK_GLPMCFG_HSIC_CONN		(1U << 30)
-#define	DWC_OTG_REG_GPWRDN		0x0058
-#define	DWC_OTG_MSK_GPWRDN_BVALID		(1U << 22)
-#define	DWC_OTG_MSK_GPWRDN_IDDIG		(1U << 21)
-#define	DWC_OTG_MSK_GPWRDN_CONNDET_INT		(1U << 14)
-#define	DWC_OTG_MSK_GPWRDN_CONNDET		(1U << 13)
-#define	DWC_OTG_MSK_GPWRDN_DISCONN_INT		(1U << 12)
-#define	DWC_OTG_MSK_GPWRDN_DISCONN		(1U << 11)
-#define	DWC_OTG_MSK_GPWRDN_RESETDET_INT		(1U << 10)
-#define	DWC_OTG_MSK_GPWRDN_RESETDET		(1U << 9)
-#define	DWC_OTG_MSK_GPWRDN_LINESTATE_INT	(1U << 8)
-#define	DWC_OTG_MSK_GPWRDN_LINESTATE		(1U << 7)
-#define	DWC_OTG_MSK_GPWRDN_DISABLE_VBUS		(1U << 6)
-#define	DWC_OTG_MSK_GPWRDN_POWER_DOWN		(1U << 5)
-#define	DWC_OTG_MSK_GPWRDN_POWER_DOWN_RST	(1U << 4)
-#define	DWC_OTG_MSK_GPWRDN_POWER_DOWN_CLAMP	(1U << 3)
-#define	DWC_OTG_MSK_GPWRDN_RESTORE		(1U << 2)
-#define	DWC_OTG_MSK_GPWRDN_PMU_ACTIVE		(1U << 1)
-#define	DWC_OTG_MSK_GPWRDN_PMU_IRQ_SEL		(1U << 0)
-
-#define	DWC_OTG_REG_GDFIFOCFG		0x005C
-#define	DWC_OTG_REG_GADPCTL		0x0060
-#define	DWC_OTG_REG_HPTXFSIZ		0x0100
-#define	DWC_OTG_REG_DPTXFSIZ(n)			(0x0100 + (4*(n)))
-#define	DWC_OTG_REG_DIEPTXF(n)			(0x0100 + (4*(n)))
-
-/* Host Mode CSR registers */
-
-#define	DWC_OTG_REG_HCFG		0x0400
-#define	DWC_OTG_REG_HFIR		0x0404
-#define	DWC_OTG_REG_HFNUM		0x0408
-#define	DWC_OTG_REG_HPTXSTS		0x0410
-#define	DWC_OTG_REG_HAINT		0x0414
-#define	DWC_OTG_REG_HAINTMSK		0x0418
-#define	DWC_OTG_REG_HPRT		0x0440
-#define	DWC_OTG_REG_HCCHAR(n)	(0x0500 + (32*(n)))
-#define	DWC_OTG_REG_HCSPLT(n)	(0x0504 + (32*(n)))
-#define	DWC_OTG_REG_HCINT(n)	(0x0508 + (32*(n)))
-#define	DWC_OTG_REG_HCINTMSK(n)	(0x050C + (32*(n)))
-#define	DWC_OTG_REG_HCTSIZ(n)	(0x0510 + (32*(n)))
-#define	DWC_OTG_REG_HCDMA(n)	(0x0514 + (32*(n)))
-#define	DWC_OTG_REG_HCDMAB(n)	(0x051C + (32*(n)))
-
-/* Device Mode CSR registers */
-
-#define	DWC_OTG_REG_DCFG		0x0800
-#define	DWC_OTG_MSK_DCFG_SET_DEV_ADDR(x) (((x) & 0x7FU) << 4)
-#define	DWC_OTG_MSK_DCFG_SET_DEV_SPEED(x) ((x) & 0x3U)
-#define	DWC_OTG_MSK_DCFG_DEV_SPEED_HI		(0U)
-#define	DWC_OTG_MSK_DCFG_DEV_SPEED_FULL20	(1U)
-#define	DWC_OTG_MSK_DCFG_DEV_SPEED_FULL10	(3U)
-
-#define	DWC_OTG_REG_DCTL		0x0804
-#define	DWC_OTG_MSK_DCTL_PWRON_PROG_DONE	(1U << 11)
-#define	DWC_OTG_MSK_DCTL_CGOUT_NAK		(1U << 10)
-#define	DWC_OTG_MSK_DCTL_CGNPIN_NAK		(1U << 8)
-#define	DWC_OTG_MSK_DCTL_SOFT_DISC		(1U << 1)
-#define	DWC_OTG_MSK_DCTL_REMOTE_WAKEUP		(1U << 0)
-
-#define	DWC_OTG_REG_DSTS		0x0808
-#define	DWC_OTG_MSK_DSTS_GET_FNUM(x)		(((x) >> 8) & 0x3FFF)
-#define	DWC_OTG_MSK_DSTS_GET_ENUM_SPEED(x)	(((x) >> 1) & 3U)
-#define	DWC_OTG_MSK_DSTS_ENUM_SPEED_HI		(0U)
-#define	DWC_OTG_MSK_DSTS_ENUM_SPEED_FULL20	(1U)
-#define	DWC_OTG_MSK_DSTS_ENUM_SPEED_LOW10	(2U)
-#define	DWC_OTG_MSK_DSTS_ENUM_SPEED_FULL10	(3U)
-#define	DWC_OTG_MSK_DSTS_SUSPEND		(1U << 0)
-
-#define	DWC_OTG_REG_DIEPMSK		0x0810
-#define	DWC_OTG_MSK_DIEP_FIFO_EMPTY		(1U << 4)
-#define	DWC_OTG_MSK_DIEP_XFER_COMPLETE		(1U << 0)
-
-#define	DWC_OTG_REG_DOEPMSK		0x0814
-#define	DWC_OTG_MSK_DOEP_FIFO_EMPTY		(1U << 4)
-#define	DWC_OTG_MSK_DOEP_XFER_COMPLETE		(1U << 0)
-
-#define	DWC_OTG_REG_DAINT		0x0818
-#define	DWC_OTG_REG_DAINTMSK		0x081C
-
-#define	DWC_OTG_MSK_ENDPOINT(x,in) \
-	((in) ? (1U << ((x) & 15U)) : \
-	 (0x10000U << ((x) & 15U)))
-
-#define	DWC_OTG_REG_DTKNQR1		0x0820
-#define	DWC_OTG_REG_DTKNQR2		0x0824
-#define	DWC_OTG_REG_DTKNQR3		0x0830
-#define	DWC_OTG_REG_DTKNQR4		0x0834
-#define	DWC_OTG_REG_DVBUSDIS		0x0828
-#define	DWC_OTG_REG_DVBUSPULSE		0x082C
-#define	DWC_OTG_REG_DTHRCTL		0x0830
-#define	DWC_OTG_REG_DIEPEMPMSK		0x0834
-#define	DWC_OTG_REG_DEACHINT		0x0838
-#define	DWC_OTG_REG_DEACHINTMSK		0x083C
-#define	DWC_OTG_REG_DIEPEACHMSK(n)	(0x0840 + (4*(n)))
-#define	DWC_OTG_REG_DOEPEACHMSK(n)	(0x0880 + (4*(n)))
-
-#define	DWC_OTG_REG_DIEPCTL(n)		(0x0900 + (32*(n)))
-#define	DWC_OTG_MSK_DIEPCTL_ENABLE		(1U << 31)
-#define	DWC_OTG_MSK_DIEPCTL_DISABLE		(1U << 30)
-#define	DWC_OTG_MSK_DIEPCTL_SET_DATA1		(1U << 29)	/* non-control */
-#define	DWC_OTG_MSK_DIEPCTL_SET_DATA0		(1U << 28)	/* non-control */
-#define	DWC_OTG_MSK_DIEPCTL_SET_NAK		(1U << 27)
-#define	DWC_OTG_MSK_DIEPCTL_CLR_NAK		(1U << 26)
-#define	DWC_OTG_MSK_DIEPCTL_FNUM(n)		(((n) & 15U) << 22)
-#define	DWC_OTG_MSK_DIEPCTL_STALL		(1U << 21)
-#define	DWC_OTG_MSK_EP_SET_TYPE(n)	(((n) & 3) << 18)
-#define	DWC_OTG_MSK_EP_TYPE_CONTROL		(0U)
-#define	DWC_OTG_MSK_EP_TYPE_ISOC		(1U)
-#define	DWC_OTG_MSK_EP_TYPE_BULK		(2U)
-#define	DWC_OTG_MSK_EP_TYPE_INTERRUPT		(3U)
-#define	DWC_OTG_MSK_DIEPCTL_USB_AEP		(1U << 15)
-#define	DWC_OTG_MSK_DIEPCTL_MPS_64		(0U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DIEPCTL_MPS_32		(1U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DIEPCTL_MPS_16		(2U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DIEPCTL_MPS_8		(3U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DIEPCTL_MPS(n)		((n) & 0x7FF)	/* non-control */
-
-#define	DWC_OTG_REG_DIEPINT(n)		(0x0908 + (32*(n)))
-#define	DWC_OTG_MSK_DXEPINT_TXFEMP		(1U << 7)
-#define	DWC_OTG_MSK_DXEPINT_SETUP		(1U << 3)
-#define	DWC_OTG_MSK_DXEPINT_XFER_COMPL		(1U << 0)
-
-#define	DWC_OTG_REG_DIEPTSIZ(n)		(0x0910 + (32*(n)))
-#define	DWC_OTG_MSK_DXEPTSIZ_SET_MULTI(n)	(((n) & 3) << 29)
-#define	DWC_OTG_MSK_DXEPTSIZ_SET_NPKT(n)	(((n) & 0x3FF) << 19)
-#define	DWC_OTG_MSK_DXEPTSIZ_GET_NPKT(n)	(((n) >> 19) & 0x3FF)
-#define	DWC_OTG_MSK_DXEPTSIZ_SET_NBYTES(n)	(((n) & 0x7FFFFF) << 0)
-#define	DWC_OTG_MSK_DXEPTSIZ_GET_NBYTES(n)	(((n) >> 0) & 0x7FFFFF)
-
-#define	DWC_OTG_REG_DIEPDMA(n)		(0x0914 + (32*(n)))
-#define	DWC_OTG_REG_DTXFSTS(n)		(0x0918 + (32*(n)))
-#define	DWC_OTG_REG_DIEPDMAB0		(0x091C + (32*(n)))
-
-#define	DWC_OTG_REG_DOEPCTL(n)		(0x0B00 + (32*(n)))
-#define	DWC_OTG_MSK_DOEPCTL_ENABLE		(1U << 31)
-#define	DWC_OTG_MSK_DOEPCTL_DISABLE		(1U << 30)
-#define	DWC_OTG_MSK_DOEPCTL_SET_DATA1		(1U << 29)	/* non-control */
-#define	DWC_OTG_MSK_DOEPCTL_SET_DATA0		(1U << 28)	/* non-control */
-#define	DWC_OTG_MSK_DOEPCTL_SET_NAK		(1U << 27)
-#define	DWC_OTG_MSK_DOEPCTL_CLR_NAK		(1U << 26)
-#define	DWC_OTG_MSK_DOEPCTL_FNUM(n)		(((n) & 15U) << 22)
-#define	DWC_OTG_MSK_DOEPCTL_STALL		(1U << 21)
-#define	DWC_OTG_MSK_DOEPCTL_EP_TYPE(n)	(((n) & 3) << 18)
-#define	DWC_OTG_MSK_DOEPCTL_USB_AEP		(1U << 15)
-#define	DWC_OTG_MSK_DOEPCTL_MPS_64		(0U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DOEPCTL_MPS_32		(1U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DOEPCTL_MPS_16		(2U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DOEPCTL_MPS_8		(3U << 0)	/* control-only */
-#define	DWC_OTG_MSK_DOEPCTL_MPS(n)	((n) & 0x7FF)	/* non-control */
-
-#define	DWC_OTG_REG_DOEPINT(n)		(0x0B08 + (32*(n)))
-#define	DWC_OTG_REG_DOEPTSIZ(n)		(0x0B10 + (32*(n)))
-#define	DWC_OTG_REG_DOEPDMA(n)		(0x0B14 + (32*(n)))
-#define	DWC_OTG_REG_DOEPDMAB(n)		(0x0B1C + (32*(n)))
-
-/* FIFO access registers */
-
-#define	DWC_OTG_REG_DFIFO(n)		(0x1000 + (0x1000 * (n)))
-
-/* Power and clock gating CSR */
-
-#define	DWC_OTG_REG_PCGCCTL		0x0E00
-
 #define	DWC_OTG_READ_4(sc, reg) \
   bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg)
 


More information about the Zrouter-src-freebsd mailing list