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
40 #define UUID_USB_CONTROLLER_DSM "ce2ee385-00e6-48cb-9f05-2edb927c4899"
44 * usb_acpi_port_lpm_incapable - check if lpm should be disabled for a port.
45 * @hdev: USB device belonging to the usb hub
51 * Arg0: UUID = ce2ee385-00e6-48cb-9f05-2edb927c4899
73 dev_dbg(&hdev->dev, "port-%d no acpi handle\n", port1); in usb_acpi_port_lpm_incapable()
74 return -ENODEV; in usb_acpi_port_lpm_incapable()
79 dev_dbg(&hdev->dev, "port-%d no _DSM function %d\n", in usb_acpi_port_lpm_incapable()
81 return -ENODEV; in usb_acpi_port_lpm_incapable()
88 dev_dbg(&hdev->dev, "evaluate port-%d _DSM failed\n", port1); in usb_acpi_port_lpm_incapable()
89 return -EINVAL; in usb_acpi_port_lpm_incapable()
92 if (obj->integer.value == 0x01) in usb_acpi_port_lpm_incapable()
102 * usb_acpi_set_power_state - control usb port's power via acpi power
104 * @hdev: USB device belonging to the usb hub
108 * Notice to use usb_acpi_power_manageable() to check whether the usb port
115 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_acpi_set_power_state() local
120 int error = -EINVAL; in usb_acpi_set_power_state()
122 if (!hub) in usb_acpi_set_power_state()
123 return -ENODEV; in usb_acpi_set_power_state()
124 port_dev = hub->ports[port1 - 1]; in usb_acpi_set_power_state()
137 dev_dbg(&port_dev->dev, "acpi: power was set to %d\n", enable); in usb_acpi_set_power_state()
139 dev_dbg(&port_dev->dev, "acpi: power failed to be set\n"); in usb_acpi_set_power_state()
154 * According to 9.14 in ACPI Spec 6.2. _PLD indicates whether usb port in usb_acpi_get_connect_type()
157 * and disconnected with USB devices. If no visible and connectable, in usb_acpi_get_connect_type()
158 * a usb device is directly hard-wired to the port. If no visible and in usb_acpi_get_connect_type()
166 if (!upc || (upc->type != ACPI_TYPE_PACKAGE) || upc->package.count != 4) in usb_acpi_get_connect_type()
169 if (upc->package.elements[0].integer.value) in usb_acpi_get_connect_type()
170 if (pld->user_visible) in usb_acpi_get_connect_type()
174 else if (!pld->user_visible) in usb_acpi_get_connect_type()
183 * Private to usb-acpi, all the core needs to know is that
184 * port_dev->location is non-zero when it has been set by the firmware.
196 /* Get the struct usb_device point of port's hub */ in usb_acpi_get_companion_for_port()
197 udev = to_usb_device(port_dev->dev.parent->parent); in usb_acpi_get_companion_for_port()
200 * The root hub ports' parent is the root hub. The non-root-hub in usb_acpi_get_companion_for_port()
201 * ports' parent is the parent hub port which the hub is in usb_acpi_get_companion_for_port()
204 if (!udev->parent) { in usb_acpi_get_companion_for_port()
205 adev = ACPI_COMPANION(&udev->dev); in usb_acpi_get_companion_for_port()
206 port1 = usb_hcd_find_raw_port_number(bus_to_hcd(udev->bus), in usb_acpi_get_companion_for_port()
207 port_dev->portnum); in usb_acpi_get_companion_for_port()
209 parent_handle = usb_get_hub_port_acpi_handle(udev->parent, in usb_acpi_get_companion_for_port()
210 udev->portnum); in usb_acpi_get_companion_for_port()
215 port1 = port_dev->portnum; in usb_acpi_get_companion_for_port()
233 handle = adev->handle; in usb_acpi_find_companion_for_port()
236 port_dev->location = USB_ACPI_LOCATION_VALID in usb_acpi_find_companion_for_port()
237 | pld->group_token << 8 | pld->group_position; in usb_acpi_find_companion_for_port()
238 port_dev->connect_type = usb_acpi_get_connect_type(handle, pld); in usb_acpi_find_companion_for_port()
250 struct usb_hub *hub; in usb_acpi_find_companion_for_device() local
252 if (!udev->parent) { in usb_acpi_find_companion_for_device()
254 * root hub is only child (_ADR=0) under its parent, the HC. in usb_acpi_find_companion_for_device()
257 adev = ACPI_COMPANION(udev->bus->sysdev); in usb_acpi_find_companion_for_device()
261 hub = usb_hub_to_struct_hub(udev->parent); in usb_acpi_find_companion_for_device()
262 if (!hub) in usb_acpi_find_companion_for_device()
266 * This is an embedded USB device connected to a port and such in usb_acpi_find_companion_for_device()
269 port_dev = hub->ports[udev->portnum - 1]; in usb_acpi_find_companion_for_device()
276 * The USB hierarchy like following: in usb_acpi_find_companion()
287 * where HUBN is root hub, and PRNN are USB ports and devices in usb_acpi_find_companion()
289 * connected composite USB devices. PRNN and FNNN may contain in usb_acpi_find_companion()
293 * On the kernel side both root hub and embedded USB devices are in usb_acpi_find_companion()
301 * devices corresponding to USB interfaces. in usb_acpi_find_companion()
317 .name = "USB",