diff options
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r-- | net/dsa/dsa.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 053eb2b8e682..76e3800765f8 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -176,6 +176,41 @@ __ATTRIBUTE_GROUPS(dsa_hwmon); | |||
176 | #endif /* CONFIG_NET_DSA_HWMON */ | 176 | #endif /* CONFIG_NET_DSA_HWMON */ |
177 | 177 | ||
178 | /* basic switch operations **************************************************/ | 178 | /* basic switch operations **************************************************/ |
179 | static int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct net_device *master) | ||
180 | { | ||
181 | struct dsa_chip_data *cd = ds->pd; | ||
182 | struct device_node *port_dn; | ||
183 | struct phy_device *phydev; | ||
184 | int ret, port, mode; | ||
185 | |||
186 | for (port = 0; port < DSA_MAX_PORTS; port++) { | ||
187 | if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) | ||
188 | continue; | ||
189 | |||
190 | port_dn = cd->port_dn[port]; | ||
191 | if (of_phy_is_fixed_link(port_dn)) { | ||
192 | ret = of_phy_register_fixed_link(port_dn); | ||
193 | if (ret) { | ||
194 | netdev_err(master, | ||
195 | "failed to register fixed PHY\n"); | ||
196 | return ret; | ||
197 | } | ||
198 | phydev = of_phy_find_device(port_dn); | ||
199 | |||
200 | mode = of_get_phy_mode(port_dn); | ||
201 | if (mode < 0) | ||
202 | mode = PHY_INTERFACE_MODE_NA; | ||
203 | phydev->interface = mode; | ||
204 | |||
205 | genphy_config_init(phydev); | ||
206 | genphy_read_status(phydev); | ||
207 | if (ds->drv->adjust_link) | ||
208 | ds->drv->adjust_link(ds, port, phydev); | ||
209 | } | ||
210 | } | ||
211 | return 0; | ||
212 | } | ||
213 | |||
179 | static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | 214 | static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) |
180 | { | 215 | { |
181 | struct dsa_switch_driver *drv = ds->drv; | 216 | struct dsa_switch_driver *drv = ds->drv; |
@@ -297,6 +332,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | |||
297 | } | 332 | } |
298 | } | 333 | } |
299 | 334 | ||
335 | /* Perform configuration of the CPU and DSA ports */ | ||
336 | ret = dsa_cpu_dsa_setup(ds, dst->master_netdev); | ||
337 | if (ret < 0) { | ||
338 | netdev_err(dst->master_netdev, "[%d] : can't configure CPU and DSA ports\n", | ||
339 | index); | ||
340 | ret = 0; | ||
341 | } | ||
342 | |||
300 | #ifdef CONFIG_NET_DSA_HWMON | 343 | #ifdef CONFIG_NET_DSA_HWMON |
301 | /* If the switch provides a temperature sensor, | 344 | /* If the switch provides a temperature sensor, |
302 | * register with hardware monitoring subsystem. | 345 | * register with hardware monitoring subsystem. |