blob: 0a3514933cbe6c5f3e2a5377367074529625b5d6 [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
Julius Wernerd13e2c42013-09-17 22:16:04 -070050 * than one interface. The 'interface' value should specify the
51 * interface we want to use (interface numbers usually start at 0).
Stefan Reinauerb56f2d02010-03-25 22:17:36 +000052 */
Julius Wernerd13e2c42013-09-17 22:16:04 -070053 { 0x1267, 0x0103, USB_QUIRK_NONE, 0 }, // Keyboard Trust KB-1800S
54 { 0x0a12, 0x0001, USB_QUIRK_NONE, 0 }, // Bluetooth Allnet ALL1575
Stefan Reinauerb56f2d02010-03-25 22:17:36 +000055
56 /* Currently unsupported, possibly interesting devices:
57 * FTDI serial: device 0x0403:0x6001 is USB 1.10 (class ff)
58 * UPEK TouchChip: device 0x147e:0x2016 is USB 1.0 (class ff)
59 */
60};
61
62u32 usb_quirk_check(u16 vendor, u16 device)
63{
64 int i;
65 for (i = 0; i < ARRAY_SIZE(usb_quirks); i++) {
66 if ((usb_quirks[i].vendor == vendor) &&
67 (usb_quirks[i].device == device)) {
Gabe Black93ded592012-11-01 15:44:10 -070068 usb_debug("USB quirks enabled: %08x\n",
Stefan Reinauerb56f2d02010-03-25 22:17:36 +000069 usb_quirks[i].quirks);
70 return usb_quirks[i].quirks;
71 }
72 }
73
74 return USB_QUIRK_NONE;
75}
76
77int usb_interface_check(u16 vendor, u16 device)
78{
79 int i;
80 for (i = 0; i < ARRAY_SIZE(usb_quirks); i++) {
81 if ((usb_quirks[i].vendor == vendor) &&
82 (usb_quirks[i].device == device)) {
83 return usb_quirks[i].interface;
84 }
85 }
86
Julius Wernerd13e2c42013-09-17 22:16:04 -070087 return -1;
Stefan Reinauerb56f2d02010-03-25 22:17:36 +000088}