From patchwork Fri Feb 21 03:36:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaedon Shin X-Patchwork-Id: 207256 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA6FBC11D24 for ; Fri, 21 Feb 2020 03:36:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81EF424650 for ; Fri, 21 Feb 2020 03:36:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cSv8qlub" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729660AbgBUDg7 (ORCPT ); Thu, 20 Feb 2020 22:36:59 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40672 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729539AbgBUDg7 (ORCPT ); Thu, 20 Feb 2020 22:36:59 -0500 Received: by mail-pf1-f194.google.com with SMTP id b185so474135pfb.7; Thu, 20 Feb 2020 19:36:58 -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=Ix9Y2nFQkgNaD5RyzKlb0GalKo293yFxFO24g2Hr7BE=; b=cSv8qlub9fbpZ3p/6Hvn1F3xU7QIFUacsg2CgrAfvXwZQj/D6PZ620DrFibo38PxUJ J34fRp6oUTIXSibPUTAXaD8rgQ7zU3sOFnI5a9/5QdNsWgWIlFUD8CyiFPWwyNV5ABgm L+DlPtVj5MSjZ+mutI1SAySDC+ABp7/8kiTbGKkNPreuEiq4de7HGCn/DKR3mePmeowp FHNAZTPjBdjOF/AhNahU+MjlivUYcIqEOWQxI7axsuEnlQ9q1Iur7aEl31PCQsVtaT+g ncFzZWNNx0X6Ld+S2aUdXJnoqzPnEsSVr7PbY8yBFhP5BJt5A2YtGuD47bG5p3GNlUUj MZqg== 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=Ix9Y2nFQkgNaD5RyzKlb0GalKo293yFxFO24g2Hr7BE=; b=k8ucfvZeLjlewPR9+Wa342mIftQlA4qk3DFRNdnHzE3MnAP9idYpjcE5iEQ8zi3ANv 8A4DbdLL9tqNAkYieVvVERn7U3tXksfzeG2qJa4PWnICc9yC0hcoIE2hNp4EENl8UJfT DkJWR2gJiHTx2Tqy1ZP9dR6Un6oYX2Hm2Wt0LUaaHmX5mS4Xe7QQpSNkfPR/MsbBeM87 vEPIiQUe859688hhvH0xRQoY1y+GDwQNJA4IKRUqmmXXGUFbZauiDMVtCTIoDxtEWtL7 73zRwuUiYW/i9UqBoANfHT3OML7xbQUNHUXUxW9nx5Mf+2543ENXPb0zYGYJLOiVIJie ATYQ== X-Gm-Message-State: APjAAAXGs/8Lc9uVWCBn4ZPRvp9Phhn/wiXr5QgNCr1VSqSy9vjhD8PB AkvGELi28ek28k8nE9cVhAA= X-Google-Smtp-Source: APXvYqyWhRoVOloNoo9kNtSguiV4jK6MA9XFVaDLEVL3Di0Yq0mE5Kxtw6jjVq1rdjQwBwZJA7LT2Q== X-Received: by 2002:a63:4823:: with SMTP id v35mr35446928pga.177.1582256218382; Thu, 20 Feb 2020 19:36:58 -0800 (PST) Received: from localhost.localdomain ([125.130.116.2]) by smtp.gmail.com with ESMTPSA id d4sm781340pjz.12.2020.02.20.19.36.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Feb 2020 19:36:58 -0800 (PST) From: Jaedon Shin To: Nicolas Saenz Julienne , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, Mark Brown Cc: Bjorn Helgaas , Rob Herring , Mark Rutland , Lorenzo Pieralisi , Andrew Murray , Gregory Fong , Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, Jaedon Shin Subject: [PATCH v2 1/2] PCI: brcmstb: Add regulator support Date: Fri, 21 Feb 2020 12:36:39 +0900 Message-Id: <20200221033640.55163-2-jaedon.shin@gmail.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20200221033640.55163-1-jaedon.shin@gmail.com> References: <20200221033640.55163-1-jaedon.shin@gmail.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org ARM-based Broadcom STB SoCs have GPIO-based voltage regulator for PCIe turning off/on power supplies. Signed-off-by: Jaedon Shin --- .../bindings/pci/brcm,stb-pcie.yaml | 3 ++ drivers/pci/controller/pcie-brcmstb.c | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 77d3e81a437b..efa5c885724b 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -56,6 +56,9 @@ properties: description: Indicates usage of spread-spectrum clocking. type: boolean + supply-names: + description: List of regulator supplies to use for PCIe + required: - reg - dma-ranges diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index d20aabc26273..8968ef7fa55d 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,6 +174,8 @@ struct brcm_pcie { int gen; u64 msi_target_addr; struct brcm_msi *msi; + struct regulator_bulk_data *vreg_bulk; + int num_vregs; }; /* @@ -898,6 +901,7 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) { brcm_msi_remove(pcie); brcm_pcie_turn_off(pcie); + regulator_bulk_disable(pcie->num_vregs, pcie->vreg_bulk); clk_disable_unprepare(pcie->clk); clk_put(pcie->clk); } @@ -920,6 +924,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) struct brcm_pcie *pcie; struct pci_bus *child; struct resource *res; + struct regulator_bulk_data *bulk; + int i; int ret; bridge = devm_pci_alloc_host_bridge(&pdev->dev, sizeof(*pcie)); @@ -955,6 +961,36 @@ static int brcm_pcie_probe(struct platform_device *pdev) return ret; } + ret = of_property_count_strings(np, "supply-names"); + pcie->num_vregs = (ret < 0) ? 0 : ret; + + if (pcie->num_vregs) { + bulk = devm_kcalloc(pcie->dev, pcie->num_vregs, sizeof(*bulk), + GFP_KERNEL); + if (!bulk) { + clk_disable_unprepare(pcie->clk); + return -ENOMEM; + } + + for (i = 0; i < pcie->num_vregs; i++) + of_property_read_string_index(np, "supply-names", i, + &bulk[i].supply); + + ret = devm_regulator_bulk_get(pcie->dev, pcie->num_vregs, bulk); + if (ret < 0) { + clk_disable_unprepare(pcie->clk); + return ret; + } + + pcie->vreg_bulk = bulk; + } + + ret = regulator_bulk_enable(pcie->num_vregs, pcie->vreg_bulk); + if (ret) { + clk_disable_unprepare(pcie->clk); + return ret; + } + ret = brcm_pcie_setup(pcie); if (ret) goto fail;