PERFORCE change 167305 for review

Sylvestre Gallon syl at FreeBSD.org
Thu Aug 13 19:18:16 UTC 2009


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

Change 167305 by syl at syl_atuin on 2009/08/13 19:17:34

	       Change the code to use generic_roothub_exec.
	       Remove old usb descriptor code.
	       Remove old roothub_exec code.

Affected files ...

.. //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/s3c24xxdci.c#19 edit

Differences ...

==== //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/s3c24xxdci.c#19 (text+ko) ====

@@ -853,483 +853,21 @@
 	.start = s3c24dci_device_nonisoc_start,
 };
 
-/*
- * s3c24dci root control support
- * Simulate a hardware HUB by handling all the necessary requests.
- */
-
-static const struct usb_device_descriptor s3c24dci_devd = {
-	.bLength = sizeof(struct usb_device_descriptor),
-	.bDescriptorType = UDESC_DEVICE,
-	.bcdUSB = {0x00, 0x02},
-	.bDeviceClass = UDCLASS_HUB,
-	.bDeviceSubClass = UDSUBCLASS_HUB,
-	.bDeviceProtocol = UDPROTO_HSHUBSTT,
-	.bMaxPacketSize = 64,
-	.bcdDevice = {0x00, 0x01},
-	.iManufacturer = 1,
-	.iProduct = 2,
-	.bNumConfigurations = 1,
-};
-
-static const struct usb_device_qualifier s3c24dci_odevd = {
-	.bLength = sizeof(struct usb_device_qualifier),
-	.bDescriptorType = UDESC_DEVICE_QUALIFIER,
-	.bcdUSB = {0x00, 0x02},
-	.bDeviceClass = UDCLASS_HUB,
-	.bDeviceSubClass = UDSUBCLASS_HUB,
-	.bDeviceProtocol = UDPROTO_FSHUB,
-	.bMaxPacketSize0 = 0,
-	.bNumConfigurations = 0,
-};
-
-static const struct s3c24dci_config_desc s3c24dci_confd = {
-	.confd = {
-		.bLength = sizeof(struct usb_config_descriptor),
-		.bDescriptorType = UDESC_CONFIG,
-		.wTotalLength[0] = sizeof(s3c24dci_confd),
-		.bNumInterface = 1,
-		.bConfigurationValue = 1,
-		.iConfiguration = 0,
-		.bmAttributes = UC_SELF_POWERED,
-		.bMaxPower = 0,
-	},
-	.ifcd = {
-		.bLength = sizeof(struct usb_interface_descriptor),
-		.bDescriptorType = UDESC_INTERFACE,
-		.bNumEndpoints = 1,
-		.bInterfaceClass = UICLASS_HUB,
-		.bInterfaceSubClass = UISUBCLASS_HUB,
-		.bInterfaceProtocol = UIPROTO_HSHUBSTT,
-	},
-	.endpd = {
-		.bLength = sizeof(struct usb_endpoint_descriptor),
-		.bDescriptorType = UDESC_ENDPOINT,
-		.bEndpointAddress = (UE_DIR_IN | S3C24_DCI_INTR_ENDPT),
-		.bmAttributes = UE_INTERRUPT,
-		.wMaxPacketSize[0] = 8,
-		.bInterval = 255,
-	},
-};
-
-static const struct usb_hub_descriptor_min s3c24dci_hubd = {
-	.bDescLength = sizeof(s3c24dci_hubd),
-	.bDescriptorType = UDESC_HUB,
-	.bNbrPorts = 1,
-	.wHubCharacteristics[0] =
-	(UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) & 0xFF,
-	.wHubCharacteristics[1] =
-	(UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL) >> 8,
-	.bPwrOn2PwrGood = 50,
-	.bHubContrCurrent = 0,
-	.DeviceRemovable = {0},		/* port is removable */
-};
-
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
-#define	STRING_VENDOR \
-  'S', 0, 'A', 0, 'M', 0, 'S', 0, 'U', 0, 'N', 0, 'G', 0
-
-#define	STRING_PRODUCT \
-  'D', 0, 'C', 0, 'I', 0, ' ', 0, 'R', 0, \
-  'o', 0, 'o', 0, 't', 0, ' ', 0, 'H', 0, \
-  'U', 0, 'B', 0,
-
-USB_MAKE_STRING_DESC(STRING_LANG, s3c24dci_langtab);
-USB_MAKE_STRING_DESC(STRING_VENDOR, s3c24dci_vendor);
-USB_MAKE_STRING_DESC(STRING_PRODUCT, s3c24dci_product);
-
 static usb_error_t
 s3c24dci_roothub_exec(struct usb_device *udev,
     struct usb_device_request *req, const void **pptr, uint16_t *plength)
 {
 	struct s3c24dci_softc *sc = S3C24_DCI_BUS2SC(udev->bus);
-	const void *ptr;
-	uint16_t len;
-	uint16_t value;
-	uint16_t index;
-	usb_error_t err;
-
-	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
-
-	/* buffer reset */
-	ptr = (const void *)&sc->sc_hub_temp;
-	len = 0;
-	err = 0;
-
-	value = UGETW(req->wValue);
-	index = UGETW(req->wIndex);
-
-	/* demultiplex the control request */
-
-	switch (req->bmRequestType) {
-	case UT_READ_DEVICE:
-		switch (req->bRequest) {
-		case UR_GET_DESCRIPTOR:
-			goto tr_handle_get_descriptor;
-		case UR_GET_CONFIG:
-			goto tr_handle_get_config;
-		case UR_GET_STATUS:
-			goto tr_handle_get_status;
-		default:
-			goto tr_stalled;
-		}
-		break;
-	
-	case UT_WRITE_DEVICE:
-		switch (req->bRequest) {
-		case UR_SET_ADDRESS:
-			goto tr_handle_set_address;
-		case UR_SET_CONFIG:
-			goto tr_handle_set_config;
-		case UR_CLEAR_FEATURE:
-			goto tr_valid;	/* nop */
-		case UR_SET_DESCRIPTOR:
-			goto tr_valid;	/* nop */
-		case UR_SET_FEATURE:
-		default:
-			goto tr_stalled;
-		}
-		break;
-	
-	case UT_WRITE_ENDPOINT:
-		switch (req->bRequest) {
-		case UR_CLEAR_FEATURE:
-			switch (UGETW(req->wValue)) {
-			case UF_ENDPOINT_HALT:
-				goto tr_handle_clear_halt;
-			case UF_DEVICE_REMOTE_WAKEUP:
-				goto tr_handle_clear_wakeup;
-			default:
-				goto tr_stalled;
-			}
-			break;
-		case UR_SET_FEATURE:
-			switch (UGETW(req->wValue)) {
-			case UF_ENDPOINT_HALT:
-				goto tr_handle_set_halt;
-			case UF_DEVICE_REMOTE_WAKEUP:
-				goto tr_handle_set_wakeup;
-			default:
-				goto tr_stalled;
-			}
-			break;
-		case UR_SYNCH_FRAME:
-			goto tr_valid;	/* nop */
-		default:
-			goto tr_stalled;
-		}
-		break;
-
-	case UT_READ_ENDPOINT:
-		switch (req->bRequest) {
-		case UR_GET_STATUS:
-			goto tr_handle_get_ep_status;
-		default:
-			goto tr_stalled;
-		}
-		break;
-
-	case UT_WRITE_INTERFACE:
-		switch (req->bRequest) {
-		case UR_SET_INTERFACE:
-			goto tr_handle_set_interface;
-		case UR_CLEAR_FEATURE:
-			goto tr_valid;	/* nop */
-		case UR_SET_FEATURE:
-		default:
-			goto tr_stalled;
-		}
-		break;
-
-	case UT_READ_INTERFACE:
-		switch (req->bRequest) {
-		case UR_GET_INTERFACE:
-			goto tr_handle_get_interface;
-		case UR_GET_STATUS:
-			goto tr_handle_get_iface_status;
-		default:
-			goto tr_stalled;
-		}
-		break;
-
-	case UT_WRITE_CLASS_INTERFACE:
-	case UT_WRITE_VENDOR_INTERFACE:
-		/* XXX forward */
-		break;
-
-	case UT_READ_CLASS_INTERFACE:
-	case UT_READ_VENDOR_INTERFACE:
-		/* XXX forward */
-		break;
-
-	case UT_WRITE_CLASS_DEVICE:
-		switch (req->bRequest) {
-		case UR_CLEAR_FEATURE:
-			goto tr_valid;
-		case UR_SET_DESCRIPTOR:
-		case UR_SET_FEATURE:
-			break;
-		default:
-			goto tr_stalled;
-		}
-		break;
-
-	case UT_WRITE_CLASS_OTHER:
-		switch (req->bRequest) {
-		case UR_CLEAR_FEATURE:
-			goto tr_handle_clear_port_feature;
-		case UR_SET_FEATURE:
-			goto tr_handle_set_port_feature;
-		case UR_CLEAR_TT_BUFFER:
-		case UR_RESET_TT:
-		case UR_STOP_TT:
-			goto tr_valid;
-
-		default:
-			goto tr_stalled;
-		}
-		break;
-
-	case UT_READ_CLASS_OTHER:
-		switch (req->bRequest) {
-		case UR_GET_TT_STATE:
-			goto tr_handle_get_tt_state;
-		case UR_GET_STATUS:
-			goto tr_handle_get_port_status;
-		default:
-			goto tr_stalled;
-		}
-		break;
-
-	case UT_READ_CLASS_DEVICE:
-		switch (req->bRequest) {
-		case UR_GET_DESCRIPTOR:
-			goto tr_handle_get_class_descriptor;
-		case UR_GET_STATUS:
-			goto tr_handle_get_class_status;
-
-		default:
-			goto tr_stalled;
-		}
-		break;
-	default:
-		goto tr_stalled;
-	}
-	goto tr_valid;
-
-tr_handle_get_descriptor:
-	switch (value >> 8) {
-	case UDESC_DEVICE:
-		if (value & 0xff) {
-			goto tr_stalled;
-		}
-		len = sizeof(s3c24dci_devd);
-		ptr = (const void *)&s3c24dci_devd;
-		goto tr_valid;
-	case UDESC_CONFIG:
-		if (value & 0xff) {
-			goto tr_stalled;
-		}
-		len = sizeof(s3c24dci_confd);
-		ptr = (const void *)&s3c24dci_confd;
-		goto tr_valid;
-	case UDESC_STRING:
-		switch (value & 0xff) {
-		case 0:		/* Language table */
-			len = sizeof(s3c24dci_langtab);
-			ptr = (const void *)&s3c24dci_langtab;
-			goto tr_valid;
-
-		case 1:		/* Vendor */
-			len = sizeof(s3c24dci_vendor);
-			ptr = (const void *)&s3c24dci_vendor;
-			goto tr_valid;
-
-		case 2:		/* Product */
-			len = sizeof(s3c24dci_product);
-			ptr = (const void *)&s3c24dci_product;
-			goto tr_valid;
-		default:
-			break;
-		}
-		break;
-	default:
-		goto tr_stalled;
-	}
-	goto tr_stalled;
-	
-tr_handle_get_config:
-	len = 1;
-	sc->sc_hub_temp.wValue[0] = sc->sc_conf;
-	goto tr_valid;
-
-tr_handle_get_status:
-	len = 2;
-	USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED);
-	goto tr_valid;
-
-tr_handle_set_address:
-	if (value & 0xFF00) {
-		goto tr_stalled;
-	}
-	sc->sc_rt_addr = value;
-	goto tr_valid;
-
-tr_handle_set_config:
-	if (value >= 2) {
-		goto tr_stalled;
-	}
-	sc->sc_conf = value;
-	goto tr_valid;
-
-tr_handle_get_interface:
-	len = 1;
-	sc->sc_hub_temp.wValue[0] = 0;
-	goto tr_valid;
-
-tr_handle_get_tt_state:
-tr_handle_get_class_status:
-tr_handle_get_iface_status:
-tr_handle_get_ep_status:
-	len = 2;
-	USETW(sc->sc_hub_temp.wValue, 0);
-	goto tr_valid;
-
-tr_handle_set_halt:
-tr_handle_set_interface:
-tr_handle_set_wakeup:
-tr_handle_clear_wakeup:
-tr_handle_clear_halt:
-	goto tr_valid;
-
-tr_handle_clear_port_feature:
-	if (index != 1) {
-		goto tr_stalled;
-	}
-	DPRINTFN(9, "UR_CLEAR_PORT_FEATURE on port %d\n", index);
-
-	switch (value) {
-	case UHF_PORT_SUSPEND:
-		s3c24dci_wakeup_peer(sc);
-		break;
-
-	case UHF_PORT_ENABLE:
-		sc->sc_flags.port_enabled = 0;
-		break;
-
-	case UHF_PORT_TEST:
-	case UHF_PORT_INDICATOR:
-	case UHF_C_PORT_ENABLE:
-	case UHF_C_PORT_OVER_CURRENT:
-	case UHF_C_PORT_RESET:
-		/* nops */
-		break;
-	case UHF_PORT_POWER:
-		sc->sc_flags.port_powered = 0;
-		s3c24dci_pull_down(sc);
-		s3c24dci_clocks_off(sc);
-		break;
-	case UHF_C_PORT_CONNECTION:
-		sc->sc_flags.change_connect = 0;
-		break;
-	case UHF_C_PORT_SUSPEND:
-		sc->sc_flags.change_suspend = 0;
-		break;
-	default:
-		err = USB_ERR_IOERROR;
-		goto done;
-	}
-	goto tr_valid;
-
-tr_handle_set_port_feature:
-	if (index != 1) {
-		goto tr_stalled;
-	}
-	DPRINTFN(9, "UR_SET_PORT_FEATURE\n");
-
-	switch (value) {
-	case UHF_PORT_ENABLE:
-		sc->sc_flags.port_enabled = 1;
-		break;
-	case UHF_PORT_SUSPEND:
-	case UHF_PORT_RESET:
-	case UHF_PORT_TEST:
-	case UHF_PORT_INDICATOR:
-		/* nops */
-		break;
-	case UHF_PORT_POWER:
-		sc->sc_flags.port_powered = 1;
-		break;
-	default:
-		err = USB_ERR_IOERROR;
-		goto done;
-	}
-	goto tr_valid;
-	
-tr_handle_get_port_status:
-
-	DPRINTFN(9, "UR_GET_PORT_STATUS\n");
-
-	if (index != 1) {
-		goto tr_stalled;
-	}
-	if (sc->sc_flags.status_vbus) {
-		s3c24dci_clocks_on(sc);
-		s3c24dci_pull_up(sc);
-	} else {
-		s3c24dci_pull_down(sc);
-		s3c24dci_clocks_off(sc);
-	}
-
-	/* Select FULL-speed and Device Side Mode */
-
-	value = UPS_PORT_MODE_DEVICE;
-
-	if (sc->sc_flags.port_powered) {
-		value |= UPS_PORT_POWER;
-	}
-	if (sc->sc_flags.port_enabled) {
-		value |= UPS_PORT_ENABLED;
-	}
-	if (sc->sc_flags.status_vbus &&
-	    sc->sc_flags.status_bus_reset) {
-		value |= UPS_CURRENT_CONNECT_STATUS;
-	}
-	if (sc->sc_flags.status_suspend) {
-		value |= UPS_SUSPEND;
-	}
-	USETW(sc->sc_hub_temp.ps.wPortStatus, value);
-
-	value = 0;
-
-	if (sc->sc_flags.change_connect) {
-		value |= UPS_C_CONNECT_STATUS;
-
-	}
-	if (sc->sc_flags.change_suspend) {
-		value |= UPS_C_SUSPEND;
-	}
-	USETW(sc->sc_hub_temp.ps.wPortChange, value);
-	len = sizeof(sc->sc_hub_temp.ps);
-	goto tr_valid;
-
-tr_handle_get_class_descriptor:
-	if (value & 0xFF) {
-		goto tr_stalled;
-	}
-	ptr = (const void *)&s3c24dci_hubd;
-	len = sizeof(s3c24dci_hubd);
-	goto tr_valid;
-
-tr_stalled:
-	err = USB_ERR_STALLED;
-tr_valid:
-done:
-	*plength = len;
-	*pptr = ptr;
-	return (err);
+	static const struct usb_roothub_fops fops = {
+	    DEFAULT_ROOTHUB,
+	    .handle_clocks_on = (usb_clocks_fops_t)&s3c24dci_clocks_on,
+	    .handle_clocks_off = (usb_clocks_fops_t)&s3c24dci_clocks_off,
+	    .handle_pull_up = (usb_clocks_fops_t)&s3c24dci_pull_up,
+	    .handle_pull_down = (usb_clocks_fops_t)&s3c24dci_pull_down,
+	    .handle_wakeup_peer = (usb_clocks_fops_t)&s3c24dci_wakeup_peer,
+	};
+	return generic_roothub_exec((struct usb_generic_softc *)sc, &fops, req, 
+	    pptr, plength);
 }
 
 static void


More information about the p4-projects mailing list