forked from xuos/xiuos
Modify xhci functions for USB core
This commit is contained in:
parent
eef25d3004
commit
a66824c9ad
|
@ -791,7 +791,64 @@ int xhci_usbh_ep_pipe_reconfigure(struct usbh_bus *usb, usbh_pipe_t pipe, uint8_
|
|||
|
||||
|
||||
int xhci_usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg){
|
||||
return 0;
|
||||
int rc = 0;
|
||||
int slot_id = 0;
|
||||
struct xhci_host *xhci = xhci_get_inst_of_port(ep_cfg->hport);
|
||||
struct usbh_hubport *hport = ep_cfg->hport;
|
||||
struct xhci_endpoint *ppipe = usb_align(XHCI_RING_SIZE, sizeof(struct xhci_endpoint));
|
||||
struct xhci_slot *slot;
|
||||
|
||||
if (NULL == ppipe) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memset(ppipe, 0, sizeof(struct xhci_endpoint));
|
||||
|
||||
ppipe->waitsem = usb_osal_sem_create(0);
|
||||
ppipe->waiter = false;
|
||||
ppipe->urb = NULL;
|
||||
ppipe->hport = hport;
|
||||
|
||||
ppipe->address = ep_cfg->ep_addr;
|
||||
ppipe->mtu = ep_cfg->ep_mps;
|
||||
ppipe->interval = ep_cfg->ep_interval;
|
||||
ppipe->ep_type = ep_cfg->ep_type;
|
||||
ppipe->burst = 0U;
|
||||
|
||||
if (ppipe->address == 0) { /* if try to allocate ctrl ep, open device first */
|
||||
USB_LOG_DBG("allocate device for port-%d \r\n", hport->port);
|
||||
rc = xhci_device_open(xhci, ppipe, &slot_id);
|
||||
if (rc) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
slot = xhci->slot[slot_id];
|
||||
USB_ASSERT(slot);
|
||||
rc = xhci_ctrl_endpoint_open(xhci, slot, ppipe);
|
||||
if (rc) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
rc = xhci_device_address(xhci, slot, ppipe);
|
||||
if (rc) {
|
||||
goto failed;
|
||||
}
|
||||
} else {
|
||||
slot_id = hport->dev_addr;
|
||||
slot = xhci->slot[slot_id];
|
||||
|
||||
rc = xhci_work_endpoint_open(xhci, slot, ppipe);
|
||||
if (rc) {
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
|
||||
*pipe = (usbh_pipe_t)ppipe;
|
||||
return rc;
|
||||
failed:
|
||||
usb_free(ppipe);
|
||||
*pipe = NULL;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue