From patchwork Wed Apr 10 12:46:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13624318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FC07CD128A for ; Wed, 10 Apr 2024 12:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wgsvEp4ZWSs1xB7reNeuuhU4C9PJwRyNhwX49FLaMm0=; b=X5wQ8+knt86D8B h4YlhFziJK3QGFURxTXdIO00YRQJbH+FzqVt7XWCJtm45lrpp2ZgKdl8vnhHM++j3g5tPYetIBQAg XIYngEGbKeJ5jS2czJNtn9BSstKvte68oN6iQYdR7alMWYzs/WJskVYo/hMgDTxKX/ixnO1nhh2+I DluCHjUvivBzT5QvBevpT/V5kKk6dISoszP2a4qG8+SGGUrGZi5Ta3X7Bu5uvK55bMXYHBRe75tuh TVtSAE+IgJbONOMl05C17OAybJss10VxBXWqkLuXVidBDoKqDpdhdEhQ+BqfyG1Q2hT8w6GDj+E5I +YX+idLordkxh56wWRBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXMT-00000006x7z-4ABF; Wed, 10 Apr 2024 12:47:33 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXM9-00000006wyY-459u for linux-arm-kernel@bombadil.infradead.org; Wed, 10 Apr 2024 12:47:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=a3VKydEHB8lHvIONMbgchmsCTkAjKSCt8ZGRsExnd9A=; b=M/arX26dt7hjTRp2637OU35yEK VUU39CP4aa3bO0ZQaSYJErXpCF6DOgtpHC6Ctxi5VmSnXg5WlJasaCsuUPf9sGtaQP915+hb3Uge0 zy/b8MCL9pWRG2WYUOyZ5QCUkwJu+U+rMMKX2UE/tLNxojJATMztWL74GxarX0HG27udDy4ojSYpd 8hCgmzpUDg9dkE67iUZHFY+fXUHaCBJusiX3UuQwpJzc5XYjiZ1l7o+dWb0mOFfl8KR2Qbky5Bxfa /G68b3UiuXKN7DfOo8XvmgcOpwjEayhVllX71Vki7jw4UwZ3ZFdcc4VxkiAKf/Ged2i9IFjMl5+s0 cihclBLw==; Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXM6-000000085BH-1aFD for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2024 12:47:12 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-417c5656adeso830635e9.2 for ; Wed, 10 Apr 2024 05:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1712753227; x=1713358027; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a3VKydEHB8lHvIONMbgchmsCTkAjKSCt8ZGRsExnd9A=; b=pzWqACYoHjaHmtkEeb4Y380QGQjuS/bs7fyPRyMzDpF/LzM//++/qSAIas12iIfVyk 4HipWMYBiT6IAX8eXTqh/CZYuG8XZxqtiO4vJmugHb6bEX/2Y59yNeSYb9mrbidfwn7k dDh6c3dLSO5YdGY7U/fxsa+O9BFCu48CBNM4+BUoNntR5kkdpdU1EsLCX7KhmbmD7Xzl h6XdhRIA2dJd2P8efo97D0SM/g4LGFiLWlv/YQem4Hodrp+tJKz+8r12pkWcNy2xq4A8 0n/gmJu9DfvaSYYoVwK5dCJdlpxKG2AKvktwP1qpI1EmZ0IbNm/zFtKMCitEebygNz/Q c8lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712753227; x=1713358027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a3VKydEHB8lHvIONMbgchmsCTkAjKSCt8ZGRsExnd9A=; b=ubklbfskFEguvfjCsScIG4PsHjAu9BPQJIwue/P8gaBlIHHgjz6U4PqIczJKKY2/sh FEb5WUX/dZCzKhDB/mQWfdovYOjArsasUynrsXHe7Oei/GSHok8ylIjq4cU/VhZ9XZ9Z YdMlt+v0M9XepwQvAfmGiYxop93d82ncGCy0mb5RTvvSYvLvQ8W6JrR/YSxvF/klOLoE hfyN6KrmRLJbd0M2CfASziuwgrcEeX//AOsRk2XyuS6VRxJPpsapcwBWbz4+3tcThNxv e95HkRTs1sTFExtt17+yeHGNUqzQbdURMYNJVocE+EbQBGqAaNQUB7DA4QdfKIvThV/g fvZA== X-Forwarded-Encrypted: i=1; AJvYcCVQOUd/KvCipjkJKeeQHKsHDv6PQub4dOaX/qiiasLcB5nXdBfarjKTuyxmWZH3t1NrEWMyr7qSk+5EnVSxd93cMZfpGT+Hnp+TYlSgYQlego+Cgec= X-Gm-Message-State: AOJu0Yxx1X+qLydulQu7WzYQHFgVWQqFv4rnuM1CYpwMyXG+t25KOyc4 qHoIRT0TEg/hbaCph6WtwLIPs6xWF743D4chaE//xb/xW8HwQCvjIWMlLApCzuY= X-Google-Smtp-Source: AGHT+IHJF6LcSwDmHG05PJXSHj73CCP4M9gnnRg/+VfczmccvVGh4FNtbdoeulp4qepsLWmvHAhUNw== X-Received: by 2002:a05:600c:1f0c:b0:416:c904:a26a with SMTP id bd12-20020a05600c1f0c00b00416c904a26amr1525110wmb.7.1712753226816; Wed, 10 Apr 2024 05:47:06 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:75a:e000:6908:7e99:35c9:d585]) by smtp.gmail.com with ESMTPSA id v13-20020a05600c444d00b0041663450a4asm2150929wmn.45.2024.04.10.05.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 05:47:06 -0700 (PDT) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov , Amit Pundir , Xilin Wu Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v7 11/16] PCI/pwrctl: create platform devices for child OF nodes of the port node Date: Wed, 10 Apr 2024 14:46:23 +0200 Message-Id: <20240410124628.171783-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240410124628.171783-1-brgl@bgdev.pl> References: <20240410124628.171783-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_134710_862861_BEBAB9D5 X-CRM114-Status: GOOD ( 16.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski In preparation for introducing PCI device power control - a set of library functions that will allow powering-up of PCI devices before they're detected on the PCI bus - we need to populate the devices defined on the device-tree. We are reusing the platform bus as it provides us with all the infrastructure we need to match the pwrctl drivers against the compatibles from OF nodes. These platform devices will be probed by the driver core and bound to the PCI pwrctl drivers we'll introduce later. Signed-off-by: Bartosz Golaszewski --- drivers/pci/bus.c | 9 +++++++++ drivers/pci/remove.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 826b5016a101..3e3517567721 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -354,6 +355,14 @@ void pci_bus_add_device(struct pci_dev *dev) pci_warn(dev, "device attach failed (%d)\n", retval); pci_dev_assign_added(dev, true); + + if (pci_is_bridge(dev)) { + retval = of_platform_populate(dev->dev.of_node, NULL, NULL, + &dev->dev); + if (retval) + pci_err(dev, "failed to populate child OF nodes (%d)\n", + retval); + } } EXPORT_SYMBOL_GPL(pci_bus_add_device); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index d749ea8250d6..fc9db2805888 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include "pci.h" static void pci_free_resources(struct pci_dev *dev) @@ -22,6 +23,7 @@ static void pci_stop_dev(struct pci_dev *dev) device_release_driver(&dev->dev); pci_proc_detach_device(dev); pci_remove_sysfs_dev_files(dev); + of_platform_depopulate(&dev->dev); of_pci_remove_node(dev); pci_dev_assign_added(dev, false);