diff mbox

[v3,2/9] net: arc_emac: add phy reset is optional for device tree

Message ID 1457942520-12859-3-git-send-email-wxt@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Caesar Wang March 14, 2016, 8:01 a.m. UTC
This patch adds the following property for arc_emac.

1) phy-reset-gpios:
The phy-reset-gpio is an optional property for arc emac device tree boot.
Change the binding document to match the driver code.

2) phy-reset-duration:
Different boards may require different phy reset duration. Add property
phy-reset-duration for device tree probe, so that the boards that need
a longer reset duration can specify it in their device tree.

Anyway, we can add the above property for arc emac.

Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc; Alexander Kochetkov <al.kochet@gmail.com>

---

Changes in v3:
- As Sergei comments, the original name is better, so
  %s/reset-gpios/phy-reset-gpios
- Add the Cc people.

Changes in v2:
- %s/phy-reset-gpios/reset-gpios

 Documentation/devicetree/bindings/net/arc_emac.txt | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Sergei Shtylyov March 16, 2016, 1:57 p.m. UTC | #1
Hello.

On 3/14/2016 11:01 AM, Caesar Wang wrote:

> This patch adds the following property for arc_emac.
>
> 1) phy-reset-gpios:
> The phy-reset-gpio is an optional property for arc emac device tree boot.
> Change the binding document to match the driver code.
>
> 2) phy-reset-duration:
> Different boards may require different phy reset duration. Add property
> phy-reset-duration for device tree probe, so that the boards that need
> a longer reset duration can specify it in their device tree.
>
> Anyway, we can add the above property for arc emac.
>
> Signed-off-by: Caesar Wang <wxt@rock-chips.com>

   Could you have a look at drivers/net/ethernet/cadence/macb/? It seems to be 
the only driver which places the PHY's "reset-gpios" prop correctly, into the 
PHY subnode? I'm currently working on adding support of this prop into phylib...

MBR, Sergei
Caesar Wang March 17, 2016, 10:02 a.m. UTC | #2
Hi Sergei,

? 2016?03?16? 21:57, Sergei Shtylyov ??:
> Hello.
>
> On 3/14/2016 11:01 AM, Caesar Wang wrote:
>
>> This patch adds the following property for arc_emac.
>>
>> 1) phy-reset-gpios:
>> The phy-reset-gpio is an optional property for arc emac device tree 
>> boot.
>> Change the binding document to match the driver code.
>>
>> 2) phy-reset-duration:
>> Different boards may require different phy reset duration. Add property
>> phy-reset-duration for device tree probe, so that the boards that need
>> a longer reset duration can specify it in their device tree.
>>
>> Anyway, we can add the above property for arc emac.
>>
>> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
>
>   Could you have a look at drivers/net/ethernet/cadence/macb/? It 
> seems to be the only driver which places the PHY's "reset-gpios" prop 
> correctly, into the PHY subnode? I'm currently working on adding 
> support of this prop into phylib...

I see the driver on now.


     /* Power up the PHY if there is a GPIO reset */
     phy_node =  of_get_next_available_child(np, NULL);
     if (phy_node) {
         int gpio = of_get_named_gpio(phy_node, "reset-gpios", 0);
         if (gpio_is_valid(gpio))
             bp->reset_gpio = gpio_to_desc(gpio);
         gpiod_set_value(bp->reset_gpio, GPIOD_OUT_HIGH);
     }
     of_node_put(phy_node);
...

Frankly, I don't like this way in device drivers.
That's seem same with the /drivers/mmc/core/pwrseq_simple.c,  power up 
the device.
Is it not really reset hardware PHY from the gpio reset pin?  Just power up.

Of course, I hope to see and test it if you improve the PHY framework to 
support the phy reset.:-)

---

Anyway,  David had applied this series patches into net branch.

Although the clock and dts patches should be applied into Heiko branch,  
I'm glad to see David's way.

Heiko branch:
https://git.kernel.org/cgit/linux/kernel/git/mmind/linux-rockchip.git/


I wish won't destory Heiko to merge in the future.


-Caesar



>
> MBR, Sergei
>
>
> _______________________________________________
> Linux-rockchip mailing list
> Linux-rockchip@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/net/arc_emac.txt b/Documentation/devicetree/bindings/net/arc_emac.txt
index a1d71eb..c73a0e9 100644
--- a/Documentation/devicetree/bindings/net/arc_emac.txt
+++ b/Documentation/devicetree/bindings/net/arc_emac.txt
@@ -7,6 +7,13 @@  Required properties:
 - max-speed: see ethernet.txt file in the same directory.
 - phy: see ethernet.txt file in the same directory.
 
+Optional properties:
+- phy-reset-gpios : Should specify the gpio for phy reset
+- phy-reset-duration : Reset duration in milliseconds.  Should present
+  only if property "phy-reset-gpios" is available.  Missing the property
+  will have the duration be 1 millisecond.  Numbers greater than 1000 are
+  invalid and 1 millisecond will be used instead.
+
 Clock handling:
 The clock frequency is needed to calculate and set polling period of EMAC.
 It must be provided by one of: