diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2018-03-01 20:12:01 -0500 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2018-03-07 11:24:27 -0500 |
commit | 58dfb24349e1d0aa6461d2b0f2811b46fe350280 (patch) | |
tree | 93ae2e1c48dfb25305d015c2745e269f804dc8be | |
parent | db0c25f8aadad8f0be1c6986cf1dcf874d40d79b (diff) |
PCI: histb: Add an optional regulator for PCIe port power control
The power supplies 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>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
-rw-r--r-- | Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt | 1 | ||||
-rw-r--r-- | drivers/pci/dwc/pcie-histb.c | 21 |
2 files changed, 22 insertions, 0 deletions
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 | |||
34 | 34 | ||
35 | Optional properties: | 35 | Optional properties: |
36 | - reset-gpios: The gpio to generate PCIe PERST# assert and deassert signal. | 36 | - reset-gpios: The gpio to generate PCIe PERST# assert and deassert signal. |
37 | - vpcie-supply: The regulator in charge of PCIe port power. | ||
37 | - phys: List of phandle and phy mode specifier, should be 0. | 38 | - phys: List of phandle and phy mode specifier, should be 0. |
38 | - phy-names: Must be "phy". | 39 | - phy-names: Must be "phy". |
39 | 40 | ||
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 { | |||
61 | struct reset_control *bus_reset; | 61 | struct reset_control *bus_reset; |
62 | void __iomem *ctrl; | 62 | void __iomem *ctrl; |
63 | int reset_gpio; | 63 | int reset_gpio; |
64 | struct regulator *vpcie; | ||
64 | }; | 65 | }; |
65 | 66 | ||
66 | static u32 histb_pcie_readl(struct histb_pcie *histb_pcie, u32 reg) | 67 | 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) | |||
227 | 228 | ||
228 | if (gpio_is_valid(hipcie->reset_gpio)) | 229 | if (gpio_is_valid(hipcie->reset_gpio)) |
229 | gpio_set_value_cansleep(hipcie->reset_gpio, 0); | 230 | gpio_set_value_cansleep(hipcie->reset_gpio, 0); |
231 | |||
232 | if (hipcie->vpcie) | ||
233 | regulator_disable(hipcie->vpcie); | ||
230 | } | 234 | } |
231 | 235 | ||
232 | static int histb_pcie_host_enable(struct pcie_port *pp) | 236 | static int histb_pcie_host_enable(struct pcie_port *pp) |
@@ -237,6 +241,14 @@ static int histb_pcie_host_enable(struct pcie_port *pp) | |||
237 | int ret; | 241 | int ret; |
238 | 242 | ||
239 | /* power on PCIe device if have */ | 243 | /* power on PCIe device if have */ |
244 | if (hipcie->vpcie) { | ||
245 | ret = regulator_enable(hipcie->vpcie); | ||
246 | if (ret) { | ||
247 | dev_err(dev, "failed to enable regulator: %d\n", ret); | ||
248 | return ret; | ||
249 | } | ||
250 | } | ||
251 | |||
240 | if (gpio_is_valid(hipcie->reset_gpio)) | 252 | if (gpio_is_valid(hipcie->reset_gpio)) |
241 | gpio_set_value_cansleep(hipcie->reset_gpio, 1); | 253 | gpio_set_value_cansleep(hipcie->reset_gpio, 1); |
242 | 254 | ||
@@ -282,6 +294,8 @@ err_pipe_clk: | |||
282 | err_sys_clk: | 294 | err_sys_clk: |
283 | clk_disable_unprepare(hipcie->bus_clk); | 295 | clk_disable_unprepare(hipcie->bus_clk); |
284 | err_bus_clk: | 296 | err_bus_clk: |
297 | if (hipcie->vpcie) | ||
298 | regulator_disable(hipcie->vpcie); | ||
285 | 299 | ||
286 | return ret; | 300 | return ret; |
287 | } | 301 | } |
@@ -331,6 +345,13 @@ static int histb_pcie_probe(struct platform_device *pdev) | |||
331 | return PTR_ERR(pci->dbi_base); | 345 | return PTR_ERR(pci->dbi_base); |
332 | } | 346 | } |
333 | 347 | ||
348 | hipcie->vpcie = devm_regulator_get_optional(dev, "vpcie"); | ||
349 | if (IS_ERR(hipcie->vpcie)) { | ||
350 | if (PTR_ERR(hipcie->vpcie) == -EPROBE_DEFER) | ||
351 | return -EPROBE_DEFER; | ||
352 | hipcie->vpcie = NULL; | ||
353 | } | ||
354 | |||
334 | hipcie->reset_gpio = of_get_named_gpio_flags(np, | 355 | hipcie->reset_gpio = of_get_named_gpio_flags(np, |
335 | "reset-gpios", 0, &of_flags); | 356 | "reset-gpios", 0, &of_flags); |
336 | if (of_flags & OF_GPIO_ACTIVE_LOW) | 357 | if (of_flags & OF_GPIO_ACTIVE_LOW) |