devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add power control for pcie-histb driver
@ 2018-03-02  1:11 Shawn Guo
  2018-03-02  1:12 ` [PATCH v3 1/2] PCI: histb: Fix error path of histb_pcie_host_enable() Shawn Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shawn Guo @ 2018-03-02  1:11 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun,
	Jiancheng Xue, linux-pci, devicetree, Shawn Guo

It adds power control support for pcie-histb driver, by utilizing
regulator infrastructural.

Changes for v3:
 - Incorporate Rob's ACK on bindings doc.
 - Capitalize  the first word of patch subject to match drivers/pci
   convention.
 - Reword vpcie-supply description a bit as per Bjorn's suggestion.

Shawn Guo (2):
  PCI: histb: Fix error path of histb_pcie_host_enable()
  PCI: histb: Add an optional regulator for PCIe port power control

 .../bindings/pci/hisilicon-histb-pcie.txt          |  1 +
 drivers/pci/dwc/pcie-histb.c                       | 28 ++++++++++++++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] PCI: histb: Fix error path of histb_pcie_host_enable()
  2018-03-02  1:11 [PATCH v3 0/2] Add power control for pcie-histb driver Shawn Guo
@ 2018-03-02  1:12 ` Shawn Guo
  2018-03-02  1:12 ` [PATCH v3 2/2] PCI: histb: Add an optional regulator for PCIe port power control Shawn Guo
  2018-03-02 14:09 ` [PATCH v3 0/2] Add power control for pcie-histb driver Lorenzo Pieralisi
  2 siblings, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2018-03-02  1:12 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun,
	Jiancheng Xue, linux-pci, devicetree, Shawn Guo

If clk_prepare_enable() call fails on a particular clock, we should not
call clk_disable_unprepare() on this clock, but on the clocks that
succeed from clk_prepare_enable() previously.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pci/dwc/pcie-histb.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/dwc/pcie-histb.c b/drivers/pci/dwc/pcie-histb.c
index 70b5c0b108bf..17ed604f5741 100644
--- a/drivers/pci/dwc/pcie-histb.c
+++ b/drivers/pci/dwc/pcie-histb.c
@@ -276,13 +276,12 @@ static int histb_pcie_host_enable(struct pcie_port *pp)
 	return 0;
 
 err_aux_clk:
-	clk_disable_unprepare(hipcie->aux_clk);
-err_pipe_clk:
 	clk_disable_unprepare(hipcie->pipe_clk);
-err_sys_clk:
+err_pipe_clk:
 	clk_disable_unprepare(hipcie->sys_clk);
-err_bus_clk:
+err_sys_clk:
 	clk_disable_unprepare(hipcie->bus_clk);
+err_bus_clk:
 
 	return ret;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] PCI: histb: Add an optional regulator for PCIe port power control
  2018-03-02  1:11 [PATCH v3 0/2] Add power control for pcie-histb driver Shawn Guo
  2018-03-02  1:12 ` [PATCH v3 1/2] PCI: histb: Fix error path of histb_pcie_host_enable() Shawn Guo
@ 2018-03-02  1:12 ` Shawn Guo
  2018-03-02 14:09 ` [PATCH v3 0/2] Add power control for pcie-histb driver Lorenzo Pieralisi
  2 siblings, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2018-03-02  1:12 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun,
	Jiancheng Xue, linux-pci, devicetree, Shawn Guo

The power supply to PCIe port are often controlled by GPIO on some board
designs.  Let's add an optional regulator which can be backed by GPIO to
control the power.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
---
 .../bindings/pci/hisilicon-histb-pcie.txt           |  1 +
 drivers/pci/dwc/pcie-histb.c                        | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt b/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt
index c84bc027930b..760b4d740616 100644
--- a/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt
@@ -34,6 +34,7 @@ Required properties
 
 Optional properties:
 - reset-gpios: The gpio to generate PCIe PERST# assert and deassert signal.
+- vpcie-supply: The regulator in charge of PCIe port power.
 - phys: List of phandle and phy mode specifier, should be 0.
 - phy-names: Must be "phy".
 
diff --git a/drivers/pci/dwc/pcie-histb.c b/drivers/pci/dwc/pcie-histb.c
index 17ed604f5741..4cef0a514944 100644
--- a/drivers/pci/dwc/pcie-histb.c
+++ b/drivers/pci/dwc/pcie-histb.c
@@ -61,6 +61,7 @@ struct histb_pcie {
 	struct reset_control *bus_reset;
 	void __iomem *ctrl;
 	int reset_gpio;
+	struct regulator *vpcie;
 };
 
 static u32 histb_pcie_readl(struct histb_pcie *histb_pcie, u32 reg)
@@ -227,6 +228,9 @@ static void histb_pcie_host_disable(struct histb_pcie *hipcie)
 
 	if (gpio_is_valid(hipcie->reset_gpio))
 		gpio_set_value_cansleep(hipcie->reset_gpio, 0);
+
+	if (hipcie->vpcie)
+		regulator_disable(hipcie->vpcie);
 }
 
 static int histb_pcie_host_enable(struct pcie_port *pp)
@@ -237,6 +241,14 @@ static int histb_pcie_host_enable(struct pcie_port *pp)
 	int ret;
 
 	/* power on PCIe device if have */
+	if (hipcie->vpcie) {
+		ret = regulator_enable(hipcie->vpcie);
+		if (ret) {
+			dev_err(dev, "failed to enable regulator: %d\n", ret);
+			return ret;
+		}
+	}
+
 	if (gpio_is_valid(hipcie->reset_gpio))
 		gpio_set_value_cansleep(hipcie->reset_gpio, 1);
 
@@ -282,6 +294,8 @@ static int histb_pcie_host_enable(struct pcie_port *pp)
 err_sys_clk:
 	clk_disable_unprepare(hipcie->bus_clk);
 err_bus_clk:
+	if (hipcie->vpcie)
+		regulator_disable(hipcie->vpcie);
 
 	return ret;
 }
@@ -331,6 +345,13 @@ static int histb_pcie_probe(struct platform_device *pdev)
 		return PTR_ERR(pci->dbi_base);
 	}
 
+	hipcie->vpcie = devm_regulator_get_optional(dev, "vpcie");
+	if (IS_ERR(hipcie->vpcie)) {
+		if (PTR_ERR(hipcie->vpcie) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		hipcie->vpcie = NULL;
+	}
+
 	hipcie->reset_gpio = of_get_named_gpio_flags(np,
 				"reset-gpios", 0, &of_flags);
 	if (of_flags & OF_GPIO_ACTIVE_LOW)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 0/2] Add power control for pcie-histb driver
  2018-03-02  1:11 [PATCH v3 0/2] Add power control for pcie-histb driver Shawn Guo
  2018-03-02  1:12 ` [PATCH v3 1/2] PCI: histb: Fix error path of histb_pcie_host_enable() Shawn Guo
  2018-03-02  1:12 ` [PATCH v3 2/2] PCI: histb: Add an optional regulator for PCIe port power control Shawn Guo
@ 2018-03-02 14:09 ` Lorenzo Pieralisi
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Pieralisi @ 2018-03-02 14:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun,
	Jiancheng Xue, linux-pci, devicetree

On Fri, Mar 02, 2018 at 09:11:59AM +0800, Shawn Guo wrote:
> It adds power control support for pcie-histb driver, by utilizing
> regulator infrastructural.
> 
> Changes for v3:
>  - Incorporate Rob's ACK on bindings doc.
>  - Capitalize  the first word of patch subject to match drivers/pci
>    convention.
>  - Reword vpcie-supply description a bit as per Bjorn's suggestion.
> 
> Shawn Guo (2):
>   PCI: histb: Fix error path of histb_pcie_host_enable()
>   PCI: histb: Add an optional regulator for PCIe port power control
> 
>  .../bindings/pci/hisilicon-histb-pcie.txt          |  1 +
>  drivers/pci/dwc/pcie-histb.c                       | 28 ++++++++++++++++++----
>  2 files changed, 25 insertions(+), 4 deletions(-)

Series applied to pci/dwc for v4.17, thanks.

Lorenzo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-02 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-02  1:11 [PATCH v3 0/2] Add power control for pcie-histb driver Shawn Guo
2018-03-02  1:12 ` [PATCH v3 1/2] PCI: histb: Fix error path of histb_pcie_host_enable() Shawn Guo
2018-03-02  1:12 ` [PATCH v3 2/2] PCI: histb: Add an optional regulator for PCIe port power control Shawn Guo
2018-03-02 14:09 ` [PATCH v3 0/2] Add power control for pcie-histb driver Lorenzo Pieralisi

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).