developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 1 | From 801da3c9fd916d3743b8af174f4ef4aefc071981 Mon Sep 17 00:00:00 2001 |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 2 | From: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 3 | Date: Thu, 17 Jun 2021 16:09:04 +0800 |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 4 | Subject: [PATCH 2/2] usb: add embedded Host feature support |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 5 | |
| 6 | add EH(Embedded Host) feature for PET authentication |
| 7 | 1. need CONFIG_USB_OTG_WHITELIST enable |
| 8 | CONFIG_USB_OTG_WHITELIST=y |
| 9 | |
| 10 | 2. host device tree node need include "tpl-support" keyword |
| 11 | &xhci { |
| 12 | tpl-support; |
| 13 | } |
| 14 | |
| 15 | Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 16 | --- |
| 17 | drivers/usb/core/hub.c | 9 +++++--- |
| 18 | drivers/usb/core/otg_whitelist.h | 39 ++++++++++++++++++++++++++++++++ |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 19 | drivers/usb/host/xhci-mtk.c | 2 ++ |
| 20 | 3 files changed, 47 insertions(+), 3 deletions(-) |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 21 | |
| 22 | diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 23 | index 303e8b3c1bda..b8c96ac26886 100644 |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 24 | --- a/drivers/usb/core/hub.c |
| 25 | +++ b/drivers/usb/core/hub.c |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 26 | @@ -2419,6 +2419,8 @@ static int usb_enumerate_device(struct usb_device *udev) |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 27 | if (err < 0) |
| 28 | dev_dbg(&udev->dev, "HNP fail, %d\n", err); |
| 29 | } |
| 30 | + |
| 31 | + dev_info(&udev->dev, "Unsupported Device!\n"); |
| 32 | return -ENOTSUPP; |
| 33 | } |
| 34 | |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 35 | @@ -4778,9 +4780,10 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 36 | goto fail; |
| 37 | } |
| 38 | if (r) { |
| 39 | - if (r != -ENODEV) |
| 40 | - dev_err(&udev->dev, "device descriptor read/64, error %d\n", |
| 41 | - r); |
| 42 | + if (r != -ENODEV) { |
| 43 | + dev_err(&udev->dev, "device descriptor read/64, error %d\n", r); |
| 44 | + dev_info(&udev->dev, "Device No Respond\n"); |
| 45 | + } |
| 46 | retval = -EMSGSIZE; |
| 47 | continue; |
| 48 | } |
| 49 | diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h |
| 50 | index 2ae90158ded7..a8dd221334c1 100644 |
| 51 | --- a/drivers/usb/core/otg_whitelist.h |
| 52 | +++ b/drivers/usb/core/otg_whitelist.h |
| 53 | @@ -39,9 +39,44 @@ static struct usb_device_id whitelist_table[] = { |
| 54 | { USB_DEVICE(0x0525, 0xa4a0), }, |
| 55 | #endif |
| 56 | |
| 57 | +/* xhci-mtk usb3 root-hub */ |
| 58 | +{ USB_DEVICE(0x1d6b, 0x0003), }, |
| 59 | + |
| 60 | +/* xhci-mtk usb2 root-hub */ |
| 61 | +{ USB_DEVICE(0x1d6b, 0x0002), }, |
| 62 | + |
| 63 | +/* */ |
| 64 | +{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, 0, 0) }, |
| 65 | + |
| 66 | { } /* Terminating entry */ |
| 67 | }; |
| 68 | |
| 69 | +static bool usb_match_any_interface(struct usb_device *udev, |
| 70 | + const struct usb_device_id *id) |
| 71 | +{ |
| 72 | + unsigned int i; |
| 73 | + |
| 74 | + for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) { |
| 75 | + struct usb_host_config *cfg = &udev->config[i]; |
| 76 | + unsigned int j; |
| 77 | + |
| 78 | + for (j = 0; j < cfg->desc.bNumInterfaces; ++j) { |
| 79 | + struct usb_interface_cache *cache; |
| 80 | + struct usb_host_interface *intf; |
| 81 | + |
| 82 | + cache = cfg->intf_cache[j]; |
| 83 | + if (cache->num_altsetting == 0) |
| 84 | + continue; |
| 85 | + |
| 86 | + intf = &cache->altsetting[0]; |
| 87 | + if (id->bInterfaceClass == intf->desc.bInterfaceClass) |
| 88 | + return true; |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + return false; |
| 93 | +} |
| 94 | + |
| 95 | static int is_targeted(struct usb_device *dev) |
| 96 | { |
| 97 | struct usb_device_id *id = whitelist_table; |
| 98 | @@ -90,6 +125,10 @@ static int is_targeted(struct usb_device *dev) |
| 99 | (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) |
| 100 | continue; |
| 101 | |
| 102 | + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) && |
| 103 | + !usb_match_any_interface(dev, id)) |
| 104 | + continue; |
| 105 | + |
| 106 | return 1; |
| 107 | } |
| 108 | |
| 109 | diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 110 | index 8bd4c95a5435..876e134a01b4 100644 |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 111 | --- a/drivers/usb/host/xhci-mtk.c |
| 112 | +++ b/drivers/usb/host/xhci-mtk.c |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 113 | @@ -560,6 +560,8 @@ static int xhci_mtk_probe(struct platform_device *pdev) |
developer | 00bd07d | 2021-06-24 09:20:42 +0800 | [diff] [blame] | 114 | goto disable_device_wakeup; |
| 115 | } |
| 116 | |
| 117 | + hcd->tpl_support = of_usb_host_tpl_support(node); |
| 118 | + xhci->shared_hcd->tpl_support = hcd->tpl_support; |
| 119 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); |
| 120 | if (ret) |
| 121 | goto put_usb3_hcd; |
| 122 | -- |
| 123 | 2.18.0 |
| 124 | |