All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc
@ 2021-09-14 12:31 Patrick Delaunay
  2021-09-14 12:31 ` [PATCH 2/2] phy: stm32-usbphyc: stm32: usbphyc: add protection on phy sub-node Patrick Delaunay
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Patrick Delaunay @ 2021-09-14 12:31 UTC (permalink / raw)
  To: u-boot; +Cc: Patrick Delaunay, Joe Hershberger, Patrice Chotard, uboot-stm32

The vbus-supply is an optional property of sub-node connector node.
and no more in the usb phyc node (in first proposed binding).

This regulator for USB VBUS may be needed for host mode.

See the latest kernel binding for details in
Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml.

  usbphyc_port0: usb-phy@0 {
      reg = <0>;
      phy-supply = <&vdd_usb>;
      #phy-cells = <0>;
      connector {
          compatible = "usb-a-connector";
          vbus-supply = <&vbus_sw>;
      };
  };

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 drivers/phy/phy-stm32-usbphyc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
index 02d859a039..c206efd28d 100644
--- a/drivers/phy/phy-stm32-usbphyc.c
+++ b/drivers/phy/phy-stm32-usbphyc.c
@@ -339,7 +339,7 @@ static int stm32_usbphyc_probe(struct udevice *dev)
 {
 	struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
 	struct reset_ctl reset;
-	ofnode node;
+	ofnode node, connector;
 	int i, ret;
 
 	usbphyc->base = dev_read_addr(dev);
@@ -395,10 +395,12 @@ static int stm32_usbphyc_probe(struct udevice *dev)
 			return ret;
 		}
 
-		ret = stm32_usbphyc_get_regulator(node, "vbus-supply",
-						  &usbphyc_phy->vbus);
-		if (ret)
-			usbphyc_phy->vbus = NULL;
+		usbphyc_phy->vbus = NULL;
+		connector = ofnode_find_subnode(node, "connector");
+		if (ofnode_valid(connector)) {
+			ret = stm32_usbphyc_get_regulator(connector, "vbus-supply",
+							  &usbphyc_phy->vbus);
+		}
 
 		node = dev_read_next_subnode(node);
 	}
-- 
2.25.1


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

* [PATCH 2/2] phy: stm32-usbphyc: stm32: usbphyc: add protection on phy sub-node
  2021-09-14 12:31 [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrick Delaunay
@ 2021-09-14 12:31 ` Patrick Delaunay
  2021-09-15  8:36   ` Patrice CHOTARD
  2021-09-15  8:35 ` [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrice CHOTARD
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Patrick Delaunay @ 2021-09-14 12:31 UTC (permalink / raw)
  To: u-boot; +Cc: Patrick Delaunay, Joe Hershberger, Patrice Chotard, U-Boot STM32

Add protection on presence and order of the phy node sub node
by using the mandatory reg information.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 drivers/phy/phy-stm32-usbphyc.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
index c206efd28d..9c1dcfae52 100644
--- a/drivers/phy/phy-stm32-usbphyc.c
+++ b/drivers/phy/phy-stm32-usbphyc.c
@@ -340,7 +340,7 @@ static int stm32_usbphyc_probe(struct udevice *dev)
 	struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
 	struct reset_ctl reset;
 	ofnode node, connector;
-	int i, ret;
+	int ret;
 
 	usbphyc->base = dev_read_addr(dev);
 	if (usbphyc->base == FDT_ADDR_T_NONE)
@@ -378,14 +378,18 @@ static int stm32_usbphyc_probe(struct udevice *dev)
 		return ret;
 	}
 
-	/*
-	 * parse all PHY subnodes in order to populate regulator associated
-	 * to each PHY port
-	 */
-	node = dev_read_first_subnode(dev);
-	for (i = 0; i < MAX_PHYS; i++) {
-		struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + i;
+	/* parse all PHY subnodes to populate regulator associated to each PHY port */
+	dev_for_each_subnode(node, dev) {
+		fdt_addr_t phy_id;
+		struct stm32_usbphyc_phy *usbphyc_phy;
 
+		phy_id = ofnode_read_u32_default(node, "reg", FDT_ADDR_T_NONE);
+		if (phy_id >= MAX_PHYS) {
+			dev_err(dev, "invalid reg value %lx for %s\n",
+				phy_id, ofnode_get_name(node));
+			return -ENOENT;
+		}
+		usbphyc_phy = usbphyc->phys + phy_id;
 		usbphyc_phy->init = false;
 		usbphyc_phy->powered = false;
 		ret = stm32_usbphyc_get_regulator(node, "phy-supply",
@@ -401,8 +405,6 @@ static int stm32_usbphyc_probe(struct udevice *dev)
 			ret = stm32_usbphyc_get_regulator(connector, "vbus-supply",
 							  &usbphyc_phy->vbus);
 		}
-
-		node = dev_read_next_subnode(node);
 	}
 
 	/* Check if second port has to be used for host controller */
-- 
2.25.1


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

* Re: [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc
  2021-09-14 12:31 [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrick Delaunay
  2021-09-14 12:31 ` [PATCH 2/2] phy: stm32-usbphyc: stm32: usbphyc: add protection on phy sub-node Patrick Delaunay
@ 2021-09-15  8:35 ` Patrice CHOTARD
  2021-10-08  6:21 ` Patrice CHOTARD
  2021-10-08  6:21 ` Patrice CHOTARD
  3 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2021-09-15  8:35 UTC (permalink / raw)
  To: Patrick Delaunay, u-boot; +Cc: Joe Hershberger, uboot-stm32

Hi Patrick

On 9/14/21 2:31 PM, Patrick Delaunay wrote:
> The vbus-supply is an optional property of sub-node connector node.
> and no more in the usb phyc node (in first proposed binding).
> 
> This regulator for USB VBUS may be needed for host mode.
> 
> See the latest kernel binding for details in
> Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml.
> 
>   usbphyc_port0: usb-phy@0 {
>       reg = <0>;
>       phy-supply = <&vdd_usb>;
>       #phy-cells = <0>;
>       connector {
>           compatible = "usb-a-connector";
>           vbus-supply = <&vbus_sw>;
>       };
>   };
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  drivers/phy/phy-stm32-usbphyc.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
> index 02d859a039..c206efd28d 100644
> --- a/drivers/phy/phy-stm32-usbphyc.c
> +++ b/drivers/phy/phy-stm32-usbphyc.c
> @@ -339,7 +339,7 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  {
>  	struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
>  	struct reset_ctl reset;
> -	ofnode node;
> +	ofnode node, connector;
>  	int i, ret;
>  
>  	usbphyc->base = dev_read_addr(dev);
> @@ -395,10 +395,12 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  			return ret;
>  		}
>  
> -		ret = stm32_usbphyc_get_regulator(node, "vbus-supply",
> -						  &usbphyc_phy->vbus);
> -		if (ret)
> -			usbphyc_phy->vbus = NULL;
> +		usbphyc_phy->vbus = NULL;
> +		connector = ofnode_find_subnode(node, "connector");
> +		if (ofnode_valid(connector)) {
> +			ret = stm32_usbphyc_get_regulator(connector, "vbus-supply",
> +							  &usbphyc_phy->vbus);
> +		}
>  
>  		node = dev_read_next_subnode(node);
>  	}
> 
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice

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

* Re: [PATCH 2/2] phy: stm32-usbphyc: stm32: usbphyc: add protection on phy sub-node
  2021-09-14 12:31 ` [PATCH 2/2] phy: stm32-usbphyc: stm32: usbphyc: add protection on phy sub-node Patrick Delaunay
@ 2021-09-15  8:36   ` Patrice CHOTARD
  0 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2021-09-15  8:36 UTC (permalink / raw)
  To: Patrick Delaunay, u-boot; +Cc: Joe Hershberger, U-Boot STM32

HI Patrick

On 9/14/21 2:31 PM, Patrick Delaunay wrote:
> Add protection on presence and order of the phy node sub node
> by using the mandatory reg information.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  drivers/phy/phy-stm32-usbphyc.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
> index c206efd28d..9c1dcfae52 100644
> --- a/drivers/phy/phy-stm32-usbphyc.c
> +++ b/drivers/phy/phy-stm32-usbphyc.c
> @@ -340,7 +340,7 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  	struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
>  	struct reset_ctl reset;
>  	ofnode node, connector;
> -	int i, ret;
> +	int ret;
>  
>  	usbphyc->base = dev_read_addr(dev);
>  	if (usbphyc->base == FDT_ADDR_T_NONE)
> @@ -378,14 +378,18 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  		return ret;
>  	}
>  
> -	/*
> -	 * parse all PHY subnodes in order to populate regulator associated
> -	 * to each PHY port
> -	 */
> -	node = dev_read_first_subnode(dev);
> -	for (i = 0; i < MAX_PHYS; i++) {
> -		struct stm32_usbphyc_phy *usbphyc_phy = usbphyc->phys + i;
> +	/* parse all PHY subnodes to populate regulator associated to each PHY port */
> +	dev_for_each_subnode(node, dev) {
> +		fdt_addr_t phy_id;
> +		struct stm32_usbphyc_phy *usbphyc_phy;
>  
> +		phy_id = ofnode_read_u32_default(node, "reg", FDT_ADDR_T_NONE);
> +		if (phy_id >= MAX_PHYS) {
> +			dev_err(dev, "invalid reg value %lx for %s\n",
> +				phy_id, ofnode_get_name(node));
> +			return -ENOENT;
> +		}
> +		usbphyc_phy = usbphyc->phys + phy_id;
>  		usbphyc_phy->init = false;
>  		usbphyc_phy->powered = false;
>  		ret = stm32_usbphyc_get_regulator(node, "phy-supply",
> @@ -401,8 +405,6 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  			ret = stm32_usbphyc_get_regulator(connector, "vbus-supply",
>  							  &usbphyc_phy->vbus);
>  		}
> -
> -		node = dev_read_next_subnode(node);
>  	}
>  
>  	/* Check if second port has to be used for host controller */
> 
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice

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

* Re: [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc
  2021-09-14 12:31 [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrick Delaunay
  2021-09-14 12:31 ` [PATCH 2/2] phy: stm32-usbphyc: stm32: usbphyc: add protection on phy sub-node Patrick Delaunay
  2021-09-15  8:35 ` [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrice CHOTARD
@ 2021-10-08  6:21 ` Patrice CHOTARD
  2021-10-08  6:21 ` Patrice CHOTARD
  3 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2021-10-08  6:21 UTC (permalink / raw)
  To: Patrick Delaunay, u-boot; +Cc: Joe Hershberger, uboot-stm32

Hi Patrick

On 9/14/21 2:31 PM, Patrick Delaunay wrote:
> The vbus-supply is an optional property of sub-node connector node.
> and no more in the usb phyc node (in first proposed binding).
> 
> This regulator for USB VBUS may be needed for host mode.
> 
> See the latest kernel binding for details in
> Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml.
> 
>   usbphyc_port0: usb-phy@0 {
>       reg = <0>;
>       phy-supply = <&vdd_usb>;
>       #phy-cells = <0>;
>       connector {
>           compatible = "usb-a-connector";
>           vbus-supply = <&vbus_sw>;
>       };
>   };
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  drivers/phy/phy-stm32-usbphyc.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
> index 02d859a039..c206efd28d 100644
> --- a/drivers/phy/phy-stm32-usbphyc.c
> +++ b/drivers/phy/phy-stm32-usbphyc.c
> @@ -339,7 +339,7 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  {
>  	struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
>  	struct reset_ctl reset;
> -	ofnode node;
> +	ofnode node, connector;
>  	int i, ret;
>  
>  	usbphyc->base = dev_read_addr(dev);
> @@ -395,10 +395,12 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  			return ret;
>  		}
>  
> -		ret = stm32_usbphyc_get_regulator(node, "vbus-supply",
> -						  &usbphyc_phy->vbus);
> -		if (ret)
> -			usbphyc_phy->vbus = NULL;
> +		usbphyc_phy->vbus = NULL;
> +		connector = ofnode_find_subnode(node, "connector");
> +		if (ofnode_valid(connector)) {
> +			ret = stm32_usbphyc_get_regulator(connector, "vbus-supply",
> +							  &usbphyc_phy->vbus);
> +		}
>  
>  		node = dev_read_next_subnode(node);
>  	}
> 

Applied on u-boot-stm32 for next

Thanks
Patrice

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

* Re: [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc
  2021-09-14 12:31 [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrick Delaunay
                   ` (2 preceding siblings ...)
  2021-10-08  6:21 ` Patrice CHOTARD
@ 2021-10-08  6:21 ` Patrice CHOTARD
  3 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2021-10-08  6:21 UTC (permalink / raw)
  To: Patrick Delaunay, u-boot; +Cc: Joe Hershberger, uboot-stm32

Hi Patrick

On 9/14/21 2:31 PM, Patrick Delaunay wrote:
> The vbus-supply is an optional property of sub-node connector node.
> and no more in the usb phyc node (in first proposed binding).
> 
> This regulator for USB VBUS may be needed for host mode.
> 
> See the latest kernel binding for details in
> Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml.
> 
>   usbphyc_port0: usb-phy@0 {
>       reg = <0>;
>       phy-supply = <&vdd_usb>;
>       #phy-cells = <0>;
>       connector {
>           compatible = "usb-a-connector";
>           vbus-supply = <&vbus_sw>;
>       };
>   };
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  drivers/phy/phy-stm32-usbphyc.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
> index 02d859a039..c206efd28d 100644
> --- a/drivers/phy/phy-stm32-usbphyc.c
> +++ b/drivers/phy/phy-stm32-usbphyc.c
> @@ -339,7 +339,7 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  {
>  	struct stm32_usbphyc *usbphyc = dev_get_priv(dev);
>  	struct reset_ctl reset;
> -	ofnode node;
> +	ofnode node, connector;
>  	int i, ret;
>  
>  	usbphyc->base = dev_read_addr(dev);
> @@ -395,10 +395,12 @@ static int stm32_usbphyc_probe(struct udevice *dev)
>  			return ret;
>  		}
>  
> -		ret = stm32_usbphyc_get_regulator(node, "vbus-supply",
> -						  &usbphyc_phy->vbus);
> -		if (ret)
> -			usbphyc_phy->vbus = NULL;
> +		usbphyc_phy->vbus = NULL;
> +		connector = ofnode_find_subnode(node, "connector");
> +		if (ofnode_valid(connector)) {
> +			ret = stm32_usbphyc_get_regulator(connector, "vbus-supply",
> +							  &usbphyc_phy->vbus);
> +		}
>  
>  		node = dev_read_next_subnode(node);
>  	}
> 

Applied on u-boot-stm32 for next

Thanks
Patrice

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

end of thread, other threads:[~2021-10-08  6:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 12:31 [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrick Delaunay
2021-09-14 12:31 ` [PATCH 2/2] phy: stm32-usbphyc: stm32: usbphyc: add protection on phy sub-node Patrick Delaunay
2021-09-15  8:36   ` Patrice CHOTARD
2021-09-15  8:35 ` [PATCH 1/2] phy: stm32-usbphyc: use connector for vbus-supply with phy-stm32-usbphyc Patrice CHOTARD
2021-10-08  6:21 ` Patrice CHOTARD
2021-10-08  6:21 ` Patrice CHOTARD

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.