From: Jaedon Shin <jaedon.shin@gmail.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Florian Fainelli <f.fainelli@gmail.com>,
bcm-kernel-feedback-list@broadcom.com,
Mark Brown <broonie@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Andrew Murray <amurray@thegoodpenguin.co.uk>,
Gregory Fong <gregory.0xf0@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-pci@vger.kernel.org, Jaedon Shin <jaedon.shin@gmail.com>
Subject: [PATCH v2 1/2] PCI: brcmstb: Add regulator support
Date: Fri, 21 Feb 2020 12:36:39 +0900 [thread overview]
Message-ID: <20200221033640.55163-2-jaedon.shin@gmail.com> (raw)
In-Reply-To: <20200221033640.55163-1-jaedon.shin@gmail.com>
ARM-based Broadcom STB SoCs have GPIO-based voltage regulator for PCIe
turning off/on power supplies.
Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
---
.../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 <linux/of_platform.h>
#include <linux/pci.h>
#include <linux/printk.h>
+#include <linux/regulator/consumer.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/string.h>
@@ -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;
--
2.21.0
next prev parent reply other threads:[~2020-02-21 3:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 3:36 [PATCH v2 0/2] PCI: brcmstb: Add Broadcom STB support Jaedon Shin
2020-02-21 3:36 ` Jaedon Shin [this message]
2020-02-21 12:12 ` [PATCH v2 1/2] PCI: brcmstb: Add regulator support Mark Brown
2020-02-21 16:33 ` Florian Fainelli
2020-02-21 17:11 ` Mark Brown
2020-02-21 17:50 ` Florian Fainelli
2020-02-21 17:57 ` Mark Brown
2020-02-21 3:36 ` [PATCH v2 2/2] PCI: brcmstb: Drop clk_put when probe fails and remove Jaedon Shin
2020-05-07 18:55 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200221033640.55163-2-jaedon.shin@gmail.com \
--to=jaedon.shin@gmail.com \
--cc=amurray@thegoodpenguin.co.uk \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bgolaszewski@baylibre.com \
--cc=bhelgaas@google.com \
--cc=broonie@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=gregory.0xf0@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mark.rutland@arm.com \
--cc=nsaenzjulienne@suse.de \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).