All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Hal Feng <hal.feng@starfivetech.com>
Cc: "Conor Dooley" <conor+dt@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Emil Renner Berthing" <emil.renner.berthing@canonical.com>,
	"Heinrich Schuchardt" <heinrich.schuchardt@canonical.com>,
	"E Shattow" <e@freeshell.de>,
	devicetree@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Kevin Xie" <kevin.xie@starfivetech.com>
Subject: Re: [PATCH v4 1/6] PCI: starfive: Use regulator APIs instead of GPIO APIs to enable the 3V3 power supply of PCIe slots
Date: Mon, 1 Dec 2025 14:52:36 -0600	[thread overview]
Message-ID: <20251201205236.GA3023515@bhelgaas> (raw)
In-Reply-To: <20251125075604.69370-2-hal.feng@starfivetech.com>

[+cc Kevin, pcie-starfive.c maintainer; will need his ack]

Subject line is excessively long.

On Tue, Nov 25, 2025 at 03:55:59PM +0800, Hal Feng wrote:
> The "enable-gpio" property is not documented in the dt-bindings and
> using GPIO APIs is not a standard method to enable or disable PCIe
> slot power, so use regulator APIs to replace them.

I can't tell from this whether existing DTs will continue to work
after this change.  It looks like previously we looked for an
"enable-gpios" or "enable-gpio" property and now we'll look for a
"vpcie3v3-supply" regulator property.

I don't see "enable-gpios" or "enable-gpio" mentioned in any of the DT
patches in this series, so maybe that property was never actually used
before, and the code for pcie->power_gpio was actually dead?

Please add something here about how we know this won't break any
existing setups using DTs that are already in the field.

> Tested-by: Matthias Brugger <mbrugger@suse.com>
> Fixes: 39b91eb40c6a ("PCI: starfive: Add JH7110 PCIe controller")

Based on the cover letter, it looks like the point of this is to add
support for a new device, which I don't think really qualifies as a
"fix".

> Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
> ---
>  drivers/pci/controller/plda/pcie-starfive.c | 25 ++++++++++++---------
>  1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c
> index 3caf53c6c082..298036c3e7f9 100644
> --- a/drivers/pci/controller/plda/pcie-starfive.c
> +++ b/drivers/pci/controller/plda/pcie-starfive.c
> @@ -55,7 +55,7 @@ struct starfive_jh7110_pcie {
>  	struct reset_control *resets;
>  	struct clk_bulk_data *clks;
>  	struct regmap *reg_syscon;
> -	struct gpio_desc *power_gpio;
> +	struct regulator *vpcie3v3;
>  	struct gpio_desc *reset_gpio;
>  	struct phy *phy;
>  
> @@ -153,11 +153,13 @@ static int starfive_pcie_parse_dt(struct starfive_jh7110_pcie *pcie,
>  		return dev_err_probe(dev, PTR_ERR(pcie->reset_gpio),
>  				     "failed to get perst-gpio\n");
>  
> -	pcie->power_gpio = devm_gpiod_get_optional(dev, "enable",
> -						   GPIOD_OUT_LOW);
> -	if (IS_ERR(pcie->power_gpio))
> -		return dev_err_probe(dev, PTR_ERR(pcie->power_gpio),
> -				     "failed to get power-gpio\n");
> +	pcie->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
> +	if (IS_ERR(pcie->vpcie3v3)) {
> +		if (PTR_ERR(pcie->vpcie3v3) != -ENODEV)
> +			return dev_err_probe(dev, PTR_ERR(pcie->vpcie3v3),
> +					     "failed to get vpcie3v3 regulator\n");
> +		pcie->vpcie3v3 = NULL;
> +	}
>  
>  	return 0;
>  }
> @@ -270,8 +272,8 @@ static void starfive_pcie_host_deinit(struct plda_pcie_rp *plda)
>  		container_of(plda, struct starfive_jh7110_pcie, plda);
>  
>  	starfive_pcie_clk_rst_deinit(pcie);
> -	if (pcie->power_gpio)
> -		gpiod_set_value_cansleep(pcie->power_gpio, 0);
> +	if (pcie->vpcie3v3)
> +		regulator_disable(pcie->vpcie3v3);
>  	starfive_pcie_disable_phy(pcie);
>  }
>  
> @@ -304,8 +306,11 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
>  	if (ret)
>  		return ret;
>  
> -	if (pcie->power_gpio)
> -		gpiod_set_value_cansleep(pcie->power_gpio, 1);
> +	if (pcie->vpcie3v3) {
> +		ret = regulator_enable(pcie->vpcie3v3);
> +		if (ret)
> +			dev_err_probe(dev, ret, "failed to enable vpcie3v3 regulator\n");
> +	}
>  
>  	if (pcie->reset_gpio)
>  		gpiod_set_value_cansleep(pcie->reset_gpio, 1);
> -- 
> 2.43.2
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <helgaas@kernel.org>
To: Hal Feng <hal.feng@starfivetech.com>
Cc: "Conor Dooley" <conor+dt@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Emil Renner Berthing" <emil.renner.berthing@canonical.com>,
	"Heinrich Schuchardt" <heinrich.schuchardt@canonical.com>,
	"E Shattow" <e@freeshell.de>,
	devicetree@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Kevin Xie" <kevin.xie@starfivetech.com>
Subject: Re: [PATCH v4 1/6] PCI: starfive: Use regulator APIs instead of GPIO APIs to enable the 3V3 power supply of PCIe slots
Date: Mon, 1 Dec 2025 14:52:36 -0600	[thread overview]
Message-ID: <20251201205236.GA3023515@bhelgaas> (raw)
In-Reply-To: <20251125075604.69370-2-hal.feng@starfivetech.com>

[+cc Kevin, pcie-starfive.c maintainer; will need his ack]

Subject line is excessively long.

On Tue, Nov 25, 2025 at 03:55:59PM +0800, Hal Feng wrote:
> The "enable-gpio" property is not documented in the dt-bindings and
> using GPIO APIs is not a standard method to enable or disable PCIe
> slot power, so use regulator APIs to replace them.

I can't tell from this whether existing DTs will continue to work
after this change.  It looks like previously we looked for an
"enable-gpios" or "enable-gpio" property and now we'll look for a
"vpcie3v3-supply" regulator property.

I don't see "enable-gpios" or "enable-gpio" mentioned in any of the DT
patches in this series, so maybe that property was never actually used
before, and the code for pcie->power_gpio was actually dead?

Please add something here about how we know this won't break any
existing setups using DTs that are already in the field.

> Tested-by: Matthias Brugger <mbrugger@suse.com>
> Fixes: 39b91eb40c6a ("PCI: starfive: Add JH7110 PCIe controller")

Based on the cover letter, it looks like the point of this is to add
support for a new device, which I don't think really qualifies as a
"fix".

> Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
> ---
>  drivers/pci/controller/plda/pcie-starfive.c | 25 ++++++++++++---------
>  1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c
> index 3caf53c6c082..298036c3e7f9 100644
> --- a/drivers/pci/controller/plda/pcie-starfive.c
> +++ b/drivers/pci/controller/plda/pcie-starfive.c
> @@ -55,7 +55,7 @@ struct starfive_jh7110_pcie {
>  	struct reset_control *resets;
>  	struct clk_bulk_data *clks;
>  	struct regmap *reg_syscon;
> -	struct gpio_desc *power_gpio;
> +	struct regulator *vpcie3v3;
>  	struct gpio_desc *reset_gpio;
>  	struct phy *phy;
>  
> @@ -153,11 +153,13 @@ static int starfive_pcie_parse_dt(struct starfive_jh7110_pcie *pcie,
>  		return dev_err_probe(dev, PTR_ERR(pcie->reset_gpio),
>  				     "failed to get perst-gpio\n");
>  
> -	pcie->power_gpio = devm_gpiod_get_optional(dev, "enable",
> -						   GPIOD_OUT_LOW);
> -	if (IS_ERR(pcie->power_gpio))
> -		return dev_err_probe(dev, PTR_ERR(pcie->power_gpio),
> -				     "failed to get power-gpio\n");
> +	pcie->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
> +	if (IS_ERR(pcie->vpcie3v3)) {
> +		if (PTR_ERR(pcie->vpcie3v3) != -ENODEV)
> +			return dev_err_probe(dev, PTR_ERR(pcie->vpcie3v3),
> +					     "failed to get vpcie3v3 regulator\n");
> +		pcie->vpcie3v3 = NULL;
> +	}
>  
>  	return 0;
>  }
> @@ -270,8 +272,8 @@ static void starfive_pcie_host_deinit(struct plda_pcie_rp *plda)
>  		container_of(plda, struct starfive_jh7110_pcie, plda);
>  
>  	starfive_pcie_clk_rst_deinit(pcie);
> -	if (pcie->power_gpio)
> -		gpiod_set_value_cansleep(pcie->power_gpio, 0);
> +	if (pcie->vpcie3v3)
> +		regulator_disable(pcie->vpcie3v3);
>  	starfive_pcie_disable_phy(pcie);
>  }
>  
> @@ -304,8 +306,11 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
>  	if (ret)
>  		return ret;
>  
> -	if (pcie->power_gpio)
> -		gpiod_set_value_cansleep(pcie->power_gpio, 1);
> +	if (pcie->vpcie3v3) {
> +		ret = regulator_enable(pcie->vpcie3v3);
> +		if (ret)
> +			dev_err_probe(dev, ret, "failed to enable vpcie3v3 regulator\n");
> +	}
>  
>  	if (pcie->reset_gpio)
>  		gpiod_set_value_cansleep(pcie->reset_gpio, 1);
> -- 
> 2.43.2
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2025-12-01 20:52 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25  7:55 [PATCH v4 0/6] Add support for StarFive VisionFive 2 Lite board Hal Feng
2025-11-25  7:55 ` Hal Feng
2025-11-25  7:55 ` [PATCH v4 1/6] PCI: starfive: Use regulator APIs instead of GPIO APIs to enable the 3V3 power supply of PCIe slots Hal Feng
2025-11-25  7:55   ` Hal Feng
2025-11-25 20:00   ` Conor Dooley
2025-11-25 20:00     ` Conor Dooley
2025-12-06 12:37     ` Matthias Brugger
2025-12-06 12:37       ` Matthias Brugger
2025-12-01  6:45   ` Hal Feng
2025-12-01  6:45     ` Hal Feng
2025-12-01 20:52   ` Bjorn Helgaas [this message]
2025-12-01 20:52     ` Bjorn Helgaas
2025-12-02  1:45     ` 回复: " Kevin Xie
2025-12-02  1:45       ` Kevin Xie
2025-12-02  3:02       ` Kevin Xie
2025-12-02  3:02         ` Kevin Xie
2025-12-02  3:16         ` Kevin Xie
2025-12-02  3:16           ` Kevin Xie
2025-12-02 16:31         ` Bjorn Helgaas
2025-12-02 16:31           ` Bjorn Helgaas
2025-12-04 13:19           ` Hal Feng
2025-12-04 13:19             ` Hal Feng
2025-12-02  3:38     ` Hal Feng
2025-12-02  3:38       ` Hal Feng
2025-11-25  7:56 ` [PATCH v4 2/6] dt-bindings: riscv: Add StarFive JH7110S SoC and VisionFive 2 Lite board Hal Feng
2025-11-25  7:56   ` Hal Feng
2025-11-25  7:56 ` [PATCH v4 3/6] riscv: dts: starfive: jh7110-common: Move out some nodes to the board dts Hal Feng
2025-11-25  7:56   ` Hal Feng
2025-11-25  7:56 ` [PATCH v4 4/6] riscv: dts: starfive: Add common board dtsi for VisionFive 2 Lite variants Hal Feng
2025-11-25  7:56   ` Hal Feng
2025-12-04 17:05   ` Anand Moon
2025-12-04 17:05     ` Anand Moon
2025-12-05  7:23     ` Maud Spierings
2025-12-05  7:23       ` Maud Spierings
2025-12-05  7:30       ` E Shattow
2025-12-05  7:30         ` E Shattow
2025-12-05  7:41     ` Hal Feng
2025-12-05  7:41       ` Hal Feng
2025-12-05  8:01       ` Anand Moon
2025-12-05  8:01         ` Anand Moon
2025-11-25  7:56 ` [PATCH v4 5/6] riscv: dts: starfive: Add VisionFive 2 Lite board device tree Hal Feng
2025-11-25  7:56   ` Hal Feng
2025-11-26  1:44   ` E Shattow
2025-11-26  1:44     ` E Shattow
2025-11-25  7:56 ` [PATCH v4 6/6] riscv: dts: starfive: Add VisionFive 2 Lite eMMC " Hal Feng
2025-11-25  7:56   ` Hal Feng
2025-11-26  1:45   ` E Shattow
2025-11-26  1:45     ` E Shattow
2025-11-25 22:24 ` (subset) [PATCH v4 0/6] Add support for StarFive VisionFive 2 Lite board Conor Dooley
2025-12-19  8:09 ` patchwork-bot+linux-riscv
2025-12-19  8:09   ` patchwork-bot+linux-riscv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251201205236.GA3023515@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=bhelgaas@google.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=e@freeshell.de \
    --cc=emil.renner.berthing@canonical.com \
    --cc=hal.feng@starfivetech.com \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=kevin.xie@starfivetech.com \
    --cc=krzk+dt@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.