Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3371751imu; Mon, 19 Nov 2018 15:06:33 -0800 (PST) X-Google-Smtp-Source: AJdET5fIxEzyrUEYhy6/NPaSQuaS/V8/mimdLvjBZkILjan64hk5Hi4M8IJuoGqnMHoOo6nci88N X-Received: by 2002:a63:c503:: with SMTP id f3mr21342459pgd.431.1542668793483; Mon, 19 Nov 2018 15:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542668793; cv=none; d=google.com; s=arc-20160816; b=kJAIqNkamQ9Ch4oqEW7YHiGm59km3YYNWqf4AauidUH6HafCV8sJ213z3uMYJySuCp GxHgyZJg9QhPC5t8i6VC5NuSuvl1ZKrvs1HG4xWv9xcJOWSg4QxiLMmGeFMHe/YzWqn8 hVH0KvtaUXFhz/rb80+91Phn4ETptvjkyWu6Ddo+LnTUm6qDpDUju+6S0r2+Fb3hW+ZX UbsstZ5ZqzLJGqiD2kL5EaxabbhfDG4RrQVS27BmPbBXRymuHNYqVuA9Ne9gAVF36Lyt XsAsoDoXOFnXd4HKrUG0MI0A7BFgNgyYez3dehytf4E6u0KsYdcIJ60Abstjac2r9HEk Zetg== 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=hozA7Ab9Mbo9dP4gWzek1tXXv9KaEdb0RAgi2ZqAK7A=; b=LFiGrdbJO6CwwGU/s0wQs5toOgxr+tbzZi9/02gARHhAoaHPKJTAI/aPfGP6+2sTfa dbLoDqPXZ7q7GDRGuLy1rDX4ShCWX2x6I0/FUg0PVzhkPXLQrQ8N/7eGWOf/vLAMWSXL I7Aj3CcNbc74ZSNZJmuMLVYyS0bZ+Yv3Tyk3ZhBbIM1Bhm+mbP0UoSgyxoD3MOTNd3C6 ishvH5BzC/8uzNrIfB4zvvABU+Q7OvuW5bQToGTOwYmIVd3B43CgWrh9fRttPTmRvTut gag1ichZgSXgNxIyi8PLGUj2/Ew+LpCljNqS4KWkyabg7y4fxjoUxOK2RuEiE3Kqjebd JtFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kNN3V41Q; 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 h10si14163815pgi.562.2018.11.19.15.06.18; Mon, 19 Nov 2018 15:06:33 -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=kNN3V41Q; 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 S1732067AbeKTJa1 (ORCPT + 99 others); Tue, 20 Nov 2018 04:30:27 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:45345 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732066AbeKTJaY (ORCPT ); Tue, 20 Nov 2018 04:30:24 -0500 Received: by mail-pl1-f202.google.com with SMTP id h10so7019606plk.12 for ; Mon, 19 Nov 2018 15:04:27 -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=hozA7Ab9Mbo9dP4gWzek1tXXv9KaEdb0RAgi2ZqAK7A=; b=kNN3V41Qzl7VMMMjqPuUBqaprYPthA6N4Txzdkq/UT8nCXoc8FSn0r0uLsCroW+mm+ Up4i7WbNMfRfe2D6Kz2I8tbhi/4Crx41wITmLIbnjGzuT0PsKBEpcVDi4bMkKAclhfdg 2S7+C0PQGe6wR4BMipewGmJmR31hCPumKJTwOp77qmHcPUnaq+nSDQUvz5kxnhbkjtT9 K6UsWb87A0mfyc1cVUeciEolkJzx1y2pXeGphR/hfzabwoZCqiEJft0Gk4SUHGeTluVQ tOiiirdzJe3yLIdxKebkMuOO+3qXTUF+XJLp/t87ENKhmt2qFZJ4Ow9IoPiJA9F07nbX vfsQ== 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=hozA7Ab9Mbo9dP4gWzek1tXXv9KaEdb0RAgi2ZqAK7A=; b=NuKbzDyh0HFI9cM85Mz1as2OYSllTo1wX52NQ3GKCVZjbESfxNxtQPHmWi5OGmoSTq 4jo4KRwEH9YAOivDwhcaOo3sGteWmLRDn8cjJ+9w54dKCw7nwwzJ25s8IunRRQPNlS1/ qibnpE8IbK1yFswFu/zXUNbnm4ayIkrvKhOAzS2b4riXLVbGumWNxlXA5TthPIF00+kO DEBfSZDzCnTRWcX5lOtLNXJmUeUWEyb5pfqHfR/U8MjA8cLOOooOy25PgpVEbF4JrP2N Uz+r74BdAmkTrOtZuIGFs4B7YPA5uVRld+mYASXb9WbQOq4+1xIAXlOM+g0ZQTpW89ho 3YzQ== X-Gm-Message-State: AGRZ1gK2P8LTVHHaE+mstDaMQcjbkJ6p9bHHeJoY5/f8xWUTmANX6/vv irtHjDUFsGfsN2se+b1Djp9ml1jiMC8g X-Received: by 2002:a63:2c13:: with SMTP id s19mr7793541pgs.75.1542668667066; Mon, 19 Nov 2018 15:04:27 -0800 (PST) Date: Mon, 19 Nov 2018 15:04:06 -0800 In-Reply-To: <20181119230409.258121-1-rajatja@google.com> Message-Id: <20181119230409.258121-2-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181119230409.258121-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 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) --- v2: same as v1 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