replace speed reconfig with mult

This commit is contained in:
sakimisu
2023-03-12 15:04:21 +08:00
parent cda6e48fc1
commit 4cd9031d31
8 changed files with 70 additions and 76 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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) {
@@ -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 {

View File

@@ -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) ||

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}