forked from yystopf/xiuos
Modifying functions in usb core is related to xhci.
This commit is contained in:
parent
7f188bff03
commit
39620c574e
|
@ -19,6 +19,11 @@ Modification: Modify function usbh_enumerate usbh_hport_activate_ep0 usbh_hport_
|
|||
2. Date: 2024-06-19
|
||||
Author: AIIT XUOS Lab
|
||||
Modification: Extract the functions of the host controller to core.
|
||||
|
||||
3. Date: 2024-06-24
|
||||
Author: AIIT XUOS Lab
|
||||
Modification: Modifying functions in usb core is related to xhci.
|
||||
|
||||
*************************************************/
|
||||
|
||||
#include "usbh_core.h"
|
||||
|
@ -857,15 +862,13 @@ int usbh_control_transfer(usbh_pipe_t pipe, struct usb_setup_packet *setup, uint
|
|||
|
||||
int usbh_control_transfer_xiuos(struct usbh_hubport *hport, usbh_pipe_t pipe, struct usb_setup_packet *setup, uint8_t *buffer)
|
||||
{
|
||||
struct usbh_bus *usb = usbh_get_bus_of_port(hport);
|
||||
struct usbh_urb *urb;
|
||||
int ret;
|
||||
|
||||
urb = usb_malloc(sizeof(struct usbh_urb));
|
||||
memset(urb, 0, sizeof(struct usbh_urb));
|
||||
|
||||
urb->usb_hc_type = usb->usb_hc_type;
|
||||
usbh_control_urb_fill(urb, pipe, setup, buffer, setup->wLength, CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT, NULL, NULL);
|
||||
usbh_control_urb_fill_xiuos(urb, hport, pipe, setup, buffer, setup->wLength, CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT, NULL, NULL);
|
||||
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret == 0) {
|
||||
|
@ -972,17 +975,64 @@ int lsusb(int argc, char **argv)
|
|||
/* xhci hardware init */
|
||||
int usb_hc_init(uint32_t id)
|
||||
{
|
||||
return 0;
|
||||
int ret = 0;
|
||||
struct usbh_bus* usb = usbh_get_bus_of_index(id);
|
||||
|
||||
if (USB_HC_XHCI == usb->usb_hc_type) {
|
||||
ret = xhci_usb_hc_init(usb->id);
|
||||
}
|
||||
else {
|
||||
USB_LOG_WRN("invalid usb controller type %d \r\n", usb->usb_hc_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int usbh_roothub_control(struct usbh_bus *usb, struct usb_setup_packet *setup, uint8_t *buf)
|
||||
{
|
||||
return 0;
|
||||
int ret = 0;
|
||||
|
||||
if (USB_HC_XHCI == usb->usb_hc_type) {
|
||||
ret = xhci_usbh_roothub_control(usb, setup, buf);
|
||||
}
|
||||
else {
|
||||
USB_LOG_WRN("invalid usb controller type %d \r\n", usb->usb_hc_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t usbh_get_port_speed(struct usbh_hub *hub, const uint8_t port)
|
||||
{
|
||||
uint8_t speed;
|
||||
struct usbh_bus *usb = hub->usb;
|
||||
|
||||
if (USB_HC_XHCI == usb->usb_hc_type) {
|
||||
speed = xhci_usbh_get_port_speed(hub, port + 1);
|
||||
}
|
||||
else {
|
||||
USB_LOG_WRN("invalid usb controller type %d \r\n", usb->usb_hc_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return speed;
|
||||
}
|
||||
|
||||
int usbh_ep_pipe_reconfigure(struct usbh_bus *usb, usbh_pipe_t pipe, uint8_t dev_addr, uint8_t mtu, uint8_t speed)
|
||||
{
|
||||
return 0;
|
||||
int rc = 0;
|
||||
|
||||
if (USB_HC_XHCI == usb->usb_hc_type) {
|
||||
rc = xhci_usbh_ep_pipe_reconfigure(usb, pipe, dev_addr, mtu, speed);
|
||||
}
|
||||
else {
|
||||
USB_LOG_WRN("invalid usb controller type %d \r\n", usb->usb_hc_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg)
|
||||
|
@ -1066,10 +1116,29 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||
|
||||
int usbh_kill_urb(struct usbh_urb *urb)
|
||||
{
|
||||
return 0;
|
||||
int ret;
|
||||
|
||||
if (USB_HC_XHCI == urb->usb_hc_type) {
|
||||
ret = xhci_usbh_kill_urb(urb);
|
||||
}
|
||||
else {
|
||||
USB_LOG_WRN("invalid usb controller type %d \r\n", urb->usb_hc_type);
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void USBH_IRQHandler(void *param)
|
||||
{
|
||||
USB_ASSERT(param);
|
||||
struct usbh_bus *bus = (struct usbh_bus *)param;
|
||||
|
||||
if (USB_HC_XHCI == bus->usb_hc_type) {
|
||||
XHCI_USBH_IRQHandler(param);
|
||||
}
|
||||
else {
|
||||
USB_LOG_WRN("invalid usb controller type %d \r\n", bus->usb_hc_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,11 @@ Others: CherryUSB third-party/cherryusb/core/usbh_core.h for references
|
|||
History:
|
||||
1. Date: 2024-06-18
|
||||
Author: AIIT XUOS Lab
|
||||
Modification: new parameter usb_hc_type for host controller type.
|
||||
Modification: New parameter usb_hc_type for host controller type.
|
||||
|
||||
2. Date: 2024-06-24
|
||||
Author: AIIT XUOS Lab
|
||||
Modification: Refactor the function that fills urb with usb_hc_type.
|
||||
*************************************************/
|
||||
|
||||
|
||||
|
@ -85,6 +89,27 @@ static inline void usbh_control_urb_fill(struct usbh_urb *urb,
|
|||
urb->arg = arg;
|
||||
}
|
||||
|
||||
static inline void usbh_control_urb_fill_xiuos(struct usbh_urb *urb,
|
||||
struct usbh_hubport *hport,
|
||||
usbh_pipe_t pipe,
|
||||
struct usb_setup_packet *setup,
|
||||
uint8_t *transfer_buffer,
|
||||
uint32_t transfer_buffer_length,
|
||||
uint32_t timeout,
|
||||
usbh_complete_callback_t complete,
|
||||
void *arg)
|
||||
{
|
||||
struct usbh_bus *usb = usbh_get_bus_of_port(hport);
|
||||
urb->usb_hc_type = usb->usb_hc_type;
|
||||
urb->pipe = pipe;
|
||||
urb->setup = setup;
|
||||
urb->transfer_buffer = transfer_buffer;
|
||||
urb->transfer_buffer_length = transfer_buffer_length;
|
||||
urb->timeout = timeout;
|
||||
urb->complete = complete;
|
||||
urb->arg = arg;
|
||||
}
|
||||
|
||||
static inline void usbh_bulk_urb_fill(struct usbh_urb *urb,
|
||||
usbh_pipe_t pipe,
|
||||
uint8_t *transfer_buffer,
|
||||
|
@ -102,6 +127,26 @@ static inline void usbh_bulk_urb_fill(struct usbh_urb *urb,
|
|||
urb->arg = arg;
|
||||
}
|
||||
|
||||
static inline void usbh_bulk_urb_fill_xiuos(struct usbh_urb *urb,
|
||||
struct usbh_hubport *hport,
|
||||
usbh_pipe_t pipe,
|
||||
uint8_t *transfer_buffer,
|
||||
uint32_t transfer_buffer_length,
|
||||
uint32_t timeout,
|
||||
usbh_complete_callback_t complete,
|
||||
void *arg)
|
||||
{
|
||||
struct usbh_bus *usb = usbh_get_bus_of_port(hport);
|
||||
urb->usb_hc_type = usb->usb_hc_type;
|
||||
urb->pipe = pipe;
|
||||
urb->setup = NULL;
|
||||
urb->transfer_buffer = transfer_buffer;
|
||||
urb->transfer_buffer_length = transfer_buffer_length;
|
||||
urb->timeout = timeout;
|
||||
urb->complete = complete;
|
||||
urb->arg = arg;
|
||||
}
|
||||
|
||||
static inline void usbh_int_urb_fill(struct usbh_urb *urb,
|
||||
usbh_pipe_t pipe,
|
||||
uint8_t *transfer_buffer,
|
||||
|
@ -119,6 +164,25 @@ static inline void usbh_int_urb_fill(struct usbh_urb *urb,
|
|||
urb->arg = arg;
|
||||
}
|
||||
|
||||
static inline void usbh_int_urb_fill_xiuos(struct usbh_urb *urb,
|
||||
struct usbh_hubport *hport,
|
||||
usbh_pipe_t pipe,
|
||||
uint8_t *transfer_buffer,
|
||||
uint32_t transfer_buffer_length,
|
||||
uint32_t timeout,
|
||||
usbh_complete_callback_t complete,
|
||||
void *arg)
|
||||
{
|
||||
struct usbh_bus *usb = usbh_get_bus_of_port(hport);
|
||||
urb->usb_hc_type = usb->usb_hc_type;
|
||||
urb->pipe = pipe;
|
||||
urb->setup = NULL;
|
||||
urb->transfer_buffer = transfer_buffer;
|
||||
urb->transfer_buffer_length = transfer_buffer_length;
|
||||
urb->timeout = timeout;
|
||||
urb->complete = complete;
|
||||
urb->arg = arg;
|
||||
}
|
||||
struct usbh_class_info {
|
||||
uint8_t match_flags; /* Used for product specific matches; range is inclusive */
|
||||
uint8_t class; /* Base device class code */
|
||||
|
|
Loading…
Reference in New Issue