Lines Matching +full:usb3 +full:- +full:if
1 // SPDX-License-Identifier: GPL-2.0
3 * USB-ACPI glue code
19 * usb_acpi_power_manageable - check whether usb port has
24 * Return true if the port has acpi power resource and false if no.
33 if (port_handle) in usb_acpi_power_manageable()
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.
48 * Some USB3 ports may not support USB3 link power management U1/U2 states
50 * if U1 and U2 states should be disabled. Evaluate _DSM with:
51 * Arg0: UUID = ce2ee385-00e6-48cb-9f05-2edb927c4899
56 * Return 1 if USB3 port is LPM incapable, negative on error, otherwise 0
68 if (ret) in usb_acpi_port_lpm_incapable()
72 if (!port_handle) { in usb_acpi_port_lpm_incapable()
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()
77 if (!acpi_check_dsm(port_handle, &guid, 0, 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()
87 if (!obj) { 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
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()
127 if (!port_handle) in usb_acpi_set_power_state()
130 if (enable) in usb_acpi_set_power_state()
136 if (!error) 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()
146 * usb_acpi_add_usb4_devlink - add device link to USB4 Host Interface for tunneled USB3 devices
148 * @udev: Tunneled USB3 device connected to a roothub.
150 * Adds a device link between a tunneled USB3 device and the USB4 Host Interface
152 * should only be called for tunneled USB3 devices.
164 if (!udev->parent || udev->parent->parent) in usb_acpi_add_usb4_devlink()
167 hub = usb_hub_to_struct_hub(udev->parent); in usb_acpi_add_usb4_devlink()
168 port_dev = hub->ports[udev->portnum - 1]; in usb_acpi_add_usb4_devlink()
171 fwnode_find_reference(dev_fwnode(&port_dev->dev), "usb4-host-interface", 0); in usb_acpi_add_usb4_devlink()
173 if (IS_ERR(nhi_fwnode) || !nhi_fwnode->dev) in usb_acpi_add_usb4_devlink()
176 link = device_link_add(&port_dev->child->dev, nhi_fwnode->dev, in usb_acpi_add_usb4_devlink()
180 if (!link) { in usb_acpi_add_usb4_devlink()
181 dev_err(&port_dev->dev, "Failed to created device link from %s to %s\n", in usb_acpi_add_usb4_devlink()
182 dev_name(&port_dev->child->dev), dev_name(nhi_fwnode->dev)); in usb_acpi_add_usb4_devlink()
183 return -EINVAL; in usb_acpi_add_usb4_devlink()
186 dev_dbg(&port_dev->dev, "Created device link from %s to %s\n", in usb_acpi_add_usb4_devlink()
187 dev_name(&port_dev->child->dev), dev_name(nhi_fwnode->dev)); in usb_acpi_add_usb4_devlink()
193 * Private to usb-acpi, all the core needs to know is that
194 * port_dev->location is non-zero when it has been set by the firmware.
209 * is user visible and _UPC indicates whether it is connectable. If in usb_acpi_get_connect_type()
211 * and disconnected with USB devices. If no visible and connectable, in usb_acpi_get_connect_type()
212 * a usb device is directly hard-wired to the port. If no visible and in usb_acpi_get_connect_type()
217 if (ACPI_SUCCESS(status) && pld) in usb_acpi_get_connect_type()
218 port_dev->location = USB_ACPI_LOCATION_VALID | in usb_acpi_get_connect_type()
219 pld->group_token << 8 | pld->group_position; in usb_acpi_get_connect_type()
222 if (ACPI_FAILURE(status)) in usb_acpi_get_connect_type()
226 if (!upc || (upc->type != ACPI_TYPE_PACKAGE) || upc->package.count != 4) in usb_acpi_get_connect_type()
230 if (upc->package.elements[0].integer.value) in usb_acpi_get_connect_type()
231 if (!pld) in usb_acpi_get_connect_type()
233 else if (pld->user_visible) in usb_acpi_get_connect_type()
240 port_dev->connect_type = connect_type; in usb_acpi_get_connect_type()
254 udev = to_usb_device(port_dev->dev.parent->parent); in usb_acpi_get_companion_for_port()
257 * The root hub ports' parent is the root hub. The non-root-hub in usb_acpi_get_companion_for_port()
261 if (!udev->parent) { in usb_acpi_get_companion_for_port()
262 adev = ACPI_COMPANION(&udev->dev); in usb_acpi_get_companion_for_port()
263 port1 = usb_hcd_find_raw_port_number(bus_to_hcd(udev->bus), in usb_acpi_get_companion_for_port()
264 port_dev->portnum); in usb_acpi_get_companion_for_port()
266 parent_handle = usb_get_hub_port_acpi_handle(udev->parent, in usb_acpi_get_companion_for_port()
267 udev->portnum); in usb_acpi_get_companion_for_port()
268 if (!parent_handle) in usb_acpi_get_companion_for_port()
272 port1 = port_dev->portnum; in usb_acpi_get_companion_for_port()
284 if (!adev) in usb_acpi_find_companion_for_port()
287 usb_acpi_get_connect_type(port_dev, adev->handle); in usb_acpi_find_companion_for_port()
299 if (!udev->parent) { in usb_acpi_find_companion_for_device()
304 adev = ACPI_COMPANION(udev->bus->sysdev); in usb_acpi_find_companion_for_device()
308 hub = usb_hub_to_struct_hub(udev->parent); in usb_acpi_find_companion_for_device()
309 if (!hub) in usb_acpi_find_companion_for_device()
313 /* Tunneled USB3 devices depend on USB4 Host Interface, set device link to it */ in usb_acpi_find_companion_for_device()
314 if (udev->speed >= USB_SPEED_SUPER && in usb_acpi_find_companion_for_device()
315 udev->tunnel_mode != USB_LINK_NATIVE) in usb_acpi_find_companion_for_device()
322 port_dev = hub->ports[udev->portnum - 1]; in usb_acpi_find_companion_for_device()
356 if (is_usb_device(dev)) in usb_acpi_find_companion()
358 else if (is_usb_port(dev)) in usb_acpi_find_companion()