Stefan Reinauer | b56f2d0 | 2010-03-25 22:17:36 +0000 | [diff] [blame] | 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 */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 46 | { 0x3538, 0x0054, USB_QUIRK_NONE, 0 }, // PQI 1GB |
Stefan Reinauer | b56f2d0 | 2010-03-25 22:17:36 +0000 | [diff] [blame] | 47 | { 0x13fd, 0x0841, USB_QUIRK_NONE, 0 }, // Samsung SE-S084 |
| 48 | |
| 49 | /* Silence the warning for known devices with more |
Julius Werner | d13e2c4 | 2013-09-17 22:16:04 -0700 | [diff] [blame] | 50 | * than one interface. The 'interface' value should specify the |
| 51 | * interface we want to use (interface numbers usually start at 0). |
Stefan Reinauer | b56f2d0 | 2010-03-25 22:17:36 +0000 | [diff] [blame] | 52 | */ |
Julius Werner | d13e2c4 | 2013-09-17 22:16:04 -0700 | [diff] [blame] | 53 | { 0x1267, 0x0103, USB_QUIRK_NONE, 0 }, // Keyboard Trust KB-1800S |
| 54 | { 0x0a12, 0x0001, USB_QUIRK_NONE, 0 }, // Bluetooth Allnet ALL1575 |
Stefan Reinauer | b56f2d0 | 2010-03-25 22:17:36 +0000 | [diff] [blame] | 55 | |
| 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 | |
| 62 | u32 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 Black | 93ded59 | 2012-11-01 15:44:10 -0700 | [diff] [blame] | 68 | usb_debug("USB quirks enabled: %08x\n", |
Stefan Reinauer | b56f2d0 | 2010-03-25 22:17:36 +0000 | [diff] [blame] | 69 | usb_quirks[i].quirks); |
| 70 | return usb_quirks[i].quirks; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return USB_QUIRK_NONE; |
| 75 | } |
| 76 | |
| 77 | int 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 Werner | d13e2c4 | 2013-09-17 22:16:04 -0700 | [diff] [blame] | 87 | return -1; |
Stefan Reinauer | b56f2d0 | 2010-03-25 22:17:36 +0000 | [diff] [blame] | 88 | } |