Skip to content

Commit f8cd875

Browse files
lunndavem330
authored andcommitted
dsa: mv88e6xxx: Handle eeprom-length property
A switch can export an attached EEPROM using the standard ethtool API. However the switch itself cannot determine the size of the EEPROM, and multiple sizes are allowed. Thus a device tree property is supported to indicate the length of the EEPROM. Parse this property during device probe, and implement a callback function to retrieve it. Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ff04955 commit f8cd875

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

drivers/net/dsa/mv88e6xxx.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,16 @@ static int mv88e6xxx_read_eeprom_word(struct dsa_switch *ds, int addr)
869869
return ret;
870870
}
871871

872+
static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
873+
{
874+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
875+
876+
if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEPROM))
877+
return ps->eeprom_len;
878+
879+
return 0;
880+
}
881+
872882
static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
873883
struct ethtool_eeprom *eeprom, u8 *data)
874884
{
@@ -3610,6 +3620,7 @@ struct dsa_switch_driver mv88e6xxx_switch_driver = {
36103620
.set_temp_limit = mv88e6xxx_set_temp_limit,
36113621
.get_temp_alarm = mv88e6xxx_get_temp_alarm,
36123622
#endif
3623+
.get_eeprom_len = mv88e6xxx_get_eeprom_len,
36133624
.get_eeprom = mv88e6xxx_get_eeprom,
36143625
.set_eeprom = mv88e6xxx_set_eeprom,
36153626
.get_regs_len = mv88e6xxx_get_regs_len,
@@ -3631,9 +3642,11 @@ struct dsa_switch_driver mv88e6xxx_switch_driver = {
36313642
int mv88e6xxx_probe(struct mdio_device *mdiodev)
36323643
{
36333644
struct device *dev = &mdiodev->dev;
3645+
struct device_node *np = dev->of_node;
36343646
struct mv88e6xxx_priv_state *ps;
36353647
int id, prod_num, rev;
36363648
struct dsa_switch *ds;
3649+
u32 eeprom_len;
36373650
int err;
36383651

36393652
ds = devm_kzalloc(dev, sizeof(*ds) + sizeof(*ps), GFP_KERNEL);
@@ -3676,6 +3689,10 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev)
36763689
}
36773690
}
36783691

3692+
if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEPROM) &&
3693+
!of_property_read_u32(np, "eeprom-length", &eeprom_len))
3694+
ps->eeprom_len = eeprom_len;
3695+
36793696
dev_set_drvdata(dev, ds);
36803697

36813698
dev_info(dev, "switch 0x%x probed: %s, revision %u\n",

drivers/net/dsa/mv88e6xxx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ struct mv88e6xxx_priv_state {
602602
* switch soft reset.
603603
*/
604604
struct gpio_desc *reset;
605+
606+
/* set to size of eeprom if supported by the switch */
607+
int eeprom_len;
605608
};
606609

607610
enum stat_type {

0 commit comments

Comments
 (0)