1 From 5378928ebac13756fc13d0b2de8dd45ace8026aa Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Mon, 15 Jul 2013 17:34:08 +0200
4 Subject: [PATCH 080/203] of: provide a binding for the 'fixed-link' property
6 Some Ethernet MACs have a "fixed link", and are not connected to a
7 normal MDIO-managed PHY device. For those situations, a Device Tree
8 binding allows to describe a "fixed link", as a "fixed-link" property
9 of the Ethernet device Device Tree node.
13 * A documentation for the Device Tree property "fixed-link".
15 * A of_phy_register_fixed_link() OF helper, which provided an OF node
16 that contains a "fixed-link" property, registers the corresponding
19 * Removes the warning on the of_phy_connect_fixed_link() that says
20 new drivers should not use it, since Grant Likely indicated that
21 this "fixed-link" property is indeed the way to go.
23 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
25 .../devicetree/bindings/net/fixed-link.txt | 26 ++++++++++++++++
26 drivers/of/of_mdio.c | 36 +++++++++++++++++++---
27 include/linux/of_mdio.h | 10 ++++++
28 3 files changed, 68 insertions(+), 4 deletions(-)
29 create mode 100644 Documentation/devicetree/bindings/net/fixed-link.txt
32 +++ b/Documentation/devicetree/bindings/net/fixed-link.txt
34 +Fixed link Device Tree binding
35 +------------------------------
37 +Some Ethernet MACs have a "fixed link", and are not connected to a
38 +normal MDIO-managed PHY device. For those situations, a Device Tree
39 +binding allows to describe a "fixed link".
41 +Such a fixed link situation is described within an Ethernet device
42 +Device Tree node using a 'fixed-link' property, composed of 5
45 + 1. A fake PHY ID, which must be unique accross all fixed-link PHYs in
47 + 2. The duplex (1 for full-duplex, 0 for half-duplex)
48 + 3. The speed (10, 100, 1000)
49 + 4. The pause setting (1 for enabled, 0 for disabled)
50 + 5. The asym pause setting (1 for enabled, 0 for disabled)
56 + fixed-link = <1 1 1000 0 0>;
60 --- a/drivers/of/of_mdio.c
61 +++ b/drivers/of/of_mdio.c
63 #include <linux/netdevice.h>
64 #include <linux/err.h>
65 #include <linux/phy.h>
66 +#include <linux/phy_fixed.h>
68 #include <linux/of_irq.h>
69 #include <linux/of_mdio.h>
70 @@ -215,10 +216,6 @@ EXPORT_SYMBOL(of_phy_connect);
71 * @dev: pointer to net_device claiming the phy
72 * @hndlr: Link state callback for the network device
73 * @iface: PHY data interface type
75 - * This function is a temporary stop-gap and will be removed soon. It is
76 - * only to support the fs_enet, ucc_geth and gianfar Ethernet drivers. Do
77 - * not call this function from new drivers.
79 struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
80 void (*hndlr)(struct net_device *),
81 @@ -247,3 +244,34 @@ struct phy_device *of_phy_connect_fixed_
82 return IS_ERR(phy) ? NULL : phy;
84 EXPORT_SYMBOL(of_phy_connect_fixed_link);
86 +#if defined(CONFIG_FIXED_PHY)
88 + * of_phy_register_fixed_link - Parse fixed-link property and register a dummy phy
89 + * @np: pointer to the OF device node that contains the "fixed-link"
90 + * property for which a dummy phy should be registered.
92 +#define FIXED_LINK_PROPERTIES_COUNT 5
93 +int of_phy_register_fixed_link(struct device_node *np)
95 + struct fixed_phy_status status = {};
96 + u32 fixed_link_props[FIXED_LINK_PROPERTIES_COUNT];
99 + ret = of_property_read_u32_array(np, "fixed-link",
101 + FIXED_LINK_PROPERTIES_COUNT);
106 + status.duplex = fixed_link_props[1];
107 + status.speed = fixed_link_props[2];
108 + status.pause = fixed_link_props[3];
109 + status.asym_pause = fixed_link_props[4];
111 + return fixed_phy_add(PHY_POLL, fixed_link_props[0],
114 +EXPORT_SYMBOL(of_phy_register_fixed_link);
116 --- a/include/linux/of_mdio.h
117 +++ b/include/linux/of_mdio.h
118 @@ -57,4 +57,14 @@ static inline struct mii_bus *of_mdio_fi
120 #endif /* CONFIG_OF */
122 +#if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY)
123 +extern int of_phy_register_fixed_link(struct device_node *np);
125 +static inline int of_phy_register_fixed_link(struct device_node *np)
132 #endif /* __LINUX_OF_MDIO_H */