Lines Matching +full:raw +full:- +full:x +full:- +full:min

56  * the standard device requests in table 9-3 from the universal serial bus
144 /* Setup packet definition used to read raw data from USB line */
167 "bmRT 0x%02x, bR 0x%02x, wV 0x%04x, wI 0x%04x, wL 0x%04x", in usb_print_setup()
168 setup->bmRequestType, in usb_print_setup()
169 setup->bRequest, in usb_print_setup()
170 setup->wValue, in usb_print_setup()
171 setup->wIndex, in usb_print_setup()
172 setup->wLength); in usb_print_setup()
216 uint32_t type = setup->RequestType.type; in usb_handle_request()
251 usb_dev.data_buf_residue -= chunk; in usb_data_to_host()
262 /* Transfers a zero-length packet */ in usb_data_to_host()
289 LOG_DBG("ep 0x%02x, status 0x%02x", ep, ep_status); in usb_handle_control_transfer()
304 setup->bmRequestType = setup_raw.bmRequestType; in usb_handle_control_transfer()
305 setup->bRequest = setup_raw.bRequest; in usb_handle_control_transfer()
306 setup->wValue = sys_le16_to_cpu(setup_raw.wValue); in usb_handle_control_transfer()
307 setup->wIndex = sys_le16_to_cpu(setup_raw.wIndex); in usb_handle_control_transfer()
308 setup->wLength = sys_le16_to_cpu(setup_raw.wLength); in usb_handle_control_transfer()
321 if (setup->wLength > CONFIG_USB_REQUEST_BUFFER_SIZE) { in usb_handle_control_transfer()
328 if (setup->wLength) { in usb_handle_control_transfer()
330 usb_dev.data_buf_len = setup->wLength; in usb_handle_control_transfer()
331 usb_dev.data_buf_residue = setup->wLength; in usb_handle_control_transfer()
346 usb_dev.data_buf_residue = MIN(usb_dev.data_buf_len, in usb_handle_control_transfer()
347 setup->wLength); in usb_handle_control_transfer()
348 /* Send first part (possibly a zero-length status message) */ in usb_handle_control_transfer()
353 /* absorb zero-length status message */ in usb_handle_control_transfer()
372 usb_dev.data_buf_residue -= chunk; in usb_handle_control_transfer()
468 type = USB_GET_DESCRIPTOR_TYPE(setup->wValue); in usb_get_descriptor()
469 index = USB_GET_DESCRIPTOR_INDEX(setup->wValue); in usb_get_descriptor()
512 LOG_DBG("Desc %x not found!", setup->wValue); in usb_get_descriptor()
518 * @brief Get 32-bit endpoint bitmask from index
520 * In the returned 32-bit word, the bit positions in the lower 16 bits
526 * @return 32-bit bitmask
535 LOG_ERR("Endpoint 0x%02x is invalid", ep); in get_ep_bm_from_addr()
564 ep_cfg.ep_addr = ep_desc->bEndpointAddress; in set_endpoint()
565 ep_cfg.ep_mps = sys_le16_to_cpu(ep_desc->wMaxPacketSize); in set_endpoint()
566 ep_cfg.ep_type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK; in set_endpoint()
568 LOG_DBG("Set endpoint 0x%x type %u MPS %u", in set_endpoint()
572 ep_bm = get_ep_bm_from_addr(ep_desc->bEndpointAddress); in set_endpoint()
582 if (ret == -EALREADY) { in set_endpoint()
583 LOG_WRN("Endpoint 0x%02x already configured", ep_cfg.ep_addr); in set_endpoint()
585 LOG_ERR("Failed to configure endpoint 0x%02x", ep_cfg.ep_addr); in set_endpoint()
592 if (ret == -EALREADY) { in set_endpoint()
593 LOG_WRN("Endpoint 0x%02x already enabled", ep_cfg.ep_addr); in set_endpoint()
595 LOG_ERR("Failed to enable endpoint 0x%02x", ep_cfg.ep_addr); in set_endpoint()
613 if (ret == -EALREADY) { in disable_endpoint()
614 LOG_WRN("Endpoint 0x%02x already disabled", ep_addr); in disable_endpoint()
616 LOG_ERR("Failed to disable endpoint 0x%02x", ep_addr); in disable_endpoint()
641 ep_cfg.ep_addr = ep_desc->bEndpointAddress; in reset_endpoint()
642 ep_cfg.ep_type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK; in reset_endpoint()
644 LOG_DBG("Reset endpoint 0x%02x type %u", in reset_endpoint()
659 LOG_DBG("Disable endpoint 0x%02x", ep_desc->bEndpointAddress); in usb_eps_reconfigure()
662 LOG_DBG("Enable endpoint 0x%02x", ep_desc->bEndpointAddress); in usb_eps_reconfigure()
687 LOG_DBG("Set Configuration %u request", setup->wValue); in usb_set_configuration()
689 if (setup->wValue == 0U) { in usb_set_configuration()
691 usb_dev.configuration = setup->wValue; in usb_set_configuration()
706 if (cur_config == setup->wValue) { in usb_set_configuration()
719 if ((cur_config != setup->wValue) || in usb_set_configuration()
737 usb_dev.configuration = setup->wValue; in usb_set_configuration()
743 LOG_DBG("Set Configuration %u failed", setup->wValue); in usb_set_configuration()
765 LOG_DBG("Set Interface %u alternate %u", setup->wIndex, setup->wValue); in usb_set_interface()
774 if (cur_iface == setup->wIndex && in usb_set_interface()
775 cur_alt_setting == setup->wValue) { in usb_set_interface()
776 ret = usb_set_alt_setting(setup->wIndex, in usb_set_interface()
777 setup->wValue); in usb_set_interface()
785 if (cur_iface == setup->wIndex) { in usb_set_interface()
788 setup->wValue); in usb_set_interface()
816 if (cur_iface == setup->wIndex) { in usb_get_interface()
819 setup->wIndex, data[0]); in usb_get_interface()
857 switch (setup->bRequest) { in usb_handle_std_device_req()
874 switch (setup->bRequest) { in usb_handle_std_device_req()
876 LOG_DBG("Set Address %u request", setup->wValue); in usb_handle_std_device_req()
877 return !usb_dc_set_address(setup->wValue); in usb_handle_std_device_req()
886 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in usb_handle_std_device_req()
897 if (setup->wValue == USB_SFS_REMOTE_WAKEUP) { in usb_handle_std_device_req()
909 LOG_DBG("Unsupported bmRequestType 0x%02x bRequest 0x%02x", in usb_handle_std_device_req()
910 setup->bmRequestType, setup->bRequest); in usb_handle_std_device_req()
922 * @return true if interface exists - valid
933 if (interface < cfg_descr->bNumInterfaces) { in is_interface_valid()
961 (!is_interface_valid((uint8_t)setup->wIndex))) { in usb_handle_std_interface_req()
966 switch (setup->bRequest) { in usb_handle_std_interface_req()
981 if (setup->bRequest == USB_SREQ_SET_INTERFACE) { in usb_handle_std_interface_req()
987 LOG_DBG("Unsupported bmRequestType 0x%02x bRequest 0x%02x", in usb_handle_std_interface_req()
988 setup->bmRequestType, setup->bRequest); in usb_handle_std_interface_req()
1001 * @return true if endpoint exists - valid
1013 ep_data = cfg_data->endpoint; in is_ep_valid()
1015 for (uint8_t n = 0; n < cfg_data->num_endpoints; n++) { in is_ep_valid()
1028 uint8_t ep = setup->wIndex; in usb_get_status_endpoint()
1044 /* bit 0 - Endpoint halted or not */ in usb_get_status_endpoint()
1057 uint8_t ep = setup->wIndex; in usb_halt_endpoint_req()
1073 LOG_INF("Set halt ep 0x%02x", ep); in usb_halt_endpoint_req()
1079 LOG_INF("Clear halt ep 0x%02x", ep); in usb_halt_endpoint_req()
1106 if (setup->bRequest == USB_SREQ_GET_STATUS) { in usb_handle_std_endpoint_req()
1110 switch (setup->bRequest) { in usb_handle_std_endpoint_req()
1112 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in usb_handle_std_endpoint_req()
1117 if (setup->wValue == USB_SFS_ENDPOINT_HALT) { in usb_handle_std_endpoint_req()
1126 LOG_DBG("Unsupported bmRequestType 0x%02x bRequest 0x%02x", in usb_handle_std_endpoint_req()
1127 setup->bmRequestType, setup->bRequest); in usb_handle_std_endpoint_req()
1161 switch (setup->RequestType.recipient) { in usb_handle_standard_request()
1164 rc = -EINVAL; in usb_handle_standard_request()
1169 rc = -EINVAL; in usb_handle_standard_request()
1174 rc = -EINVAL; in usb_handle_standard_request()
1178 rc = -EINVAL; in usb_handle_standard_request()
1219 ep_data = cfg_data->endpoint; in foreach_ep()
1221 for (uint8_t n = 0; n < cfg_data->num_endpoints; n++) { in foreach_ep()
1239 ret = usb_dc_ep_disable(ep_data->ep_addr); in disable_interface_ep()
1242 ep_bm = get_ep_bm_from_addr(ep_data->ep_addr); in disable_interface_ep()
1263 if (cfg_data->cb_usb_status) { in forward_status_cb()
1264 cfg_data->cb_usb_status(cfg_data, status, param); in forward_status_cb()
1277 * zephyr,usb-device property that points to the usb device controller node.
1278 * Additionally the usb device controller node should have a vbus-gpios
1284 * zephyr,usb-device = &usbd;
1288 * vbus-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
1304 LOG_DBG("USB requires GPIO. Device %s is not ready!", gpio_dev.port->name); in usb_vbus_set()
1305 return -ENODEV; in usb_vbus_set()
1394 if (ret == -EAGAIN) { in usb_write()
1395 LOG_WRN("Failed to write endpoint buffer 0x%02x", ep); in usb_write()
1399 } while (ret == -EAGAIN && tries--); in usb_write()
1440 return -EACCES; in usb_wakeup_request()
1442 return -ENOTSUP; in usb_wakeup_request()
1464 LOG_DBG("bRequest 0x%02x, wIndex 0x%04x", in class_handler()
1465 pSetup->bRequest, pSetup->wIndex); in class_handler()
1468 iface = &cfg_data->interface; in class_handler()
1469 if_descr = cfg_data->interface_descriptor; in class_handler()
1478 if (iface->class_handler && in class_handler()
1479 if_descr->bInterfaceNumber == (pSetup->wIndex & 0xFF)) { in class_handler()
1480 return iface->class_handler(pSetup, len, data); in class_handler()
1484 return -ENOTSUP; in class_handler()
1493 LOG_DBG("bRequest 0x%02x, wIndex 0x%04x", in custom_handler()
1494 pSetup->bRequest, pSetup->wIndex); in custom_handler()
1497 iface = &cfg_data->interface; in custom_handler()
1498 if_descr = cfg_data->interface_descriptor; in custom_handler()
1507 if (iface->custom_handler == NULL) { in custom_handler()
1511 if (if_descr->bInterfaceNumber == (pSetup->wIndex & 0xFF)) { in custom_handler()
1512 return iface->custom_handler(pSetup, len, data); in custom_handler()
1521 if (if_descr->bInterfaceClass == USB_BCC_AUDIO) { in custom_handler()
1522 (void)iface->custom_handler(pSetup, len, data); in custom_handler()
1527 return -ENOTSUP; in custom_handler()
1535 LOG_DBG("bRequest 0x%02x, wIndex 0x%04x", in vendor_handler()
1536 pSetup->bRequest, pSetup->wIndex); in vendor_handler()
1545 iface = &cfg_data->interface; in vendor_handler()
1546 if (iface->vendor_handler) { in vendor_handler()
1547 if (!iface->vendor_handler(pSetup, len, data)) { in vendor_handler()
1553 return -ENOTSUP; in vendor_handler()
1561 ep_data = cfg_data->endpoint; in composite_setup_ep_cb()
1562 for (uint8_t n = 0; n < cfg_data->num_endpoints; n++) { in composite_setup_ep_cb()
1563 LOG_DBG("set cb, ep: 0x%x", ep_data[n].ep_addr); in composite_setup_ep_cb()
1566 return -1; in composite_setup_ep_cb()
1609 ret = -EALREADY; in usb_enable()
1622 ret = -1; in usb_enable()
1648 if (dev_desc->bDescriptorType != USB_DESC_DEVICE || in usb_enable()
1649 dev_desc->bMaxPacketSize0 == 0) { in usb_enable()
1651 ret = -EINVAL; in usb_enable()
1656 usb_dev.mps0 = dev_desc->bMaxPacketSize0; in usb_enable()