Skip to content

Commit 6797e4d

Browse files
Wolfram Sangkwilczynski
authored andcommitted
PCI: rcar-host: Add support for optional regulators
The KingFisher board has regulators for miniPCIe, so enable these optional regulators using devm. devm will automatically disable them when the driver releases the device. Order variables in reverse-xmas while we are here. [kwilczynski: update style to match rest of the code] Link: https://lore.kernel.org/linux-pci/20231105092908.3792-3-wsa+renesas@sang-engineering.com Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Manivannan Sadhasivam <mani@kernel.org>
1 parent b952f96 commit 6797e4d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

drivers/pci/controller/pcie-rcar-host.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/phy/phy.h>
3030
#include <linux/platform_device.h>
3131
#include <linux/pm_runtime.h>
32+
#include <linux/regulator/consumer.h>
3233

3334
#include "pcie-rcar.h"
3435

@@ -953,14 +954,22 @@ static const struct of_device_id rcar_pcie_of_match[] = {
953954
{},
954955
};
955956

957+
/* Design note 346 from Linear Technology says order is not important. */
958+
static const char * const rcar_pcie_supplies[] = {
959+
"vpcie1v5",
960+
"vpcie3v3",
961+
"vpcie12v",
962+
};
963+
956964
static int rcar_pcie_probe(struct platform_device *pdev)
957965
{
958966
struct device *dev = &pdev->dev;
967+
struct pci_host_bridge *bridge;
959968
struct rcar_pcie_host *host;
960969
struct rcar_pcie *pcie;
970+
unsigned int i;
961971
u32 data;
962972
int err;
963-
struct pci_host_bridge *bridge;
964973

965974
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*host));
966975
if (!bridge)
@@ -971,6 +980,13 @@ static int rcar_pcie_probe(struct platform_device *pdev)
971980
pcie->dev = dev;
972981
platform_set_drvdata(pdev, host);
973982

983+
for (i = 0; i < ARRAY_SIZE(rcar_pcie_supplies); i++) {
984+
err = devm_regulator_get_enable_optional(dev, rcar_pcie_supplies[i]);
985+
if (err < 0 && err != -ENODEV)
986+
return dev_err_probe(dev, err, "failed to enable regulator: %s\n",
987+
rcar_pcie_supplies[i]);
988+
}
989+
974990
pm_runtime_enable(pcie->dev);
975991
err = pm_runtime_get_sync(pcie->dev);
976992
if (err < 0) {

0 commit comments

Comments
 (0)