Commit 65ac79e1 authored by Arun Ramadoss's avatar Arun Ramadoss Committed by David S. Miller

net: dsa: microchip: add the phylink get_caps

This patch add the support for phylink_get_caps for ksz8795 and ksz9477
series switch. It updates the struct ksz_switch_chip with the details of
the internal phys and xmii interface. Then during the get_caps based on
the bits set in the structure, corresponding phy mode is set.
Signed-off-by: default avatarArun Ramadoss <arun.ramadoss@microchip.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b094c679
...@@ -1376,15 +1376,7 @@ static void ksz8_get_caps(struct dsa_switch *ds, int port, ...@@ -1376,15 +1376,7 @@ static void ksz8_get_caps(struct dsa_switch *ds, int port,
{ {
struct ksz_device *dev = ds->priv; struct ksz_device *dev = ds->priv;
if (port == dev->cpu_port) { ksz_phylink_get_caps(ds, port, config);
__set_bit(PHY_INTERFACE_MODE_RMII,
config->supported_interfaces);
__set_bit(PHY_INTERFACE_MODE_MII,
config->supported_interfaces);
} else {
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
config->supported_interfaces);
}
config->mac_capabilities = MAC_10 | MAC_100; config->mac_capabilities = MAC_10 | MAC_100;
......
...@@ -1097,6 +1097,15 @@ static void ksz9477_phy_errata_setup(struct ksz_device *dev, int port) ...@@ -1097,6 +1097,15 @@ static void ksz9477_phy_errata_setup(struct ksz_device *dev, int port)
ksz9477_port_mmd_write(dev, port, 0x1c, 0x20, 0xeeee); ksz9477_port_mmd_write(dev, port, 0x1c, 0x20, 0xeeee);
} }
static void ksz9477_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{
ksz_phylink_get_caps(ds, port, config);
config->mac_capabilities = MAC_10 | MAC_100 | MAC_1000FD |
MAC_ASYM_PAUSE | MAC_SYM_PAUSE;
}
static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port) static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
{ {
struct ksz_port *p = &dev->ports[port]; struct ksz_port *p = &dev->ports[port];
...@@ -1322,6 +1331,7 @@ static const struct dsa_switch_ops ksz9477_switch_ops = { ...@@ -1322,6 +1331,7 @@ static const struct dsa_switch_ops ksz9477_switch_ops = {
.phy_read = ksz9477_phy_read16, .phy_read = ksz9477_phy_read16,
.phy_write = ksz9477_phy_write16, .phy_write = ksz9477_phy_write16,
.phylink_mac_link_down = ksz_mac_link_down, .phylink_mac_link_down = ksz_mac_link_down,
.phylink_get_caps = ksz9477_get_caps,
.port_enable = ksz_enable_port, .port_enable = ksz_enable_port,
.get_strings = ksz_get_strings, .get_strings = ksz_get_strings,
.get_ethtool_stats = ksz_get_ethtool_stats, .get_ethtool_stats = ksz_get_ethtool_stats,
......
...@@ -151,6 +151,10 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -151,6 +151,10 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
.internal_phy = {true, true, true, true, false},
}, },
[KSZ8794] = { [KSZ8794] = {
...@@ -179,6 +183,10 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -179,6 +183,10 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
.internal_phy = {true, true, true, false, false},
}, },
[KSZ8765] = { [KSZ8765] = {
...@@ -193,6 +201,10 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -193,6 +201,10 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
.internal_phy = {true, true, true, true, false},
}, },
[KSZ8830] = { [KSZ8830] = {
...@@ -206,6 +218,9 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -206,6 +218,9 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz88xx_mib_names, .mib_names = ksz88xx_mib_names,
.mib_cnt = ARRAY_SIZE(ksz88xx_mib_names), .mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, true},
.supports_rmii = {false, false, true},
.internal_phy = {true, true, false},
}, },
[KSZ9477] = { [KSZ9477] = {
...@@ -220,6 +235,14 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -220,6 +235,14 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false,
false, true, false},
.supports_rmii = {false, false, false, false,
false, true, false},
.supports_rgmii = {false, false, false, false,
false, true, false},
.internal_phy = {true, true, true, true,
true, false, false},
}, },
[KSZ9897] = { [KSZ9897] = {
...@@ -234,6 +257,14 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -234,6 +257,14 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false,
false, true, true},
.supports_rmii = {false, false, false, false,
false, true, true},
.supports_rgmii = {false, false, false, false,
false, true, true},
.internal_phy = {true, true, true, true,
true, false, false},
}, },
[KSZ9893] = { [KSZ9893] = {
...@@ -247,6 +278,10 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -247,6 +278,10 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, true},
.supports_rmii = {false, false, true},
.supports_rgmii = {false, false, true},
.internal_phy = {true, true, false},
}, },
[KSZ9567] = { [KSZ9567] = {
...@@ -261,6 +296,14 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -261,6 +296,14 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false,
false, true, true},
.supports_rmii = {false, false, false, false,
false, true, true},
.supports_rgmii = {false, false, false, false,
false, true, true},
.internal_phy = {true, true, true, true,
true, false, false},
}, },
[LAN9370] = { [LAN9370] = {
...@@ -274,6 +317,10 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -274,6 +317,10 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
.internal_phy = {true, true, true, true, false},
}, },
[LAN9371] = { [LAN9371] = {
...@@ -287,6 +334,10 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -287,6 +334,10 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false, true, true},
.supports_rmii = {false, false, false, false, true, true},
.supports_rgmii = {false, false, false, false, true, true},
.internal_phy = {true, true, true, true, false, false},
}, },
[LAN9372] = { [LAN9372] = {
...@@ -300,6 +351,14 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -300,6 +351,14 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false,
true, true, false, false},
.supports_rmii = {false, false, false, false,
true, true, false, false},
.supports_rgmii = {false, false, false, false,
true, true, false, false},
.internal_phy = {true, true, true, true,
false, false, true, true},
}, },
[LAN9373] = { [LAN9373] = {
...@@ -313,6 +372,14 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -313,6 +372,14 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false,
true, true, false, false},
.supports_rmii = {false, false, false, false,
true, true, false, false},
.supports_rgmii = {false, false, false, false,
true, true, false, false},
.internal_phy = {true, true, true, false,
false, false, true, true},
}, },
[LAN9374] = { [LAN9374] = {
...@@ -326,6 +393,14 @@ const struct ksz_chip_data ksz_switch_chips[] = { ...@@ -326,6 +393,14 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_names = ksz9477_mib_names, .mib_names = ksz9477_mib_names,
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM, .reg_mib_cnt = MIB_COUNTER_NUM,
.supports_mii = {false, false, false, false,
true, true, false, false},
.supports_rmii = {false, false, false, false,
true, true, false, false},
.supports_rgmii = {false, false, false, false,
true, true, false, false},
.internal_phy = {true, true, true, true,
false, false, true, true},
}, },
}; };
EXPORT_SYMBOL_GPL(ksz_switch_chips); EXPORT_SYMBOL_GPL(ksz_switch_chips);
...@@ -361,6 +436,29 @@ static int ksz_check_device_id(struct ksz_device *dev) ...@@ -361,6 +436,29 @@ static int ksz_check_device_id(struct ksz_device *dev)
return 0; return 0;
} }
void ksz_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{
struct ksz_device *dev = ds->priv;
config->legacy_pre_march2020 = false;
if (dev->info->supports_mii[port])
__set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces);
if (dev->info->supports_rmii[port])
__set_bit(PHY_INTERFACE_MODE_RMII,
config->supported_interfaces);
if (dev->info->supports_rgmii[port])
phy_interface_set_rgmii(config->supported_interfaces);
if (dev->info->internal_phy[port])
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
config->supported_interfaces);
}
EXPORT_SYMBOL_GPL(ksz_phylink_get_caps);
void ksz_r_mib_stats64(struct ksz_device *dev, int port) void ksz_r_mib_stats64(struct ksz_device *dev, int port)
{ {
struct rtnl_link_stats64 *stats; struct rtnl_link_stats64 *stats;
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <linux/regmap.h> #include <linux/regmap.h>
#include <net/dsa.h> #include <net/dsa.h>
#define KSZ_MAX_NUM_PORTS 8
struct vlan_table { struct vlan_table {
u32 table[3]; u32 table[3];
}; };
...@@ -44,6 +46,10 @@ struct ksz_chip_data { ...@@ -44,6 +46,10 @@ struct ksz_chip_data {
const struct ksz_mib_names *mib_names; const struct ksz_mib_names *mib_names;
int mib_cnt; int mib_cnt;
u8 reg_mib_cnt; u8 reg_mib_cnt;
bool supports_mii[KSZ_MAX_NUM_PORTS];
bool supports_rmii[KSZ_MAX_NUM_PORTS];
bool supports_rgmii[KSZ_MAX_NUM_PORTS];
bool internal_phy[KSZ_MAX_NUM_PORTS];
}; };
struct ksz_port { struct ksz_port {
...@@ -198,6 +204,8 @@ void ksz_init_mib_timer(struct ksz_device *dev); ...@@ -198,6 +204,8 @@ void ksz_init_mib_timer(struct ksz_device *dev);
void ksz_r_mib_stats64(struct ksz_device *dev, int port); void ksz_r_mib_stats64(struct ksz_device *dev, int port);
void ksz_get_stats64(struct dsa_switch *ds, int port, void ksz_get_stats64(struct dsa_switch *ds, int port,
struct rtnl_link_stats64 *s); struct rtnl_link_stats64 *s);
void ksz_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config);
extern const struct ksz_chip_data ksz_switch_chips[]; extern const struct ksz_chip_data ksz_switch_chips[];
/* Common DSA access functions */ /* Common DSA access functions */
......
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