.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
---|
2 | | -/** |
---|
| 2 | +/* |
---|
3 | 3 | * host.c - DesignWare USB3 DRD Controller Host Glue |
---|
4 | 4 | * |
---|
5 | | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com |
---|
| 5 | + * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com |
---|
6 | 6 | * |
---|
7 | 7 | * Authors: Felipe Balbi <balbi@ti.com>, |
---|
8 | 8 | */ |
---|
9 | 9 | |
---|
| 10 | +#include <linux/acpi.h> |
---|
10 | 11 | #include <linux/platform_device.h> |
---|
11 | 12 | |
---|
12 | 13 | #include "core.h" |
---|
.. | .. |
---|
16 | 17 | struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); |
---|
17 | 18 | int irq; |
---|
18 | 19 | |
---|
19 | | - irq = platform_get_irq_byname(dwc3_pdev, "host"); |
---|
| 20 | + irq = platform_get_irq_byname_optional(dwc3_pdev, "host"); |
---|
20 | 21 | if (irq > 0) |
---|
21 | 22 | goto out; |
---|
22 | 23 | |
---|
23 | 24 | if (irq == -EPROBE_DEFER) |
---|
24 | 25 | goto out; |
---|
25 | 26 | |
---|
26 | | - irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3"); |
---|
| 27 | + irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3"); |
---|
27 | 28 | if (irq > 0) |
---|
28 | 29 | goto out; |
---|
29 | 30 | |
---|
.. | .. |
---|
34 | 35 | if (irq > 0) |
---|
35 | 36 | goto out; |
---|
36 | 37 | |
---|
37 | | - if (irq != -EPROBE_DEFER) |
---|
38 | | - dev_err(dwc->dev, "missing host IRQ\n"); |
---|
39 | | - |
---|
40 | 38 | if (!irq) |
---|
41 | 39 | irq = -EINVAL; |
---|
42 | 40 | |
---|
.. | .. |
---|
46 | 44 | |
---|
47 | 45 | int dwc3_host_init(struct dwc3 *dwc) |
---|
48 | 46 | { |
---|
49 | | - struct property_entry props[8]; |
---|
| 47 | + struct property_entry props[5]; |
---|
50 | 48 | struct platform_device *xhci; |
---|
51 | 49 | int ret, irq; |
---|
52 | 50 | struct resource *res; |
---|
.. | .. |
---|
78 | 76 | } |
---|
79 | 77 | |
---|
80 | 78 | xhci->dev.parent = dwc->dev; |
---|
| 79 | + ACPI_COMPANION_SET(&xhci->dev, ACPI_COMPANION(dwc->dev)); |
---|
81 | 80 | |
---|
82 | 81 | dwc->xhci = xhci; |
---|
83 | 82 | |
---|
.. | .. |
---|
85 | 84 | DWC3_XHCI_RESOURCES_NUM); |
---|
86 | 85 | if (ret) { |
---|
87 | 86 | dev_err(dwc->dev, "couldn't add resources to xHCI device\n"); |
---|
88 | | - goto err1; |
---|
| 87 | + goto err; |
---|
89 | 88 | } |
---|
90 | 89 | |
---|
91 | 90 | memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props)); |
---|
92 | 91 | |
---|
93 | 92 | 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"); |
---|
101 | 94 | |
---|
102 | 95 | if (dwc->usb2_lpm_disable) |
---|
103 | | - props[prop_idx++].name = "usb2-lpm-disable"; |
---|
| 96 | + props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb2-lpm-disable"); |
---|
104 | 97 | |
---|
105 | | - if (dwc->dis_u3_autosuspend_quirk) |
---|
106 | | - props[prop_idx++].name = "usb3-dis-autosuspend"; |
---|
107 | 98 | /** |
---|
108 | 99 | * WORKAROUND: dwc3 revisions <=3.00a have a limitation |
---|
109 | 100 | * where Port Disable command doesn't work. |
---|
.. | .. |
---|
113 | 104 | * |
---|
114 | 105 | * This following flag tells XHCI to do just that. |
---|
115 | 106 | */ |
---|
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"); |
---|
121 | 109 | |
---|
122 | 110 | 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"); |
---|
124 | 112 | |
---|
125 | 113 | if (prop_idx) { |
---|
126 | 114 | ret = platform_device_add_properties(xhci, props); |
---|
127 | 115 | if (ret) { |
---|
128 | 116 | dev_err(dwc->dev, "failed to add properties to xHCI\n"); |
---|
129 | | - goto err1; |
---|
| 117 | + goto err; |
---|
130 | 118 | } |
---|
131 | 119 | } |
---|
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)); |
---|
137 | 120 | |
---|
138 | 121 | ret = platform_device_add(xhci); |
---|
139 | 122 | if (ret) { |
---|
140 | 123 | dev_err(dwc->dev, "failed to register xHCI device\n"); |
---|
141 | | - goto err2; |
---|
| 124 | + goto err; |
---|
142 | 125 | } |
---|
143 | 126 | |
---|
144 | 127 | 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: |
---|
151 | 129 | platform_device_put(xhci); |
---|
152 | 130 | return ret; |
---|
153 | 131 | } |
---|
154 | | -EXPORT_SYMBOL_GPL(dwc3_host_init); |
---|
155 | 132 | |
---|
156 | 133 | void dwc3_host_exit(struct dwc3 *dwc) |
---|
157 | 134 | { |
---|
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)); |
---|
162 | 135 | platform_device_unregister(dwc->xhci); |
---|
| 136 | + dwc->xhci = NULL; |
---|
163 | 137 | } |
---|
164 | | -EXPORT_SYMBOL_GPL(dwc3_host_exit); |
---|