blob: c4970ebc0b9292db20027244d6c18ae481f82948 [file] [log] [blame]
developer3c58fe12022-08-15 17:17:33 +08001From be6839b4144867c7ea6ffbedb6c6a2a42976e16d 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
developer3c58fe12022-08-15 17:17:33 +08004Subject: [PATCH 3/3] 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
developerabd06d72022-03-03 16:13:41 +080023index 4cf0dc7f330d..f2f330606d0c 100644
developer00bd07d2021-06-24 09:20:42 +080024--- a/drivers/usb/core/hub.c
25+++ b/drivers/usb/core/hub.c
developerabd06d72022-03-03 16:13:41 +080026@@ -2422,6 +2422,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
developerabd06d72022-03-03 16:13:41 +080035@@ -4779,9 +4781,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
developer3c58fe12022-08-15 17:17:33 +0800110index d4345657945d..2a4b73a658f9 100644
developer00bd07d2021-06-24 09:20:42 +0800111--- a/drivers/usb/host/xhci-mtk.c
112+++ b/drivers/usb/host/xhci-mtk.c
developer3c58fe12022-08-15 17:17:33 +0800113@@ -571,6 +571,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