All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci: Make Rockchip PCIe voltage regulators optional
@ 2020-05-24 20:32 Mark Kettenis
  2020-05-25  2:56 ` Kever Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mark Kettenis @ 2020-05-24 20:32 UTC (permalink / raw)
  To: u-boot

The vpcie*-supply properties are optional and these are absent on
boards like the ROCKPro64 and Firefly RK3399 where the voltage is
supplied by always-on regulators that are already enabled upon
boot.  Make these regulators optional and properly check their
presence before attempting to enable them.

Makes PCIe work on un U-Boot on the boards mentioned above.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
---
 drivers/pci/pcie_rockchip.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c
index 82a8396e42..0edc2464a8 100644
--- a/drivers/pci/pcie_rockchip.c
+++ b/drivers/pci/pcie_rockchip.c
@@ -322,7 +322,7 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev)
 	struct rockchip_pcie *priv = dev_get_priv(dev);
 	int ret;
 
-	if (!IS_ERR(priv->vpcie3v3)) {
+	if (priv->vpcie3v3) {
 		ret = regulator_set_enable(priv->vpcie3v3, true);
 		if (ret) {
 			dev_err(dev, "failed to enable vpcie3v3 (ret=%d)\n",
@@ -331,24 +331,31 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev)
 		}
 	}
 
-	ret = regulator_set_enable(priv->vpcie1v8, true);
-	if (ret) {
-		dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n", ret);
-		goto err_disable_3v3;
+	if (priv->vpcie1v8) {
+		ret = regulator_set_enable(priv->vpcie1v8, true);
+		if (ret) {
+			dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n",
+				ret);
+			goto err_disable_3v3;
+		}
 	}
 
-	ret = regulator_set_enable(priv->vpcie0v9, true);
-	if (ret) {
-		dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n", ret);
-		goto err_disable_1v8;
+	if (priv->vpcie0v9) {
+		ret = regulator_set_enable(priv->vpcie0v9, true);
+		if (ret) {
+			dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n",
+				ret);
+			goto err_disable_1v8;
+		}
 	}
 
 	return 0;
 
 err_disable_1v8:
-	regulator_set_enable(priv->vpcie1v8, false);
+	if (priv->vpcie1v8)
+		regulator_set_enable(priv->vpcie1v8, false);
 err_disable_3v3:
-	if (!IS_ERR(priv->vpcie3v3))
+	if (priv->vpcie3v3)
 		regulator_set_enable(priv->vpcie3v3, false);
 	return ret;
 }
@@ -424,14 +431,14 @@ static int rockchip_pcie_parse_dt(struct udevice *dev)
 
 	ret = device_get_supply_regulator(dev, "vpcie1v8-supply",
 					  &priv->vpcie1v8);
-	if (ret) {
+	if (ret && ret != -ENOENT) {
 		dev_err(dev, "failed to get vpcie1v8 supply (ret=%d)\n", ret);
 		return ret;
 	}
 
 	ret = device_get_supply_regulator(dev, "vpcie0v9-supply",
 					  &priv->vpcie0v9);
-	if (ret) {
+	if (ret && ret != -ENOENT) {
 		dev_err(dev, "failed to get vpcie0v9 supply (ret=%d)\n", ret);
 		return ret;
 	}
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] pci: Make Rockchip PCIe voltage regulators optional
  2020-05-24 20:32 [PATCH] pci: Make Rockchip PCIe voltage regulators optional Mark Kettenis
@ 2020-05-25  2:56 ` Kever Yang
  2020-06-01  0:56   ` Kever Yang
  2020-05-25  9:10 ` Marcin Juszkiewicz
  2020-05-28 18:43 ` Kurt Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Kever Yang @ 2020-05-25  2:56 UTC (permalink / raw)
  To: u-boot


On 2020/5/25 ??4:32, Mark Kettenis wrote:
> The vpcie*-supply properties are optional and these are absent on
> boards like the ROCKPro64 and Firefly RK3399 where the voltage is
> supplied by always-on regulators that are already enabled upon
> boot.  Make these regulators optional and properly check their
> presence before attempting to enable them.
>
> Makes PCIe work on un U-Boot on the boards mentioned above.
>
> Signed-off-by: Mark Kettenis <kettenis@openbsd.org>

Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/pci/pcie_rockchip.c | 33 ++++++++++++++++++++-------------
>   1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c
> index 82a8396e42..0edc2464a8 100644
> --- a/drivers/pci/pcie_rockchip.c
> +++ b/drivers/pci/pcie_rockchip.c
> @@ -322,7 +322,7 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev)
>   	struct rockchip_pcie *priv = dev_get_priv(dev);
>   	int ret;
>   
> -	if (!IS_ERR(priv->vpcie3v3)) {
> +	if (priv->vpcie3v3) {
>   		ret = regulator_set_enable(priv->vpcie3v3, true);
>   		if (ret) {
>   			dev_err(dev, "failed to enable vpcie3v3 (ret=%d)\n",
> @@ -331,24 +331,31 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev)
>   		}
>   	}
>   
> -	ret = regulator_set_enable(priv->vpcie1v8, true);
> -	if (ret) {
> -		dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n", ret);
> -		goto err_disable_3v3;
> +	if (priv->vpcie1v8) {
> +		ret = regulator_set_enable(priv->vpcie1v8, true);
> +		if (ret) {
> +			dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n",
> +				ret);
> +			goto err_disable_3v3;
> +		}
>   	}
>   
> -	ret = regulator_set_enable(priv->vpcie0v9, true);
> -	if (ret) {
> -		dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n", ret);
> -		goto err_disable_1v8;
> +	if (priv->vpcie0v9) {
> +		ret = regulator_set_enable(priv->vpcie0v9, true);
> +		if (ret) {
> +			dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n",
> +				ret);
> +			goto err_disable_1v8;
> +		}
>   	}
>   
>   	return 0;
>   
>   err_disable_1v8:
> -	regulator_set_enable(priv->vpcie1v8, false);
> +	if (priv->vpcie1v8)
> +		regulator_set_enable(priv->vpcie1v8, false);
>   err_disable_3v3:
> -	if (!IS_ERR(priv->vpcie3v3))
> +	if (priv->vpcie3v3)
>   		regulator_set_enable(priv->vpcie3v3, false);
>   	return ret;
>   }
> @@ -424,14 +431,14 @@ static int rockchip_pcie_parse_dt(struct udevice *dev)
>   
>   	ret = device_get_supply_regulator(dev, "vpcie1v8-supply",
>   					  &priv->vpcie1v8);
> -	if (ret) {
> +	if (ret && ret != -ENOENT) {
>   		dev_err(dev, "failed to get vpcie1v8 supply (ret=%d)\n", ret);
>   		return ret;
>   	}
>   
>   	ret = device_get_supply_regulator(dev, "vpcie0v9-supply",
>   					  &priv->vpcie0v9);
> -	if (ret) {
> +	if (ret && ret != -ENOENT) {
>   		dev_err(dev, "failed to get vpcie0v9 supply (ret=%d)\n", ret);
>   		return ret;
>   	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] pci: Make Rockchip PCIe voltage regulators optional
  2020-05-24 20:32 [PATCH] pci: Make Rockchip PCIe voltage regulators optional Mark Kettenis
  2020-05-25  2:56 ` Kever Yang
@ 2020-05-25  9:10 ` Marcin Juszkiewicz
  2020-05-28 18:43 ` Kurt Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Marcin Juszkiewicz @ 2020-05-25  9:10 UTC (permalink / raw)
  To: u-boot

W dniu 24.05.2020 o?22:32, Mark Kettenis pisze:
> The vpcie*-supply properties are optional and these are absent on
> boards like the ROCKPro64 and Firefly RK3399 where the voltage is
> supplied by always-on regulators that are already enabled upon
> boot.  Make these regulators optional and properly check their
> presence before attempting to enable them.
> 
> Makes PCIe work on un U-Boot on the boards mentioned above.
> 
> Signed-off-by: Mark Kettenis <kettenis@openbsd.org>

Tested-by: Marcin Juszkiewicz <marcin@juszkiewicz.com.pl>

Model: Pine64 RockPro64 v2.1

=> pci enum
=> pci
Scanning PCI devices on bus 0
BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
_____________________________________________________________
00.00.00   0x1d87     0x0100     Bridge device           0x04
=> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] pci: Make Rockchip PCIe voltage regulators optional
  2020-05-24 20:32 [PATCH] pci: Make Rockchip PCIe voltage regulators optional Mark Kettenis
  2020-05-25  2:56 ` Kever Yang
  2020-05-25  9:10 ` Marcin Juszkiewicz
@ 2020-05-28 18:43 ` Kurt Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Kurt Miller @ 2020-05-28 18:43 UTC (permalink / raw)
  To: u-boot

On Sun, 2020-05-24 at 22:32 +0200, Mark Kettenis wrote:
> The vpcie*-supply properties are optional and these are absent on
> boards like the ROCKPro64 and Firefly RK3399 where the voltage is
> supplied by always-on regulators that are already enabled upon
> boot.??Make these regulators optional and properly check their
> presence before attempting to enable them.
> 
> Makes PCIe work on un U-Boot on the boards mentioned above.
> 
> Signed-off-by: Mark Kettenis <kettenis@openbsd.org>

Tested by: Kurt Miller <kurt@intricatesoftware.com>

Model: Pine64 RockPro64 v2.1

=> pci
Scanning PCI devices on bus 0
BusDevFun??VendorId???DeviceId???Device Class???????Sub-Class
_____________________________________________________________
00.00.00???0x1d87?????0x0100?????Bridge device???????????0x04
=> pci 1
Scanning PCI devices on bus 1
BusDevFun??VendorId???DeviceId???Device Class???????Sub-Class
_____________________________________________________________
01.00.00???0x1b4b?????0x9128?????Mass storage controller 0x06

> ---
> ?drivers/pci/pcie_rockchip.c | 33 ++++++++++++++++++++-------------
> ?1 file changed, 20 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c
> index 82a8396e42..0edc2464a8 100644
> --- a/drivers/pci/pcie_rockchip.c
> +++ b/drivers/pci/pcie_rockchip.c
> @@ -322,7 +322,7 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev)
> ?	struct rockchip_pcie *priv = dev_get_priv(dev);
> ?	int ret;
> ?
> -	if (!IS_ERR(priv->vpcie3v3)) {
> +	if (priv->vpcie3v3) {
> ?		ret = regulator_set_enable(priv->vpcie3v3, true);
> ?		if (ret) {
> ?			dev_err(dev, "failed to enable vpcie3v3 (ret=%d)\n",
> @@ -331,24 +331,31 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev)
> ?		}
> ?	}
> ?
> -	ret = regulator_set_enable(priv->vpcie1v8, true);
> -	if (ret) {
> -		dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n", ret);
> -		goto err_disable_3v3;
> +	if (priv->vpcie1v8) {
> +		ret = regulator_set_enable(priv->vpcie1v8, true);
> +		if (ret) {
> +			dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n",
> +				ret);
> +			goto err_disable_3v3;
> +		}
> ?	}
> ?
> -	ret = regulator_set_enable(priv->vpcie0v9, true);
> -	if (ret) {
> -		dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n", ret);
> -		goto err_disable_1v8;
> +	if (priv->vpcie0v9) {
> +		ret = regulator_set_enable(priv->vpcie0v9, true);
> +		if (ret) {
> +			dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n",
> +				ret);
> +			goto err_disable_1v8;
> +		}
> ?	}
> ?
> ?	return 0;
> ?
> ?err_disable_1v8:
> -	regulator_set_enable(priv->vpcie1v8, false);
> +	if (priv->vpcie1v8)
> +		regulator_set_enable(priv->vpcie1v8, false);
> ?err_disable_3v3:
> -	if (!IS_ERR(priv->vpcie3v3))
> +	if (priv->vpcie3v3)
> ?		regulator_set_enable(priv->vpcie3v3, false);
> ?	return ret;
> ?}
> @@ -424,14 +431,14 @@ static int rockchip_pcie_parse_dt(struct udevice *dev)
> ?
> ?	ret = device_get_supply_regulator(dev, "vpcie1v8-supply",
> ?					??&priv->vpcie1v8);
> -	if (ret) {
> +	if (ret && ret != -ENOENT) {
> ?		dev_err(dev, "failed to get vpcie1v8 supply (ret=%d)\n", ret);
> ?		return ret;
> ?	}
> ?
> ?	ret = device_get_supply_regulator(dev, "vpcie0v9-supply",
> ?					??&priv->vpcie0v9);
> -	if (ret) {
> +	if (ret && ret != -ENOENT) {
> ?		dev_err(dev, "failed to get vpcie0v9 supply (ret=%d)\n", ret);
> ?		return ret;
> ?	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] pci: Make Rockchip PCIe voltage regulators optional
  2020-05-25  2:56 ` Kever Yang
@ 2020-06-01  0:56   ` Kever Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Kever Yang @ 2020-06-01  0:56 UTC (permalink / raw)
  To: u-boot


On 2020/5/25 ??10:56, Kever Yang wrote:
>
> On 2020/5/25 ??4:32, Mark Kettenis wrote:
>> The vpcie*-supply properties are optional and these are absent on
>> boards like the ROCKPro64 and Firefly RK3399 where the voltage is
>> supplied by always-on regulators that are already enabled upon
>> boot.? Make these regulators optional and properly check their
>> presence before attempting to enable them.
>>
>> Makes PCIe work on un U-Boot on the boards mentioned above.
>>
>> Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
>
> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Applied to u-boot-rockchip master.

Thanks,
- Kever

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-01  0:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-24 20:32 [PATCH] pci: Make Rockchip PCIe voltage regulators optional Mark Kettenis
2020-05-25  2:56 ` Kever Yang
2020-06-01  0:56   ` Kever Yang
2020-05-25  9:10 ` Marcin Juszkiewicz
2020-05-28 18:43 ` Kurt Miller

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.