@@ -200,30 +200,56 @@ static struct acpi_device *
200
200
usb_acpi_find_companion_for_device (struct usb_device * udev )
201
201
{
202
202
struct acpi_device * adev ;
203
+ struct usb_port * port_dev ;
204
+ struct usb_hub * hub ;
205
+
206
+ if (!udev -> parent ) {
207
+ /* root hub is only child (_ADR=0) under its parent, the HC */
208
+ adev = ACPI_COMPANION (udev -> dev .parent );
209
+ return acpi_find_child_device (adev , 0 , false);
210
+ }
203
211
204
- if (!udev -> parent )
212
+ hub = usb_hub_to_struct_hub (udev -> parent );
213
+ if (!hub )
205
214
return NULL ;
206
215
207
- /* root hub is only child (_ADR=0) under its parent, the HC */
208
- adev = ACPI_COMPANION (udev -> dev .parent );
209
- return acpi_find_child_device (adev , 0 , false);
216
+ /*
217
+ * This is an embedded USB device connected to a port and such
218
+ * devices share port's ACPI companion.
219
+ */
220
+ port_dev = hub -> ports [udev -> portnum - 1 ];
221
+ return usb_acpi_get_companion_for_port (port_dev );
210
222
}
211
223
212
-
213
224
static struct acpi_device * usb_acpi_find_companion (struct device * dev )
214
225
{
215
226
/*
216
- * In the ACPI DSDT table, only usb root hub and usb ports are
217
- * acpi device nodes. The hierarchy like following.
227
+ * The USB hierarchy like following:
228
+ *
218
229
* Device (EHC1)
219
230
* Device (HUBN)
220
231
* Device (PR01)
221
232
* Device (PR11)
222
233
* Device (PR12)
234
+ * Device (FN12)
235
+ * Device (FN13)
223
236
* Device (PR13)
224
237
* ...
225
- * So all binding process is divided into two parts. binding
226
- * root hub and usb ports.
238
+ * where HUBN is root hub, and PRNN are USB ports and devices
239
+ * connected to them, and FNNN are individualk functions for
240
+ * connected composite USB devices. PRNN and FNNN may contain
241
+ * _CRS and other methods describing sideband resources for
242
+ * the connected device.
243
+ *
244
+ * On the kernel side both root hub and embedded USB devices are
245
+ * represented as instances of usb_device structure, and ports
246
+ * are represented as usb_port structures, so the whole process
247
+ * is split into 2 parts: finding companions for devices and
248
+ * finding companions for ports.
249
+ *
250
+ * Note that we do not handle individual functions of composite
251
+ * devices yet, for that we would need to assign companions to
252
+ * devices corresponding to USB interfaces.
227
253
*/
228
254
if (is_usb_device (dev ))
229
255
return usb_acpi_find_companion_for_device (to_usb_device (dev ));
0 commit comments