All of lore.kernel.org
 help / color / mirror / Atom feed
From: Romain Perier <romain.perier@gmail.com>
To: "Heiko Stübner" <heiko@sntech.de>
Cc: peppe.cavallaro@st.com, netdev <netdev@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	devicetree <devicetree@vger.kernel.org>,
	roger.chen@rock-chips.com
Subject: Re: [PATCH v1 3/4] net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator
Date: Tue, 20 Jan 2015 07:55:45 +0100	[thread overview]
Message-ID: <CABgxDoLY3hkj5=QP1s8h4fotx7vSfOiP6xZd9L=t8ZffteO8QQ@mail.gmail.com> (raw)
In-Reply-To: <4603622.ltPA9iTIiK@phil>

Hi,

Ok I will do these changes. However, the property "phy_regulator" was
not documented in
Documentation/devicetree/bindings/net/rockchip-dwmac.txt ... I can
document it anyway, it has probably been forgotten.

Thanks !

2015-01-19 21:12 GMT+01:00 Heiko Stübner <heiko@sntech.de>:
> Am Montag, 19. Januar 2015, 18:08:08 schrieb Romain Perier:
>> Currently, dwmac-rk uses a custom propety "phy_regulator" to get the name of
>> the right regulator to use to power on or power off the phy. This commit
>> converts the driver to use phy-supply devicetree property and the
>> corresponding API, it cleans the code a bit and make it simpler to
>> maintain.
>>
>> Signed-off-by: Romain Perier <romain.perier@gmail.com>
>
> I don't see updated binding documentation in here.
>
> Secondly I think patch4 which changes the property in the evb-rk808 could be
> in here. The change is simple enough and would keep it bisectable without
> needing transistional patches.
>
> And there is the one warning down below.
>
>
>> ---
>>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 61
>> ++++++++------------------ 1 file changed, 19 insertions(+), 42
>> deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 06e1637..8a8091c
>> 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> @@ -32,7 +32,7 @@
>>  struct rk_priv_data {
>>       struct platform_device *pdev;
>>       int phy_iface;
>> -     char regulator[32];
>> +     struct regulator *regulator;
>>
>>       bool clk_enabled;
>>       bool clock_input;
>> @@ -287,46 +287,25 @@ static int gmac_clk_enable(struct rk_priv_data
>> *bsp_priv, bool enable)
>>
>>  static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
>>  {
>> -     struct regulator *ldo;
>> -     char *ldostr = bsp_priv->regulator;
>> +     struct regulator *ldo = bsp_priv->regulator;
>>       int ret;
>>       struct device *dev = &bsp_priv->pdev->dev;
>>
>> -     if (!ldostr) {
>> -             dev_err(dev, "%s: no ldo found\n", __func__);
>> +     if (!ldo) {
>> +             dev_err(dev, "%s: no regulator found\n", __func__);
>>               return -1;
>>       }
>>
>> -     ldo = regulator_get(NULL, ldostr);
>> -     if (!ldo) {
>> -             dev_err(dev, "\n%s get ldo %s failed\n", __func__, ldostr);
>> +     if (enable) {
>> +             ret = regulator_enable(ldo);
>> +             if (ret)
>> +                     dev_err(dev, "%s: fail to enable phy-supply\n",
>> +                             __func__);
>>       } else {
>> -             if (enable) {
>> -                     if (!regulator_is_enabled(ldo)) {
>> -                             ret = regulator_enable(ldo);
>> -                             if (ret != 0)
>> -                                     dev_err(dev, "%s: fail to enable %s\n",
>> -                                             __func__, ldostr);
>> -                             else
>> -                                     dev_info(dev, "turn on ldo done.\n");
>> -                     } else {
>> -                             dev_warn(dev, "%s is enabled before enable",
>> -                                      ldostr);
>> -                     }
>> -             } else {
>> -                     if (regulator_is_enabled(ldo)) {
>> -                             ret = regulator_disable(ldo);
>> -                             if (ret != 0)
>> -                                     dev_err(dev, "%s: fail to disable %s\n",
>> -                                             __func__, ldostr);
>> -                             else
>> -                                     dev_info(dev, "turn off ldo done.\n");
>> -                     } else {
>> -                             dev_warn(dev, "%s is disabled before disable",
>> -                                      ldostr);
>> -                     }
>> -             }
>> -             regulator_put(ldo);
>> +             ret = regulator_disable(ldo);
>> +             if (ret)
>> +                     dev_err(dev, "%s: fail to disable phy-supply\n",
>> +                             __func__);
>>       }
>>
>>       return 0;
>> @@ -346,14 +325,12 @@ static void *rk_gmac_setup(struct platform_device
>> *pdev)
>>
>>       bsp_priv->phy_iface = of_get_phy_mode(dev->of_node);
>>
>> -     ret = of_property_read_string(dev->of_node, "phy_regulator", &strings);
>> -     if (ret) {
>> -             dev_warn(dev, "%s: Can not read property: phy_regulator.\n",
>> -                      __func__);
>> -     } else {
>> -             dev_info(dev, "%s: PHY power controlled by regulator(%s).\n",
>> -                      __func__, strings);
>> -             strcpy(bsp_priv->regulator, strings);
>> +     bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
>> +     if (IS_ERR(bsp_priv->regulator)) {
>> +             if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER)
>> +                     return -EPROBE_DEFER;
>
> this should be return ERR_PTR(-EPROBE_DEFER) and produces a warning in its
> current state
>
>
>> +             dev_err(dev, "no regulator found\n");
>> +             bsp_priv->regulator = NULL;
>>       }
>>
>>       ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
>

WARNING: multiple messages have this Message-ID (diff)
From: Romain Perier <romain.perier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Heiko Stübner" <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
Cc: peppe.cavallaro-qxv4g6HH51o@public.gmane.org,
	netdev <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux Kernel Mailing List
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	roger.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org
Subject: Re: [PATCH v1 3/4] net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator
Date: Tue, 20 Jan 2015 07:55:45 +0100	[thread overview]
Message-ID: <CABgxDoLY3hkj5=QP1s8h4fotx7vSfOiP6xZd9L=t8ZffteO8QQ@mail.gmail.com> (raw)
In-Reply-To: <4603622.ltPA9iTIiK@phil>

Hi,

Ok I will do these changes. However, the property "phy_regulator" was
not documented in
Documentation/devicetree/bindings/net/rockchip-dwmac.txt ... I can
document it anyway, it has probably been forgotten.

Thanks !

2015-01-19 21:12 GMT+01:00 Heiko Stübner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>:
> Am Montag, 19. Januar 2015, 18:08:08 schrieb Romain Perier:
>> Currently, dwmac-rk uses a custom propety "phy_regulator" to get the name of
>> the right regulator to use to power on or power off the phy. This commit
>> converts the driver to use phy-supply devicetree property and the
>> corresponding API, it cleans the code a bit and make it simpler to
>> maintain.
>>
>> Signed-off-by: Romain Perier <romain.perier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> I don't see updated binding documentation in here.
>
> Secondly I think patch4 which changes the property in the evb-rk808 could be
> in here. The change is simple enough and would keep it bisectable without
> needing transistional patches.
>
> And there is the one warning down below.
>
>
>> ---
>>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 61
>> ++++++++------------------ 1 file changed, 19 insertions(+), 42
>> deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 06e1637..8a8091c
>> 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> @@ -32,7 +32,7 @@
>>  struct rk_priv_data {
>>       struct platform_device *pdev;
>>       int phy_iface;
>> -     char regulator[32];
>> +     struct regulator *regulator;
>>
>>       bool clk_enabled;
>>       bool clock_input;
>> @@ -287,46 +287,25 @@ static int gmac_clk_enable(struct rk_priv_data
>> *bsp_priv, bool enable)
>>
>>  static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
>>  {
>> -     struct regulator *ldo;
>> -     char *ldostr = bsp_priv->regulator;
>> +     struct regulator *ldo = bsp_priv->regulator;
>>       int ret;
>>       struct device *dev = &bsp_priv->pdev->dev;
>>
>> -     if (!ldostr) {
>> -             dev_err(dev, "%s: no ldo found\n", __func__);
>> +     if (!ldo) {
>> +             dev_err(dev, "%s: no regulator found\n", __func__);
>>               return -1;
>>       }
>>
>> -     ldo = regulator_get(NULL, ldostr);
>> -     if (!ldo) {
>> -             dev_err(dev, "\n%s get ldo %s failed\n", __func__, ldostr);
>> +     if (enable) {
>> +             ret = regulator_enable(ldo);
>> +             if (ret)
>> +                     dev_err(dev, "%s: fail to enable phy-supply\n",
>> +                             __func__);
>>       } else {
>> -             if (enable) {
>> -                     if (!regulator_is_enabled(ldo)) {
>> -                             ret = regulator_enable(ldo);
>> -                             if (ret != 0)
>> -                                     dev_err(dev, "%s: fail to enable %s\n",
>> -                                             __func__, ldostr);
>> -                             else
>> -                                     dev_info(dev, "turn on ldo done.\n");
>> -                     } else {
>> -                             dev_warn(dev, "%s is enabled before enable",
>> -                                      ldostr);
>> -                     }
>> -             } else {
>> -                     if (regulator_is_enabled(ldo)) {
>> -                             ret = regulator_disable(ldo);
>> -                             if (ret != 0)
>> -                                     dev_err(dev, "%s: fail to disable %s\n",
>> -                                             __func__, ldostr);
>> -                             else
>> -                                     dev_info(dev, "turn off ldo done.\n");
>> -                     } else {
>> -                             dev_warn(dev, "%s is disabled before disable",
>> -                                      ldostr);
>> -                     }
>> -             }
>> -             regulator_put(ldo);
>> +             ret = regulator_disable(ldo);
>> +             if (ret)
>> +                     dev_err(dev, "%s: fail to disable phy-supply\n",
>> +                             __func__);
>>       }
>>
>>       return 0;
>> @@ -346,14 +325,12 @@ static void *rk_gmac_setup(struct platform_device
>> *pdev)
>>
>>       bsp_priv->phy_iface = of_get_phy_mode(dev->of_node);
>>
>> -     ret = of_property_read_string(dev->of_node, "phy_regulator", &strings);
>> -     if (ret) {
>> -             dev_warn(dev, "%s: Can not read property: phy_regulator.\n",
>> -                      __func__);
>> -     } else {
>> -             dev_info(dev, "%s: PHY power controlled by regulator(%s).\n",
>> -                      __func__, strings);
>> -             strcpy(bsp_priv->regulator, strings);
>> +     bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
>> +     if (IS_ERR(bsp_priv->regulator)) {
>> +             if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER)
>> +                     return -EPROBE_DEFER;
>
> this should be return ERR_PTR(-EPROBE_DEFER) and produces a warning in its
> current state
>
>
>> +             dev_err(dev, "no regulator found\n");
>> +             bsp_priv->regulator = NULL;
>>       }
>>
>>       ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: romain.perier@gmail.com (Romain Perier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1 3/4] net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator
Date: Tue, 20 Jan 2015 07:55:45 +0100	[thread overview]
Message-ID: <CABgxDoLY3hkj5=QP1s8h4fotx7vSfOiP6xZd9L=t8ZffteO8QQ@mail.gmail.com> (raw)
In-Reply-To: <4603622.ltPA9iTIiK@phil>

Hi,

Ok I will do these changes. However, the property "phy_regulator" was
not documented in
Documentation/devicetree/bindings/net/rockchip-dwmac.txt ... I can
document it anyway, it has probably been forgotten.

Thanks !

2015-01-19 21:12 GMT+01:00 Heiko St?bner <heiko@sntech.de>:
> Am Montag, 19. Januar 2015, 18:08:08 schrieb Romain Perier:
>> Currently, dwmac-rk uses a custom propety "phy_regulator" to get the name of
>> the right regulator to use to power on or power off the phy. This commit
>> converts the driver to use phy-supply devicetree property and the
>> corresponding API, it cleans the code a bit and make it simpler to
>> maintain.
>>
>> Signed-off-by: Romain Perier <romain.perier@gmail.com>
>
> I don't see updated binding documentation in here.
>
> Secondly I think patch4 which changes the property in the evb-rk808 could be
> in here. The change is simple enough and would keep it bisectable without
> needing transistional patches.
>
> And there is the one warning down below.
>
>
>> ---
>>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 61
>> ++++++++------------------ 1 file changed, 19 insertions(+), 42
>> deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 06e1637..8a8091c
>> 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>> @@ -32,7 +32,7 @@
>>  struct rk_priv_data {
>>       struct platform_device *pdev;
>>       int phy_iface;
>> -     char regulator[32];
>> +     struct regulator *regulator;
>>
>>       bool clk_enabled;
>>       bool clock_input;
>> @@ -287,46 +287,25 @@ static int gmac_clk_enable(struct rk_priv_data
>> *bsp_priv, bool enable)
>>
>>  static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
>>  {
>> -     struct regulator *ldo;
>> -     char *ldostr = bsp_priv->regulator;
>> +     struct regulator *ldo = bsp_priv->regulator;
>>       int ret;
>>       struct device *dev = &bsp_priv->pdev->dev;
>>
>> -     if (!ldostr) {
>> -             dev_err(dev, "%s: no ldo found\n", __func__);
>> +     if (!ldo) {
>> +             dev_err(dev, "%s: no regulator found\n", __func__);
>>               return -1;
>>       }
>>
>> -     ldo = regulator_get(NULL, ldostr);
>> -     if (!ldo) {
>> -             dev_err(dev, "\n%s get ldo %s failed\n", __func__, ldostr);
>> +     if (enable) {
>> +             ret = regulator_enable(ldo);
>> +             if (ret)
>> +                     dev_err(dev, "%s: fail to enable phy-supply\n",
>> +                             __func__);
>>       } else {
>> -             if (enable) {
>> -                     if (!regulator_is_enabled(ldo)) {
>> -                             ret = regulator_enable(ldo);
>> -                             if (ret != 0)
>> -                                     dev_err(dev, "%s: fail to enable %s\n",
>> -                                             __func__, ldostr);
>> -                             else
>> -                                     dev_info(dev, "turn on ldo done.\n");
>> -                     } else {
>> -                             dev_warn(dev, "%s is enabled before enable",
>> -                                      ldostr);
>> -                     }
>> -             } else {
>> -                     if (regulator_is_enabled(ldo)) {
>> -                             ret = regulator_disable(ldo);
>> -                             if (ret != 0)
>> -                                     dev_err(dev, "%s: fail to disable %s\n",
>> -                                             __func__, ldostr);
>> -                             else
>> -                                     dev_info(dev, "turn off ldo done.\n");
>> -                     } else {
>> -                             dev_warn(dev, "%s is disabled before disable",
>> -                                      ldostr);
>> -                     }
>> -             }
>> -             regulator_put(ldo);
>> +             ret = regulator_disable(ldo);
>> +             if (ret)
>> +                     dev_err(dev, "%s: fail to disable phy-supply\n",
>> +                             __func__);
>>       }
>>
>>       return 0;
>> @@ -346,14 +325,12 @@ static void *rk_gmac_setup(struct platform_device
>> *pdev)
>>
>>       bsp_priv->phy_iface = of_get_phy_mode(dev->of_node);
>>
>> -     ret = of_property_read_string(dev->of_node, "phy_regulator", &strings);
>> -     if (ret) {
>> -             dev_warn(dev, "%s: Can not read property: phy_regulator.\n",
>> -                      __func__);
>> -     } else {
>> -             dev_info(dev, "%s: PHY power controlled by regulator(%s).\n",
>> -                      __func__, strings);
>> -             strcpy(bsp_priv->regulator, strings);
>> +     bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
>> +     if (IS_ERR(bsp_priv->regulator)) {
>> +             if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER)
>> +                     return -EPROBE_DEFER;
>
> this should be return ERR_PTR(-EPROBE_DEFER) and produces a warning in its
> current state
>
>
>> +             dev_err(dev, "no regulator found\n");
>> +             bsp_priv->regulator = NULL;
>>       }
>>
>>       ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
>

  reply	other threads:[~2015-01-20  6:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19 18:08 [PATCH v1 0/4] net: stmmac: dwmac-rk: Fix phy regulator issues Romain Perier
2015-01-19 18:08 ` Romain Perier
2015-01-19 18:08 ` Romain Perier
2015-01-19 18:08 ` [PATCH v1 1/4] net: stmmac: dwmac-rk: Don't set the regulator voltage for phy from the driver Romain Perier
2015-01-19 18:08   ` Romain Perier
2015-01-19 18:08 ` [PATCH v1 2/4] ARM: dts: Add regulator voltage settings for vcc_phy in rk3288-evb.dtsi Romain Perier
2015-01-19 18:08   ` Romain Perier
2015-01-19 18:08   ` Romain Perier
2015-01-19 18:08 ` [PATCH v1 3/4] net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator Romain Perier
2015-01-19 18:08   ` Romain Perier
2015-01-19 20:12   ` Heiko Stübner
2015-01-19 20:12     ` Heiko Stübner
2015-01-19 20:12     ` Heiko Stübner
2015-01-20  6:55     ` Romain Perier [this message]
2015-01-20  6:55       ` Romain Perier
2015-01-20  6:55       ` Romain Perier
2015-01-19 18:08 ` [PATCH v1 4/4] ARM: dts: Convert gmac to phy-supply in rk3288-evb-rk808.dts Romain Perier
2015-01-19 18:08   ` Romain Perier
2015-01-19 20:19 ` [PATCH v1 0/4] net: stmmac: dwmac-rk: Fix phy regulator issues Heiko Stübner
2015-01-19 20:19   ` Heiko Stübner
2015-01-20  6:58   ` Romain Perier
2015-01-20  6:58     ` Romain Perier
2015-01-20  6:58     ` Romain Perier

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='CABgxDoLY3hkj5=QP1s8h4fotx7vSfOiP6xZd9L=t8ZffteO8QQ@mail.gmail.com' \
    --to=romain.perier@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=roger.chen@rock-chips.com \
    /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.