aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/dsa.h10
-rw-r--r--net/dsa/dsa.c4
-rw-r--r--net/dsa/slave.c41
3 files changed, 55 insertions, 0 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 55e75e7e8d41..37856a28c8d3 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -38,6 +38,9 @@ struct dsa_chip_data {
38 struct device *host_dev; 38 struct device *host_dev;
39 int sw_addr; 39 int sw_addr;
40 40
41 /* set to size of eeprom if supported by the switch */
42 int eeprom_len;
43
41 /* Device tree node pointer for this specific switch chip 44 /* Device tree node pointer for this specific switch chip
42 * used during switch setup in case additional properties 45 * used during switch setup in case additional properties
43 * and resources needs to be used 46 * and resources needs to be used
@@ -258,6 +261,13 @@ struct dsa_switch_driver {
258 int (*set_temp_limit)(struct dsa_switch *ds, int temp); 261 int (*set_temp_limit)(struct dsa_switch *ds, int temp);
259 int (*get_temp_alarm)(struct dsa_switch *ds, bool *alarm); 262 int (*get_temp_alarm)(struct dsa_switch *ds, bool *alarm);
260#endif 263#endif
264
265 /* EEPROM access */
266 int (*get_eeprom_len)(struct dsa_switch *ds);
267 int (*get_eeprom)(struct dsa_switch *ds,
268 struct ethtool_eeprom *eeprom, u8 *data);
269 int (*set_eeprom)(struct dsa_switch *ds,
270 struct ethtool_eeprom *eeprom, u8 *data);
261}; 271};
262 272
263void register_switch_driver(struct dsa_switch_driver *type); 273void register_switch_driver(struct dsa_switch_driver *type);
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 5edbbca89f1f..b51ef592f0a2 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -575,6 +575,7 @@ static int dsa_of_probe(struct platform_device *pdev)
575 const char *port_name; 575 const char *port_name;
576 int chip_index, port_index; 576 int chip_index, port_index;
577 const unsigned int *sw_addr, *port_reg; 577 const unsigned int *sw_addr, *port_reg;
578 u32 eeprom_len;
578 int ret; 579 int ret;
579 580
580 mdio = of_parse_phandle(np, "dsa,mii-bus", 0); 581 mdio = of_parse_phandle(np, "dsa,mii-bus", 0);
@@ -626,6 +627,9 @@ static int dsa_of_probe(struct platform_device *pdev)
626 if (cd->sw_addr > PHY_MAX_ADDR) 627 if (cd->sw_addr > PHY_MAX_ADDR)
627 continue; 628 continue;
628 629
630 if (!of_property_read_u32(np, "eeprom-length", &eeprom_len))
631 cd->eeprom_len = eeprom_len;
632
629 for_each_available_child_of_node(child, port) { 633 for_each_available_child_of_node(child, port) {
630 port_reg = of_get_property(port, "reg", NULL); 634 port_reg = of_get_property(port, "reg", NULL);
631 if (!port_reg) 635 if (!port_reg)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 6d1817449c36..ff2fbe79bc57 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -271,6 +271,44 @@ static u32 dsa_slave_get_link(struct net_device *dev)
271 return -EOPNOTSUPP; 271 return -EOPNOTSUPP;
272} 272}
273 273
274static int dsa_slave_get_eeprom_len(struct net_device *dev)
275{
276 struct dsa_slave_priv *p = netdev_priv(dev);
277 struct dsa_switch *ds = p->parent;
278
279 if (ds->pd->eeprom_len)
280 return ds->pd->eeprom_len;
281
282 if (ds->drv->get_eeprom_len)
283 return ds->drv->get_eeprom_len(ds);
284
285 return 0;
286}
287
288static int dsa_slave_get_eeprom(struct net_device *dev,
289 struct ethtool_eeprom *eeprom, u8 *data)
290{
291 struct dsa_slave_priv *p = netdev_priv(dev);
292 struct dsa_switch *ds = p->parent;
293
294 if (ds->drv->get_eeprom)
295 return ds->drv->get_eeprom(ds, eeprom, data);
296
297 return -EOPNOTSUPP;
298}
299
300static int dsa_slave_set_eeprom(struct net_device *dev,
301 struct ethtool_eeprom *eeprom, u8 *data)
302{
303 struct dsa_slave_priv *p = netdev_priv(dev);
304 struct dsa_switch *ds = p->parent;
305
306 if (ds->drv->set_eeprom)
307 return ds->drv->set_eeprom(ds, eeprom, data);
308
309 return -EOPNOTSUPP;
310}
311
274static void dsa_slave_get_strings(struct net_device *dev, 312static void dsa_slave_get_strings(struct net_device *dev,
275 uint32_t stringset, uint8_t *data) 313 uint32_t stringset, uint8_t *data)
276{ 314{
@@ -387,6 +425,9 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
387 .get_drvinfo = dsa_slave_get_drvinfo, 425 .get_drvinfo = dsa_slave_get_drvinfo,
388 .nway_reset = dsa_slave_nway_reset, 426 .nway_reset = dsa_slave_nway_reset,
389 .get_link = dsa_slave_get_link, 427 .get_link = dsa_slave_get_link,
428 .get_eeprom_len = dsa_slave_get_eeprom_len,
429 .get_eeprom = dsa_slave_get_eeprom,
430 .set_eeprom = dsa_slave_set_eeprom,
390 .get_strings = dsa_slave_get_strings, 431 .get_strings = dsa_slave_get_strings,
391 .get_ethtool_stats = dsa_slave_get_ethtool_stats, 432 .get_ethtool_stats = dsa_slave_get_ethtool_stats,
392 .get_sset_count = dsa_slave_get_sset_count, 433 .get_sset_count = dsa_slave_get_sset_count,