blob: 7776441b7cf9908402a4e4fc5d319c1a2dfedc9e [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From 32950d08c99f51e88a2db8dd30c5076a4947de24 Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:27 +0800
4Subject: [PATCH]
developer3de3aca2023-06-07 20:44:59 +08005 [high-speed-io][999-2622-usb-add-embedded-Host-feature-support.patch]
developer00bd07d2021-06-24 09:20:42 +08006
developer00bd07d2021-06-24 09:20:42 +08007---
8 drivers/usb/core/hub.c | 9 +++++---
9 drivers/usb/core/otg_whitelist.h | 39 ++++++++++++++++++++++++++++++++
developerba28e032021-12-07 10:40:00 +080010 drivers/usb/host/xhci-mtk.c | 2 ++
11 3 files changed, 47 insertions(+), 3 deletions(-)
developer00bd07d2021-06-24 09:20:42 +080012
13diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
developer5d148cb2023-06-02 13:08:11 +080014index f787e9771..7687711f1 100644
developer00bd07d2021-06-24 09:20:42 +080015--- a/drivers/usb/core/hub.c
16+++ b/drivers/usb/core/hub.c
developer5d148cb2023-06-02 13:08:11 +080017@@ -2424,6 +2424,8 @@ static int usb_enumerate_device(struct usb_device *udev)
developer00bd07d2021-06-24 09:20:42 +080018 if (err < 0)
19 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
20 }
21+
22+ dev_info(&udev->dev, "Unsupported Device!\n");
23 return -ENOTSUPP;
24 }
25
developer5d148cb2023-06-02 13:08:11 +080026@@ -4781,9 +4783,10 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
developer00bd07d2021-06-24 09:20:42 +080027 goto fail;
28 }
29 if (r) {
30- if (r != -ENODEV)
31- dev_err(&udev->dev, "device descriptor read/64, error %d\n",
32- r);
33+ if (r != -ENODEV) {
34+ dev_err(&udev->dev, "device descriptor read/64, error %d\n", r);
35+ dev_info(&udev->dev, "Device No Respond\n");
36+ }
37 retval = -EMSGSIZE;
38 continue;
39 }
40diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h
developer5d148cb2023-06-02 13:08:11 +080041index 2ae90158d..a8dd22133 100644
developer00bd07d2021-06-24 09:20:42 +080042--- a/drivers/usb/core/otg_whitelist.h
43+++ b/drivers/usb/core/otg_whitelist.h
44@@ -39,9 +39,44 @@ static struct usb_device_id whitelist_table[] = {
45 { USB_DEVICE(0x0525, 0xa4a0), },
46 #endif
47
48+/* xhci-mtk usb3 root-hub */
49+{ USB_DEVICE(0x1d6b, 0x0003), },
50+
51+/* xhci-mtk usb2 root-hub */
52+{ USB_DEVICE(0x1d6b, 0x0002), },
53+
54+/* */
55+{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, 0, 0) },
56+
57 { } /* Terminating entry */
58 };
59
60+static bool usb_match_any_interface(struct usb_device *udev,
61+ const struct usb_device_id *id)
62+{
63+ unsigned int i;
64+
65+ for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
66+ struct usb_host_config *cfg = &udev->config[i];
67+ unsigned int j;
68+
69+ for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
70+ struct usb_interface_cache *cache;
71+ struct usb_host_interface *intf;
72+
73+ cache = cfg->intf_cache[j];
74+ if (cache->num_altsetting == 0)
75+ continue;
76+
77+ intf = &cache->altsetting[0];
78+ if (id->bInterfaceClass == intf->desc.bInterfaceClass)
79+ return true;
80+ }
81+ }
82+
83+ return false;
84+}
85+
86 static int is_targeted(struct usb_device *dev)
87 {
88 struct usb_device_id *id = whitelist_table;
89@@ -90,6 +125,10 @@ static int is_targeted(struct usb_device *dev)
90 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
91 continue;
92
93+ if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
94+ !usb_match_any_interface(dev, id))
95+ continue;
96+
97 return 1;
98 }
99
100diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
developer5d148cb2023-06-02 13:08:11 +0800101index 7a2007931..19b54c343 100644
developer00bd07d2021-06-24 09:20:42 +0800102--- a/drivers/usb/host/xhci-mtk.c
103+++ b/drivers/usb/host/xhci-mtk.c
developer5d148cb2023-06-02 13:08:11 +0800104@@ -575,6 +575,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
developer00bd07d2021-06-24 09:20:42 +0800105 goto disable_device_wakeup;
106 }
107
108+ hcd->tpl_support = of_usb_host_tpl_support(node);
109+ xhci->shared_hcd->tpl_support = hcd->tpl_support;
110 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
111 if (ret)
112 goto put_usb3_hcd;
113--
developer5d148cb2023-06-02 13:08:11 +08001142.34.1
developer00bd07d2021-06-24 09:20:42 +0800115