PERFORCE change 144367 for review

Hans Petter Selasky hselasky at FreeBSD.org
Mon Jun 30 15:32:03 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=144367

Change 144367 by hselasky at hselasky_laptop001 on 2008/06/30 15:31:28

	
	The USB Controller module is complete.
	
	- Mostly symbol renaming. "s/usbd_|usb_/usb2/g" (scripted)
	- Device ID tables have been converted into new format. (scripted)

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb2/controller/at91dci.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/at91dci.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/at91dci_atmelarm.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2_pci.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/ohci2_atmelarm.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/ohci2_pci.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2_pci.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/usb2_bus.h#1 add
.. //depot/projects/usb/src/sys/dev/usb2/controller/usb2_controller.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/usb2_controller.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/uss820dci.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/uss820dci.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/uss820dci_pccard.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_compat_linux.c#4 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.c#4 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#3 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dynamic.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dynamic.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_handle_request.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#4 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.h#3 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_transfer.c#3 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_transfer.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/include/usb2_defs.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/include/usb2_standard.h#3 edit
.. //depot/projects/usb/src/sys/modules/usb2/controller/Makefile#2 edit
.. //depot/projects/usb/src/sys/modules/usb2/core/Makefile#3 edit
.. //depot/projects/usb/src/sys/modules/usb2/ethernet/Makefile#3 edit
.. //depot/projects/usb/src/sys/modules/usb2/wlan/Makefile#3 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb2/controller/at91dci.c#2 (text+ko) ====

@@ -1,9 +1,8 @@
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/at9100_dci.c $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/at91dci.c $");
 
 /*-
- * Copyright (c) 2007 Hans Petter Selasky <hselasky at freebsd.org>
- * All rights reserved.
+ * Copyright (c) 2007-2008 Hans Petter Selasky. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,69 +44,70 @@
  * endpoints, Function-address and more.
  */
 
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/endian.h>
-#include <sys/queue.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
+#include <dev/usb2/include/usb2_standard.h>
+#include <dev/usb2/include/usb2_mfunc.h>
+#include <dev/usb2/include/usb2_revision.h>
+#include <dev/usb2/include/usb2_error.h>
+#include <dev/usb2/include/usb2_defs.h>
+
+#define	USB_DEBUG_VAR at91dcidebug
+#define	usb2_config_td_cc at91dci_config_copy
+#define	usb2_config_td_softc at91dci_softc
 
-#define	usbd_config_td_cc at9100_dci_config_copy
-#define	usbd_config_td_softc at9100_dci_softc
+#include <dev/usb2/core/usb2_core.h>
+#include <dev/usb2/core/usb2_debug.h>
+#include <dev/usb2/core/usb2_busdma.h>
+#include <dev/usb2/core/usb2_process.h>
+#include <dev/usb2/core/usb2_config_td.h>
+#include <dev/usb2/core/usb2_sw_transfer.h>
+#include <dev/usb2/core/usb2_transfer.h>
+#include <dev/usb2/core/usb2_device.h>
+#include <dev/usb2/core/usb2_hub.h>
+#include <dev/usb2/core/usb2_util.h>
 
-#include <dev/usb/usb_port.h>
-#include <dev/usb/usb.h>
-#include <dev/usb/usb_subr.h>
-#include <dev/usb/at9100_dci.h>
+#include <dev/usb2/controller/usb2_controller.h>
+#include <dev/usb2/controller/usb2_bus.h>
+#include <dev/usb2/controller/at91dci.h>
 
 #define	AT9100_DCI_BUS2SC(bus) \
-   ((struct at9100_dci_softc *)(((uint8_t *)(bus)) - \
-   POINTER_TO_UNSIGNED(&(((struct at9100_dci_softc *)0)->sc_bus))))
+   ((struct at91dci_softc *)(((uint8_t *)(bus)) - \
+   USB_P2U(&(((struct at91dci_softc *)0)->sc_bus))))
 
 #define	AT9100_DCI_PC2SC(pc) \
    AT9100_DCI_BUS2SC((pc)->tag_parent->info->bus)
 
 #ifdef USB_DEBUG
-#define	DPRINTFN(n,fmt,...) do {			\
-  if (at9100_dcidebug > (n)) {				\
-    printf("%s: " fmt, __FUNCTION__,## __VA_ARGS__);	\
-  }							\
-} while (0)
+static int at91dcidebug = 0;
 
-static int at9100_dcidebug = 0;
-
-SYSCTL_NODE(_hw_usb, OID_AUTO, at9100_dci, CTLFLAG_RW, 0, "USB at9100_dci");
-SYSCTL_INT(_hw_usb_at9100_dci, OID_AUTO, debug, CTLFLAG_RW,
-    &at9100_dcidebug, 0, "at9100_dci debug level");
-#else
-#define	DPRINTFN(...) do { } while (0)
+SYSCTL_NODE(_hw_usb2, OID_AUTO, at91dci, CTLFLAG_RW, 0, "USB at91dci");
+SYSCTL_INT(_hw_usb2_at91dci, OID_AUTO, debug, CTLFLAG_RW,
+    &at91dcidebug, 0, "at91dci debug level");
 #endif
 
 #define	AT9100_DCI_INTR_ENDPT 1
 
 /* prototypes */
 
-struct usbd_bus_methods at9100_dci_bus_methods;
-struct usbd_pipe_methods at9100_dci_device_bulk_methods;
-struct usbd_pipe_methods at9100_dci_device_ctrl_methods;
-struct usbd_pipe_methods at9100_dci_device_intr_methods;
-struct usbd_pipe_methods at9100_dci_device_isoc_fs_methods;
-struct usbd_pipe_methods at9100_dci_root_ctrl_methods;
-struct usbd_pipe_methods at9100_dci_root_intr_methods;
+struct usb2_bus_methods at91dci_bus_methods;
+struct usb2_pipe_methods at91dci_device_bulk_methods;
+struct usb2_pipe_methods at91dci_device_ctrl_methods;
+struct usb2_pipe_methods at91dci_device_intr_methods;
+struct usb2_pipe_methods at91dci_device_isoc_fs_methods;
+struct usb2_pipe_methods at91dci_root_ctrl_methods;
+struct usb2_pipe_methods at91dci_root_intr_methods;
 
-static at9100_dci_cmd_t at9100_dci_setup_rx;
-static at9100_dci_cmd_t at9100_dci_data_rx;
-static at9100_dci_cmd_t at9100_dci_data_tx;
-static at9100_dci_cmd_t at9100_dci_data_tx_sync;
-static void at9100_dci_device_done(struct usbd_xfer *xfer, usbd_status_t error);
-static void at9100_dci_do_poll(struct usbd_bus *bus);
-static void at9100_dci_root_ctrl_poll(struct at9100_dci_softc *sc);
-static void at9100_dci_standard_done(struct usbd_xfer *xfer);
+static at91dci_cmd_t at91dci_setup_rx;
+static at91dci_cmd_t at91dci_data_rx;
+static at91dci_cmd_t at91dci_data_tx;
+static at91dci_cmd_t at91dci_data_tx_sync;
+static void at91dci_device_done(struct usb2_xfer *xfer, usb2_error_t error);
+static void at91dci_do_poll(struct usb2_bus *bus);
+static void at91dci_root_ctrl_poll(struct at91dci_softc *sc);
+static void at91dci_standard_done(struct usb2_xfer *xfer);
 
-static usbd_std_root_transfer_func_t at9100_dci_root_intr_done;
-static usbd_std_root_transfer_func_t at9100_dci_root_ctrl_done;
-static usbd_config_td_command_t at9100_dci_root_ctrl_task;
+static usb2_sw_transfer_func_t at91dci_root_intr_done;
+static usb2_sw_transfer_func_t at91dci_root_ctrl_done;
+static usb2_config_td_command_t at91dci_root_ctrl_task;
 
 /*
  * NOTE: Some of the bits in the CSR register have inverse meaning so
@@ -128,8 +128,8 @@
  * Here is a list of what the chip supports.
  * Probably it supports more than listed here!
  */
-static const struct usbd_hw_ep_profile
-	at9100_dci_ep_profile[AT91_UDP_EP_MAX] = {
+static const struct usb2_hw_ep_profile
+	at91dci_ep_profile[AT91_UDP_EP_MAX] = {
 
 	[0] = {
 		.max_frame_size = 8,
@@ -187,11 +187,11 @@
 };
 
 static void
-at9100_dci_get_hw_ep_profile(struct usbd_device *udev,
-    const struct usbd_hw_ep_profile **ppf, uint8_t ep_addr)
+at91dci_get_hw_ep_profile(struct usb2_device *udev,
+    const struct usb2_hw_ep_profile **ppf, uint8_t ep_addr)
 {
 	if (ep_addr < AT91_UDP_EP_MAX) {
-		*ppf = (at9100_dci_ep_profile + ep_addr);
+		*ppf = (at91dci_ep_profile + ep_addr);
 	} else {
 		*ppf = NULL;
 	}
@@ -199,12 +199,12 @@
 }
 
 static void
-at9100_dci_clocks_on(struct at9100_dci_softc *sc)
+at91dci_clocks_on(struct at91dci_softc *sc)
 {
 	if (sc->sc_flags.clocks_off &&
 	    sc->sc_flags.port_powered) {
 
-		DPRINTFN(4, "\n");
+		DPRINTF(4, "\n");
 
 		if (sc->sc_clocks_on) {
 			(sc->sc_clocks_on) (sc->sc_clocks_arg);
@@ -218,11 +218,11 @@
 }
 
 static void
-at9100_dci_clocks_off(struct at9100_dci_softc *sc)
+at91dci_clocks_off(struct at91dci_softc *sc)
 {
 	if (!sc->sc_flags.clocks_off) {
 
-		DPRINTFN(4, "\n");
+		DPRINTF(4, "\n");
 
 		/* disable Transceiver */
 		AT91_UDP_WRITE_4(sc, AT91_UDP_TXVC, AT91_UDP_TXVC_DIS);
@@ -236,7 +236,7 @@
 }
 
 static void
-at9100_dci_pull_up(struct at9100_dci_softc *sc)
+at91dci_pull_up(struct at91dci_softc *sc)
 {
 	/* pullup D+, if possible */
 
@@ -249,7 +249,7 @@
 }
 
 static void
-at9100_dci_pull_down(struct at9100_dci_softc *sc)
+at91dci_pull_down(struct at91dci_softc *sc)
 {
 	/* pulldown D+, if possible */
 
@@ -261,7 +261,7 @@
 }
 
 static void
-at9100_dci_wakeup_peer(struct at9100_dci_softc *sc)
+at91dci_wakeup_peer(struct at91dci_softc *sc)
 {
 	uint32_t temp;
 
@@ -279,12 +279,12 @@
 }
 
 static void
-at9100_dci_rem_wakeup_set(struct usbd_device *udev, uint8_t is_on)
+at91dci_rem_wakeup_set(struct usb2_device *udev, uint8_t is_on)
 {
-	struct at9100_dci_softc *sc;
+	struct at91dci_softc *sc;
 	uint32_t temp;
 
-	DPRINTFN(4, "is_on=%u\n", is_on);
+	DPRINTF(4, "is_on=%u\n", is_on);
 
 	mtx_assert(&(udev->bus->mtx), MA_OWNED);
 
@@ -304,9 +304,9 @@
 }
 
 static void
-at9100_dci_set_address(struct at9100_dci_softc *sc, uint8_t addr)
+at91dci_set_address(struct at91dci_softc *sc, uint8_t addr)
 {
-	DPRINTFN(4, "addr=%d\n", addr);
+	DPRINTF(4, "addr=%d\n", addr);
 
 	AT91_UDP_WRITE_4(sc, AT91_UDP_FADDR, addr |
 	    AT91_UDP_FADDR_EN);
@@ -315,10 +315,10 @@
 }
 
 static uint8_t
-at9100_dci_setup_rx(struct at9100_dci_td *td)
+at91dci_setup_rx(struct at91dci_td *td)
 {
-	struct at9100_dci_softc *sc;
-	usb_device_request_t req;
+	struct at91dci_softc *sc;
+	struct usb2_device_request req;
 	uint32_t csr;
 	uint32_t temp;
 	uint16_t count;
@@ -327,7 +327,7 @@
 	csr = bus_space_read_4(td->io_tag, td->io_hdl,
 	    td->status_reg);
 
-	DPRINTFN(4, "csr=0x%08x rem=%u\n", csr, td->remainder);
+	DPRINTF(4, "csr=0x%08x rem=%u\n", csr, td->remainder);
 
 	temp = csr;
 	temp &= (AT91_UDP_CSR_RX_DATA_BK0 |
@@ -339,7 +339,7 @@
 	if (!(csr & AT91_UDP_CSR_RXSETUP)) {
 		/* abort any ongoing transfer */
 		if (!td->did_stall) {
-			DPRINTFN(4, "stalling\n");
+			DPRINTF(4, "stalling\n");
 			temp |= AT91_UDP_CSR_FORCESTALL;
 			td->did_stall = 1;
 		}
@@ -350,12 +350,12 @@
 
 	/* verify data length */
 	if (count != td->remainder) {
-		DPRINTFN(-1, "Invalid SETUP packet "
+		DPRINTF(-1, "Invalid SETUP packet "
 		    "length, %d bytes\n", count);
 		goto not_complete;
 	}
 	if (count != sizeof(req)) {
-		DPRINTFN(-1, "Unsupported SETUP packet "
+		DPRINTF(-1, "Unsupported SETUP packet "
 		    "length, %d bytes\n", count);
 		goto not_complete;
 	}
@@ -364,7 +364,7 @@
 	    td->fifo_reg, (void *)&req, sizeof(req));
 
 	/* copy data into real buffer */
-	usbd_copy_in(td->pc, 0, &req, sizeof(req));
+	usb2_copy_in(td->pc, 0, &req, sizeof(req));
 
 	td->offset = sizeof(req);
 	td->remainder = 0;
@@ -396,7 +396,7 @@
 not_complete:
 	/* clear interrupts, if any */
 	if (temp) {
-		DPRINTFN(4, "clearing 0x%08x\n", temp);
+		DPRINTF(4, "clearing 0x%08x\n", temp);
 		AT91_CSR_ACK(csr, temp);
 		bus_space_write_4(td->io_tag, td->io_hdl,
 		    td->status_reg, csr);
@@ -406,9 +406,9 @@
 }
 
 static uint8_t
-at9100_dci_data_rx(struct at9100_dci_td *td)
+at91dci_data_rx(struct at91dci_td *td)
 {
-	struct usbd_page_search buf_res;
+	struct usb2_page_search buf_res;
 	uint32_t csr;
 	uint32_t temp;
 	uint16_t count;
@@ -424,7 +424,7 @@
 	csr = bus_space_read_4(td->io_tag, td->io_hdl,
 	    td->status_reg);
 
-	DPRINTFN(4, "csr=0x%08x rem=%u\n", csr, td->remainder);
+	DPRINTF(4, "csr=0x%08x rem=%u\n", csr, td->remainder);
 
 	if (csr & AT91_UDP_CSR_RXSETUP) {
 		if (td->remainder == 0) {
@@ -432,7 +432,7 @@
 			 * We are actually complete and have
 			 * received the next SETUP
 			 */
-			DPRINTFN(4, "faking complete\n");
+			DPRINTF(4, "faking complete\n");
 			return (0);	/* complete */
 		}
 		/*
@@ -478,7 +478,7 @@
 		return (0);		/* we are complete */
 	}
 	while (count > 0) {
-		usbd_get_page(td->pc, td->offset, &buf_res);
+		usb2_get_page(td->pc, td->offset, &buf_res);
 
 		/* get correct length */
 		if (buf_res.length > count) {
@@ -533,9 +533,9 @@
 }
 
 static uint8_t
-at9100_dci_data_tx(struct at9100_dci_td *td)
+at91dci_data_tx(struct at91dci_td *td)
 {
-	struct usbd_page_search buf_res;
+	struct usb2_page_search buf_res;
 	uint32_t csr;
 	uint32_t temp;
 	uint16_t count;
@@ -549,7 +549,7 @@
 	csr = bus_space_read_4(td->io_tag, td->io_hdl,
 	    td->status_reg);
 
-	DPRINTFN(4, "csr=0x%08x rem=%u\n", csr, td->remainder);
+	DPRINTF(4, "csr=0x%08x rem=%u\n", csr, td->remainder);
 
 	if (csr & AT91_UDP_CSR_RXSETUP) {
 		/*
@@ -585,7 +585,7 @@
 	}
 	while (count > 0) {
 
-		usbd_get_page(td->pc, td->offset, &buf_res);
+		usb2_get_page(td->pc, td->offset, &buf_res);
 
 		/* get correct length */
 		if (buf_res.length > count) {
@@ -620,9 +620,9 @@
 }
 
 static uint8_t
-at9100_dci_data_tx_sync(struct at9100_dci_td *td)
+at91dci_data_tx_sync(struct at91dci_td *td)
 {
-	struct at9100_dci_softc *sc;
+	struct at91dci_softc *sc;
 	uint32_t csr;
 	uint32_t temp;
 
@@ -634,10 +634,10 @@
 	csr = bus_space_read_4(td->io_tag, td->io_hdl,
 	    td->status_reg);
 
-	DPRINTFN(4, "csr=0x%08x\n", csr);
+	DPRINTF(4, "csr=0x%08x\n", csr);
 
 	if (csr & AT91_UDP_CSR_RXSETUP) {
-		DPRINTFN(4, "faking complete\n");
+		DPRINTF(4, "faking complete\n");
 		/* Race condition */
 		return (0);		/* complete */
 	}
@@ -659,7 +659,7 @@
 		 * setting the address and that is to write the new
 		 * address before clearing TXCOMP:
 		 */
-		at9100_dci_set_address(sc, sc->sc_dv_addr);
+		at91dci_set_address(sc, sc->sc_dv_addr);
 	}
 	/* write command */
 	AT91_CSR_ACK(csr, temp);
@@ -679,13 +679,13 @@
 }
 
 static uint8_t
-at9100_dci_xfer_do_fifo(struct usbd_xfer *xfer)
+at91dci_xfer_do_fifo(struct usb2_xfer *xfer)
 {
-	struct at9100_dci_softc *sc;
-	struct at9100_dci_td *td;
+	struct at91dci_softc *sc;
+	struct at91dci_td *td;
 	uint8_t temp;
 
-	DPRINTFN(8, "\n");
+	DPRINTF(8, "\n");
 
 	td = xfer->td_transfer_cache;
 	while (1) {
@@ -722,7 +722,7 @@
 	return (1);			/* not complete */
 
 done:
-	sc = xfer->usb_sc;
+	sc = xfer->usb2_sc;
 	temp = (xfer->endpoint & UE_ADDR);
 
 	/* update FIFO bank flag and multi buffer */
@@ -734,32 +734,32 @@
 
 	/* compute all actual lengths */
 
-	at9100_dci_standard_done(xfer);
+	at91dci_standard_done(xfer);
 
 	return (0);			/* complete */
 }
 
 static void
-at9100_dci_interrupt_poll(struct at9100_dci_softc *sc)
+at91dci_interrupt_poll(struct at91dci_softc *sc)
 {
-	struct usbd_xfer *xfer;
+	struct usb2_xfer *xfer;
 
-	LIST_FOREACH(xfer, &sc->sc_bus.intr_list_head, interrupt_list) {
-		if (!at9100_dci_xfer_do_fifo(xfer)) {
-			/* queue callback for execution */
-			usbd_callback_wrapper(xfer, NULL,
-			    USBD_CONTEXT_CALLBACK);
+repeat:
+	TAILQ_FOREACH(xfer, &(sc->sc_bus.intr_q.head), wait_entry) {
+		if (!at91dci_xfer_do_fifo(xfer)) {
+			/* queue has been modified */
+			goto repeat;
 		}
 	}
 	return;
 }
 
 static void
-at9100_dci_vbus_interrupt(struct usbd_bus *bus, uint8_t is_on)
+at91dci_vbus_interrupt(struct usb2_bus *bus, uint8_t is_on)
 {
-	struct at9100_dci_softc *sc = AT9100_DCI_BUS2SC(bus);
+	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(bus);
 
-	DPRINTFN(4, "vbus = %u\n", is_on);
+	DPRINTF(4, "vbus = %u\n", is_on);
 
 	mtx_lock(&(sc->sc_bus.mtx));
 	if (is_on) {
@@ -768,8 +768,8 @@
 
 			/* complete root HUB interrupt endpoint */
 
-			usbd_std_root_transfer(&(sc->sc_root_intr),
-			    &at9100_dci_root_intr_done);
+			usb2_sw_transfer(&(sc->sc_root_intr),
+			    &at91dci_root_intr_done);
 		}
 	} else {
 		if (sc->sc_flags.status_vbus) {
@@ -781,8 +781,8 @@
 
 			/* complete root HUB interrupt endpoint */
 
-			usbd_std_root_transfer(&(sc->sc_root_intr),
-			    &at9100_dci_root_intr_done);
+			usb2_sw_transfer(&(sc->sc_root_intr),
+			    &at91dci_root_intr_done);
 		}
 	}
 
@@ -792,7 +792,7 @@
 }
 
 void
-at9100_dci_interrupt(struct at9100_dci_softc *sc)
+at91dci_interrupt(struct at91dci_softc *sc)
 {
 	uint32_t status;
 
@@ -813,7 +813,7 @@
 
 	if (status & AT91_UDP_INT_BUS) {
 
-		DPRINTFN(4, "real bus interrupt 0x%08x\n", status);
+		DPRINTF(4, "real bus interrupt 0x%08x\n", status);
 
 		if (status & AT91_UDP_INT_END_BR) {
 
@@ -863,16 +863,16 @@
 		}
 		/* complete root HUB interrupt endpoint */
 
-		usbd_std_root_transfer(&(sc->sc_root_intr),
-		    &at9100_dci_root_intr_done);
+		usb2_sw_transfer(&(sc->sc_root_intr),
+		    &at91dci_root_intr_done);
 	}
 	/* check for any endpoint interrupts */
 
 	if (status & AT91_UDP_INT_EPS) {
 
-		DPRINTFN(4, "real endpoint interrupt 0x%08x\n", status);
+		DPRINTF(4, "real endpoint interrupt 0x%08x\n", status);
 
-		at9100_dci_interrupt_poll(sc);
+		at91dci_interrupt_poll(sc);
 	}
 	mtx_unlock(&(sc->sc_bus.mtx));
 
@@ -880,9 +880,9 @@
 }
 
 static void
-at9100_dci_setup_standard_chain_sub(struct at9100_std_temp *temp)
+at91dci_setup_standard_chain_sub(struct at91dci_std_temp *temp)
 {
-	struct at9100_dci_td *td;
+	struct at91dci_td *td;
 
 	/* get current Transfer Descriptor */
 	td = temp->td_next;
@@ -905,18 +905,18 @@
 }
 
 static void
-at9100_dci_setup_standard_chain(struct usbd_xfer *xfer)
+at91dci_setup_standard_chain(struct usb2_xfer *xfer)
 {
-	struct at9100_std_temp temp;
-	struct at9100_dci_softc *sc;
-	struct at9100_dci_td *td;
+	struct at91dci_std_temp temp;
+	struct at91dci_softc *sc;
+	struct at91dci_td *td;
 	uint32_t x;
 	uint8_t need_sync;
 	uint8_t ep_no;
 
-	DPRINTFN(8, "addr=%d endpt=%d sumlen=%d speed=%d\n",
+	DPRINTF(8, "addr=%d endpt=%d sumlen=%d speed=%d\n",
 	    xfer->address, UE_GET_ADDR(xfer->endpoint),
-	    xfer->sumlen, usbd_get_speed(xfer->udev));
+	    xfer->sumlen, usb2_get_speed(xfer->udev));
 
 	temp.max_frame_size = xfer->max_frame_size;
 
@@ -931,7 +931,7 @@
 	temp.setup_alt_next = xfer->flags_int.short_frames_ok;
 	temp.offset = 0;
 
-	sc = xfer->usb_sc;
+	sc = xfer->usb2_sc;
 	ep_no = (xfer->endpoint & UE_ADDR);
 
 	/* check if we should prepend a setup message */
@@ -939,12 +939,12 @@
 	if (xfer->flags_int.control_xfr) {
 		if (xfer->flags_int.control_hdr) {
 
-			temp.func = &at9100_dci_setup_rx;
+			temp.func = &at91dci_setup_rx;
 			temp.len = xfer->frlengths[0];
 			temp.pc = xfer->frbuffers + 0;
 			temp.short_pkt = temp.len ? 1 : 0;
 
-			at9100_dci_setup_standard_chain_sub(&temp);
+			at91dci_setup_standard_chain_sub(&temp);
 		}
 		x = 1;
 	} else {
@@ -953,10 +953,10 @@
 
 	if (x != xfer->nframes) {
 		if (xfer->endpoint & UE_DIR_IN) {
-			temp.func = &at9100_dci_data_tx;
+			temp.func = &at91dci_data_tx;
 			need_sync = 1;
 		} else {
-			temp.func = &at9100_dci_data_rx;
+			temp.func = &at91dci_data_rx;
 			need_sync = 0;
 		}
 
@@ -990,7 +990,7 @@
 			temp.short_pkt = (xfer->flags.force_short_xfer) ? 0 : 1;
 		}
 
-		at9100_dci_setup_standard_chain_sub(&temp);
+		at91dci_setup_standard_chain_sub(&temp);
 
 		if (xfer->flags_int.isochronous_xfr) {
 			temp.offset += temp.len;
@@ -1007,11 +1007,11 @@
 	if (need_sync && !xfer->flags_int.isochronous_xfr) {
 
 		/* we need a SYNC point after TX */
-		temp.func = &at9100_dci_data_tx_sync;
+		temp.func = &at91dci_data_tx_sync;
 		temp.len = 0;
 		temp.short_pkt = 0;
 
-		at9100_dci_setup_standard_chain_sub(&temp);
+		at91dci_setup_standard_chain_sub(&temp);
 	}
 	/* check if we should append a status stage */
 
@@ -1023,23 +1023,23 @@
 		 * endpoint direction.
 		 */
 		if (xfer->endpoint & UE_DIR_IN) {
-			temp.func = &at9100_dci_data_rx;
+			temp.func = &at91dci_data_rx;
 			need_sync = 0;
 		} else {
-			temp.func = &at9100_dci_data_tx;
+			temp.func = &at91dci_data_tx;
 			need_sync = 1;
 		}
 		temp.len = 0;
 		temp.short_pkt = 0;
 
-		at9100_dci_setup_standard_chain_sub(&temp);
+		at91dci_setup_standard_chain_sub(&temp);
 		if (need_sync) {
 			/* we need a SYNC point after TX */
-			temp.func = &at9100_dci_data_tx_sync;
+			temp.func = &at91dci_data_tx_sync;
 			temp.len = 0;
 			temp.short_pkt = 0;
 
-			at9100_dci_setup_standard_chain_sub(&temp);
+			at91dci_setup_standard_chain_sub(&temp);
 		}
 	}
 	/* must have at least one frame! */
@@ -1055,34 +1055,32 @@
 }
 
 static void
-at9100_dci_timeout(struct usbd_xfer *xfer)
+at91dci_timeout(void *arg)
 {
-	struct at9100_dci_softc *sc = xfer->usb_sc;
+	struct usb2_xfer *xfer = arg;
+	struct at91dci_softc *sc = xfer->usb2_sc;
 
-	DPRINTFN(0, "xfer=%p\n", xfer);
+	DPRINTF(0, "xfer=%p\n", xfer);
 
 	mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
 
 	/* transfer is transferred */
-	at9100_dci_device_done(xfer, USBD_ERR_TIMEOUT);
+	at91dci_device_done(xfer, USB_ERR_TIMEOUT);
 
-	/* queue callback for execution */
-	usbd_callback_wrapper(xfer, NULL, USBD_CONTEXT_CALLBACK);
-
 	mtx_unlock(&sc->sc_bus.mtx);
 
 	return;
 }
 
 static void
-at9100_dci_start_standard_chain(struct usbd_xfer *xfer)
+at91dci_start_standard_chain(struct usb2_xfer *xfer)
 {
-	DPRINTFN(8, "\n");
+	DPRINTF(8, "\n");
 
 	/* poll one time */
-	if (at9100_dci_xfer_do_fifo(xfer)) {
+	if (at91dci_xfer_do_fifo(xfer)) {
 
-		struct at9100_dci_softc *sc = xfer->usb_sc;
+		struct at91dci_softc *sc = xfer->usb2_sc;
 		uint8_t ep_no = xfer->endpoint & UE_ADDR;
 
 		/*
@@ -1092,42 +1090,34 @@
 		 */
 		AT91_UDP_WRITE_4(sc, AT91_UDP_IER, AT91_UDP_INT_EP(ep_no));
 
-		DPRINTFN(14, "enable interrupts on endpoint %d\n", ep_no);
+		DPRINTF(14, "enable interrupts on endpoint %d\n", ep_no);
 
-		/* queue up transfer on interrupt list */
-		usbd_transfer_intr_enqueue(xfer);
+		/* put transfer on interrupt queue */
+		usb2_transfer_enqueue(&(xfer->udev->bus->intr_q), xfer);
 
-		/* setup a timeout, if any */
-		if (xfer->timeout && (!xfer->flags.use_polling)) {
-			usb_callout_reset(&xfer->timeout_handle,
-			    USBD_MS_TO_TICKS(xfer->timeout),
-			    (void *)&at9100_dci_timeout, xfer);
+		/* start timeout, if any */
+		if (xfer->timeout != 0) {
+			usb2_transfer_timeout_ms(xfer,
+			    &at91dci_timeout, xfer->timeout);
 		}
-	} else {
-		/*
-		 * The USB transfer is complete. Queue callback for
-		 * execution:
-		 */
-		usbd_callback_wrapper(xfer, NULL,
-		    USBD_CONTEXT_CALLBACK);
 	}
 	return;
 }
 
 static void
-at9100_dci_root_intr_done(struct usbd_xfer *xfer,
-    struct usbd_std_root_transfer *std)
+at91dci_root_intr_done(struct usb2_xfer *xfer,
+    struct usb2_sw_transfer *std)
 {
-	struct at9100_dci_softc *sc = xfer->usb_sc;
+	struct at91dci_softc *sc = xfer->usb2_sc;
 
-	DPRINTFN(8, "\n");
+	DPRINTF(8, "\n");
 
 	mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
 
-	if (std->state != USBD_STD_ROOT_TR_PRE_DATA) {
-		if (std->state == USBD_STD_ROOT_TR_PRE_CALLBACK) {
+	if (std->state != USB_SW_TR_PRE_DATA) {
+		if (std->state == USB_SW_TR_PRE_CALLBACK) {
 			/* transfer transferred */
-			at9100_dci_device_done(xfer, std->err);
+			at91dci_device_done(xfer, std->err);
 		}
 		goto done;
 	}
@@ -1142,14 +1132,14 @@
 	return;
 }
 
-static usbd_status_t
-at9100_dci_standard_done_sub(struct usbd_xfer *xfer)
+static usb2_error_t
+at91dci_standard_done_sub(struct usb2_xfer *xfer)
 {
-	struct at9100_dci_td *td;
+	struct at91dci_td *td;
 	uint32_t len;
 	uint8_t error;
 
-	DPRINTFN(8, "\n");
+	DPRINTF(8, "\n");
 
 	td = xfer->td_transfer_cache;
 
@@ -1203,15 +1193,15 @@
 	xfer->td_transfer_cache = td;
 
 	return (error ?
-	    USBD_ERR_STALLED : USBD_ERR_NORMAL_COMPLETION);
+	    USB_ERR_STALLED : USB_ERR_NORMAL_COMPLETION);
 }
 
 static void
-at9100_dci_standard_done(struct usbd_xfer *xfer)
+at91dci_standard_done(struct usb2_xfer *xfer)
 {
-	usbd_status_t err = 0;
+	usb2_error_t err = 0;
 
-	DPRINTFN(12, "xfer=%p pipe=%p transfer done\n",
+	DPRINTF(12, "xfer=%p pipe=%p transfer done\n",
 	    xfer, xfer->pipe);
 
 	/* reset scanner */
@@ -1222,7 +1212,7 @@
 
 		if (xfer->flags_int.control_hdr) {
 
-			err = at9100_dci_standard_done_sub(xfer);
+			err = at91dci_standard_done_sub(xfer);
 		}
 		xfer->aframes = 1;
 
@@ -1232,7 +1222,7 @@
 	}
 	while (xfer->aframes != xfer->nframes) {
 
-		err = at9100_dci_standard_done_sub(xfer);
+		err = at91dci_standard_done_sub(xfer);
 		xfer->aframes++;
 
 		if (xfer->td_transfer_cache == NULL) {
@@ -1243,58 +1233,58 @@
 	if (xfer->flags_int.control_xfr &&
 	    !xfer->flags_int.control_act) {
 
-		err = at9100_dci_standard_done_sub(xfer);
+		err = at91dci_standard_done_sub(xfer);
 	}
 done:
-	at9100_dci_device_done(xfer, err);
+	at91dci_device_done(xfer, err);
 	return;
 }
 
 /*------------------------------------------------------------------------*
- *	at9100_dci_device_done
+ *	at91dci_device_done
  *
  * NOTE: this function can be called more than one time on the
  * same USB transfer!
  *------------------------------------------------------------------------*/
 static void
-at9100_dci_device_done(struct usbd_xfer *xfer, usbd_status_t error)
+at91dci_device_done(struct usb2_xfer *xfer, usb2_error_t error)
 {
-	struct at9100_dci_softc *sc = xfer->usb_sc;
+	struct at91dci_softc *sc = xfer->usb2_sc;
 	uint8_t ep_no;
 
 	mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
 
-	DPRINTFN(1, "xfer=%p, pipe=%p, error=%d\n",
+	DPRINTF(1, "xfer=%p, pipe=%p, error=%d\n",
 	    xfer, xfer->pipe, error);
 
-	if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) {
+	if (xfer->flags_int.usb2_mode == USB_MODE_DEVICE) {
 		ep_no = (xfer->endpoint & UE_ADDR);
 
 		/* disable endpoint interrupt */
 		AT91_UDP_WRITE_4(sc, AT91_UDP_IDR, AT91_UDP_INT_EP(ep_no));
 
-		DPRINTFN(14, "disable interrupts on endpoint %d\n", ep_no);
+		DPRINTF(14, "disable interrupts on endpoint %d\n", ep_no);
 	}
 	/* dequeue transfer and start next transfer */
-	usbd_transfer_dequeue(xfer, error);
+	usb2_transfer_done(xfer, error);
 	return;
 }
 
 static void
-at9100_dci_set_stall(struct usbd_device *udev, struct usbd_xfer *xfer,
-    struct usbd_pipe *pipe)
+at91dci_set_stall(struct usb2_device *udev, struct usb2_xfer *xfer,
+    struct usb2_pipe *pipe)
 {
-	struct at9100_dci_softc *sc;
+	struct at91dci_softc *sc;
 	uint32_t csr_val;
 	uint8_t csr_reg;
 
 	mtx_assert(&(udev->bus->mtx), MA_OWNED);
 
-	DPRINTFN(4, "pipe=%p\n", pipe);
+	DPRINTF(4, "pipe=%p\n", pipe);
 
 	if (xfer) {
 		/* cancel any ongoing transfers */
-		at9100_dci_device_done(xfer, USBD_ERR_STALLED);
+		at91dci_device_done(xfer, USB_ERR_STALLED);
 	}
 	/* set FORCESTALL */
 	sc = AT9100_DCI_BUS2SC(udev->bus);
@@ -1307,10 +1297,10 @@
 }
 
 static void
-at9100_dci_clear_stall_sub(struct at9100_dci_softc *sc, uint8_t ep_no,
+at91dci_clear_stall_sub(struct at91dci_softc *sc, uint8_t ep_no,
     uint8_t ep_type, uint8_t ep_dir)
 {
-	const struct usbd_hw_ep_profile *pf;
+	const struct usb2_hw_ep_profile *pf;
 	uint32_t csr_val;
 	uint32_t temp;
 	uint8_t csr_reg;
@@ -1331,7 +1321,7 @@
 	AT91_UDP_WRITE_4(sc, csr_reg, csr_val);
 
 	/* get endpoint profile */
-	at9100_dci_get_hw_ep_profile(NULL, &pf, ep_no);
+	at91dci_get_hw_ep_profile(NULL, &pf, ep_no);
 
 	/* reset FIFO */
 	AT91_UDP_WRITE_4(sc, AT91_UDP_RST, AT91_UDP_RST_EP(ep_no));
@@ -1405,17 +1395,17 @@
 }
 
 static void
-at9100_dci_clear_stall(struct usbd_device *udev, struct usbd_pipe *pipe)
+at91dci_clear_stall(struct usb2_device *udev, struct usb2_pipe *pipe)
 {
-	struct at9100_dci_softc *sc;
-	usb_endpoint_descriptor_t *ed;
+	struct at91dci_softc *sc;
+	struct usb2_endpoint_descriptor *ed;
 
-	DPRINTFN(4, "pipe=%p\n", pipe);
+	DPRINTF(4, "pipe=%p\n", pipe);
 
 	mtx_assert(&(udev->bus->mtx), MA_OWNED);
 
 	/* check mode */
-	if (udev->flags.usb_mode != USB_MODE_DEVICE) {
+	if (udev->flags.usb2_mode != USB_MODE_DEVICE) {
 		/* not supported */
 		return;
 	}
@@ -1426,24 +1416,24 @@
 	ed = pipe->edesc;
 
 	/* reset endpoint */
-	at9100_dci_clear_stall_sub(sc,
+	at91dci_clear_stall_sub(sc,
 	    (ed->bEndpointAddress & UE_ADDR),
 	    (ed->bmAttributes & UE_XFERTYPE),

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list