summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakimisu <[email protected]>2023-03-12 15:04:21 +0800
committersakimisu <[email protected]>2023-03-12 15:05:35 +0800
commit4cd9031d31c2cd2a045e72122e1e8e7d28d6a3b7 (patch)
tree8da7f22708bf27067a9290ffd57e549ddbd32066
parentcda6e48fc11497ed1edc8e4467d9d5719f528633 (diff)
replace speed reconfig with mult
-rw-r--r--common/usb_hc.h8
-rw-r--r--core/usbh_core.c4
-rw-r--r--port/ch32/usb_hc_usbfs.c80
-rw-r--r--port/ch32/usb_hc_usbhs.c27
-rw-r--r--port/dwc2/usb_hc_dwc2.c3
-rw-r--r--port/ehci/usb_hc_ehci.c4
-rw-r--r--port/musb/usb_hc_musb.c17
-rw-r--r--port/template/usb_hc.c3
8 files changed, 70 insertions, 76 deletions
diff --git a/common/usb_hc.h b/common/usb_hc.h
index 880149fe..dfe20703 100644
--- a/common/usb_hc.h
+++ b/common/usb_hc.h
@@ -85,15 +85,15 @@ uint16_t usbh_get_frame_number(void);
int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf);
/**
- * @brief reconfig control endpoint pipe.
+ * @brief reconfig endpoint pipe.
*
* @param pipe A memory allocated for pipe.
* @param dev_addr device address.
- * @param ep_mps control endpoint max packet size.
- * @param speed port speed
+ * @param ep_mps endpoint max packet size.
+ * @param mult endpoint additional transcation
* @return On success will return 0, and others indicate fail.
*/
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed);
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult);
/**
* @brief Allocate pipe for endpoint
diff --git a/core/usbh_core.c b/core/usbh_core.c
index 3a231d66..798dd027 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -438,7 +438,7 @@ int usbh_enumerate(struct usbh_hubport *hport)
ep_mps = ((struct usb_device_descriptor *)ep0_request_buffer)->bMaxPacketSize0;
/* Reconfigure EP0 with the correct maximum packet size */
- usbh_ep0_pipe_reconfigure(hport->ep0, 0, ep_mps, hport->speed);
+ usbh_ep_pipe_reconfigure(hport->ep0, 0, ep_mps, 0);
#ifdef CONFIG_USBHOST_XHCI
extern int usbh_get_xhci_devaddr(usbh_pipe_t * pipe);
@@ -478,7 +478,7 @@ int usbh_enumerate(struct usbh_hubport *hport)
hport->dev_addr = dev_addr;
/* And reconfigure EP0 with the correct address */
- usbh_ep0_pipe_reconfigure(hport->ep0, dev_addr, ep_mps, hport->speed);
+ usbh_ep_pipe_reconfigure(hport->ep0, dev_addr, ep_mps, 0);
/* Read the full device descriptor */
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_DEVICE;
diff --git a/port/ch32/usb_hc_usbfs.c b/port/ch32/usb_hc_usbfs.c
index df587bf2..16ce5aa4 100644
--- a/port/ch32/usb_hc_usbfs.c
+++ b/port/ch32/usb_hc_usbfs.c
@@ -607,23 +607,12 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
return 0;
}
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult)
{
struct chusb_pipe *ppipe = (struct chusb_pipe *)pipe;
ppipe->dev_addr = dev_addr;
ppipe->ep_mps = ep_mps;
- ppipe->speed = speed;
-
- if (speed == USB_SPEED_HIGH) {
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_HIGH \r\n");
- } else if (speed == USB_SPEED_FULL) {
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_FULL \r\n");
- chusbh_set_self_speed(USB_SPEED_FULL);
- } else if (speed == USB_SPEED_LOW) {
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_LOW \r\n");
- chusbh_set_self_speed(USB_SPEED_LOW);
- }
USBFS_HOST->DEV_ADDR = (USBFS_DEV_ADDR_OFFSET & USBFS_UDA_GP_BIT) | (dev_addr & USBFS_USB_ADDR_MASK);
return 0;
@@ -661,6 +650,15 @@ int usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg)
ppipe->hport = ep_cfg->hport;
if (ep_cfg->ep_type == USB_ENDPOINT_TYPE_CONTROL) {
+ if (ppipe->speed == USB_SPEED_HIGH) {
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_HIGH \r\n");
+ } else if (ppipe->speed == USB_SPEED_FULL) {
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_FULL \r\n");
+ chusbh_set_self_speed(USB_SPEED_FULL);
+ } else if (ppipe->speed == USB_SPEED_LOW) {
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_LOW \r\n");
+ chusbh_set_self_speed(USB_SPEED_LOW);
+ }
} else {
if (ppipe->speed == USB_SPEED_HIGH) {
} else if (ppipe->speed == USB_SPEED_FULL) {
@@ -842,7 +840,7 @@ static int8_t chusb_outpipe_irq_handler(uint8_t res_state)
} else {
if (g_chusb_hcd.prv_set_zero == true) {
/**
- * It is unlikely to run here,
+ * It is unlikely to run here,
* because the device can probably receive 0 length byte packets
*/
urb->errorcode = 0;
@@ -1121,7 +1119,7 @@ static int8_t chusb_inpipe_irq_handler(uint8_t res_state)
/*!< Ctrol endpoint */
/**
* Status stage
- *
+ *
* Setup ---> out data ---> in status stage
*/
if ((g_chusb_hcd.ep0_state == USB_EP0_STATE_IN_STATUS) && (rx_len == 0)) {
@@ -1252,37 +1250,37 @@ void USBH_IRQHandler(void)
}
} else if (intflag & USBFS_UIF_DETECT) {
if (USBFS_HOST->MIS_ST & USBFS_UMS_DEV_ATTACH) {
- USB_LOG_INFO("Dev connect \r\n");
- g_chusb_hcd.port_csc = 1;
- g_chusb_hcd.port_pec = 1;
- g_chusb_hcd.port_pe = 1;
- usbh_roothub_thread_wakeup(1);
+ USB_LOG_INFO("Dev connect \r\n");
+ g_chusb_hcd.port_csc = 1;
+ g_chusb_hcd.port_pec = 1;
+ g_chusb_hcd.port_pe = 1;
+ usbh_roothub_thread_wakeup(1);
} else {
- USB_LOG_INFO("Dev remove \r\n");
- /**
+ USB_LOG_INFO("Dev remove \r\n");
+ /**
* Device remove
* Disable port and stop send sof
*/
- USBFS_HOST->HOST_SETUP &= ~USBFS_UH_SOF_EN;
- USBFS_HOST->HOST_CTRL &= ~USBFS_UH_PORT_EN;
- if (g_chusb_hcd.main_pipe_using) {
- g_chusb_hcd.main_pipe_using = false;
- }
- g_chusb_hcd.port_csc = 1;
- g_chusb_hcd.port_pec = 1;
- g_chusb_hcd.port_pe = 0;
- for (uint8_t index = 0; index < CONFIG_USBHOST_PIPE_NUM; index++) {
- for (uint8_t j = 0; j < 2; j++) {
- struct chusb_pipe *pipe = &g_chusb_hcd.pipe_pool[index][j];
- struct usbh_urb *urb = pipe->urb;
- if (pipe->waiter) {
- pipe->waiter = false;
- urb->errorcode = -ESHUTDOWN;
- usb_osal_sem_give(pipe->waitsem);
- }
+ USBFS_HOST->HOST_SETUP &= ~USBFS_UH_SOF_EN;
+ USBFS_HOST->HOST_CTRL &= ~USBFS_UH_PORT_EN;
+ if (g_chusb_hcd.main_pipe_using) {
+ g_chusb_hcd.main_pipe_using = false;
+ }
+ g_chusb_hcd.port_csc = 1;
+ g_chusb_hcd.port_pec = 1;
+ g_chusb_hcd.port_pe = 0;
+ for (uint8_t index = 0; index < CONFIG_USBHOST_PIPE_NUM; index++) {
+ for (uint8_t j = 0; j < 2; j++) {
+ struct chusb_pipe *pipe = &g_chusb_hcd.pipe_pool[index][j];
+ struct usbh_urb *urb = pipe->urb;
+ if (pipe->waiter) {
+ pipe->waiter = false;
+ urb->errorcode = -ESHUTDOWN;
+ usb_osal_sem_give(pipe->waitsem);
}
}
- usbh_roothub_thread_wakeup(1);
+ }
+ usbh_roothub_thread_wakeup(1);
}
USBFS_HOST->INT_FG = USBFS_UIF_DETECT;
} else {
@@ -1293,8 +1291,8 @@ void USBH_IRQHandler(void)
return;
pipe_wait:
/**
- * enerally, only errors can arrive here.
- * After testing, most cases arrive here because of the problem of the DATA PID,
+ * enerally, only errors can arrive here.
+ * After testing, most cases arrive here because of the problem of the DATA PID,
* but the transmission will be completed correctly next time.
*/
chusb_pipe_waitup(g_chusb_hcd.current_pipe, true);
diff --git a/port/ch32/usb_hc_usbhs.c b/port/ch32/usb_hc_usbhs.c
index 19f038ca..bce61ca9 100644
--- a/port/ch32/usb_hc_usbhs.c
+++ b/port/ch32/usb_hc_usbhs.c
@@ -669,24 +669,13 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
return 0;
}
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
{
struct chusb_pipe *ppipe = (struct chusb_pipe *)pipe;
ppipe->dev_addr = dev_addr;
ppipe->ep_mps = ep_mps;
- ppipe->speed = speed;
- if (speed == USB_SPEED_HIGH) {
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_HIGH \r\n");
- chusbh_set_self_speed(USB_SPEED_HIGH);
- } else if (speed == USB_SPEED_FULL) {
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_FULL \r\n");
- chusbh_set_self_speed(USB_SPEED_FULL);
- } else if (speed == USB_SPEED_LOW) {
- USB_LOG_INFO("ep0 reconfigure USB_SPEED_LOW \r\n");
- chusbh_set_self_speed(USB_SPEED_LOW);
- }
USBHS_HOST->DEV_AD = dev_addr & 0x7f;
return 0;
}
@@ -723,6 +712,16 @@ int usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg)
ppipe->hport = ep_cfg->hport;
if (ep_cfg->ep_type == USB_ENDPOINT_TYPE_CONTROL) {
+ if (ppipe->speed == USB_SPEED_HIGH) {
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_HIGH \r\n");
+ chusbh_set_self_speed(USB_SPEED_HIGH);
+ } else if (ppipe->speed == USB_SPEED_FULL) {
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_FULL \r\n");
+ chusbh_set_self_speed(USB_SPEED_FULL);
+ } else if (ppipe->speed == USB_SPEED_LOW) {
+ USB_LOG_INFO("ep0 reconfigure USB_SPEED_LOW \r\n");
+ chusbh_set_self_speed(USB_SPEED_LOW);
+ }
} else {
if (ppipe->speed == USB_SPEED_HIGH) {
if ((ep_cfg->ep_type == USB_ENDPOINT_TYPE_ISOCHRONOUS) ||
@@ -914,7 +913,7 @@ static int8_t chusb_outpipe_irq_handler(uint8_t res_state)
urb->errorcode = 0;
if (g_chusb_hcd.prv_set_zero == true) {
/**
- * It is unlikely to run here,
+ * It is unlikely to run here,
* because the device can probably receive 0 length byte packets
*/
g_chusb_hcd.prv_set_zero = false;
@@ -1172,7 +1171,7 @@ static int8_t chusb_inpipe_irq_handler(uint8_t res_state)
/*!< Ctrol endpoint */
/**
* Status stage
- *
+ *
* Setup ---> out data ---> in status stage
*/
if ((g_chusb_hcd.ep0_state == USB_EP0_STATE_IN_STATUS) && (rx_len == 0)) {
diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c
index 0ad34c51..19dcebc5 100644
--- a/port/dwc2/usb_hc_dwc2.c
+++ b/port/dwc2/usb_hc_dwc2.c
@@ -676,7 +676,7 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
return 0;
}
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult)
{
struct dwc2_pipe *chan;
@@ -684,7 +684,6 @@ int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps
chan->dev_addr = dev_addr;
chan->ep_mps = ep_mps;
- chan->speed = speed;
return 0;
}
diff --git a/port/ehci/usb_hc_ehci.c b/port/ehci/usb_hc_ehci.c
index 96f667ae..79e5e851 100644
--- a/port/ehci/usb_hc_ehci.c
+++ b/port/ehci/usb_hc_ehci.c
@@ -959,13 +959,13 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
return 0;
}
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult)
{
struct ehci_pipe *ppipe = (struct ehci_pipe *)pipe;
ppipe->dev_addr = dev_addr;
ppipe->ep_mps = ep_mps;
- ppipe->speed = speed;
+ ppipe->mult = mult;
return 0;
}
diff --git a/port/musb/usb_hc_musb.c b/port/musb/usb_hc_musb.c
index 75414461..51887883 100644
--- a/port/musb/usb_hc_musb.c
+++ b/port/musb/usb_hc_musb.c
@@ -551,21 +551,13 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
return 0;
}
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult)
{
struct musb_pipe *ppipe = (struct musb_pipe *)pipe;
ppipe->dev_addr = dev_addr;
ppipe->ep_mps = ep_mps;
- if (speed == USB_SPEED_HIGH) {
- ppipe->speed = USB_TYPE0_SPEED_HIGH;
- } else if (speed == USB_SPEED_FULL) {
- ppipe->speed = USB_TYPE0_SPEED_FULL;
- } else if (speed == USB_SPEED_LOW) {
- ppipe->speed = USB_TYPE0_SPEED_LOW;
- }
-
return 0;
}
@@ -605,6 +597,13 @@ int usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg)
ppipe->hport = ep_cfg->hport;
if (ep_cfg->ep_type == USB_ENDPOINT_TYPE_CONTROL) {
+ if (ppipe->speed == USB_SPEED_HIGH) {
+ ppipe->speed = USB_TYPE0_SPEED_HIGH;
+ } else if (ppipe->speed == USB_SPEED_FULL) {
+ ppipe->speed = USB_TYPE0_SPEED_FULL;
+ } else if (ppipe->speed == USB_SPEED_LOW) {
+ ppipe->speed = USB_TYPE0_SPEED_LOW;
+ }
} else {
if (ppipe->speed == USB_SPEED_HIGH) {
ppipe->speed = USB_TXTYPE1_SPEED_HIGH;
diff --git a/port/template/usb_hc.c b/port/template/usb_hc.c
index 75980630..2bc8ce07 100644
--- a/port/template/usb_hc.c
+++ b/port/template/usb_hc.c
@@ -185,7 +185,7 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf)
return 0;
}
-int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t speed)
+int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult)
{
struct dwc2_pipe *chan;
@@ -193,7 +193,6 @@ int usbh_ep0_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps
chan->dev_addr = dev_addr;
chan->ep_mps = ep_mps;
- chan->speed = speed;
return 0;
}