libpayload: Fix OHCI some more
[coreboot.git] / payloads / libpayload / drivers / usb / quirks.c
1 /*
2  * This file is part of the libpayload project.
3  *
4  * Copyright (C) 2010 coresystems GmbH
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29
30 //#define USB_DEBUG
31
32 #include <libpayload-config.h>
33 #include <usb/usb.h>
34
35 typedef struct {
36         u16 vendor, device;
37         u32 quirks;
38         int interface;
39 } usb_quirks_t;
40
41 // IDs without a quirk don't need to be mentioned in this list
42 // but some are here for easier testing.
43
44 usb_quirks_t usb_quirks[] = {
45         /* Working chips,... remove before next release */
46         { 0x3538, 0x0054, USB_QUIRK_NONE, 0 },  // PQI 1GB
47         { 0x13fd, 0x0841, USB_QUIRK_NONE, 0 },  // Samsung SE-S084
48
49         /* Silence the warning for known devices with more
50          * than one interface
51          */
52         { 0x1267, 0x0103, USB_QUIRK_NONE, 1 },  // Keyboard Trust KB-1800S
53         { 0x0a12, 0x0001, USB_QUIRK_NONE, 1 },  // Bluetooth Allnet ALL1575
54
55         /* Currently unsupported, possibly interesting devices:
56          * FTDI serial: device 0x0403:0x6001 is USB 1.10 (class ff)
57          * UPEK TouchChip: device 0x147e:0x2016 is USB 1.0 (class ff)
58          */
59 };
60
61 u32 usb_quirk_check(u16 vendor, u16 device)
62 {
63         int i;
64         for (i = 0; i < ARRAY_SIZE(usb_quirks); i++) {
65                 if ((usb_quirks[i].vendor == vendor) &&
66                                 (usb_quirks[i].device == device)) {
67                         debug("USB quirks enabled: %08x\n",
68                                         usb_quirks[i].quirks);
69                         return usb_quirks[i].quirks;
70                 }
71         }
72
73         return USB_QUIRK_NONE;
74 }
75
76 int usb_interface_check(u16 vendor, u16 device)
77 {
78         int i;
79         for (i = 0; i < ARRAY_SIZE(usb_quirks); i++) {
80                 if ((usb_quirks[i].vendor == vendor) &&
81                                 (usb_quirks[i].device == device)) {
82                         return usb_quirks[i].interface;
83                 }
84         }
85
86         return 0;
87 }
88