forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/usb/dwc3/host.c
....@@ -1,12 +1,13 @@
11 // SPDX-License-Identifier: GPL-2.0
2
-/**
2
+/*
33 * host.c - DesignWare USB3 DRD Controller Host Glue
44 *
5
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
5
+ * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com
66 *
77 * Authors: Felipe Balbi <balbi@ti.com>,
88 */
99
10
+#include <linux/acpi.h>
1011 #include <linux/platform_device.h>
1112
1213 #include "core.h"
....@@ -16,14 +17,14 @@
1617 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
1718 int irq;
1819
19
- irq = platform_get_irq_byname(dwc3_pdev, "host");
20
+ irq = platform_get_irq_byname_optional(dwc3_pdev, "host");
2021 if (irq > 0)
2122 goto out;
2223
2324 if (irq == -EPROBE_DEFER)
2425 goto out;
2526
26
- irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
27
+ irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3");
2728 if (irq > 0)
2829 goto out;
2930
....@@ -34,9 +35,6 @@
3435 if (irq > 0)
3536 goto out;
3637
37
- if (irq != -EPROBE_DEFER)
38
- dev_err(dwc->dev, "missing host IRQ\n");
39
-
4038 if (!irq)
4139 irq = -EINVAL;
4240
....@@ -46,7 +44,7 @@
4644
4745 int dwc3_host_init(struct dwc3 *dwc)
4846 {
49
- struct property_entry props[8];
47
+ struct property_entry props[5];
5048 struct platform_device *xhci;
5149 int ret, irq;
5250 struct resource *res;
....@@ -78,6 +76,7 @@
7876 }
7977
8078 xhci->dev.parent = dwc->dev;
79
+ ACPI_COMPANION_SET(&xhci->dev, ACPI_COMPANION(dwc->dev));
8180
8281 dwc->xhci = xhci;
8382
....@@ -85,25 +84,17 @@
8584 DWC3_XHCI_RESOURCES_NUM);
8685 if (ret) {
8786 dev_err(dwc->dev, "couldn't add resources to xHCI device\n");
88
- goto err1;
87
+ goto err;
8988 }
9089
9190 memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props));
9291
9392 if (dwc->usb3_lpm_capable)
94
- props[prop_idx++].name = "usb3-lpm-capable";
95
-
96
- if (dwc->xhci_slow_suspend_quirk)
97
- props[prop_idx++].name = "xhci-slow-suspend";
98
-
99
- if (dwc->xhci_trb_ent_quirk)
100
- props[prop_idx++].name = "xhci-trb-ent-quirk";
93
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb3-lpm-capable");
10194
10295 if (dwc->usb2_lpm_disable)
103
- props[prop_idx++].name = "usb2-lpm-disable";
96
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb2-lpm-disable");
10497
105
- if (dwc->dis_u3_autosuspend_quirk)
106
- props[prop_idx++].name = "usb3-dis-autosuspend";
10798 /**
10899 * WORKAROUND: dwc3 revisions <=3.00a have a limitation
109100 * where Port Disable command doesn't work.
....@@ -113,52 +104,34 @@
113104 *
114105 * This following flag tells XHCI to do just that.
115106 */
116
- if (dwc->revision <= DWC3_REVISION_300A)
117
- props[prop_idx++].name = "quirk-broken-port-ped";
118
-
119
- if (dwc->xhci_warm_reset_on_suspend_quirk)
120
- props[prop_idx++].name = "xhci-warm-reset-on-suspend";
107
+ if (DWC3_VER_IS_WITHIN(DWC3, ANY, 300A))
108
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("quirk-broken-port-ped");
121109
122110 if (!dwc->dis_u2_susphy_quirk)
123
- props[prop_idx++].name = "xhci-u2-broken-suspend";
111
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-u2-broken-suspend");
124112
125113 if (prop_idx) {
126114 ret = platform_device_add_properties(xhci, props);
127115 if (ret) {
128116 dev_err(dwc->dev, "failed to add properties to xHCI\n");
129
- goto err1;
117
+ goto err;
130118 }
131119 }
132
-
133
- phy_create_lookup(dwc->usb2_generic_phy, "usb2-phy",
134
- dev_name(dwc->dev));
135
- phy_create_lookup(dwc->usb3_generic_phy, "usb3-phy",
136
- dev_name(dwc->dev));
137120
138121 ret = platform_device_add(xhci);
139122 if (ret) {
140123 dev_err(dwc->dev, "failed to register xHCI device\n");
141
- goto err2;
124
+ goto err;
142125 }
143126
144127 return 0;
145
-err2:
146
- phy_remove_lookup(dwc->usb2_generic_phy, "usb2-phy",
147
- dev_name(dwc->dev));
148
- phy_remove_lookup(dwc->usb3_generic_phy, "usb3-phy",
149
- dev_name(dwc->dev));
150
-err1:
128
+err:
151129 platform_device_put(xhci);
152130 return ret;
153131 }
154
-EXPORT_SYMBOL_GPL(dwc3_host_init);
155132
156133 void dwc3_host_exit(struct dwc3 *dwc)
157134 {
158
- phy_remove_lookup(dwc->usb2_generic_phy, "usb2-phy",
159
- dev_name(dwc->dev));
160
- phy_remove_lookup(dwc->usb3_generic_phy, "usb3-phy",
161
- dev_name(dwc->dev));
162135 platform_device_unregister(dwc->xhci);
136
+ dwc->xhci = NULL;
163137 }
164
-EXPORT_SYMBOL_GPL(dwc3_host_exit);