developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame^] | 1 | From be6839b4144867c7ea6ffbedb6c6a2a42976e16d 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 | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3/3] 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 | abd06d7 | 2022-03-03 16:13:41 +0800 | [diff] [blame] | 23 | index 4cf0dc7f330d..f2f330606d0c 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 | abd06d7 | 2022-03-03 16:13:41 +0800 | [diff] [blame] | 26 | @@ -2422,6 +2422,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 | abd06d7 | 2022-03-03 16:13:41 +0800 | [diff] [blame] | 35 | @@ -4779,9 +4781,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 | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame^] | 110 | index d4345657945d..2a4b73a658f9 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 | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame^] | 113 | @@ -571,6 +571,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 | |