summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2024-02-09 12:35:35 +0800
committersakumisu <[email protected]>2024-02-09 12:35:44 +0800
commit4313a2666ea7ca497e31a9b2174ebd8ad89e936e (patch)
treecbb95f0b7ee9f8a7ea3039ac49aba5b6f2e1e845
parent466d241c31106c538f80548475f33639899b6b28 (diff)
check if device is on extern hub
-rw-r--r--port/dwc2/usb_hc_dwc2.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c
index 364b9cc6..2c371290 100644
--- a/port/dwc2/usb_hc_dwc2.c
+++ b/port/dwc2/usb_hc_dwc2.c
@@ -146,6 +146,26 @@ static inline void dwc2_drivebus(struct usbh_bus *bus, uint8_t state)
}
}
+static uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
+{
+ __IO uint32_t hprt0 = 0U;
+ uint8_t speed;
+
+ hprt0 = USB_OTG_HPRT;
+
+ speed = (hprt0 & USB_OTG_HPRT_PSPD) >> 17;
+
+ if (speed == HPRT0_PRTSPD_HIGH_SPEED) {
+ return USB_SPEED_HIGH;
+ } else if (speed == HPRT0_PRTSPD_FULL_SPEED) {
+ return USB_SPEED_FULL;
+ } else if (speed == HPRT0_PRTSPD_LOW_SPEED) {
+ return USB_SPEED_LOW;
+ } else {
+ return USB_SPEED_UNKNOWN;
+ }
+}
+
static void dwc2_chan_init(struct usbh_bus *bus, uint8_t ch_num, uint8_t devaddr, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps, uint8_t speed)
{
uint32_t regval;
@@ -197,7 +217,7 @@ static void dwc2_chan_init(struct usbh_bus *bus, uint8_t ch_num, uint8_t devaddr
}
/* LS device plugged to HUB */
- if (speed == USB_SPEED_LOW) {
+ if ((speed == USB_SPEED_LOW) && (usbh_get_port_speed(bus, 0) != USB_SPEED_LOW)) {
regval |= USB_OTG_HCCHAR_LSDEV;
}
@@ -300,26 +320,6 @@ static int usbh_reset_port(struct usbh_bus *bus, const uint8_t port)
return 0;
}
-static uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
-{
- __IO uint32_t hprt0 = 0U;
- uint8_t speed;
-
- hprt0 = USB_OTG_HPRT;
-
- speed = (hprt0 & USB_OTG_HPRT_PSPD) >> 17;
-
- if (speed == HPRT0_PRTSPD_HIGH_SPEED) {
- return USB_SPEED_HIGH;
- } else if (speed == HPRT0_PRTSPD_FULL_SPEED) {
- return USB_SPEED_FULL;
- } else if (speed == HPRT0_PRTSPD_LOW_SPEED) {
- return USB_SPEED_LOW;
- } else {
- return USB_SPEED_UNKNOWN;
- }
-}
-
/**
* @brief dwc2_get_glb_intstatus: return the global USB interrupt status
* @retval status
@@ -351,7 +351,7 @@ static int dwc2_chan_alloc(struct usbh_bus *bus)
static void dwc2_chan_free(struct dwc2_chan *chan)
{
size_t flags;
-
+
flags = usb_osal_enter_critical_section();
chan->inuse = false;
usb_osal_leave_critical_section(flags);