Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Dec 2007 01:45:19 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 131196 for review
Message-ID:  <200712190145.lBJ1jJAk008036@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=131196

Change 131196 by hselasky@hselasky_laptop001 on 2007/12/19 01:44:56

	
	Some small updates to the USB bus methods and the USB
	template system.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#79 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_template.c#4 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_template.h#5 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#79 (text+ko) ====

@@ -113,6 +113,7 @@
 struct proc;
 struct usb_device;			/* Linux compat */
 struct cdev;
+struct intr_event;
 
 typedef uint8_t usbd_status_t;
 
@@ -120,8 +121,6 @@
 
 typedef void (usbd_std_root_transfer_func_t)(struct usbd_xfer *, struct usbd_std_root_transfer *);
 
-typedef struct usbd_hw_ep_profile * (usbd_get_hw_ep_profile_t)(struct usbd_device *udev, uint8_t ep_addr);
-
 /* USB modes */
 
 enum {
@@ -161,11 +160,27 @@
 };
 
 struct usbd_bus_methods {
+
+	/* USB Device and Host mode - Mandatory */
+
 	void    (*pipe_init) (struct usbd_device *udev, usb_endpoint_descriptor_t *edesc, struct usbd_pipe *pipe);
 	void    (*do_poll) (struct usbd_bus *);
 	void    (*xfer_setup) (struct usbd_setup_params *parm);
 	void    (*xfer_unsetup) (struct usbd_xfer *xfer);
-	usbd_get_hw_ep_profile_t *get_hw_ep_profile;
+
+	/* USB Device and Host mode - Optional */
+
+	void	(*set_config) (struct usbd_device *udev, usb_config_descriptor_t *cd);
+	void    (*set_address) (struct usbd_device *udev, uint8_t addr);
+
+	/* USB Device mode only - Mandatory */
+
+	void	(*get_hw_ep_profile)(struct usbd_device *udev, const struct usbd_hw_ep_profile **ppf, uint8_t ep_addr);
+	void    (*set_stall) (struct usbd_device *udev, struct usbd_xfer *xfer, struct usbd_pipe *pipe);
+	void    (*clear_stall) (struct usbd_device *udev, struct usbd_pipe *pipe);
+
+	/* USB Device mode only - Optional */
+	void	(*vbus_interrupt) (struct usbd_bus *, uint8_t is_on);
 };
 
 struct usbd_pipe_methods {
@@ -176,11 +191,6 @@
 	void    (*close) (struct usbd_xfer *xfer);
 	void    (*enter) (struct usbd_xfer *xfer);
 	void    (*start) (struct usbd_xfer *xfer);
-
-	/* USB Device mode only: */
-
-	void    (*set_stall) (struct usbd_device *udev, struct usbd_xfer *xfer, struct usbd_pipe *pipe);
-	void    (*clear_stall) (struct usbd_device *udev, struct usbd_pipe *pipe);
 };
 
 struct usbd_port {
@@ -279,13 +289,13 @@
 struct usbd_hw_ep_profile {
 	uint16_t max_frame_size;
 	uint8_t is_simplex:1;
-	uint8_t is_multi_buffer:1;
+	uint8_t support_multi_buffer:1;
 	uint8_t support_bulk:1;
 	uint8_t support_control:1;
 	uint8_t support_interrupt:1;
 	uint8_t support_isochronous:1;
-	uint8_t support_in:1;
-	uint8_t support_out:1;
+	uint8_t support_in:1; /* IN-token is supported */
+	uint8_t support_out:1; /* OUT-token is supported */
 };
 
 struct usbd_sw_ep_scratch {
@@ -303,7 +313,7 @@
 	struct usbd_sw_ep_scratch *ep_max;
 	usb_config_descriptor_t *cd;
 	struct usbd_device *udev;
-	usbd_get_hw_ep_profile_t *get_hw_ep_profile;
+	struct usbd_bus_methods *methods;
 	uint8_t bmOutAlloc[(USB_MAX_ENDPOINTS+15)/16];
 	uint8_t bmInAlloc[(USB_MAX_ENDPOINTS+15)/16];
 };
@@ -391,7 +401,8 @@
 
 	uint8_t	toggle_next:1;		/* next data toggle value */
 	uint8_t	is_stalled:1;		/* set if pipe is stalled */
-	uint8_t	unused:6;
+	uint8_t did_dma_delay:1;	/* set if we waited for DMA */
+	uint8_t	unused:5;
 	uint8_t	iface_index;		/* not used by "default pipe" */
 };
 
@@ -617,6 +628,7 @@
 	LIST_HEAD(, usbd_xfer) dma_head;
 	LIST_HEAD(, usbd_xfer) done_head;
 
+	struct intr_event *done_event;	/* software interrupt event */
 	void   *done_cookie;		/* software interrupt thread cookie */
 	void   *memory_base;
 	struct mtx *priv_mtx;

==== //depot/projects/usb/src/sys/dev/usb/usb_template.c#4 (text+ko) ====

@@ -117,33 +117,41 @@
 		ed->bmAttributes = ted->bmAttributes;
 		USETW(ed->wMaxPacketSize, mps);
 
-		switch (et) {
-		case UE_BULK:
-		case UE_CONTROL:
-			ed->bInterval = 0;	/* not used */
-			break;
-		case UE_INTERRUPT:
-			switch (temp->usb_speed) {
-			case USB_SPEED_LOW:
-			case USB_SPEED_FULL:
-				ed->bInterval = 1;	/* 1 ms */
+		/* setup bInterval parameter */
+
+		if (ted->pIntervals &&
+		    ted->pIntervals->bInterval[temp->usb_speed]) {
+			ed->bInterval =
+			    ted->pIntervals->bInterval[temp->usb_speed];
+		} else {
+			switch (et) {
+			case UE_BULK:
+			case UE_CONTROL:
+				ed->bInterval = 0;	/* not used */
 				break;
-			default:
-				ed->bInterval = 8;	/* 8*125 us */
+			case UE_INTERRUPT:
+				switch (temp->usb_speed) {
+				case USB_SPEED_LOW:
+				case USB_SPEED_FULL:
+					ed->bInterval = 1;	/* 1 ms */
+					break;
+				default:
+					ed->bInterval = 8;	/* 8*125 us */
+					break;
+				}
 				break;
-			}
-			break;
-		default:		/* UE_ISOCHRONOUS */
-			switch (temp->usb_speed) {
-			case USB_SPEED_LOW:
-			case USB_SPEED_FULL:
-				ed->bInterval = 1;	/* 1 ms */
-				break;
-			default:
-				ed->bInterval = 1;	/* 125 us */
+			default:	/* UE_ISOCHRONOUS */
+				switch (temp->usb_speed) {
+				case USB_SPEED_LOW:
+				case USB_SPEED_FULL:
+					ed->bInterval = 1;	/* 1 ms */
+					break;
+				default:
+					ed->bInterval = 1;	/* 125 us */
+					break;
+				}
 				break;
 			}
-			break;
 		}
 	}
 	return;
@@ -406,7 +414,7 @@
 			}
 		}
 		/* get HW endpoint profile */
-		pf = (ues->get_hw_ep_profile) (ues->udev, n);
+		(ues->methods->get_hw_ep_profile) (ues->udev, &pf, n);
 		if (pf == NULL) {
 			/* end of profiles */
 			break;
@@ -624,18 +632,18 @@
 {
 	struct usbd_hw_ep_scratch *ues;
 	struct usbd_sw_ep_scratch *ep;
-	struct usbd_hw_ep_profile *pf;
-	struct usbd_bus *bus;
+	const struct usbd_hw_ep_profile *pf;
+	struct usbd_bus_methods *methods;
 	usb_device_descriptor_t *dd;
 	uint16_t mps;
 
 	if (desc == NULL) {
 		return (USBD_INVAL);
 	}
-	/* get bus structure */
-	bus = udev->bus;
+	/* get bus methods */
+	methods = udev->bus->methods;
 
-	if (bus->methods->get_hw_ep_profile == NULL) {
+	if (methods->get_hw_ep_profile == NULL) {
 		return (USBD_INVAL);
 	}
 	if (desc->bDescriptorType == UDESC_DEVICE) {
@@ -646,7 +654,7 @@
 		dd = (void *)desc;
 
 		/* get HW control endpoint 0 profile */
-		pf = (bus->methods->get_hw_ep_profile) (ues->udev, 0);
+		(methods->get_hw_ep_profile) (ues->udev, &pf, 0);
 		if (pf == NULL) {
 			return (USBD_INVAL);
 		}
@@ -700,7 +708,7 @@
 
 	ues->ep_max = ues->ep;
 	ues->cd = (void *)desc;
-	ues->get_hw_ep_profile = bus->methods->get_hw_ep_profile;
+	ues->methods = methods;
 	ues->udev = udev;
 
 	/* Get all the endpoints we need */

==== //depot/projects/usb/src/sys/dev/usb/usb_template.h#5 (text+ko) ====

@@ -37,9 +37,14 @@
 	uint16_t mps[USB_SPEED_MAX];
 };
 
+struct usb_temp_interval {
+	uint8_t	bInterval[USB_SPEED_MAX];
+};
+
 struct usb_temp_endpoint_desc {
 	const void **ppRawDesc;
 	const struct usb_temp_packet_size *pPacketSize;
+	const struct usb_temp_interval *pIntervals;
 	uint8_t	direction;		/* UE_DIR_IN or UE_DIR_OUT */
 	uint8_t	bmAttributes;
 };



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