blob: a8f2622e31e9f126555cbb974933c849edecdef4 [file] [log] [blame]
Stefan Reinauerb56f2d02010-03-25 22:17:36 +00001/*
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
35typedef 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
44usb_quirks_t usb_quirks[] = {
45 /* Working chips,... remove before next release */
Stefan Reinauer14e22772010-04-27 06:56:47 +000046 { 0x3538, 0x0054, USB_QUIRK_NONE, 0 }, // PQI 1GB
Stefan Reinauerb56f2d02010-03-25 22:17:36 +000047 { 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
Stefan Reinauer14e22772010-04-27 06:56:47 +000053 { 0x0a12, 0x0001, USB_QUIRK_NONE, 1 }, // Bluetooth Allnet ALL1575
Stefan Reinauerb56f2d02010-03-25 22:17:36 +000054
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
61u32 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)) {
Gabe Black93ded592012-11-01 15:44:10 -070067 usb_debug("USB quirks enabled: %08x\n",
Stefan Reinauerb56f2d02010-03-25 22:17:36 +000068 usb_quirks[i].quirks);
69 return usb_quirks[i].quirks;
70 }
71 }
72
73 return USB_QUIRK_NONE;
74}
75
76int 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