BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / cfe / cfe / usb / usbdevs.c
blob53a07544456e4c17cb397ddcfac15cf60845364c
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * USB Driver List File: usbdevs.c
5 *
6 * This module contains a table of supported USB devices and
7 * the routines to look up appropriate drivers given
8 * USB product, device, and class codes.
9 *
10 * Author: Mitch Lichtenberg (mpl@broadcom.com)
12 *********************************************************************
14 * Copyright 2000,2001,2002,2003
15 * Broadcom Corporation. All rights reserved.
17 * This software is furnished under license and may be used and
18 * copied only in accordance with the following terms and
19 * conditions. Subject to these conditions, you may download,
20 * copy, install, use, modify and distribute modified or unmodified
21 * copies of this software in source and/or binary form. No title
22 * or ownership is transferred hereby.
24 * 1) Any source code used, modified or distributed must reproduce
25 * and retain this copyright notice and list of conditions
26 * as they appear in the source file.
28 * 2) No right is granted to use any trade name, trademark, or
29 * logo of Broadcom Corporation. The "Broadcom Corporation"
30 * name may not be used to endorse or promote products derived
31 * from this software without the prior written permission of
32 * Broadcom Corporation.
34 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
35 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
36 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
38 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
39 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
40 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
44 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
45 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
46 * THE POSSIBILITY OF SUCH DAMAGE.
47 ********************************************************************* */
49 #ifndef _CFE_
50 #include <stdio.h>
51 #include <memory.h>
52 #include <stdint.h>
53 #include "usbhack.h"
54 #else
55 #include "lib_types.h"
56 #include "lib_string.h"
57 #include "lib_printf.h"
58 #endif
60 #include "lib_malloc.h"
61 #include "lib_queue.h"
62 #include "usbchap9.h"
63 #include "usbd.h"
65 /* *********************************************************************
66 * The list of drivers we support. If you add more drivers,
67 * list them here.
68 ********************************************************************* */
70 extern usb_driver_t usbhub_driver;
71 extern usb_driver_t usbhid_driver;
72 extern usb_driver_t usbmass_driver;
73 extern usb_driver_t usbserial_driver;
74 extern usb_driver_t usbeth_driver;
76 usb_drvlist_t usb_drivers[] = {
79 * Hub driver
82 {USB_DEVICE_CLASS_HUB, VENDOR_ANY, PRODUCT_ANY, &usbhub_driver},
85 * Keyboards and mice
88 {USB_DEVICE_CLASS_HUMAN_INTERFACE, VENDOR_ANY,PRODUCT_ANY, &usbhid_driver},
91 * Mass storage devices
94 {USB_DEVICE_CLASS_STORAGE, VENDOR_ANY, PRODUCT_ANY, &usbmass_driver},
97 * Serial ports
100 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x557,0x2008,&usbserial_driver},
103 * Ethernet Adapters
106 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x506,0x4601,&usbeth_driver}, /* 3Com */
107 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2202,&usbeth_driver}, /* Linksys */
108 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2203,&usbeth_driver}, /* Linksys */
109 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2204,&usbeth_driver}, /* Linksys */
110 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x2206,&usbeth_driver}, /* Linksys */
111 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x400b,&usbeth_driver}, /* Linksys */
112 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x66b,0x200c,&usbeth_driver}, /* Linksys */
113 {USB_DEVICE_CLASS_RESERVED,0xbda,0x8150,&usbeth_driver}, /* Realtek */
114 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x423,0x000a,&usbeth_driver}, /* CATC */
115 {USB_DEVICE_CLASS_VENDOR_SPECIFIC,0x423,0x000c,&usbeth_driver}, /* Belkin */
117 {0,0,0,NULL}
121 /* *********************************************************************
122 * usb_find_driver(class,vendor,product)
124 * Find a suitable device driver to handle the specified
125 * class, vendor, or product.
127 * Input parameters:
128 * devdescr - device descriptor
130 * Return value:
131 * pointer to device driver or NULL
132 ********************************************************************* */
134 usb_driver_t *usb_find_driver(usbdev_t *dev)
136 usb_device_descr_t *devdescr;
137 usb_interface_descr_t *ifdescr;
138 usb_drvlist_t *list;
139 int dclass,vendor,product;
141 devdescr = &(dev->ud_devdescr);
143 dclass = devdescr->bDeviceClass;
144 if (dclass == 0) {
145 ifdescr = usb_find_cfg_descr(dev,USB_INTERFACE_DESCRIPTOR_TYPE,0);
146 if (ifdescr) dclass = ifdescr->bInterfaceClass;
149 vendor = (int) GETUSBFIELD(devdescr,idVendor);
150 product = (int) GETUSBFIELD(devdescr,idProduct);
152 printf("USB: Locating Class %02X Vendor %04X Product %04X: ",dclass,vendor,product);
154 list = usb_drivers;
155 while (list->udl_disp) {
156 if (((list->udl_class == dclass) || (list->udl_class == CLASS_ANY)) &&
157 ((list->udl_vendor == vendor) || (list->udl_vendor == VENDOR_ANY)) &&
158 ((list->udl_product == product) || (list->udl_product == PRODUCT_ANY))) {
159 printf("%s\n",list->udl_disp->udrv_name);
160 return list->udl_disp;
162 list++;
165 printf("Not found.\n");
167 return NULL;