blob: 356ae99f80b5ce97598c7202579e6a12814aad44 [file] [log] [blame]
developerba28e032021-12-07 10:40:00 +08001From 801da3c9fd916d3743b8af174f4ef4aefc071981 Mon Sep 17 00:00:00 2001
developer00bd07d2021-06-24 09:20:42 +08002From: Zhanyong Wang <zhanyong.wang@mediatek.com>
3Date: Thu, 17 Jun 2021 16:09:04 +0800
developerba28e032021-12-07 10:40:00 +08004Subject: [PATCH 2/2] usb: add embedded Host feature support
developer00bd07d2021-06-24 09:20:42 +08005
6add EH(Embedded Host) feature for PET authentication
71. need CONFIG_USB_OTG_WHITELIST enable
8 CONFIG_USB_OTG_WHITELIST=y
9
102. host device tree node need include "tpl-support" keyword
11 &xhci {
12 tpl-support;
13 }
14
15Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
16---
17 drivers/usb/core/hub.c | 9 +++++---
18 drivers/usb/core/otg_whitelist.h | 39 ++++++++++++++++++++++++++++++++
developerba28e032021-12-07 10:40:00 +080019 drivers/usb/host/xhci-mtk.c | 2 ++
20 3 files changed, 47 insertions(+), 3 deletions(-)
developer00bd07d2021-06-24 09:20:42 +080021
22diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
developerba28e032021-12-07 10:40:00 +080023index 303e8b3c1bda..b8c96ac26886 100644
developer00bd07d2021-06-24 09:20:42 +080024--- a/drivers/usb/core/hub.c
25+++ b/drivers/usb/core/hub.c
developerba28e032021-12-07 10:40:00 +080026@@ -2419,6 +2419,8 @@ static int usb_enumerate_device(struct usb_device *udev)
developer00bd07d2021-06-24 09:20:42 +080027 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
developerba28e032021-12-07 10:40:00 +080035@@ -4778,9 +4780,10 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
developer00bd07d2021-06-24 09:20:42 +080036 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 }
49diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h
50index 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
109diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
developerba28e032021-12-07 10:40:00 +0800110index 8bd4c95a5435..876e134a01b4 100644
developer00bd07d2021-06-24 09:20:42 +0800111--- a/drivers/usb/host/xhci-mtk.c
112+++ b/drivers/usb/host/xhci-mtk.c
developerba28e032021-12-07 10:40:00 +0800113@@ -560,6 +560,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
developer00bd07d2021-06-24 09:20:42 +0800114 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--
1232.18.0
124