Modify the hub to decouple from xhci.
This commit is contained in:
parent
513b74b845
commit
47a330b08f
|
@ -8,9 +8,16 @@ File name: usbh_hub.c
|
|||
Description: adopt cherry USB to XiZi AIOT.
|
||||
Others: CherryUSB third-party/cherryusb/class/hub/usbh_hub.c for references
|
||||
https://gitee.com/phytium_embedded/phytium-free-rtos-sdk/blob/master/third-party/cherryusb/class/hub/usbh_hub.c
|
||||
|
||||
History:
|
||||
1. Date: 2024-06-24
|
||||
Author: AIIT XUOS Lab
|
||||
Modification: Modify the hub to decouple from xhci.
|
||||
*************************************************/
|
||||
|
||||
#include "usbh_hub.h"
|
||||
#include "usb_def.h"
|
||||
|
||||
|
||||
#define DEV_FORMAT "/usb%d/hub%d"
|
||||
|
||||
|
@ -96,7 +103,7 @@ static int _usbh_hub_get_hub_descriptor(struct usbh_hub *hub, uint8_t *buffer)
|
|||
setup->wIndex = 0;
|
||||
setup->wLength = USB_SIZEOF_HUB_DESC;
|
||||
|
||||
ret = usbh_control_transfer(hub->parent->ep0, setup, hub->g_hub_buf);
|
||||
ret = usbh_control_transfer_xiuos(hub->parent, hub->parent->ep0, setup, hub->g_hub_buf);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -117,7 +124,7 @@ static int _usbh_hub_get_status(struct usbh_hub *hub, uint8_t *buffer)
|
|||
setup->wIndex = 0;
|
||||
setup->wLength = 2;
|
||||
|
||||
ret = usbh_control_transfer(hub->parent->ep0, setup, hub->g_hub_buf);
|
||||
ret = usbh_control_transfer_xiuos(hub->parent, hub->parent->ep0, setup, hub->g_hub_buf);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -139,7 +146,7 @@ static int _usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct h
|
|||
setup->wIndex = port;
|
||||
setup->wLength = 4;
|
||||
|
||||
ret = usbh_control_transfer(hub->parent->ep0, setup, hub->g_hub_buf);
|
||||
ret = usbh_control_transfer_xiuos(hub->parent, hub->parent->ep0, setup, hub->g_hub_buf);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -159,7 +166,7 @@ static int _usbh_hub_set_feature(struct usbh_hub *hub, uint8_t port, uint8_t fea
|
|||
setup->wIndex = port;
|
||||
setup->wLength = 0;
|
||||
|
||||
return usbh_control_transfer(hub->parent->ep0, setup, NULL);
|
||||
return usbh_control_transfer_xiuos(hub->parent, hub->parent->ep0, setup, NULL);
|
||||
}
|
||||
|
||||
static int _usbh_hub_clear_feature(struct usbh_hub *hub, uint8_t port, uint8_t feature)
|
||||
|
@ -174,7 +181,7 @@ static int _usbh_hub_clear_feature(struct usbh_hub *hub, uint8_t port, uint8_t f
|
|||
setup->wIndex = port;
|
||||
setup->wLength = 0;
|
||||
|
||||
return usbh_control_transfer(hub->parent->ep0, setup, NULL);
|
||||
return usbh_control_transfer_xiuos(hub->parent, hub->parent->ep0, setup, NULL);
|
||||
}
|
||||
|
||||
static int _usbh_hub_set_depth(struct usbh_hub *hub, uint16_t depth)
|
||||
|
@ -189,7 +196,7 @@ static int _usbh_hub_set_depth(struct usbh_hub *hub, uint16_t depth)
|
|||
setup->wIndex = 0;
|
||||
setup->wLength = 0;
|
||||
|
||||
return usbh_control_transfer(hub->parent->ep0, setup, NULL);
|
||||
return usbh_control_transfer_xiuos(hub->parent, hub->parent->ep0, setup, NULL);
|
||||
}
|
||||
|
||||
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
|
||||
|
@ -378,7 +385,7 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||
USB_LOG_RAW("Register HUB Class:%s for USB-%d\r\n", hport->config.intf[intf].devname, usb->id);
|
||||
|
||||
hub->int_buffer = hub->g_hub_intbuf[hub->index - 1];
|
||||
usbh_int_urb_fill(&hub->intin_urb, hub->intin, hub->int_buffer, 1, 0, hub_int_complete_callback, hub);
|
||||
usbh_int_urb_fill_xiuos(&hub->intin_urb, hub->parent, hub->intin, hub->int_buffer, 1, 0, hub_int_complete_callback, hub);
|
||||
usbh_submit_urb(&hub->intin_urb);
|
||||
return 0;
|
||||
}
|
||||
|
@ -394,7 +401,7 @@ static int usbh_hub_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||
usbh_hub_devno_free(hub->index);
|
||||
|
||||
if (hub->intin) {
|
||||
usbh_pipe_free(hub->intin);
|
||||
usbh_pipe_free_xiuos(hport, hub->intin);
|
||||
}
|
||||
|
||||
for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
|
||||
|
@ -597,8 +604,6 @@ static void usbh_hub_events(struct usbh_hub *hub)
|
|||
#ifdef CONFIG_USBHOST_XHCI
|
||||
/* USB3.0 speed cannot get from portstatus, checkout port speed instead */
|
||||
else {
|
||||
extern uint8_t usbh_get_port_speed(struct usbh_hub *hub, const uint8_t port);
|
||||
|
||||
uint8_t port_speed = usbh_get_port_speed(hub, port + 1);
|
||||
if (port_speed >= USB_SPEED_SUPER) {
|
||||
/* assert that when using USB 3.0 ports, attached device must also be USB 3.0 speed */
|
||||
|
|
Loading…
Reference in New Issue