Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Shawn Guo and committed by
Lorenzo Pieralisi
58dfb243 db0c25f8

+22
+1
Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt
··· 34 34 35 35 Optional properties: 36 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 38 - phys: List of phandle and phy mode specifier, should be 0. 38 39 - phy-names: Must be "phy". 39 40
+21
drivers/pci/dwc/pcie-histb.c
··· 61 61 struct reset_control *bus_reset; 62 62 void __iomem *ctrl; 63 63 int reset_gpio; 64 + struct regulator *vpcie; 64 65 }; 65 66 66 67 static u32 histb_pcie_readl(struct histb_pcie *histb_pcie, u32 reg) ··· 228 227 229 228 if (gpio_is_valid(hipcie->reset_gpio)) 230 229 gpio_set_value_cansleep(hipcie->reset_gpio, 0); 230 + 231 + if (hipcie->vpcie) 232 + regulator_disable(hipcie->vpcie); 231 233 } 232 234 233 235 static int histb_pcie_host_enable(struct pcie_port *pp) ··· 241 237 int ret; 242 238 243 239 /* power on PCIe device if have */ 240 + if (hipcie->vpcie) { 241 + ret = regulator_enable(hipcie->vpcie); 242 + if (ret) { 243 + dev_err(dev, "failed to enable regulator: %d\n", ret); 244 + return ret; 245 + } 246 + } 247 + 244 248 if (gpio_is_valid(hipcie->reset_gpio)) 245 249 gpio_set_value_cansleep(hipcie->reset_gpio, 1); 246 250 ··· 294 282 err_sys_clk: 295 283 clk_disable_unprepare(hipcie->bus_clk); 296 284 err_bus_clk: 285 + if (hipcie->vpcie) 286 + regulator_disable(hipcie->vpcie); 297 287 298 288 return ret; 299 289 } ··· 343 329 if (IS_ERR(pci->dbi_base)) { 344 330 dev_err(dev, "cannot get rc-dbi base\n"); 345 331 return PTR_ERR(pci->dbi_base); 332 + } 333 + 334 + hipcie->vpcie = devm_regulator_get_optional(dev, "vpcie"); 335 + if (IS_ERR(hipcie->vpcie)) { 336 + if (PTR_ERR(hipcie->vpcie) == -EPROBE_DEFER) 337 + return -EPROBE_DEFER; 338 + hipcie->vpcie = NULL; 346 339 } 347 340 348 341 hipcie->reset_gpio = of_get_named_gpio_flags(np,