Lines Matching +full:usb +full:- +full:hub

1 // SPDX-License-Identifier: GPL-2.0
3 * USB-ACPI glue code
8 #include <linux/usb.h>
14 #include <linux/usb/hcd.h>
16 #include "hub.h"
19 * usb_acpi_power_manageable - check whether usb port has
21 * @hdev: USB device belonging to the usb hub
41 * usb_acpi_set_power_state - control usb port's power via acpi power
43 * @hdev: USB device belonging to the usb hub
47 * Notice to use usb_acpi_power_manageable() to check whether the usb port
54 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_acpi_set_power_state() local
59 int error = -EINVAL; in usb_acpi_set_power_state()
61 if (!hub) in usb_acpi_set_power_state()
62 return -ENODEV; in usb_acpi_set_power_state()
63 port_dev = hub->ports[port1 - 1]; in usb_acpi_set_power_state()
76 dev_dbg(&port_dev->dev, "acpi: power was set to %d\n", enable); in usb_acpi_set_power_state()
78 dev_dbg(&port_dev->dev, "acpi: power failed to be set\n"); in usb_acpi_set_power_state()
93 * According to 9.14 in ACPI Spec 6.2. _PLD indicates whether usb port in usb_acpi_get_connect_type()
96 * and disconnected with USB devices. If no visible and connectable, in usb_acpi_get_connect_type()
97 * a usb device is directly hard-wired to the port. If no visible and in usb_acpi_get_connect_type()
105 if (!upc || (upc->type != ACPI_TYPE_PACKAGE) || upc->package.count != 4) in usb_acpi_get_connect_type()
108 if (upc->package.elements[0].integer.value) in usb_acpi_get_connect_type()
109 if (pld->user_visible) in usb_acpi_get_connect_type()
113 else if (!pld->user_visible) in usb_acpi_get_connect_type()
122 * Private to usb-acpi, all the core needs to know is that
123 * port_dev->location is non-zero when it has been set by the firmware.
135 /* Get the struct usb_device point of port's hub */ in usb_acpi_get_companion_for_port()
136 udev = to_usb_device(port_dev->dev.parent->parent); in usb_acpi_get_companion_for_port()
139 * The root hub ports' parent is the root hub. The non-root-hub in usb_acpi_get_companion_for_port()
140 * ports' parent is the parent hub port which the hub is in usb_acpi_get_companion_for_port()
143 if (!udev->parent) { in usb_acpi_get_companion_for_port()
144 adev = ACPI_COMPANION(&udev->dev); in usb_acpi_get_companion_for_port()
145 port1 = usb_hcd_find_raw_port_number(bus_to_hcd(udev->bus), in usb_acpi_get_companion_for_port()
146 port_dev->portnum); in usb_acpi_get_companion_for_port()
148 parent_handle = usb_get_hub_port_acpi_handle(udev->parent, in usb_acpi_get_companion_for_port()
149 udev->portnum); in usb_acpi_get_companion_for_port()
154 port1 = port_dev->portnum; in usb_acpi_get_companion_for_port()
172 handle = adev->handle; in usb_acpi_find_companion_for_port()
175 port_dev->location = USB_ACPI_LOCATION_VALID in usb_acpi_find_companion_for_port()
176 | pld->group_token << 8 | pld->group_position; in usb_acpi_find_companion_for_port()
177 port_dev->connect_type = usb_acpi_get_connect_type(handle, pld); in usb_acpi_find_companion_for_port()
189 struct usb_hub *hub; in usb_acpi_find_companion_for_device() local
191 if (!udev->parent) { in usb_acpi_find_companion_for_device()
193 * root hub is only child (_ADR=0) under its parent, the HC. in usb_acpi_find_companion_for_device()
196 adev = ACPI_COMPANION(udev->bus->sysdev); in usb_acpi_find_companion_for_device()
200 hub = usb_hub_to_struct_hub(udev->parent); in usb_acpi_find_companion_for_device()
201 if (!hub) in usb_acpi_find_companion_for_device()
205 * This is an embedded USB device connected to a port and such in usb_acpi_find_companion_for_device()
208 port_dev = hub->ports[udev->portnum - 1]; in usb_acpi_find_companion_for_device()
215 * The USB hierarchy like following: in usb_acpi_find_companion()
226 * where HUBN is root hub, and PRNN are USB ports and devices in usb_acpi_find_companion()
228 * connected composite USB devices. PRNN and FNNN may contain in usb_acpi_find_companion()
232 * On the kernel side both root hub and embedded USB devices are in usb_acpi_find_companion()
240 * devices corresponding to USB interfaces. in usb_acpi_find_companion()
256 .name = "USB",