diff mbox

[v1,1/3] phy: phy-core: allow specifying supply at port level

Message ID 1426886727-537-2-git-send-email-arun.ramamurthy@broadcom.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arun Ramamurthy March 20, 2015, 9:25 p.m. UTC
Multi-port phy's may have per-port power supplies. Let's change phy core
to first attempt to look up the supply at the port level, and then, if
not found, check parent device.

Reviewed-by: Ray Jui <rjui@broadcom.com>
Reviewed-by: Scott Branden <sbranden@broadcom.com>
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Arun Ramamurthy <arun.ramamurthy@broadcom.com>
---
 drivers/phy/phy-core.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

Comments

Dmitry Torokhov March 20, 2015, 9:31 p.m. UTC | #1
Hi Arun,

On Fri, Mar 20, 2015 at 02:25:25PM -0700, Arun Ramamurthy wrote:
> Multi-port phy's may have per-port power supplies. Let's change phy core
> to first attempt to look up the supply at the port level, and then, if
> not found, check parent device.
> 
> Reviewed-by: Ray Jui <rjui@broadcom.com>
> Reviewed-by: Scott Branden <sbranden@broadcom.com>
> Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
> Signed-off-by: Arun Ramamurthy <arun.ramamurthy@broadcom.com>
>

This should have had:

From: Dmitry Torokhov <dtor@chromium.org>

as first line of the body of e-mail as the patch was authored by me.

Thanks.

 ---
>  drivers/phy/phy-core.c | 30 ++++++++++++++++++++----------
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index a12d353..b43bb6b 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -650,16 +650,6 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
>  		goto free_phy;
>  	}
>  
> -	/* phy-supply */
> -	phy->pwr = regulator_get_optional(dev, "phy");
> -	if (IS_ERR(phy->pwr)) {
> -		if (PTR_ERR(phy->pwr) == -EPROBE_DEFER) {
> -			ret = -EPROBE_DEFER;
> -			goto free_ida;
> -		}
> -		phy->pwr = NULL;
> -	}
> -
>  	device_initialize(&phy->dev);
>  	mutex_init(&phy->mutex);
>  
> @@ -673,6 +663,26 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
>  	if (ret)
>  		goto put_dev;
>  
> +	/*
> +	 * Locate phy-supply. We first try individual port and then,
> +	 * if supply is not found, try parent device.
> +	 */
> +	phy->pwr = regulator_get_optional(&phy->dev, "phy");
> +	if (IS_ERR(phy->pwr)) {
> +		ret = PTR_ERR(phy->pwr);
> +		if (ret == -EPROBE_DEFER)
> +			goto free_ida;
> +
> +		phy->pwr = regulator_get_optional(phy->dev.parent, "phy");
> +		if (IS_ERR(phy->pwr)) {
> +			ret = PTR_ERR(phy->pwr);
> +			if (ret == -EPROBE_DEFER)
> +				goto free_ida;
> +
> +			phy->pwr = NULL;
> +		}
> +	}
> +
>  	ret = device_add(&phy->dev);
>  	if (ret)
>  		goto put_dev;
> -- 
> 2.3.2
>
Kishon Vijay Abraham I March 25, 2015, 10:11 p.m. UTC | #2
Hi,

On Saturday 21 March 2015 02:55 AM, Arun Ramamurthy wrote:
> Multi-port phy's may have per-port power supplies. Let's change phy core
> to first attempt to look up the supply at the port level, and then, if
> not found, check parent device.

Why not just have every port provide the power supply if it needs?
I don't think checking for parent device should be present in the phy-core at
all.

Thanks
Kishon
Dmitry Torokhov March 25, 2015, 10:17 p.m. UTC | #3
On Wed, Mar 25, 2015 at 3:11 PM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> Hi,
>
> On Saturday 21 March 2015 02:55 AM, Arun Ramamurthy wrote:
>> Multi-port phy's may have per-port power supplies. Let's change phy core
>> to first attempt to look up the supply at the port level, and then, if
>> not found, check parent device.
>
> Why not just have every port provide the power supply if it needs?
> I don't think checking for parent device should be present in the phy-core at
> all.

We need to do that if we want to keep compatibility with the current
DTSes: before this patch the supply would be always looked up on
device and not port level.

Thanks,
Dmitry
Kishon Vijay Abraham I March 25, 2015, 10:39 p.m. UTC | #4
Hi,

On Thursday 26 March 2015 03:47 AM, Dmitry Torokhov wrote:
> On Wed, Mar 25, 2015 at 3:11 PM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
>> Hi,
>>
>> On Saturday 21 March 2015 02:55 AM, Arun Ramamurthy wrote:
>>> Multi-port phy's may have per-port power supplies. Let's change phy core
>>> to first attempt to look up the supply at the port level, and then, if
>>> not found, check parent device.
>>
>> Why not just have every port provide the power supply if it needs?
>> I don't think checking for parent device should be present in the phy-core at
>> all.
> 
> We need to do that if we want to keep compatibility with the current
> DTSes: before this patch the supply would be always looked up on
> device and not port level.

ah okay.
so just using regulator_get_optional(&phy->dev, "phy"); should be sufficient
right? Why do we need regulator_get_optional(phy->dev.parent, "phy");?

Thanks
Kishon
Dmitry Torokhov March 25, 2015, 10:49 p.m. UTC | #5
On Thu, Mar 26, 2015 at 04:09:23AM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Thursday 26 March 2015 03:47 AM, Dmitry Torokhov wrote:
> > On Wed, Mar 25, 2015 at 3:11 PM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> >> Hi,
> >>
> >> On Saturday 21 March 2015 02:55 AM, Arun Ramamurthy wrote:
> >>> Multi-port phy's may have per-port power supplies. Let's change phy core
> >>> to first attempt to look up the supply at the port level, and then, if
> >>> not found, check parent device.
> >>
> >> Why not just have every port provide the power supply if it needs?
> >> I don't think checking for parent device should be present in the phy-core at
> >> all.
> > 
> > We need to do that if we want to keep compatibility with the current
> > DTSes: before this patch the supply would be always looked up on
> > device and not port level.
> 
> ah okay.
> so just using regulator_get_optional(&phy->dev, "phy"); should be sufficient

This is for regulators specified at port level (&phy->dev represents
port).

> right? Why do we need regulator_get_optional(phy->dev.parent, "phy");?
> 

This is for compatibility with old multi-port bindings where supply is
specified at parent device level and phy_create() is called with dev and
node that is not NULL and not the same as dev->of_node. I have no idea
if such bindings exist in wild, but wanted to keep them working given
stated DT stability rules.

Thanks.
Kishon Vijay Abraham I March 25, 2015, 11:44 p.m. UTC | #6
Hi,

On Thursday 26 March 2015 04:19 AM, Dmitry Torokhov wrote:
> On Thu, Mar 26, 2015 at 04:09:23AM +0530, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Thursday 26 March 2015 03:47 AM, Dmitry Torokhov wrote:
>>> On Wed, Mar 25, 2015 at 3:11 PM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
>>>> Hi,
>>>>
>>>> On Saturday 21 March 2015 02:55 AM, Arun Ramamurthy wrote:
>>>>> Multi-port phy's may have per-port power supplies. Let's change phy core
>>>>> to first attempt to look up the supply at the port level, and then, if
>>>>> not found, check parent device.
>>>>
>>>> Why not just have every port provide the power supply if it needs?
>>>> I don't think checking for parent device should be present in the phy-core at
>>>> all.
>>>
>>> We need to do that if we want to keep compatibility with the current
>>> DTSes: before this patch the supply would be always looked up on
>>> device and not port level.
>>
>> ah okay.
>> so just using regulator_get_optional(&phy->dev, "phy"); should be sufficient
> 
> This is for regulators specified at port level (&phy->dev represents
> port).
> 
>> right? Why do we need regulator_get_optional(phy->dev.parent, "phy");?
>>
> 
> This is for compatibility with old multi-port bindings where supply is
> specified at parent device level and phy_create() is called with dev and
> node that is not NULL and not the same as dev->of_node. I have no idea
> if such bindings exist in wild, but wanted to keep them working given
> stated DT stability rules.

Such a binding doesn't exist. So let's keep only the
regulator_get_optional(&phy->dev, "phy"); part. Only TI SoCs and recently
sun9i started using phy-supply and none of them use multi-phy PHY provider.

Thanks
Kishon
Dmitry Torokhov March 25, 2015, 11:48 p.m. UTC | #7
On Thu, Mar 26, 2015 at 05:14:07AM +0530, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Thursday 26 March 2015 04:19 AM, Dmitry Torokhov wrote:
> > On Thu, Mar 26, 2015 at 04:09:23AM +0530, Kishon Vijay Abraham I wrote:
> >> Hi,
> >>
> >> On Thursday 26 March 2015 03:47 AM, Dmitry Torokhov wrote:
> >>> On Wed, Mar 25, 2015 at 3:11 PM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> >>>> Hi,
> >>>>
> >>>> On Saturday 21 March 2015 02:55 AM, Arun Ramamurthy wrote:
> >>>>> Multi-port phy's may have per-port power supplies. Let's change phy core
> >>>>> to first attempt to look up the supply at the port level, and then, if
> >>>>> not found, check parent device.
> >>>>
> >>>> Why not just have every port provide the power supply if it needs?
> >>>> I don't think checking for parent device should be present in the phy-core at
> >>>> all.
> >>>
> >>> We need to do that if we want to keep compatibility with the current
> >>> DTSes: before this patch the supply would be always looked up on
> >>> device and not port level.
> >>
> >> ah okay.
> >> so just using regulator_get_optional(&phy->dev, "phy"); should be sufficient
> > 
> > This is for regulators specified at port level (&phy->dev represents
> > port).
> > 
> >> right? Why do we need regulator_get_optional(phy->dev.parent, "phy");?
> >>
> > 
> > This is for compatibility with old multi-port bindings where supply is
> > specified at parent device level and phy_create() is called with dev and
> > node that is not NULL and not the same as dev->of_node. I have no idea
> > if such bindings exist in wild, but wanted to keep them working given
> > stated DT stability rules.
> 
> Such a binding doesn't exist. So let's keep only the
> regulator_get_optional(&phy->dev, "phy"); part. Only TI SoCs and recently
> sun9i started using phy-supply and none of them use multi-phy PHY provider.

OK, fair enough.

Thanks.
diff mbox

Patch

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index a12d353..b43bb6b 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -650,16 +650,6 @@  struct phy *phy_create(struct device *dev, struct device_node *node,
 		goto free_phy;
 	}
 
-	/* phy-supply */
-	phy->pwr = regulator_get_optional(dev, "phy");
-	if (IS_ERR(phy->pwr)) {
-		if (PTR_ERR(phy->pwr) == -EPROBE_DEFER) {
-			ret = -EPROBE_DEFER;
-			goto free_ida;
-		}
-		phy->pwr = NULL;
-	}
-
 	device_initialize(&phy->dev);
 	mutex_init(&phy->mutex);
 
@@ -673,6 +663,26 @@  struct phy *phy_create(struct device *dev, struct device_node *node,
 	if (ret)
 		goto put_dev;
 
+	/*
+	 * Locate phy-supply. We first try individual port and then,
+	 * if supply is not found, try parent device.
+	 */
+	phy->pwr = regulator_get_optional(&phy->dev, "phy");
+	if (IS_ERR(phy->pwr)) {
+		ret = PTR_ERR(phy->pwr);
+		if (ret == -EPROBE_DEFER)
+			goto free_ida;
+
+		phy->pwr = regulator_get_optional(phy->dev.parent, "phy");
+		if (IS_ERR(phy->pwr)) {
+			ret = PTR_ERR(phy->pwr);
+			if (ret == -EPROBE_DEFER)
+				goto free_ida;
+
+			phy->pwr = NULL;
+		}
+	}
+
 	ret = device_add(&phy->dev);
 	if (ret)
 		goto put_dev;