* [PATCH v2 0/2] Add power control for pcie-histb driver @ 2018-01-23 15:45 Shawn Guo [not found] ` <1516722337-1533-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Shawn Guo @ 2018-01-23 15:45 UTC (permalink / raw) To: Bjorn Helgaas Cc: Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci, devicetree, project-aspen-dev, Shawn Guo The first patch is a small fix which is useful for the second one. This version basically follows Fabio's suggestion to reimplement the first version patch, using a regulator that can be backed by GPIO to control the power to PCIe port. 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] 9+ messages in thread
[parent not found: <1516722337-1533-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* [PATCH v2 1/2] PCI: histb: fix error path of histb_pcie_host_enable() [not found] ` <1516722337-1533-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2018-01-23 15:45 ` Shawn Guo 0 siblings, 0 replies; 9+ messages in thread From: Shawn Guo @ 2018-01-23 15:45 UTC (permalink / raw) To: Bjorn Helgaas Cc: Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, project-aspen-dev-QSEj5FYQhm4dnm+yROfE0A, 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-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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 33b01b734d7d..6395394be5b4 100644 --- a/drivers/pci/dwc/pcie-histb.c +++ b/drivers/pci/dwc/pcie-histb.c @@ -279,13 +279,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 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] PCI: histb: add an optional regulator for PCIe port power control 2018-01-23 15:45 [PATCH v2 0/2] Add power control for pcie-histb driver Shawn Guo [not found] ` <1516722337-1533-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2018-01-23 15:45 ` Shawn Guo [not found] ` <1516722337-1533-3-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2018-03-01 15:09 ` Bjorn Helgaas 2018-03-01 1:22 ` [PATCH v2 0/2] Add power control for pcie-histb driver Shawn Guo 2 siblings, 2 replies; 9+ messages in thread From: Shawn Guo @ 2018-01-23 15:45 UTC (permalink / raw) To: Bjorn Helgaas Cc: Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci, devicetree, project-aspen-dev, 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> --- .../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..f995664e6d7f 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: Should specify 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 6395394be5b4..8eb3028432b3 100644 --- a/drivers/pci/dwc/pcie-histb.c +++ b/drivers/pci/dwc/pcie-histb.c @@ -64,6 +64,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) @@ -230,6 +231,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) @@ -240,6 +244,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); @@ -285,6 +297,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; } @@ -334,6 +348,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] 9+ messages in thread
[parent not found: <1516722337-1533-3-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH v2 2/2] PCI: histb: add an optional regulator for PCIe port power control [not found] ` <1516722337-1533-3-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2018-01-30 0:07 ` Rob Herring 0 siblings, 0 replies; 9+ messages in thread From: Rob Herring @ 2018-01-30 0:07 UTC (permalink / raw) To: Shawn Guo Cc: Bjorn Helgaas, Fabio Estevam, Jianguo Sun, linux-pci-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, project-aspen-dev-QSEj5FYQhm4dnm+yROfE0A On Tue, Jan 23, 2018 at 11:45:37PM +0800, Shawn Guo wrote: > 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-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > --- > .../bindings/pci/hisilicon-histb-pcie.txt | 1 + Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > drivers/pci/dwc/pcie-histb.c | 21 +++++++++++++++++++++ > 2 files changed, 22 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] PCI: histb: add an optional regulator for PCIe port power control 2018-01-23 15:45 ` [PATCH v2 2/2] PCI: histb: add an optional regulator for PCIe port power control Shawn Guo [not found] ` <1516722337-1533-3-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2018-03-01 15:09 ` Bjorn Helgaas 1 sibling, 0 replies; 9+ messages in thread From: Bjorn Helgaas @ 2018-03-01 15:09 UTC (permalink / raw) To: Shawn Guo Cc: Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci, devicetree, project-aspen-dev On Tue, Jan 23, 2018 at 11:45:37PM +0800, Shawn Guo wrote: > 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> > --- > .../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..f995664e6d7f 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: Should specify the regulator in charge of PCIe port power. s/Should specify the/The/ > - 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 6395394be5b4..8eb3028432b3 100644 > --- a/drivers/pci/dwc/pcie-histb.c > +++ b/drivers/pci/dwc/pcie-histb.c > @@ -64,6 +64,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) > @@ -230,6 +231,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) > @@ -240,6 +244,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); > > @@ -285,6 +297,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; > } > @@ -334,6 +348,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 [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/2] Add power control for pcie-histb driver 2018-01-23 15:45 [PATCH v2 0/2] Add power control for pcie-histb driver Shawn Guo [not found] ` <1516722337-1533-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2018-01-23 15:45 ` [PATCH v2 2/2] PCI: histb: add an optional regulator for PCIe port power control Shawn Guo @ 2018-03-01 1:22 ` Shawn Guo 2018-03-01 15:08 ` Bjorn Helgaas 2 siblings, 1 reply; 9+ messages in thread From: Shawn Guo @ 2018-03-01 1:22 UTC (permalink / raw) To: Bjorn Helgaas Cc: Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci, devicetree, Jiancheng Xue On Tue, Jan 23, 2018 at 11:45:35PM +0800, Shawn Guo wrote: > The first patch is a small fix which is useful for the second one. > This version basically follows Fabio's suggestion to reimplement the > first version patch, using a regulator that can be backed by GPIO to > control the power to PCIe port. > > 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(-) Hi Bjorn, Did you get a chance to look at the series? Shawn ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/2] Add power control for pcie-histb driver 2018-03-01 1:22 ` [PATCH v2 0/2] Add power control for pcie-histb driver Shawn Guo @ 2018-03-01 15:08 ` Bjorn Helgaas 2018-03-01 18:11 ` Lorenzo Pieralisi 0 siblings, 1 reply; 9+ messages in thread From: Bjorn Helgaas @ 2018-03-01 15:08 UTC (permalink / raw) To: Shawn Guo Cc: Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci, devicetree, Jiancheng Xue, Lorenzo Pieralisi [+cc Lorenzo] On Thu, Mar 01, 2018 at 09:22:46AM +0800, Shawn Guo wrote: > On Tue, Jan 23, 2018 at 11:45:35PM +0800, Shawn Guo wrote: > > The first patch is a small fix which is useful for the second one. > > This version basically follows Fabio's suggestion to reimplement the > > first version patch, using a regulator that can be backed by GPIO to > > control the power to PCIe port. > > > > 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(-) > > Hi Bjorn, > > Did you get a chance to look at the series? I cc'd Lorenzo, who is now taking care of this area. If/when you repost this, please incorporate Rob's ack and capitalize the first word of your summary ("Fix", "Add") to match the drivers/pci convention. Also, the original post used "PCI: hisi:", but here you use "PCI: histb:". It probably does make sense to distinguish "hisi" from "histb", but I want it to be a conscious choice so future patches can be consistent with it. Bjorn ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/2] Add power control for pcie-histb driver 2018-03-01 15:08 ` Bjorn Helgaas @ 2018-03-01 18:11 ` Lorenzo Pieralisi 2018-03-02 0:43 ` Shawn Guo 0 siblings, 1 reply; 9+ messages in thread From: Lorenzo Pieralisi @ 2018-03-01 18:11 UTC (permalink / raw) To: Bjorn Helgaas Cc: Shawn Guo, Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci, devicetree, Jiancheng Xue On Thu, Mar 01, 2018 at 09:08:22AM -0600, Bjorn Helgaas wrote: > [+cc Lorenzo] > > On Thu, Mar 01, 2018 at 09:22:46AM +0800, Shawn Guo wrote: > > On Tue, Jan 23, 2018 at 11:45:35PM +0800, Shawn Guo wrote: > > > The first patch is a small fix which is useful for the second one. > > > This version basically follows Fabio's suggestion to reimplement the > > > first version patch, using a regulator that can be backed by GPIO to > > > control the power to PCIe port. > > > > > > 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(-) > > > > Hi Bjorn, > > > > Did you get a chance to look at the series? > > I cc'd Lorenzo, who is now taking care of this area. > > If/when you repost this, please incorporate Rob's ack and capitalize > the first word of your summary ("Fix", "Add") to match the drivers/pci > convention. > > Also, the original post used "PCI: hisi:", but here you use > "PCI: histb:". It probably does make sense to distinguish > "hisi" from "histb", but I want it to be a conscious choice > so future patches can be consistent with it. I suspect that using histb makes more sense but I will wait Shawn's feedback on this, this series was on my radar anyway but thanks for the flag up. Lorenzo ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/2] Add power control for pcie-histb driver 2018-03-01 18:11 ` Lorenzo Pieralisi @ 2018-03-02 0:43 ` Shawn Guo 0 siblings, 0 replies; 9+ messages in thread From: Shawn Guo @ 2018-03-02 0:43 UTC (permalink / raw) To: Lorenzo Pieralisi Cc: Bjorn Helgaas, Bjorn Helgaas, Rob Herring, Fabio Estevam, Jianguo Sun, linux-pci, devicetree, Jiancheng Xue On Thu, Mar 01, 2018 at 06:11:19PM +0000, Lorenzo Pieralisi wrote: > On Thu, Mar 01, 2018 at 09:08:22AM -0600, Bjorn Helgaas wrote: > > [+cc Lorenzo] > > > > On Thu, Mar 01, 2018 at 09:22:46AM +0800, Shawn Guo wrote: > > > On Tue, Jan 23, 2018 at 11:45:35PM +0800, Shawn Guo wrote: > > > > The first patch is a small fix which is useful for the second one. > > > > This version basically follows Fabio's suggestion to reimplement the > > > > first version patch, using a regulator that can be backed by GPIO to > > > > control the power to PCIe port. > > > > > > > > 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(-) > > > > > > Hi Bjorn, > > > > > > Did you get a chance to look at the series? > > > > I cc'd Lorenzo, who is now taking care of this area. > > > > If/when you repost this, please incorporate Rob's ack and capitalize > > the first word of your summary ("Fix", "Add") to match the drivers/pci > > convention. > > > > Also, the original post used "PCI: hisi:", but here you use > > "PCI: histb:". It probably does make sense to distinguish > > "hisi" from "histb", but I want it to be a conscious choice > > so future patches can be consistent with it. > > I suspect that using histb makes more sense but I will wait Shawn's > feedback on this, Yes, we want to distinguish the driver pcie-histb.c from pcie-hisi.c, and will consistently use "PCI: histb:" for this driver. > this series was on my radar anyway but thanks > for the flag up. Cool. I will keep you posted on v3. Thanks, Bjorn, Lorenzo. Shawn ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-03-02 0:43 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-01-23 15:45 [PATCH v2 0/2] Add power control for pcie-histb driver Shawn Guo [not found] ` <1516722337-1533-1-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2018-01-23 15:45 ` [PATCH v2 1/2] PCI: histb: fix error path of histb_pcie_host_enable() Shawn Guo 2018-01-23 15:45 ` [PATCH v2 2/2] PCI: histb: add an optional regulator for PCIe port power control Shawn Guo [not found] ` <1516722337-1533-3-git-send-email-shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2018-01-30 0:07 ` Rob Herring 2018-03-01 15:09 ` Bjorn Helgaas 2018-03-01 1:22 ` [PATCH v2 0/2] Add power control for pcie-histb driver Shawn Guo 2018-03-01 15:08 ` Bjorn Helgaas 2018-03-01 18:11 ` Lorenzo Pieralisi 2018-03-02 0:43 ` Shawn Guo
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).