From patchwork Thu Feb 13 02:59:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaedon Shin X-Patchwork-Id: 11379705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6730E109A for ; Thu, 13 Feb 2020 03:00:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 42CC22168B for ; Thu, 13 Feb 2020 03:00:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NlanRocC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="daxpuG2m" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42CC22168B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Evkm71E/vcLnepctLpXiTYruFEG7oEZqzkYCPpk6EQQ=; b=NlanRocCC0T2Xg khCODhim6ZtIz+R4HSd2+KoIs4je5MmFxhg5OursusVJDie/3Zu2AiA9kO+uB1wGUnx6uHlGsKDM7 WtJX+RxM/tXJunX+vV5lNHNaHWV9+2fYIidDX46z2pIe30PTDqWO9erB/Gp9bsvsRsEmKrIC0XBrb qfhlY8d+5Vr0X2fW0mQlbq+9HzBAbgbX4+lD6JV34cynBr5z+2ZGkhG2Rg3XYaCipg2gmtbAv3D+M czvsIppIEGvJOv2ILjJQFu81a72/f3AwScaxFl5xGJSsJ8zxy9hq3ME17t8kRAGt6wQ2i6BEG8k9v 31u8hLTQoffjC3bS65uA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j24jc-0003Qb-AE; Thu, 13 Feb 2020 03:00:12 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j24jE-0002Iw-2U for linux-arm-kernel@lists.infradead.org; Thu, 13 Feb 2020 02:59:49 +0000 Received: by mail-pg1-x542.google.com with SMTP id d9so2277233pgu.3 for ; Wed, 12 Feb 2020 18:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w1ACxcpxWUpfzA7rugNOMv+lfet19/IxHVNmDiRm8Aw=; b=daxpuG2mhvKGy6M+bSiOIwXjqRUVAN/lbjca+U36wYkrCCZX2EKevydXjk2r45oCpf vpkx5vstvROVHer+RuxLdwhIpYKjcvbwuwzTGzvg1xGRkPmItTiKij9A0UZHMCBvQCHq Xf4+FdrE9h2r9bx9Eu6Vxie/UfNPcQrcoNxBi8m2vNUZHZG1/hmsdm5mAhqhhgbpbYzr JPkmknGHuTRViDawI41aenAiSQpSweWVwounqIVc4+06YXSoMkYUQ8veXkCkxn3gMT19 OgVtOBuju6iHCFv6Y3XQmrWnrzN5OWVFobvYJEy720vHiib4d/1r+mE9d9DAFjag+9ib O3/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w1ACxcpxWUpfzA7rugNOMv+lfet19/IxHVNmDiRm8Aw=; b=NaWVATdfehj3dSAJeEVgzSqnAdWR3ma6ZQ2avi5qQyVeRo/y85RWVCis9vj1MMicrU oKffJwT8QSOJ2HN0VUYFHNdSdUngUK/P3JWe8v+sT1Ww0tce1OmJ8KtP9T/LpGhh7wiJ boBoetea7Cj2GZU6UYvN6cpj/YfK2jUKyDPa+BvCzBHc3I1h1hvu4eCEr6lFDvoDraMU HaWnHoashbhu+bKdDXLjDwKWPlG5gMvDp6at/hQoo5rIK+2qqBqisCjTCxhpjVJTdgmt zXgeItGEH2j0OTaJRv5YbkGSK8W5FzKezlelL2Esx3gxU0lA3t0R96gZGRL/VMSqj30P qCNg== X-Gm-Message-State: APjAAAW9yU+WScR/8zq7PD+O39xeUhBPhzPH7k6cQVnMFvk+oA2VhkxB +j5Hw1t0pVaR/TDR1oYJ2Ps= X-Google-Smtp-Source: APXvYqxWHZU6f5pO82paK++ztXzf5iJMlD9SeitS31R2oQJvZ/P1yqFU3xfce65klYAvkb3EDr0Huw== X-Received: by 2002:a05:6a00:2b7:: with SMTP id q23mr11460797pfs.43.1581562787459; Wed, 12 Feb 2020 18:59:47 -0800 (PST) Received: from localhost.localdomain ([125.130.116.2]) by smtp.gmail.com with ESMTPSA id 64sm602643pfd.48.2020.02.12.18.59.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Feb 2020 18:59:47 -0800 (PST) From: Jaedon Shin To: Nicolas Saenz Julienne , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com Subject: [PATCH 1/3] PCI: brcmstb: Enable ARCH_BRCMSTB Date: Thu, 13 Feb 2020 11:59:28 +0900 Message-Id: <20200213025930.27943-2-jaedon.shin@gmail.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20200213025930.27943-1-jaedon.shin@gmail.com> References: <20200213025930.27943-1-jaedon.shin@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200212_185948_131873_473F7BA7 X-CRM114-Status: GOOD ( 14.08 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:542 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaedon.shin[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , linux-gpio@vger.kernel.org, linux-pci@vger.kernel.org, Linus Walleij , Jaedon Shin , Bartosz Golaszewski , Rob Herring , Gregory Fong , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Andrew Murray Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add PCIe support for ARM-based Broadcom STB SoCs. Signed-off-by: Jaedon Shin --- Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml | 8 +++++++- drivers/pci/controller/Kconfig | 2 +- drivers/pci/controller/pcie-brcmstb.c | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 77d3e81a437b..fb1a78606f78 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -14,7 +14,13 @@ allOf: properties: compatible: - const: brcm,bcm2711-pcie # The Raspberry Pi 4 + oneOf: + - description: + BCM2711 based Boards + const: brcm,bcm2711-pcie + - description: + ARM-based BCM7XXX Broadcom STB Boards + const: brcm,bcm7445-pcie reg: maxItems: 1 diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index 20bf00f587bd..c60a27cff81a 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -254,7 +254,7 @@ config VMD config PCIE_BRCMSTB tristate "Broadcom Brcmstb PCIe host controller" - depends on ARCH_BCM2835 || COMPILE_TEST + depends on ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST depends on OF depends on PCI_MSI_IRQ_DOMAIN help diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index d20aabc26273..34581a6a7313 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -996,6 +996,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) static const struct of_device_id brcm_pcie_match[] = { { .compatible = "brcm,bcm2711-pcie" }, + { .compatible = "brcm,bcm7445-pcie" }, {}, }; MODULE_DEVICE_TABLE(of, brcm_pcie_match); From patchwork Thu Feb 13 02:59:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaedon Shin X-Patchwork-Id: 11379707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D1291395 for ; Thu, 13 Feb 2020 03:00:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 09E282168B for ; Thu, 13 Feb 2020 03:00:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Z/2xe1ML"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AYDo7SGz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09E282168B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xqAFnZJOAvzqqslBCxpjFJxYxt8nQUInhpU9mU0M8sI=; b=Z/2xe1MLPEIATG +rQDGlDEJywenGLNe1DAkhvRRSbA++8bihtwAB56Us8Y0F9nUoh1yjgRkM3vQSjJ9wCrTaCFzta0Z uu5tGRj7T/FglRhD0Rz8MOVW264K5+5RNWcicORp6v4eC3g8HqQLcAYv+rSzYQtsfLUYRjhiQbau2 RXRWcTdWMFB9NRtZLgE0lZ7DecOa9mmjuGWYQIcR4re7xcijlSYjkmmMgU99/PeacGpdTbXiLutav R/8rpsAMaIfkPKflrDUb/BLAS4OWscxhRvOuIOqW2Aq4QgwVezk5Lc93nxwt59OhLceYhReqJL6oE rJC0cxQ3XsmMqWE9z07Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j24jo-00040V-Bq; Thu, 13 Feb 2020 03:00:24 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j24jI-0002No-Ew for linux-arm-kernel@lists.infradead.org; Thu, 13 Feb 2020 02:59:54 +0000 Received: by mail-pg1-x543.google.com with SMTP id z12so2277470pgl.4 for ; Wed, 12 Feb 2020 18:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8BL8vP5NMTytKwhGPCvc8BMjPI7WOjnt3iXA7k4tMW0=; b=AYDo7SGzZo1jCJpr+m7BD1pY3VP53RipV5laq/W2ASp6gfmJ3iAqMdM9Bi4euhNhfm 92pi4BlyDTC/S5maH98qaD96PimUhXZCY/2hp5iMNsQr6QKAGMbrpj4sEb9Nsst41+0a SkPVA4PtURhsqCZpqoeENGYJpBcOdXD6Ybkr0zgtEwmN5Kd7PuVXJi+4ErI/NCt/diO7 5kzpq9sZ4kT/LcUqEn2mqgVM0UwJkt5ygGVi5s+IWWOLvHRC65zFVr3iHRXMmPgKaSBL cTzOT0u3p6Q87UX/MevuG1pJ3Q/FRXSGy+g0XMevZDEAYbssYiOe0o0kDNX3Q/SXzuuo vqDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8BL8vP5NMTytKwhGPCvc8BMjPI7WOjnt3iXA7k4tMW0=; b=opD8Twd8WmJDniWCNd7ArS9ozEjOp+LDuKb4FTqaUbaFKhjpX3qzh9SbYxt9DMvWHh 0RAOnbyxNrmJAz9BStw9N/7p+GQco5jT/4Ob8eLH5lFjO7Vxi5buhIes78zPGPXICY52 +IEzmkumFoWN5qmuCTr1j3+4ULNco6CQ+2XQU4T/JJM7vLC8CIM7+QiqRkbz3CJqeRfa +NL1Ds9BEbCiHtT+FCkawQDf6KehJREbvu2rVUDpoGmp2HgvEFVpvU8uFJgbgP9JOWZK r44nVuDhMchuNgoU/ois8k5T7rKarBB7N0O6aEJTWPDMFly10d/BZLIBZNoAYA0NA+VG uZtQ== X-Gm-Message-State: APjAAAU1x1Uo66REJ6sicwwr/iI4qFPhuy80oKkJcjUVTSWK1OlKdq9X CcILDpV4msgRu6YEtm08Bao= X-Google-Smtp-Source: APXvYqwK+4zKLSl6S5rlqW83Vct22r2bYLt3O1CMcbxDrjJ6dMSoXBvT82hT9HnOw5OQvRnaOzcPUA== X-Received: by 2002:aa7:979a:: with SMTP id o26mr11705841pfp.257.1581562791654; Wed, 12 Feb 2020 18:59:51 -0800 (PST) Received: from localhost.localdomain ([125.130.116.2]) by smtp.gmail.com with ESMTPSA id 64sm602643pfd.48.2020.02.12.18.59.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Feb 2020 18:59:51 -0800 (PST) From: Jaedon Shin To: Nicolas Saenz Julienne , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com Subject: [PATCH 2/3] PCI: brcmstb: Add regulator support Date: Thu, 13 Feb 2020 11:59:29 +0900 Message-Id: <20200213025930.27943-3-jaedon.shin@gmail.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20200213025930.27943-1-jaedon.shin@gmail.com> References: <20200213025930.27943-1-jaedon.shin@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200212_185952_535710_E8D30AA0 X-CRM114-Status: GOOD ( 17.72 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaedon.shin[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , linux-gpio@vger.kernel.org, linux-pci@vger.kernel.org, Linus Walleij , Jaedon Shin , Bartosz Golaszewski , Rob Herring , Gregory Fong , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Andrew Murray Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org ARM-based Broadcom STB SoCs have GPIO-based voltage regulator for PCIe turning off/on power supplies. Signed-off-by: Jaedon Shin --- drivers/gpio/gpio-brcmstb.c | 13 ++++- drivers/pci/controller/pcie-brcmstb.c | 76 +++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index 05e3f99ae59c..0cee5fcd2782 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -777,7 +777,18 @@ static struct platform_driver brcmstb_gpio_driver = { .remove = brcmstb_gpio_remove, .shutdown = brcmstb_gpio_shutdown, }; -module_platform_driver(brcmstb_gpio_driver); + +static int __init brcmstb_gpio_init(void) +{ + return platform_driver_register(&brcmstb_gpio_driver); +} +subsys_initcall(brcmstb_gpio_init); + +static void __exit brcmstb_gpio_exit(void) +{ + platform_driver_unregister(&brcmstb_gpio_driver); +} +module_exit(brcmstb_gpio_exit); MODULE_AUTHOR("Gregory Fong"); MODULE_DESCRIPTION("Driver for Broadcom BRCMSTB SoC UPG GPIO"); diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 34581a6a7313..0e0ca39a680b 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -173,8 +174,79 @@ struct brcm_pcie { int gen; u64 msi_target_addr; struct brcm_msi *msi; +#ifdef CONFIG_REGULATOR + int num_regs; + struct regulator **regs; +#endif }; +#ifdef CONFIG_REGULATOR +static void brcm_pcie_regulator_enable(struct brcm_pcie *pcie) +{ + int i, ret; + + for (i = 0; i < pcie->num_regs; i++) { + if (!pcie->regs[i]) + continue; + + ret = regulator_enable(pcie->regs[i]); + if (ret) + dev_err(pcie->dev, "Failed to enable regulator\n"); + } +} + +static void brcm_pcie_regulator_disable(struct brcm_pcie *pcie) +{ + int i, ret; + + for (i = 0; i < pcie->num_regs; i++) { + if (!pcie->regs[i]) + continue; + + ret = regulator_disable(pcie->regs[i]); + if (ret) + dev_err(pcie->dev, "Failed to disable regulator\n"); + } +} + +static void brcm_pcie_regulator_init(struct brcm_pcie *pcie) +{ + struct device_node *np = pcie->dev->of_node; + struct device *dev = pcie->dev; + const char *name; + struct regulator *reg; + int i; + + pcie->num_regs = of_property_count_strings(np, "supply-names"); + if (pcie->num_regs <= 0) { + pcie->num_regs = 0; + return; + } + + pcie->regs = devm_kcalloc(dev, pcie->num_regs, sizeof(pcie->regs[0]), + GFP_KERNEL); + if (!pcie->regs) { + pcie->num_regs = 0; + return; + } + + for (i = 0; i < pcie->num_regs; i++) { + if (of_property_read_string_index(np, "supply-names", i, &name)) + continue; + + reg = devm_regulator_get_optional(dev, name); + if (IS_ERR(reg)) + continue; + + pcie->regs[i] = reg; + } +} +#else +static inline void brcm_pcie_regulator_enable(struct brcm_pcie *pcie) { } +static inline void brcm_pcie_regulator_disable(struct brcm_pcie *pcie) { } +static inline void brcm_pcie_regulator_init(struct brcm_pcie *pcie) { } +#endif + /* * This is to convert the size of the inbound "BAR" region to the * non-linear values of PCIE_X_MISC_RC_BAR[123]_CONFIG_LO.SIZE @@ -898,6 +970,7 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) { brcm_msi_remove(pcie); brcm_pcie_turn_off(pcie); + brcm_pcie_regulator_disable(pcie); clk_disable_unprepare(pcie->clk); clk_put(pcie->clk); } @@ -955,6 +1028,9 @@ static int brcm_pcie_probe(struct platform_device *pdev) return ret; } + brcm_pcie_regulator_init(pcie); + brcm_pcie_regulator_enable(pcie); + ret = brcm_pcie_setup(pcie); if (ret) goto fail; From patchwork Thu Feb 13 02:59:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaedon Shin X-Patchwork-Id: 11379709 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C75C1395 for ; Thu, 13 Feb 2020 03:00:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0A4D121739 for ; Thu, 13 Feb 2020 03:00:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oMEKEwOV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IIL6NVQF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A4D121739 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8FtE1Lw+rnz2Jt3DhscpaexAqiBANQyaHwTeIP5OSi4=; b=oMEKEwOVnaSEKy IR8mPuWleIJZASEhb2+Kdp+JFpjCrRjRGlHEplAJtnpzFj6eMJVkmh0lDuO7o+YVZt5Ej3WSiWjIf 9783b9588rv1BmYLv6KTt9mkYQYAKtnP4W+GiMNq+tCqTu9w3R0D4qYN8s0s3mqzJsQ9yKX0w3eMj 4PMMs5j7e5ISBMp4hURHAFf/hiZ+tV8xRn3WJ1ng7sCw8qwJrXaFUwBxkPHnEtpkoZf4k+viIFqC7 aJl1LSmIwRrQNq//0tLp39JPMA4UXlX4Gq9Fp/3O+W3KRxuGpYE6l9dAp38gsXh+r8XSQT5/LTTEd PBKEBJYj2LIebM88bx7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j24k6-0004Hj-V4; Thu, 13 Feb 2020 03:00:42 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j24jM-0002SW-3m for linux-arm-kernel@lists.infradead.org; Thu, 13 Feb 2020 02:59:57 +0000 Received: by mail-pf1-x443.google.com with SMTP id 2so2241753pfg.12 for ; Wed, 12 Feb 2020 18:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FWL9gVxhHfG18kJOeUk3fD6tEj/BEQbVcbiFy71a6G8=; b=IIL6NVQFhgBPqd3xzyM73Ymzd0NxREmAFRHpKjqtuIsN+B3xEFuWU29pDGvgdkkn2P ZQ9nCD+p+ESw1phZlEumdMSDlfvOhTQmmDk+cX0eCgOMaNBrD6seyJgOXIZNZ3VNPGfn 0cBJCkQL2IQVJaNNXFoOVjtPWmnn3/jqhZaWDLU6ty5TuvZTI9DGaSV/k6UdMtbYMtjL kw1AEQDUhCqmzw2uMz15tqbjhKceYNZPp++NIShvseX4oogtd8wsa+FAkG4C1t0XYL+O JbeL96iAUTbkrt+Y10SBG1bnq5uEVWpW49E5qgwrPDhmNYAGYCFiMFO6I1UUuzYoqZXb lkYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FWL9gVxhHfG18kJOeUk3fD6tEj/BEQbVcbiFy71a6G8=; b=cs2j/UrRl19qI1zQPFhdjiAQbfmoHA/ztj0sbh9mhqs4U3y+HjgCyWc+xzY+HlLkZS jKU0EVU3xQNm5g4UysY7gnFJldFNJWFOpCmA+CVJ9lQV55GvrxHOp5MXyvnlS2I/TAaP PXjIemQDiu6iGpLdn2ZDUG4NEjcNSMVLTPZA9Mc1R8iVT2Vb/mn2k4SdfNwZ/bmRvKos XTPNrG8rzbE/u4/RwZahBjGVpVR7vf/IyD8Xxqbfz6rin7z+8KeE5t36vl43Y4wwZ93u ma8S9khe/Ypxqb1iwqac1llXDU9OpOm9k6EDio/C33EImUBdkuzR1G2qKQWP2tzvH+JI kpyQ== X-Gm-Message-State: APjAAAVaYsiYZSQovnO6+QLOmgQyJG1zie4Y+v/hjnTGiN1BYm+SNn2W vgiacxxsxGJoOyk1s5BOF1A= X-Google-Smtp-Source: APXvYqwbqDHzihlVsSPDvVdo8SS90JnUF1N9IWw5udOtAYmfqHcjP5jqpmnQj6HQ7G3RHvmnhJ39kA== X-Received: by 2002:aa7:9e0b:: with SMTP id y11mr12203202pfq.182.1581562795547; Wed, 12 Feb 2020 18:59:55 -0800 (PST) Received: from localhost.localdomain ([125.130.116.2]) by smtp.gmail.com with ESMTPSA id 64sm602643pfd.48.2020.02.12.18.59.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Feb 2020 18:59:55 -0800 (PST) From: Jaedon Shin To: Nicolas Saenz Julienne , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com Subject: [PATCH 3/3] PCI: brcmstb: Drop clk_put when probe fails and remove Date: Thu, 13 Feb 2020 11:59:30 +0900 Message-Id: <20200213025930.27943-4-jaedon.shin@gmail.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20200213025930.27943-1-jaedon.shin@gmail.com> References: <20200213025930.27943-1-jaedon.shin@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200212_185956_175911_01E4C342 X-CRM114-Status: GOOD ( 12.03 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaedon.shin[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , linux-gpio@vger.kernel.org, linux-pci@vger.kernel.org, Linus Walleij , Jaedon Shin , Bartosz Golaszewski , Rob Herring , Gregory Fong , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Andrew Murray Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org devm_clk_get* APIs are device managed and get freed automatically when the device detaches. so there is no reason to explicitly call clk_put() in probe or remove functions. Signed-off-by: Jaedon Shin Acked-by: Florian Fainelli Acked-by: Nicolas Saenz Julienne --- drivers/pci/controller/pcie-brcmstb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 0e0ca39a680b..3e48d9e238bb 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -972,7 +972,6 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) brcm_pcie_turn_off(pcie); brcm_pcie_regulator_disable(pcie); clk_disable_unprepare(pcie->clk); - clk_put(pcie->clk); } static int brcm_pcie_remove(struct platform_device *pdev)