* [PATCH 0/2] KingFisher: support regulators for PCIe
@ 2023-05-10 6:58 Wolfram Sang
2023-05-10 6:58 ` [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators Wolfram Sang
2023-05-10 6:58 ` [PATCH 2/2] PCI: rcar-host: add support for " Wolfram Sang
0 siblings, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-05-10 6:58 UTC (permalink / raw)
To: linux-renesas-soc
Cc: Wolfram Sang, devicetree, linux-kernel, linux-pci, Marek Vasut,
Yoshihiro Shimoda
Here are the patches to make PCIe cards work in the slot CN15 on a
KingFisher board. Look at the patches for a changelog, please.
Wolfram
Wolfram Sang (2):
dt-bindings: PCI: rcar-pci-host: add optional regulators
PCI: rcar-host: add support for optional regulators
.../devicetree/bindings/pci/rcar-pci-host.yaml | 11 +++++++++++
drivers/pci/controller/pcie-rcar-host.c | 15 ++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators
2023-05-10 6:58 [PATCH 0/2] KingFisher: support regulators for PCIe Wolfram Sang
@ 2023-05-10 6:58 ` Wolfram Sang
2023-05-10 7:22 ` Geert Uytterhoeven
2023-05-10 7:56 ` Krzysztof Kozlowski
2023-05-10 6:58 ` [PATCH 2/2] PCI: rcar-host: add support for " Wolfram Sang
1 sibling, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-05-10 6:58 UTC (permalink / raw)
To: linux-renesas-soc
Cc: Wolfram Sang, Marek Vasut, Yoshihiro Shimoda, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Krzysztof Kozlowski, Conor Dooley, linux-pci, devicetree,
linux-kernel
Support regulators found on the e.g. KingFisher board for miniPCIe and
add a 12v regulator while we are here.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Changes since RFC:
* added 12V supply for completeness
* use PCIe slot in the example instead of miniPCIe because that is what
the Koelsch board offers (just without the regulators ;))
.../devicetree/bindings/pci/rcar-pci-host.yaml | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Documentation/devicetree/bindings/pci/rcar-pci-host.yaml b/Documentation/devicetree/bindings/pci/rcar-pci-host.yaml
index 8fdfbc763d70..b6a7cb32f61e 100644
--- a/Documentation/devicetree/bindings/pci/rcar-pci-host.yaml
+++ b/Documentation/devicetree/bindings/pci/rcar-pci-host.yaml
@@ -68,6 +68,15 @@ properties:
phy-names:
const: pcie
+ vpcie1v5-supply:
+ description: The 1.5v regulator to use for PCIe.
+
+ vpcie3v3-supply:
+ description: The 3.3v regulator to use for PCIe.
+
+ vpcie12v-supply:
+ description: The 12v regulator to use for PCIe.
+
required:
- compatible
- reg
@@ -121,5 +130,7 @@ examples:
clock-names = "pcie", "pcie_bus";
power-domains = <&sysc R8A7791_PD_ALWAYS_ON>;
resets = <&cpg 319>;
+ vpcie3v3-supply = <&pcie_3v3>;
+ vpcie12v-supply = <&pcie_12v>;
};
};
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] PCI: rcar-host: add support for optional regulators
2023-05-10 6:58 [PATCH 0/2] KingFisher: support regulators for PCIe Wolfram Sang
2023-05-10 6:58 ` [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators Wolfram Sang
@ 2023-05-10 6:58 ` Wolfram Sang
2023-05-10 7:27 ` Geert Uytterhoeven
1 sibling, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2023-05-10 6:58 UTC (permalink / raw)
To: linux-renesas-soc
Cc: Wolfram Sang, Marek Vasut, Yoshihiro Shimoda, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, linux-pci,
linux-kernel
The KingFisher board has regulators. They just need to be en-/disabled,
so we can leave the handling to devm.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Changes since RFC:
* add 12v regulator
* add comment about the order of enabling the regulators
* use a for-loop to iterate over the regulators
Sidenote: I tried to introduce 'devm_regulator_bulk_get_enable_optional'
to avoid the for-loop but that was a too intrusive change because all of
the regulator_bulk logic is designed to fail if something bad happens
somewhere.
drivers/pci/controller/pcie-rcar-host.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
index e80e56b2a842..e86bf0f7729b 100644
--- a/drivers/pci/controller/pcie-rcar-host.c
+++ b/drivers/pci/controller/pcie-rcar-host.c
@@ -29,6 +29,7 @@
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
#include "pcie-rcar.h"
@@ -974,13 +975,18 @@ static const struct of_device_id rcar_pcie_of_match[] = {
{},
};
+/* Design note 346 from Linear Technology says order is not important */
+static const char * const rcar_pcie_supplies[] = {
+ "vpcie12v", "vpcie3v3", "vpcie1v5"
+};
+
static int rcar_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct rcar_pcie_host *host;
struct rcar_pcie *pcie;
u32 data;
- int err;
+ int i, err;
struct pci_host_bridge *bridge;
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*host));
@@ -992,6 +998,13 @@ static int rcar_pcie_probe(struct platform_device *pdev)
pcie->dev = dev;
platform_set_drvdata(pdev, host);
+ for (i = 0; i < ARRAY_SIZE(rcar_pcie_supplies); i++) {
+ err = devm_regulator_get_enable_optional(dev, rcar_pcie_supplies[i]);
+ if (err < 0 && err != -ENODEV)
+ dev_err_probe(dev, err, "error enabling regulator %s\n",
+ rcar_pcie_supplies[i]);
+ }
+
pm_runtime_enable(pcie->dev);
err = pm_runtime_get_sync(pcie->dev);
if (err < 0) {
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators
2023-05-10 6:58 ` [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators Wolfram Sang
@ 2023-05-10 7:22 ` Geert Uytterhoeven
2023-05-10 7:56 ` Krzysztof Kozlowski
1 sibling, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2023-05-10 7:22 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-renesas-soc, Marek Vasut, Yoshihiro Shimoda,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Krzysztof Kozlowski, Conor Dooley, linux-pci,
devicetree, linux-kernel
On Wed, May 10, 2023 at 8:59 AM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> Support regulators found on the e.g. KingFisher board for miniPCIe and
> add a 12v regulator while we are here.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>
> Changes since RFC:
> * added 12V supply for completeness
> * use PCIe slot in the example instead of miniPCIe because that is what
> the Koelsch board offers (just without the regulators ;))
Same for e.g. Salvator-XS.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] PCI: rcar-host: add support for optional regulators
2023-05-10 6:58 ` [PATCH 2/2] PCI: rcar-host: add support for " Wolfram Sang
@ 2023-05-10 7:27 ` Geert Uytterhoeven
2023-05-10 7:46 ` Wolfram Sang
2023-05-10 21:18 ` Bjorn Helgaas
0 siblings, 2 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2023-05-10 7:27 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-renesas-soc, Marek Vasut, Yoshihiro Shimoda,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, linux-pci, linux-kernel
Hi Wolfram,
On Wed, May 10, 2023 at 8:59 AM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> The KingFisher board has regulators. They just need to be en-/disabled,
> so we can leave the handling to devm.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>
> Changes since RFC:
> * add 12v regulator
> * add comment about the order of enabling the regulators
> * use a for-loop to iterate over the regulators
Thanks for the update!
> --- a/drivers/pci/controller/pcie-rcar-host.c
> +++ b/drivers/pci/controller/pcie-rcar-host.c
> @@ -29,6 +29,7 @@
> #include <linux/phy/phy.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> +#include <linux/regulator/consumer.h>
>
> #include "pcie-rcar.h"
>
> @@ -974,13 +975,18 @@ static const struct of_device_id rcar_pcie_of_match[] = {
> {},
> };
>
> +/* Design note 346 from Linear Technology says order is not important */
> +static const char * const rcar_pcie_supplies[] = {
> + "vpcie12v", "vpcie3v3", "vpcie1v5"
> +};
> +
> static int rcar_pcie_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct rcar_pcie_host *host;
> struct rcar_pcie *pcie;
> u32 data;
> - int err;
> + int i, err;
unsigned int i?
> struct pci_host_bridge *bridge;
The (lack of) reverse-Xmas-tree ordering is hurting my OCD, but that's
not your fault...
> @@ -992,6 +998,13 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> pcie->dev = dev;
> platform_set_drvdata(pdev, host);
>
> + for (i = 0; i < ARRAY_SIZE(rcar_pcie_supplies); i++) {
> + err = devm_regulator_get_enable_optional(dev, rcar_pcie_supplies[i]);
> + if (err < 0 && err != -ENODEV)
> + dev_err_probe(dev, err, "error enabling regulator %s\n",
> + rcar_pcie_supplies[i]);
Shouldn't this return, and propagate the error code upstream?
> + }
> +
> pm_runtime_enable(pcie->dev);
> err = pm_runtime_get_sync(pcie->dev);
> if (err < 0) {
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] PCI: rcar-host: add support for optional regulators
2023-05-10 7:27 ` Geert Uytterhoeven
@ 2023-05-10 7:46 ` Wolfram Sang
2023-05-10 21:18 ` Bjorn Helgaas
1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-05-10 7:46 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: linux-renesas-soc, Marek Vasut, Yoshihiro Shimoda,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, linux-pci, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
> > + int i, err;
>
> unsigned int i?
OK.
>
> > struct pci_host_bridge *bridge;
>
> The (lack of) reverse-Xmas-tree ordering is hurting my OCD, but that's
> not your fault...
Ack :) I can change it, though.
> > + dev_err_probe(dev, err, "error enabling regulator %s\n",
> > + rcar_pcie_supplies[i]);
>
> Shouldn't this return, and propagate the error code upstream?
Ouch, brown paper bag, please.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators
2023-05-10 6:58 ` [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators Wolfram Sang
2023-05-10 7:22 ` Geert Uytterhoeven
@ 2023-05-10 7:56 ` Krzysztof Kozlowski
1 sibling, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-10 7:56 UTC (permalink / raw)
To: Wolfram Sang, linux-renesas-soc
Cc: Marek Vasut, Yoshihiro Shimoda, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Krzysztof Kozlowski, Conor Dooley, linux-pci, devicetree,
linux-kernel
On 10/05/2023 08:58, Wolfram Sang wrote:
> Support regulators found on the e.g. KingFisher board for miniPCIe and
> add a 12v regulator while we are here.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>
> Changes since RFC:
> * added 12V supply for completeness
> * use PCIe slot in the example instead of miniPCIe because that is what
> the Koelsch board offers (just without the regulators ;))
>
> .../devicetree/bindings/pci/rcar-pci-host.yaml | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/pci/rcar-pci-host.yaml
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] PCI: rcar-host: add support for optional regulators
2023-05-10 7:27 ` Geert Uytterhoeven
2023-05-10 7:46 ` Wolfram Sang
@ 2023-05-10 21:18 ` Bjorn Helgaas
1 sibling, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2023-05-10 21:18 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Wolfram Sang, linux-renesas-soc, Marek Vasut, Yoshihiro Shimoda,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, linux-pci, linux-kernel
On Wed, May 10, 2023 at 09:27:46AM +0200, Geert Uytterhoeven wrote:
> On Wed, May 10, 2023 at 8:59 AM Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> ...
> > static int rcar_pcie_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > struct rcar_pcie_host *host;
> > struct rcar_pcie *pcie;
> > u32 data;
> > - int err;
> > + int i, err;
>
> unsigned int i?
>
> > struct pci_host_bridge *bridge;
>
> The (lack of) reverse-Xmas-tree ordering is hurting my OCD, but that's
> not your fault...
I usually put things in order of use, with initializations from
parameters first. Happily, that is often a pretty good approximation
of reverse-Xmas-tree, as it is here, so I'm all in favor of moving
"struct pci_host_bridge" up there :)
Bjorn
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-05-10 21:18 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-10 6:58 [PATCH 0/2] KingFisher: support regulators for PCIe Wolfram Sang
2023-05-10 6:58 ` [PATCH 1/2] dt-bindings: PCI: rcar-pci-host: add optional regulators Wolfram Sang
2023-05-10 7:22 ` Geert Uytterhoeven
2023-05-10 7:56 ` Krzysztof Kozlowski
2023-05-10 6:58 ` [PATCH 2/2] PCI: rcar-host: add support for " Wolfram Sang
2023-05-10 7:27 ` Geert Uytterhoeven
2023-05-10 7:46 ` Wolfram Sang
2023-05-10 21:18 ` Bjorn Helgaas
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).