Commit aadbdb8a authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: mv88e6xxx: factorize EEE access

Add a MV88E6XXX_FLAG_EEE flag to describe switch models featuring Energy
Efficient Ethernet. Use it to conditionally support such access in the
common code.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1d13a06e
...@@ -117,6 +117,8 @@ struct dsa_switch_driver mv88e6123_switch_driver = { ...@@ -117,6 +117,8 @@ struct dsa_switch_driver mv88e6123_switch_driver = {
.set_addr = mv88e6xxx_set_addr, .set_addr = mv88e6xxx_set_addr,
.phy_read = mv88e6xxx_phy_read, .phy_read = mv88e6xxx_phy_read,
.phy_write = mv88e6xxx_phy_write, .phy_write = mv88e6xxx_phy_write,
.set_eee = mv88e6xxx_set_eee,
.get_eee = mv88e6xxx_get_eee,
.get_strings = mv88e6xxx_get_strings, .get_strings = mv88e6xxx_get_strings,
.get_ethtool_stats = mv88e6xxx_get_ethtool_stats, .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count, .get_sset_count = mv88e6xxx_get_sset_count,
......
...@@ -150,6 +150,8 @@ struct dsa_switch_driver mv88e6131_switch_driver = { ...@@ -150,6 +150,8 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
.set_addr = mv88e6xxx_set_addr, .set_addr = mv88e6xxx_set_addr,
.phy_read = mv88e6xxx_phy_read, .phy_read = mv88e6xxx_phy_read,
.phy_write = mv88e6xxx_phy_write, .phy_write = mv88e6xxx_phy_write,
.set_eee = mv88e6xxx_set_eee,
.get_eee = mv88e6xxx_get_eee,
.get_strings = mv88e6xxx_get_strings, .get_strings = mv88e6xxx_get_strings,
.get_ethtool_stats = mv88e6xxx_get_ethtool_stats, .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count, .get_sset_count = mv88e6xxx_get_sset_count,
......
...@@ -126,6 +126,8 @@ struct dsa_switch_driver mv88e6171_switch_driver = { ...@@ -126,6 +126,8 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.set_addr = mv88e6xxx_set_addr, .set_addr = mv88e6xxx_set_addr,
.phy_read = mv88e6xxx_phy_read, .phy_read = mv88e6xxx_phy_read,
.phy_write = mv88e6xxx_phy_write, .phy_write = mv88e6xxx_phy_write,
.set_eee = mv88e6xxx_set_eee,
.get_eee = mv88e6xxx_get_eee,
.get_strings = mv88e6xxx_get_strings, .get_strings = mv88e6xxx_get_strings,
.get_ethtool_stats = mv88e6xxx_get_ethtool_stats, .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
.get_sset_count = mv88e6xxx_get_sset_count, .get_sset_count = mv88e6xxx_get_sset_count,
......
...@@ -1105,6 +1105,9 @@ int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) ...@@ -1105,6 +1105,9 @@ int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e)
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int reg; int reg;
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE))
return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
reg = _mv88e6xxx_phy_read_indirect(ps, port, 16); reg = _mv88e6xxx_phy_read_indirect(ps, port, 16);
...@@ -1133,6 +1136,9 @@ int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, ...@@ -1133,6 +1136,9 @@ int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
int reg; int reg;
int ret; int ret;
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE))
return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
ret = _mv88e6xxx_phy_read_indirect(ps, port, 16); ret = _mv88e6xxx_phy_read_indirect(ps, port, 16);
......
...@@ -351,6 +351,10 @@ enum mv88e6xxx_family { ...@@ -351,6 +351,10 @@ enum mv88e6xxx_family {
}; };
enum mv88e6xxx_cap { enum mv88e6xxx_cap {
/* Energy Efficient Ethernet.
*/
MV88E6XXX_CAP_EEE,
/* EEPROM Command and Data registers. /* EEPROM Command and Data registers.
* See GLOBAL2_EEPROM_OP and GLOBAL2_EEPROM_DATA. * See GLOBAL2_EEPROM_OP and GLOBAL2_EEPROM_DATA.
*/ */
...@@ -382,6 +386,7 @@ enum mv88e6xxx_cap { ...@@ -382,6 +386,7 @@ enum mv88e6xxx_cap {
}; };
/* Bitmask of capabilities */ /* Bitmask of capabilities */
#define MV88E6XXX_FLAG_EEE BIT(MV88E6XXX_CAP_EEE)
#define MV88E6XXX_FLAG_EEPROM BIT(MV88E6XXX_CAP_EEPROM) #define MV88E6XXX_FLAG_EEPROM BIT(MV88E6XXX_CAP_EEPROM)
#define MV88E6XXX_FLAG_PPU BIT(MV88E6XXX_CAP_PPU) #define MV88E6XXX_FLAG_PPU BIT(MV88E6XXX_CAP_PPU)
#define MV88E6XXX_FLAG_SMI_PHY BIT(MV88E6XXX_CAP_SMI_PHY) #define MV88E6XXX_FLAG_SMI_PHY BIT(MV88E6XXX_CAP_SMI_PHY)
...@@ -403,7 +408,8 @@ enum mv88e6xxx_cap { ...@@ -403,7 +408,8 @@ enum mv88e6xxx_cap {
MV88E6XXX_FLAG_PPU MV88E6XXX_FLAG_PPU
#define MV88E6XXX_FLAGS_FAMILY_6320 \ #define MV88E6XXX_FLAGS_FAMILY_6320 \
(MV88E6XXX_FLAG_EEPROM | \ (MV88E6XXX_FLAG_EEE | \
MV88E6XXX_FLAG_EEPROM | \
MV88E6XXX_FLAG_SMI_PHY | \ MV88E6XXX_FLAG_SMI_PHY | \
MV88E6XXX_FLAG_SWITCH_MAC | \ MV88E6XXX_FLAG_SWITCH_MAC | \
MV88E6XXX_FLAG_TEMP | \ MV88E6XXX_FLAG_TEMP | \
...@@ -415,7 +421,8 @@ enum mv88e6xxx_cap { ...@@ -415,7 +421,8 @@ enum mv88e6xxx_cap {
MV88E6XXX_FLAG_TEMP) MV88E6XXX_FLAG_TEMP)
#define MV88E6XXX_FLAGS_FAMILY_6352 \ #define MV88E6XXX_FLAGS_FAMILY_6352 \
(MV88E6XXX_FLAG_EEPROM | \ (MV88E6XXX_FLAG_EEE | \
MV88E6XXX_FLAG_EEPROM | \
MV88E6XXX_FLAG_SMI_PHY | \ MV88E6XXX_FLAG_SMI_PHY | \
MV88E6XXX_FLAG_SWITCH_MAC | \ MV88E6XXX_FLAG_SWITCH_MAC | \
MV88E6XXX_FLAG_TEMP | \ MV88E6XXX_FLAG_TEMP | \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment