mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
USB Consolidate descriptor definitions
The header files usb.h and usbdescriptors.h have the same nameed structure definitions for usb_config_descriptor usb_interface_descriptor usb_endpoint_descriptor usb_device_descriptor usb_string_descriptor These are out right duplicates in usb.h usb_device_descriptor usb_string_descriptor This one has extra unused elements usb_endpoint_descriptor unsigned char bRefresh unsigned char bSynchAddress; These in usb.h have extra elements at the end of the usb 2.0 specified descriptor and are used. usb_config_descriptor usb_interface_descriptor The change is to consolidate the definition of the descriptors to usbdescriptors.h. The dublicates in usb.h are removed. The extra element structure will have their name shorted by removing the '_descriptor' suffix. So usb_config_descriptor -> usb_config usb_interface_descriptor -> usb_interface For these, the common descriptor elements are accessed now by an element 'desc'. As an example - if (iface->bInterfaceClass != USB_CLASS_HUB) + if (iface->desc.bInterfaceClass != USB_CLASS_HUB) This has been compile tested on MAKEALL arm, ppc and mips. Signed-off-by: Tom Rix <Tom.Rix@windriver.com>
This commit is contained in:
parent
bb3bcfa242
commit
8f8bd565f3
8 changed files with 61 additions and 110 deletions
|
@ -157,7 +157,7 @@ void usb_display_desc(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
|
if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
|
||||||
printf("%d: %s, USB Revision %x.%x\n", dev->devnum,
|
printf("%d: %s, USB Revision %x.%x\n", dev->devnum,
|
||||||
usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
|
usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass),
|
||||||
(dev->descriptor.bcdUSB>>8) & 0xff,
|
(dev->descriptor.bcdUSB>>8) & 0xff,
|
||||||
dev->descriptor.bcdUSB & 0xff);
|
dev->descriptor.bcdUSB & 0xff);
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ void usb_display_desc(struct usb_device *dev)
|
||||||
} else {
|
} else {
|
||||||
printf(" - Class: (from Interface) %s\n",
|
printf(" - Class: (from Interface) %s\n",
|
||||||
usb_get_class_desc(
|
usb_get_class_desc(
|
||||||
dev->config.if_desc[0].bInterfaceClass));
|
dev->config.if_desc[0].desc.bInterfaceClass));
|
||||||
}
|
}
|
||||||
printf(" - PacketSize: %d Configurations: %d\n",
|
printf(" - PacketSize: %d Configurations: %d\n",
|
||||||
dev->descriptor.bMaxPacketSize0,
|
dev->descriptor.bMaxPacketSize0,
|
||||||
|
@ -187,14 +187,14 @@ void usb_display_desc(struct usb_device *dev)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_display_conf_desc(struct usb_config_descriptor *config,
|
void usb_display_conf_desc(struct usb_configuration_descriptor *config,
|
||||||
struct usb_device *dev)
|
struct usb_device *dev)
|
||||||
{
|
{
|
||||||
printf(" Configuration: %d\n", config->bConfigurationValue);
|
printf(" Configuration: %d\n", config->bConfigurationValue);
|
||||||
printf(" - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
|
printf(" - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
|
||||||
(config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
|
(config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
|
||||||
(config->bmAttributes & 0x20) ? "Remote Wakeup " : "",
|
(config->bmAttributes & 0x20) ? "Remote Wakeup " : "",
|
||||||
config->MaxPower*2);
|
config->bMaxPower*2);
|
||||||
if (config->iConfiguration) {
|
if (config->iConfiguration) {
|
||||||
printf(" - ");
|
printf(" - ");
|
||||||
usb_display_string(dev, config->iConfiguration);
|
usb_display_string(dev, config->iConfiguration);
|
||||||
|
@ -246,16 +246,16 @@ void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
|
||||||
/* main routine to diasplay the configs, interfaces and endpoints */
|
/* main routine to diasplay the configs, interfaces and endpoints */
|
||||||
void usb_display_config(struct usb_device *dev)
|
void usb_display_config(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
struct usb_config_descriptor *config;
|
struct usb_config *config;
|
||||||
struct usb_interface_descriptor *ifdesc;
|
struct usb_interface *ifdesc;
|
||||||
struct usb_endpoint_descriptor *epdesc;
|
struct usb_endpoint_descriptor *epdesc;
|
||||||
int i, ii;
|
int i, ii;
|
||||||
|
|
||||||
config = &dev->config;
|
config = &dev->config;
|
||||||
usb_display_conf_desc(config, dev);
|
usb_display_conf_desc(&config->desc, dev);
|
||||||
for (i = 0; i < config->no_of_if; i++) {
|
for (i = 0; i < config->no_of_if; i++) {
|
||||||
ifdesc = &config->if_desc[i];
|
ifdesc = &config->if_desc[i];
|
||||||
usb_display_if_desc(ifdesc, dev);
|
usb_display_if_desc(&ifdesc->desc, dev);
|
||||||
for (ii = 0; ii < ifdesc->no_of_ep; ii++) {
|
for (ii = 0; ii < ifdesc->no_of_ep; ii++) {
|
||||||
epdesc = &ifdesc->ep_desc[ii];
|
epdesc = &ifdesc->ep_desc[ii];
|
||||||
usb_display_ep_desc(epdesc);
|
usb_display_ep_desc(epdesc);
|
||||||
|
@ -319,9 +319,9 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre)
|
||||||
pre[index++] = has_child ? '|' : ' ';
|
pre[index++] = has_child ? '|' : ' ';
|
||||||
pre[index] = 0;
|
pre[index] = 0;
|
||||||
printf(" %s (%s, %dmA)\n", usb_get_class_desc(
|
printf(" %s (%s, %dmA)\n", usb_get_class_desc(
|
||||||
dev->config.if_desc[0].bInterfaceClass),
|
dev->config.if_desc[0].desc.bInterfaceClass),
|
||||||
portspeed(dev->speed),
|
portspeed(dev->speed),
|
||||||
dev->config.MaxPower * 2);
|
dev->config.desc.bMaxPower * 2);
|
||||||
if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
|
if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
|
||||||
printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial);
|
printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial);
|
||||||
printf(" %s\n", pre);
|
printf(" %s\n", pre);
|
||||||
|
|
35
common/usb.c
35
common/usb.c
|
@ -299,8 +299,8 @@ int usb_set_maxpacket(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
int i, ii;
|
int i, ii;
|
||||||
|
|
||||||
for (i = 0; i < dev->config.bNumInterfaces; i++)
|
for (i = 0; i < dev->config.desc.bNumInterfaces; i++)
|
||||||
for (ii = 0; ii < dev->config.if_desc[i].bNumEndpoints; ii++)
|
for (ii = 0; ii < dev->config.if_desc[i].desc.bNumEndpoints; ii++)
|
||||||
usb_set_maxpacket_ep(dev,
|
usb_set_maxpacket_ep(dev,
|
||||||
&dev->config.if_desc[i].ep_desc[ii]);
|
&dev->config.if_desc[i].ep_desc[ii]);
|
||||||
|
|
||||||
|
@ -330,14 +330,14 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(&dev->config, buffer, buffer[0]);
|
memcpy(&dev->config, buffer, buffer[0]);
|
||||||
le16_to_cpus(&(dev->config.wTotalLength));
|
le16_to_cpus(&(dev->config.desc.wTotalLength));
|
||||||
dev->config.no_of_if = 0;
|
dev->config.no_of_if = 0;
|
||||||
|
|
||||||
index = dev->config.bLength;
|
index = dev->config.desc.bLength;
|
||||||
/* Ok the first entry must be a configuration entry,
|
/* Ok the first entry must be a configuration entry,
|
||||||
* now process the others */
|
* now process the others */
|
||||||
head = (struct usb_descriptor_header *) &buffer[index];
|
head = (struct usb_descriptor_header *) &buffer[index];
|
||||||
while (index + 1 < dev->config.wTotalLength) {
|
while (index + 1 < dev->config.desc.wTotalLength) {
|
||||||
switch (head->bDescriptorType) {
|
switch (head->bDescriptorType) {
|
||||||
case USB_DT_INTERFACE:
|
case USB_DT_INTERFACE:
|
||||||
if (((struct usb_interface_descriptor *) \
|
if (((struct usb_interface_descriptor *) \
|
||||||
|
@ -350,7 +350,7 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
||||||
dev->config.if_desc[ifno].no_of_ep = 0;
|
dev->config.if_desc[ifno].no_of_ep = 0;
|
||||||
dev->config.if_desc[ifno].num_altsetting = 1;
|
dev->config.if_desc[ifno].num_altsetting = 1;
|
||||||
curr_if_num =
|
curr_if_num =
|
||||||
dev->config.if_desc[ifno].bInterfaceNumber;
|
dev->config.if_desc[ifno].desc.bInterfaceNumber;
|
||||||
} else {
|
} else {
|
||||||
/* found alternate setting for the interface */
|
/* found alternate setting for the interface */
|
||||||
dev->config.if_desc[ifno].num_altsetting++;
|
dev->config.if_desc[ifno].num_altsetting++;
|
||||||
|
@ -440,10 +440,9 @@ int usb_get_configuration_no(struct usb_device *dev,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
unsigned int tmp;
|
unsigned int tmp;
|
||||||
struct usb_config_descriptor *config;
|
struct usb_configuration_descriptor *config;
|
||||||
|
|
||||||
|
config = (struct usb_configuration_descriptor *)&buffer[0];
|
||||||
config = (struct usb_config_descriptor *)&buffer[0];
|
|
||||||
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9);
|
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9);
|
||||||
if (result < 9) {
|
if (result < 9) {
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
|
@ -489,11 +488,11 @@ int usb_set_address(struct usb_device *dev)
|
||||||
*/
|
*/
|
||||||
int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
||||||
{
|
{
|
||||||
struct usb_interface_descriptor *if_face = NULL;
|
struct usb_interface *if_face = NULL;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
for (i = 0; i < dev->config.bNumInterfaces; i++) {
|
for (i = 0; i < dev->config.desc.bNumInterfaces; i++) {
|
||||||
if (dev->config.if_desc[i].bInterfaceNumber == interface) {
|
if (dev->config.if_desc[i].desc.bInterfaceNumber == interface) {
|
||||||
if_face = &dev->config.if_desc[i];
|
if_face = &dev->config.if_desc[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -897,7 +896,7 @@ int usb_new_device(struct usb_device *dev)
|
||||||
usb_parse_config(dev, &tmpbuf[0], 0);
|
usb_parse_config(dev, &tmpbuf[0], 0);
|
||||||
usb_set_maxpacket(dev);
|
usb_set_maxpacket(dev);
|
||||||
/* we set the default configuration here */
|
/* we set the default configuration here */
|
||||||
if (usb_set_configuration(dev, dev->config.bConfigurationValue)) {
|
if (usb_set_configuration(dev, dev->config.desc.bConfigurationValue)) {
|
||||||
printf("failed to set default configuration " \
|
printf("failed to set default configuration " \
|
||||||
"len %d, status %lX\n", dev->act_len, dev->status);
|
"len %d, status %lX\n", dev->act_len, dev->status);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1347,21 +1346,21 @@ int usb_hub_configure(struct usb_device *dev)
|
||||||
|
|
||||||
int usb_hub_probe(struct usb_device *dev, int ifnum)
|
int usb_hub_probe(struct usb_device *dev, int ifnum)
|
||||||
{
|
{
|
||||||
struct usb_interface_descriptor *iface;
|
struct usb_interface *iface;
|
||||||
struct usb_endpoint_descriptor *ep;
|
struct usb_endpoint_descriptor *ep;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
iface = &dev->config.if_desc[ifnum];
|
iface = &dev->config.if_desc[ifnum];
|
||||||
/* Is it a hub? */
|
/* Is it a hub? */
|
||||||
if (iface->bInterfaceClass != USB_CLASS_HUB)
|
if (iface->desc.bInterfaceClass != USB_CLASS_HUB)
|
||||||
return 0;
|
return 0;
|
||||||
/* Some hubs have a subclass of 1, which AFAICT according to the */
|
/* Some hubs have a subclass of 1, which AFAICT according to the */
|
||||||
/* specs is not defined, but it works */
|
/* specs is not defined, but it works */
|
||||||
if ((iface->bInterfaceSubClass != 0) &&
|
if ((iface->desc.bInterfaceSubClass != 0) &&
|
||||||
(iface->bInterfaceSubClass != 1))
|
(iface->desc.bInterfaceSubClass != 1))
|
||||||
return 0;
|
return 0;
|
||||||
/* Multiple endpoints? What kind of mutant ninja-hub is this? */
|
/* Multiple endpoints? What kind of mutant ninja-hub is this? */
|
||||||
if (iface->bNumEndpoints != 1)
|
if (iface->desc.bNumEndpoints != 1)
|
||||||
return 0;
|
return 0;
|
||||||
ep = &iface->ep_desc[0];
|
ep = &iface->ep_desc[0];
|
||||||
/* Output endpoint? Curiousier and curiousier.. */
|
/* Output endpoint? Curiousier and curiousier.. */
|
||||||
|
|
|
@ -229,7 +229,7 @@ int usb_kbd_deregister(void)
|
||||||
|
|
||||||
static void usb_kbd_setled(struct usb_device *dev)
|
static void usb_kbd_setled(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
struct usb_interface_descriptor *iface;
|
struct usb_interface *iface;
|
||||||
iface = &dev->config.if_desc[0];
|
iface = &dev->config.if_desc[0];
|
||||||
leds=0;
|
leds=0;
|
||||||
if(scroll_lock!=0)
|
if(scroll_lock!=0)
|
||||||
|
@ -242,7 +242,7 @@ static void usb_kbd_setled(struct usb_device *dev)
|
||||||
leds|=1;
|
leds|=1;
|
||||||
usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||||
USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||||
0x200, iface->bInterfaceNumber,(void *)&leds, 1, 0);
|
0x200, iface->desc.bInterfaceNumber, (void *)&leds, 1, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,17 +348,21 @@ static int usb_kbd_irq(struct usb_device *dev)
|
||||||
/* probes the USB device dev for keyboard type */
|
/* probes the USB device dev for keyboard type */
|
||||||
static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
|
static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
|
||||||
{
|
{
|
||||||
struct usb_interface_descriptor *iface;
|
struct usb_interface *iface;
|
||||||
struct usb_endpoint_descriptor *ep;
|
struct usb_endpoint_descriptor *ep;
|
||||||
int pipe,maxp;
|
int pipe,maxp;
|
||||||
|
|
||||||
if (dev->descriptor.bNumConfigurations != 1) return 0;
|
if (dev->descriptor.bNumConfigurations != 1) return 0;
|
||||||
iface = &dev->config.if_desc[ifnum];
|
iface = &dev->config.if_desc[ifnum];
|
||||||
|
|
||||||
if (iface->bInterfaceClass != 3) return 0;
|
if (iface->desc.bInterfaceClass != 3)
|
||||||
if (iface->bInterfaceSubClass != 1) return 0;
|
return 0;
|
||||||
if (iface->bInterfaceProtocol != 1) return 0;
|
if (iface->desc.bInterfaceSubClass != 1)
|
||||||
if (iface->bNumEndpoints != 1) return 0;
|
return 0;
|
||||||
|
if (iface->desc.bInterfaceProtocol != 1)
|
||||||
|
return 0;
|
||||||
|
if (iface->desc.bNumEndpoints != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
ep = &iface->ep_desc[0];
|
ep = &iface->ep_desc[0];
|
||||||
|
|
||||||
|
@ -367,9 +371,9 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
|
||||||
USB_KBD_PRINTF("USB KBD found set protocol...\n");
|
USB_KBD_PRINTF("USB KBD found set protocol...\n");
|
||||||
/* ok, we found a USB Keyboard, install it */
|
/* ok, we found a USB Keyboard, install it */
|
||||||
/* usb_kbd_get_hid_desc(dev); */
|
/* usb_kbd_get_hid_desc(dev); */
|
||||||
usb_set_protocol(dev, iface->bInterfaceNumber, 0);
|
usb_set_protocol(dev, iface->desc.bInterfaceNumber, 0);
|
||||||
USB_KBD_PRINTF("USB KBD found set idle...\n");
|
USB_KBD_PRINTF("USB KBD found set idle...\n");
|
||||||
usb_set_idle(dev, iface->bInterfaceNumber, REPEAT_RATE, 0);
|
usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE, 0);
|
||||||
memset(&new[0], 0, 8);
|
memset(&new[0], 0, 8);
|
||||||
memset(&old[0], 0, 8);
|
memset(&old[0], 0, 8);
|
||||||
repeat_delay=0;
|
repeat_delay=0;
|
||||||
|
|
|
@ -1070,7 +1070,7 @@ retry_it:
|
||||||
int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
|
int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
|
||||||
struct us_data *ss)
|
struct us_data *ss)
|
||||||
{
|
{
|
||||||
struct usb_interface_descriptor *iface;
|
struct usb_interface *iface;
|
||||||
int i;
|
int i;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
|
|
||||||
|
@ -1094,9 +1094,9 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dev->descriptor.bDeviceClass != 0 ||
|
if (dev->descriptor.bDeviceClass != 0 ||
|
||||||
iface->bInterfaceClass != USB_CLASS_MASS_STORAGE ||
|
iface->desc.bInterfaceClass != USB_CLASS_MASS_STORAGE ||
|
||||||
iface->bInterfaceSubClass < US_SC_MIN ||
|
iface->desc.bInterfaceSubClass < US_SC_MIN ||
|
||||||
iface->bInterfaceSubClass > US_SC_MAX) {
|
iface->desc.bInterfaceSubClass > US_SC_MAX) {
|
||||||
/* if it's not a mass storage, we go no further */
|
/* if it's not a mass storage, we go no further */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1119,8 +1119,8 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
|
||||||
ss->subclass = subclass;
|
ss->subclass = subclass;
|
||||||
ss->protocol = protocol;
|
ss->protocol = protocol;
|
||||||
} else {
|
} else {
|
||||||
ss->subclass = iface->bInterfaceSubClass;
|
ss->subclass = iface->desc.bInterfaceSubClass;
|
||||||
ss->protocol = iface->bInterfaceProtocol;
|
ss->protocol = iface->desc.bInterfaceProtocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the handler pointers based on the protocol */
|
/* set the handler pointers based on the protocol */
|
||||||
|
@ -1153,7 +1153,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
|
||||||
* An optional interrupt is OK (necessary for CBI protocol).
|
* An optional interrupt is OK (necessary for CBI protocol).
|
||||||
* We will ignore any others.
|
* We will ignore any others.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < iface->bNumEndpoints; i++) {
|
for (i = 0; i < iface->desc.bNumEndpoints; i++) {
|
||||||
/* is it an BULK endpoint? */
|
/* is it an BULK endpoint? */
|
||||||
if ((iface->ep_desc[i].bmAttributes &
|
if ((iface->ep_desc[i].bmAttributes &
|
||||||
USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) {
|
USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) {
|
||||||
|
@ -1178,7 +1178,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
|
||||||
ss->ep_in, ss->ep_out, ss->ep_int);
|
ss->ep_in, ss->ep_out, ss->ep_int);
|
||||||
|
|
||||||
/* Do some basic sanity checks, and bail if we find a problem */
|
/* Do some basic sanity checks, and bail if we find a problem */
|
||||||
if (usb_set_interface(dev, iface->bInterfaceNumber, 0) ||
|
if (usb_set_interface(dev, iface->desc.bInterfaceNumber, 0) ||
|
||||||
!ss->ep_in || !ss->ep_out ||
|
!ss->ep_in || !ss->ep_out ||
|
||||||
(ss->protocol == US_PR_CBI && ss->ep_int == 0)) {
|
(ss->protocol == US_PR_CBI && ss->ep_int == 0)) {
|
||||||
USB_STOR_PRINTF("Problems with device\n");
|
USB_STOR_PRINTF("Problems with device\n");
|
||||||
|
|
|
@ -21,7 +21,7 @@ void process_endpoints(unsigned short usb2d0_intrin)
|
||||||
{
|
{
|
||||||
/*will hold the packet received */
|
/*will hold the packet received */
|
||||||
struct usb_device_descriptor usb_device_packet;
|
struct usb_device_descriptor usb_device_packet;
|
||||||
struct usb_config_descriptor usb_config_packet;
|
struct usb_configuration_descriptor usb_config_packet;
|
||||||
struct usb_string_descriptor usb_string_packet;
|
struct usb_string_descriptor usb_string_packet;
|
||||||
struct devrequest setup_packet;
|
struct devrequest setup_packet;
|
||||||
unsigned int *setup_packet_pt;
|
unsigned int *setup_packet_pt;
|
||||||
|
@ -99,7 +99,7 @@ void process_endpoints(unsigned short usb2d0_intrin)
|
||||||
usb_config_packet.bConfigurationValue = 1;
|
usb_config_packet.bConfigurationValue = 1;
|
||||||
usb_config_packet.iConfiguration = 0;
|
usb_config_packet.iConfiguration = 0;
|
||||||
usb_config_packet.bmAttributes = 0x40;
|
usb_config_packet.bmAttributes = 0x40;
|
||||||
usb_config_packet.MaxPower = 0;
|
usb_config_packet.bMaxPower = 0;
|
||||||
|
|
||||||
/*put packet in fifo */
|
/*put packet in fifo */
|
||||||
packet_pt = (unsigned char *)&usb_config_packet;
|
packet_pt = (unsigned char *)&usb_config_packet;
|
||||||
|
|
|
@ -96,7 +96,7 @@ static struct descriptor {
|
||||||
* UE_DIR_IN | EHCI_INTR_ENDPT
|
* UE_DIR_IN | EHCI_INTR_ENDPT
|
||||||
*/
|
*/
|
||||||
3, /* bmAttributes: UE_INTERRUPT */
|
3, /* bmAttributes: UE_INTERRUPT */
|
||||||
8, 0, /* wMaxPacketSize */
|
8, /* wMaxPacketSize */
|
||||||
255 /* bInterval */
|
255 /* bInterval */
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -803,7 +803,7 @@ void usb_event_poll()
|
||||||
{
|
{
|
||||||
struct stdio_dev *dev;
|
struct stdio_dev *dev;
|
||||||
struct usb_device *usb_kbd_dev;
|
struct usb_device *usb_kbd_dev;
|
||||||
struct usb_interface_descriptor *iface;
|
struct usb_interface *iface;
|
||||||
struct usb_endpoint_descriptor *ep;
|
struct usb_endpoint_descriptor *ep;
|
||||||
int pipe;
|
int pipe;
|
||||||
int maxp;
|
int maxp;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#define _USB_H_
|
#define _USB_H_
|
||||||
|
|
||||||
#include <usb_defs.h>
|
#include <usb_defs.h>
|
||||||
|
#include <usbdescriptors.h>
|
||||||
|
|
||||||
/* Everything is aribtrary */
|
/* Everything is aribtrary */
|
||||||
#define USB_ALTSETTINGALLOC 4
|
#define USB_ALTSETTINGALLOC 4
|
||||||
|
@ -41,13 +42,6 @@
|
||||||
|
|
||||||
#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
|
#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
|
||||||
|
|
||||||
/* String descriptor */
|
|
||||||
struct usb_string_descriptor {
|
|
||||||
unsigned char bLength;
|
|
||||||
unsigned char bDescriptorType;
|
|
||||||
unsigned short wData[1];
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
/* device request (setup) */
|
/* device request (setup) */
|
||||||
struct devrequest {
|
struct devrequest {
|
||||||
unsigned char requesttype;
|
unsigned char requesttype;
|
||||||
|
@ -63,47 +57,9 @@ struct usb_descriptor_header {
|
||||||
unsigned char bDescriptorType;
|
unsigned char bDescriptorType;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Device descriptor */
|
/* Interface */
|
||||||
struct usb_device_descriptor {
|
struct usb_interface {
|
||||||
unsigned char bLength;
|
struct usb_interface_descriptor desc;
|
||||||
unsigned char bDescriptorType;
|
|
||||||
unsigned short bcdUSB;
|
|
||||||
unsigned char bDeviceClass;
|
|
||||||
unsigned char bDeviceSubClass;
|
|
||||||
unsigned char bDeviceProtocol;
|
|
||||||
unsigned char bMaxPacketSize0;
|
|
||||||
unsigned short idVendor;
|
|
||||||
unsigned short idProduct;
|
|
||||||
unsigned short bcdDevice;
|
|
||||||
unsigned char iManufacturer;
|
|
||||||
unsigned char iProduct;
|
|
||||||
unsigned char iSerialNumber;
|
|
||||||
unsigned char bNumConfigurations;
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
/* Endpoint descriptor */
|
|
||||||
struct usb_endpoint_descriptor {
|
|
||||||
unsigned char bLength;
|
|
||||||
unsigned char bDescriptorType;
|
|
||||||
unsigned char bEndpointAddress;
|
|
||||||
unsigned char bmAttributes;
|
|
||||||
unsigned short wMaxPacketSize;
|
|
||||||
unsigned char bInterval;
|
|
||||||
unsigned char bRefresh;
|
|
||||||
unsigned char bSynchAddress;
|
|
||||||
} __attribute__ ((packed)) __attribute__ ((aligned(2)));
|
|
||||||
|
|
||||||
/* Interface descriptor */
|
|
||||||
struct usb_interface_descriptor {
|
|
||||||
unsigned char bLength;
|
|
||||||
unsigned char bDescriptorType;
|
|
||||||
unsigned char bInterfaceNumber;
|
|
||||||
unsigned char bAlternateSetting;
|
|
||||||
unsigned char bNumEndpoints;
|
|
||||||
unsigned char bInterfaceClass;
|
|
||||||
unsigned char bInterfaceSubClass;
|
|
||||||
unsigned char bInterfaceProtocol;
|
|
||||||
unsigned char iInterface;
|
|
||||||
|
|
||||||
unsigned char no_of_ep;
|
unsigned char no_of_ep;
|
||||||
unsigned char num_altsetting;
|
unsigned char num_altsetting;
|
||||||
|
@ -112,20 +68,12 @@ struct usb_interface_descriptor {
|
||||||
struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS];
|
struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
/* Configuration information.. */
|
||||||
/* Configuration descriptor information.. */
|
struct usb_config {
|
||||||
struct usb_config_descriptor {
|
struct usb_configuration_descriptor desc;
|
||||||
unsigned char bLength;
|
|
||||||
unsigned char bDescriptorType;
|
|
||||||
unsigned short wTotalLength;
|
|
||||||
unsigned char bNumInterfaces;
|
|
||||||
unsigned char bConfigurationValue;
|
|
||||||
unsigned char iConfiguration;
|
|
||||||
unsigned char bmAttributes;
|
|
||||||
unsigned char MaxPower;
|
|
||||||
|
|
||||||
unsigned char no_of_if; /* number of interfaces */
|
unsigned char no_of_if; /* number of interfaces */
|
||||||
struct usb_interface_descriptor if_desc[USB_MAXINTERFACES];
|
struct usb_interface if_desc[USB_MAXINTERFACES];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -156,7 +104,7 @@ struct usb_device {
|
||||||
|
|
||||||
int configno; /* selected config number */
|
int configno; /* selected config number */
|
||||||
struct usb_device_descriptor descriptor; /* Device Descriptor */
|
struct usb_device_descriptor descriptor; /* Device Descriptor */
|
||||||
struct usb_config_descriptor config; /* config descriptor */
|
struct usb_config config; /* config descriptor */
|
||||||
|
|
||||||
int have_langid; /* whether string_langid is valid yet */
|
int have_langid; /* whether string_langid is valid yet */
|
||||||
int string_langid; /* language ID for strings */
|
int string_langid; /* language ID for strings */
|
||||||
|
|
Loading…
Reference in a new issue