Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp49857imu; Fri, 16 Nov 2018 17:09:00 -0800 (PST) X-Google-Smtp-Source: AJdET5cgGHSqL1qtM9H16rsGtovJgHVvdm9vs1wTno+FltteSXttsbj2Tm6hAf8nNPgI0Q3CA0u9 X-Received: by 2002:a17:902:a81:: with SMTP id 1-v6mr13153352plp.20.1542416940413; Fri, 16 Nov 2018 17:09:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542416940; cv=none; d=google.com; s=arc-20160816; b=YDz5b62eKMnxuo6DEr071ZSHzvZw+sCC2RvjVn/LF51DFUGNLNQQDZAit9bDxGWXsz Lv6jQvj84LoAwTJKuYuKFH9Hc+mqG0OEf3xCNcV2LwsRCt4OTd/ybX0ol0efMFjtPsxK RsTY281Nwi7PQJsEIx13DLoYBuxBHa1S/9zU0bpV/NWwA3N0jwdvptfA7OzeGx4kqxJs 9C90GTjU2TOQ1ubn53zou7sMjyq+6ZqwU+wVvYUBNfNYCC1vXz+XAZILfZ916aVeCeeM ZRdhnfCisaMY9YbfKvydqWTsO9q5byRs0KLN3io5cKra7EDpiGHYUQYxCOTQZLiJLRpp /z7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=s3V1He2Zj5wng/11t7K3HEWj/4wZGpXZr3vO1JV3B7s=; b=tMGNmBCBkYV5VQAv/Le0Xtn6lpew1NriMn2u3qdKzreGBGNOInCgGs2vVJCuBnbf8J YsaM30BM2f2WFzg3JIQtspfFj3HRYX/7AoRwBdvy6w8mLGyqjL+kw8j2We4lurGsYHG5 ZBAUPi9FG5hYrgrgEbTgm0Hd5Ax8y1/LzVnlQhlGSCZrwspeyVcpnd8du3AwkXCJVr8w Ps9uerv6G+l8jG1j4+Lwr20hA4GY/KucXp4/R5u5FwVPkSeLUbAQ3/laQEeBVUXsT3SP DhySPWnUHCg62wYZav8+K5vEn+7CzgVy+eRM/XNpC4cqE/u5g8W80DT/IxPRcMLFSKpW VtSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VoTZcDlK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32-v6si34402316pld.70.2018.11.16.17.08.44; Fri, 16 Nov 2018 17:09:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VoTZcDlK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730838AbeKQLWn (ORCPT + 99 others); Sat, 17 Nov 2018 06:22:43 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:50946 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730286AbeKQLWm (ORCPT ); Sat, 17 Nov 2018 06:22:42 -0500 Received: by mail-pl1-f202.google.com with SMTP id d11-v6so18377892plo.17 for ; Fri, 16 Nov 2018 17:08:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=s3V1He2Zj5wng/11t7K3HEWj/4wZGpXZr3vO1JV3B7s=; b=VoTZcDlK+vJS5EdgLM8TokoaYkl1BgjquuNWLN560DpIJoU8cTccEOBZb0dyCqJwzN 39fteUJOWxdSIDetnAJYERMadSBBhZRFD3fSExO4UQrlWBf8YisCo1zT+5/xtA7GQHLW JefAYZ9XiCf2CIa3Ypzngk4KgvISSKXfv2gtPkCDcIZp9Pumw4a/PziS47Tx5tP0jaiN PPeLBOr0U6oFM6HqQwrdnRkqHFYC1xFqPVGGMZNf+xeKeWtP4JZryYmD2Ka9QR6EOJLL HTyTWHh6QpqmQiO0TaqcKxYDSAWJV4hWgoPuN9YX8oSCjXG1lLCt3RaQD+vHGrYfOeP8 hvsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=s3V1He2Zj5wng/11t7K3HEWj/4wZGpXZr3vO1JV3B7s=; b=oakqG33zKAIH1ec4zHLhjaHKNDCkdWPjsajhCFcQ0NqWT6BZhpx9tLv3kQ6s/Kxhyp vNuNz944hbvCf4MNF+hw13Aa7YhcNp29UMojvZKRhuZ1Rp+5fwZ5h5bJr/mzZd1ODmZz HY9kindp38vr7lxRPd8rj9tet1Umvv0NuRUaiK4bSUBmIO1zZos/CtUKfEQ2SF2t5DnK yPxwUqj18lwo55qNfYlno7sWn8DwqCQ6Zm1aSXh3pobXM9KyFYTEWau+hZeWALET6vP+ 5BZSgYZ5Z+9Yj8CiUbil/AmQ9mBEiBcdu7I1ajWcxTOrRs9IOuV5O20a9twLaHRuv82j q11w== X-Gm-Message-State: AGRZ1gKn3tAQmlmoD3nxjTDKSTTpTy2LrK0ClKTezA7+l1g/lM0ff49g n0ie/gcqP5GPjUAovM/V7caYDoY4vYz5 X-Received: by 2002:aa7:8157:: with SMTP id d23-v6mr186165pfn.136.1542416881178; Fri, 16 Nov 2018 17:08:01 -0800 (PST) Date: Fri, 16 Nov 2018 17:07:45 -0800 In-Reply-To: <20181117010748.24347-1-rajatja@google.com> Message-Id: <20181117010748.24347-3-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH 2/5] usb: assign ACPI companions for embedded USB devices From: Rajat Jain To: Marcel Holtmann , Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Rajat Jain , Alex Hung , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: rajatxjain@gmail.com, dtor@google.com, raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Torokhov USB devices permanently connected to USB ports may be described in ACPI tables and share ACPI devices with ports they are connected to. See [1] for details. This will allow us to describe sideband resources for devices, such as, for example, hard reset line for BT USB controllers. [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/other-acpi-namespace-objects#acpi-namespace-hierarchy-and-adr-for-embedded-usb-devices Signed-off-by: Dmitry Torokhov Signed-off-by: Rajat Jain (changed how we get the usb_port) --- drivers/usb/core/usb-acpi.c | 44 +++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index 8ff73c83e8e8..9043d7242d67 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -200,30 +200,56 @@ static struct acpi_device * usb_acpi_find_companion_for_device(struct usb_device *udev) { struct acpi_device *adev; + struct usb_port *port_dev; + struct usb_hub *hub; + + if (!udev->parent) { + /* root hub is only child (_ADR=0) under its parent, the HC */ + adev = ACPI_COMPANION(udev->dev.parent); + return acpi_find_child_device(adev, 0, false); + } - if (!udev->parent) + hub = usb_hub_to_struct_hub(udev->parent); + if (!hub) return NULL; - /* root hub is only child (_ADR=0) under its parent, the HC */ - adev = ACPI_COMPANION(udev->dev.parent); - return acpi_find_child_device(adev, 0, false); + /* + * This is an embedded USB device connected to a port and such + * devices share port's ACPI companion. + */ + port_dev = hub->ports[udev->portnum - 1]; + return usb_acpi_get_companion_for_port(port_dev); } - static struct acpi_device *usb_acpi_find_companion(struct device *dev) { /* - * In the ACPI DSDT table, only usb root hub and usb ports are - * acpi device nodes. The hierarchy like following. + * The USB hierarchy like following: + * * Device (EHC1) * Device (HUBN) * Device (PR01) * Device (PR11) * Device (PR12) + * Device (FN12) + * Device (FN13) * Device (PR13) * ... - * So all binding process is divided into two parts. binding - * root hub and usb ports. + * where HUBN is root hub, and PRNN are USB ports and devices + * connected to them, and FNNN are individualk functions for + * connected composite USB devices. PRNN and FNNN may contain + * _CRS and other methods describing sideband resources for + * the connected device. + * + * On the kernel side both root hub and embedded USB devices are + * represented as instances of usb_device structure, and ports + * are represented as usb_port structures, so the whole process + * is split into 2 parts: finding companions for devices and + * finding companions for ports. + * + * Note that we do not handle individual functions of composite + * devices yet, for that we would need to assign companions to + * devices corresponding to USB interfaces. */ if (is_usb_device(dev)) return usb_acpi_find_companion_for_device(to_usb_device(dev)); -- 2.19.1.1215.g8438c0b245-goog