aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2016-05-16 14:52:43 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-17 14:31:09 -0400
commit81003bc924bac0a99bfdc2869f5dff5a87aa4a3d (patch)
treeeb51d133e67c396f2c6c6f52deef7ff78e681ed0 /drivers/net/phy
parent7f32541c2fdaa84af418c3e1431bbd066ab44d09 (diff)
phy dp83867: Make rgmii parameters optional
If you compile without OF_MDIO support in an RGMII configuration, we fail to configure the dp83867 phy today by writing garbage into its configuration registers. On the other hand if you do compile with OF_MDIO and the phy gets loaded via device tree, you have to have the properties set in the device tree, otherwise we fail to load the driver and don't even attach the generic phy driver to the interface anymore. To make things slightly more consistent, make the rgmii configuration properties optional and allow a user to omit them in their device tree. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/dp83867.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 94cc278b3136..1b01680987c4 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -65,6 +65,7 @@ struct dp83867_private {
65 int rx_id_delay; 65 int rx_id_delay;
66 int tx_id_delay; 66 int tx_id_delay;
67 int fifo_depth; 67 int fifo_depth;
68 int values_are_sane;
68}; 69};
69 70
70static int dp83867_ack_interrupt(struct phy_device *phydev) 71static int dp83867_ack_interrupt(struct phy_device *phydev)
@@ -113,15 +114,30 @@ static int dp83867_of_init(struct phy_device *phydev)
113 ret = of_property_read_u32(of_node, "ti,rx-internal-delay", 114 ret = of_property_read_u32(of_node, "ti,rx-internal-delay",
114 &dp83867->rx_id_delay); 115 &dp83867->rx_id_delay);
115 if (ret) 116 if (ret)
116 return ret; 117 goto invalid_dt;
117 118
118 ret = of_property_read_u32(of_node, "ti,tx-internal-delay", 119 ret = of_property_read_u32(of_node, "ti,tx-internal-delay",
119 &dp83867->tx_id_delay); 120 &dp83867->tx_id_delay);
120 if (ret) 121 if (ret)
121 return ret; 122 goto invalid_dt;
122 123
123 return of_property_read_u32(of_node, "ti,fifo-depth", 124 ret = of_property_read_u32(of_node, "ti,fifo-depth",
124 &dp83867->fifo_depth); 125 &dp83867->fifo_depth);
126 if (ret)
127 goto invalid_dt;
128
129 dp83867->values_are_sane = 1;
130
131 return 0;
132
133invalid_dt:
134 phydev_err(phydev, "missing properties in device tree");
135
136 /*
137 * We can still run with a broken dt by not using any of the optional
138 * parameters, so just don't set dp83867->values_are_sane.
139 */
140 return 0;
125} 141}
126#else 142#else
127static int dp83867_of_init(struct phy_device *phydev) 143static int dp83867_of_init(struct phy_device *phydev)
@@ -150,6 +166,15 @@ static int dp83867_config_init(struct phy_device *phydev)
150 dp83867 = (struct dp83867_private *)phydev->priv; 166 dp83867 = (struct dp83867_private *)phydev->priv;
151 } 167 }
152 168
169 /*
170 * With no or broken device tree, we don't have the values that we would
171 * want to configure the phy with. In that case, cross our fingers and
172 * assume that firmware did everything correctly for us or that we don't
173 * need them.
174 */
175 if (!dp83867->values_are_sane)
176 return 0;
177
153 if (phy_interface_is_rgmii(phydev)) { 178 if (phy_interface_is_rgmii(phydev)) {
154 ret = phy_write(phydev, MII_DP83867_PHYCTRL, 179 ret = phy_write(phydev, MII_DP83867_PHYCTRL,
155 (dp83867->fifo_depth << DP83867_PHYCR_FIFO_DEPTH_SHIFT)); 180 (dp83867->fifo_depth << DP83867_PHYCR_FIFO_DEPTH_SHIFT));