forked from xuos/xiuos
usb class info is created when initialized.
This commit is contained in:
parent
7a7318734b
commit
721763bb00
|
@ -731,8 +731,28 @@ void usbh_roothub_thread_wakeup(uint32_t usb_id, uint8_t port)
|
|||
usbh_hub_thread_wakeup(roothub);
|
||||
}
|
||||
|
||||
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
|
||||
const struct usbh_class_driver hub_class_driver = {
|
||||
.driver_name = "hub",
|
||||
.connect = usbh_hub_connect,
|
||||
.disconnect = usbh_hub_disconnect
|
||||
};
|
||||
|
||||
CLASS_INFO_DEFINE struct usbh_class_info hub_class_info = {
|
||||
.match_flags = USB_CLASS_MATCH_INTF_CLASS,
|
||||
.class = USB_DEVICE_CLASS_HUB,
|
||||
.subclass = 0,
|
||||
.protocol = 0,
|
||||
.vid = 0x00,
|
||||
.pid = 0x00,
|
||||
.class_driver = &hub_class_driver
|
||||
};
|
||||
#endif
|
||||
|
||||
int usbh_hub_initialize(struct usbh_bus *usb)
|
||||
{
|
||||
usbh_class_info_set(USBH_CLASS_INFO_HUB, &hub_class_info);
|
||||
|
||||
usbh_roothub_register(usb);
|
||||
|
||||
usb->hub_mq = usb_osal_mq_create(7);
|
||||
|
@ -749,20 +769,3 @@ int usbh_hub_initialize(struct usbh_bus *usb)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
|
||||
const struct usbh_class_driver hub_class_driver = {
|
||||
.driver_name = "hub",
|
||||
.connect = usbh_hub_connect,
|
||||
.disconnect = usbh_hub_disconnect
|
||||
};
|
||||
|
||||
CLASS_INFO_DEFINE const struct usbh_class_info hub_class_info = {
|
||||
.match_flags = USB_CLASS_MATCH_INTF_CLASS,
|
||||
.class = USB_DEVICE_CLASS_HUB,
|
||||
.subclass = 0,
|
||||
.protocol = 0,
|
||||
.vid = 0x00,
|
||||
.pid = 0x00,
|
||||
.class_driver = &hub_class_driver
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -467,7 +467,7 @@ static const struct usbh_class_driver rndis_class_driver = {
|
|||
.disconnect = usbh_rndis_disconnect
|
||||
};
|
||||
|
||||
CLASS_INFO_DEFINE const struct usbh_class_info rndis_class_info = {
|
||||
CLASS_INFO_DEFINE struct usbh_class_info rndis_class_info = {
|
||||
.match_flags = USB_CLASS_MATCH_INTF_CLASS | USB_CLASS_MATCH_INTF_SUBCLASS | USB_CLASS_MATCH_INTF_PROTOCOL,
|
||||
.class = USB_DEVICE_CLASS_WIRELESS,
|
||||
.subclass = 0x01,
|
||||
|
@ -476,3 +476,9 @@ CLASS_INFO_DEFINE const struct usbh_class_info rndis_class_info = {
|
|||
.pid = 0x00,
|
||||
.class_driver = &rndis_class_driver
|
||||
};
|
||||
|
||||
int usbh_rndis_initialize(struct usbh_bus *usb)
|
||||
{
|
||||
usbh_class_info_set(USBH_CLASS_INFO_RNDIS, &rndis_class_info);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ struct usbh_rndis {
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int usbh_rndis_initialize(struct usbh_bus *usb);
|
||||
|
||||
int usbh_rndis_bulk_out_transfer(struct usbh_rndis *rndis_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout);
|
||||
int usbh_rndis_bulk_in_transfer(struct usbh_rndis *rndis_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout);
|
||||
|
|
|
@ -34,7 +34,9 @@ Modification: usb core uses naive_mmap to assign virtual and physical addresses
|
|||
#include "usbh_hub.h"
|
||||
#include "usb_hc_xhci.h"
|
||||
#include "usyscall.h"
|
||||
#include "usbh_rndis.h"
|
||||
|
||||
CLASS_INFO_DEFINE struct usbh_class_info usbh_class_info_table[USBH_CLASS_INFO_MAX] = {0};
|
||||
struct usbh_class_info *usbh_class_info_table_begin = NULL;
|
||||
struct usbh_class_info *usbh_class_info_table_end = NULL;
|
||||
|
||||
|
@ -826,10 +828,8 @@ int usbh_initialize(uint32_t id, struct usbh_bus *usb)
|
|||
usbh_class_info_table_begin = (struct usbh_class_info *)&usbh_class_info$$Base;
|
||||
usbh_class_info_table_end = (struct usbh_class_info *)&usbh_class_info$$Limit;
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t __usbh_class_info_start__;
|
||||
extern uint32_t __usbh_class_info_end__;
|
||||
usbh_class_info_table_begin = (struct usbh_class_info *)&__usbh_class_info_start__;
|
||||
usbh_class_info_table_end = (struct usbh_class_info *)&__usbh_class_info_end__;
|
||||
usbh_class_info_table_begin = (struct usbh_class_info *)&usbh_class_info_table[0];
|
||||
usbh_class_info_table_end = (struct usbh_class_info *)&usbh_class_info_table[USBH_CLASS_INFO_MAX];
|
||||
#elif defined(__ICCARM__) || defined(__ICCRX__)
|
||||
usbh_class_info_table_begin = (struct usbh_class_info *)__section_begin("usbh_class_info");
|
||||
usbh_class_info_table_end = (struct usbh_class_info *)__section_end("usbh_class_info");
|
||||
|
@ -856,6 +856,7 @@ int usbh_initialize(uint32_t id, struct usbh_bus *usb)
|
|||
|
||||
usb_slist_add_tail(&usb_buses, &(usb->list));
|
||||
usbh_hub_initialize(usb);
|
||||
usbh_rndis_initialize(usb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -994,6 +995,17 @@ int lsusb(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Set usb class info */
|
||||
int usbh_class_info_set(enum usbh_class_info_type class_type, struct usbh_class_info *class_info)
|
||||
{
|
||||
if(!(class_type >=0 && class_type < USBH_CLASS_INFO_MAX)) {
|
||||
USB_LOG_ERR("invalid usb class info type %d \r\n", class_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
memcpy(&usbh_class_info_table[class_type], class_info, sizeof(struct usbh_class_info));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* xhci hardware init */
|
||||
int usb_hc_init(uint32_t id)
|
||||
{
|
||||
|
|
|
@ -57,6 +57,13 @@ extern "C" {
|
|||
#define USB_HC_XHCI 5
|
||||
#define USB_HC_DWC3 6
|
||||
|
||||
/** Supported usb class types */
|
||||
enum usbh_class_info_type {
|
||||
USBH_CLASS_INFO_HUB = 0,
|
||||
USBH_CLASS_INFO_RNDIS = 1,
|
||||
USBH_CLASS_INFO_MAX = 2
|
||||
};
|
||||
|
||||
#define USB_CLASS_MATCH_VENDOR 0x0001
|
||||
#define USB_CLASS_MATCH_PRODUCT 0x0002
|
||||
#define USB_CLASS_MATCH_INTF_CLASS 0x0004
|
||||
|
@ -372,6 +379,8 @@ struct usbh_hubport *usbh_find_hubport(uint32_t id, uint8_t dev_addr);
|
|||
void *usbh_find_class_instance(const char *devname);
|
||||
int lsusb(int argc, char **argv);
|
||||
|
||||
int usbh_class_info_set(enum usbh_class_info_type class_type, struct usbh_class_info *class_info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue