lkml.org 
[lkml]   [2016]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] net: macb: add phy-handle support for the macb
Date
This patch adds support for the 'phy-handle' binding which allows for a
system to specifically select a phy which can be attached via any MDIO
bus available in the system.

Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>
---
Documentation/devicetree/bindings/net/macb.txt | 3 +++
drivers/net/ethernet/cadence/macb.c | 11 +++++++++--
drivers/net/ethernet/cadence/macb.h | 1 +
3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
index b5a42df..3cfff7c 100644
--- a/Documentation/devicetree/bindings/net/macb.txt
+++ b/Documentation/devicetree/bindings/net/macb.txt
@@ -23,6 +23,9 @@ Required properties:
Optional elements: 'tx_clk'
- clocks: Phandles to input clocks.

+Optional properties:
+- phy-handle : See ethernet.txt file in the same directory.
+
Optional properties for PHY child node:
- reset-gpios : Should specify the gpio for phy reset
- magic-packet : If present, indicates that the hardware supports waking
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 6b797e3..4ddd45d 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -421,7 +421,7 @@ static int macb_mii_probe(struct net_device *dev)
static int macb_mii_init(struct macb *bp)
{
struct macb_platform_data *pdata;
- struct device_node *np;
+ struct device_node *np, *np1;
int err = -ENXIO, i;

/* Enable management port */
@@ -445,7 +445,13 @@ static int macb_mii_init(struct macb *bp)
dev_set_drvdata(&bp->dev->dev, bp->mii_bus);

np = bp->pdev->dev.of_node;
- if (np) {
+ np1 = of_get_parent(bp->phy_node);
+ if (np1) {
+ of_node_put(np1);
+ err = of_mdiobus_register(bp->mii_bus, np1);
+ if (err)
+ goto err_out_unregister_bus;
+ } else if (np) {
/* try dt phy registration */
err = of_mdiobus_register(bp->mii_bus, np);

@@ -3016,6 +3022,7 @@ static int macb_probe(struct platform_device *pdev)
} else {
bp->phy_interface = err;
}
+ bp->phy_node = of_parse_phandle(np, "phy-handle", 0);

/* IP specific init */
err = init(pdev);
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index aa3aeec..83d1617 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -855,6 +855,7 @@ struct macb {
unsigned int jumbo_max_len;

u32 wol;
+ struct device_node *phy_node;
};

static inline bool macb_is_gem(struct macb *bp)
--
2.1.2
\
 
 \ /
  Last update: 2016-09-17 09:56    [W:0.223 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site