Date: Wed, 12 Aug 2009 18:34:06 GMT From: Sylvestre Gallon <syl@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 167253 for review Message-ID: <200908121834.n7CIY6J1033878@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=167253 Change 167253 by syl@syl_atuin on 2009/08/12 18:33:27 Implement at91dci dependant get_port_status. 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/at91dci.c#12 edit Differences ... ==== //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/at91dci.c#12 (text+ko) ==== @@ -1580,426 +1580,17 @@ .start = at91dci_device_isoc_fs_start, }; -/*------------------------------------------------------------------------* - * at91dci root control support - *------------------------------------------------------------------------* - * Simulate a hardware HUB by handling all the necessary requests. - *------------------------------------------------------------------------*/ - -static const struct usb_device_descriptor at91dci_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 at91dci_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 at91dci_config_desc at91dci_confd = { - .confd = { - .bLength = sizeof(struct usb_config_descriptor), - .bDescriptorType = UDESC_CONFIG, - .wTotalLength[0] = sizeof(at91dci_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 | AT9100_DCI_INTR_ENDPT), - .bmAttributes = UE_INTERRUPT, - .wMaxPacketSize[0] = 8, - .bInterval = 255, - }, -}; - -static const struct usb_hub_descriptor_min at91dci_hubd = { - .bDescLength = sizeof(at91dci_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 \ - 'A', 0, 'T', 0, 'M', 0, 'E', 0, 'L', 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, at91dci_langtab); -USB_MAKE_STRING_DESC(STRING_VENDOR, at91dci_vendor); -USB_MAKE_STRING_DESC(STRING_PRODUCT, at91dci_product); - static usb_error_t -at91dci_roothub_exec(struct usb_device *udev, - struct usb_device_request *req, const void **pptr, uint16_t *plength) +at91dci_get_port_status(struct usb_generic_softc *gensc, + struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, + uint16_t *index) { - struct at91dci_softc *sc = AT9100_DCI_BUS2SC(udev->bus); - struct usb_roothub_fops fops; - - bzero(&fops, sizeof(struct usb_roothub_fops)); - fops.handle_clocks_on = (usb_clocks_fops_t)&at91dci_clocks_on; - fops.handle_clocks_off = (usb_clocks_fops_t)&at91dci_clocks_off; - fops.handle_pull_up = (usb_clocks_fops_t)&at91dci_pull_up; - fops.handle_pull_down = (usb_clocks_fops_t)&at91dci_pull_down; - fops.handle_wakeup_peer = (usb_clocks_fops_t)&at91dci_wakeup_peer; - return generic_roothub_exec((struct usb_generic_softc *)sc, &fops, req, - pptr, plength); -/* USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); - - ptr = (const void *)&sc->sc_hub_temp; - len = 0; - err = 0; - - value = UGETW(req->wValue); - index = UGETW(req->wIndex); - - - 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; - case UR_SET_DESCRIPTOR: - goto tr_valid; - 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; - default: - goto tr_stalled; - } - break; + struct at91dci_softc *sc = (struct at91dci_softc *)gensc; - 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; - 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: - break; - - case UT_READ_CLASS_INTERFACE: - case UT_READ_VENDOR_INTERFACE: - 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(at91dci_devd); - ptr = (const void *)&at91dci_devd; - goto tr_valid; - case UDESC_CONFIG: - if (value & 0xff) { - goto tr_stalled; - } - len = sizeof(at91dci_confd); - ptr = (const void *)&at91dci_confd; - goto tr_valid; - case UDESC_STRING: - switch (value & 0xff) { - case 0: - len = sizeof(at91dci_langtab); - ptr = (const void *)&at91dci_langtab; - goto tr_valid; - - case 1: - len = sizeof(at91dci_vendor); - ptr = (const void *)&at91dci_vendor; - goto tr_valid; - - case 2: - len = sizeof(at91dci_product); - ptr = (const void *)&at91dci_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: - at91dci_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: - break; - case UHF_PORT_POWER: - sc->sc_flags.port_powered = 0; - at91dci_pull_down(sc); - at91dci_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: - 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 (*index != 1) { + return (USB_ERR_STALLED); } if (sc->sc_flags.status_vbus) { at91dci_clocks_on(sc); @@ -2009,27 +1600,27 @@ at91dci_clocks_off(sc); } - value = UPS_PORT_MODE_DEVICE; + *value = UPS_PORT_MODE_DEVICE; if (sc->sc_flags.port_powered) { - value |= UPS_PORT_POWER; + *value |= UPS_PORT_POWER; } if (sc->sc_flags.port_enabled) { - value |= UPS_PORT_ENABLED; + *value |= UPS_PORT_ENABLED; } if (sc->sc_flags.status_vbus && sc->sc_flags.status_bus_reset) { - value |= UPS_CURRENT_CONNECT_STATUS; + *value |= UPS_CURRENT_CONNECT_STATUS; } if (sc->sc_flags.status_suspend) { - value |= UPS_SUSPEND; + *value |= UPS_SUSPEND; } - USETW(sc->sc_hub_temp.ps.wPortStatus, value); + USETW(sc->sc_hub_temp.ps.wPortStatus, *value); - value = 0; + *value = 0; if (sc->sc_flags.change_connect) { - value |= UPS_C_CONNECT_STATUS; + *value |= UPS_C_CONNECT_STATUS; if (sc->sc_flags.status_vbus && sc->sc_flags.status_bus_reset) { @@ -2037,27 +1628,29 @@ } } if (sc->sc_flags.change_suspend) { - value |= UPS_C_SUSPEND; + *value |= UPS_C_SUSPEND; } - USETW(sc->sc_hub_temp.ps.wPortChange, value); - len = sizeof(sc->sc_hub_temp.ps); - goto tr_valid; + USETW(sc->sc_hub_temp.ps.wPortChange, *value); + *len = sizeof(sc->sc_hub_temp.ps); + return (0); +} -tr_handle_get_class_descriptor: - if (value & 0xFF) { - goto tr_stalled; - } - ptr = (const void *)&at91dci_hubd; - len = sizeof(at91dci_hubd); - goto tr_valid; +static usb_error_t +at91dci_roothub_exec(struct usb_device *udev, + struct usb_device_request *req, const void **pptr, uint16_t *plength) +{ + struct at91dci_softc *sc = AT9100_DCI_BUS2SC(udev->bus); + struct usb_roothub_fops fops; -tr_stalled: - err = USB_ERR_STALLED; -tr_valid: -done: - *plength = len; - *pptr = ptr; - return (err);*/ + bzero(&fops, sizeof(struct usb_roothub_fops)); + fops.handle_get_port_status = &at91dci_get_port_status; + fops.handle_clocks_on = (usb_clocks_fops_t)&at91dci_clocks_on; + fops.handle_clocks_off = (usb_clocks_fops_t)&at91dci_clocks_off; + fops.handle_pull_up = (usb_clocks_fops_t)&at91dci_pull_up; + fops.handle_pull_down = (usb_clocks_fops_t)&at91dci_pull_down; + fops.handle_wakeup_peer = (usb_clocks_fops_t)&at91dci_wakeup_peer; + return generic_roothub_exec((struct usb_generic_softc *)sc, &fops, req, + pptr, plength); } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908121834.n7CIY6J1033878>