Commit ecc2ae61 authored by Matthias Schiffer's avatar Matthias Schiffer Committed by Jakub Kicinski

net: phy: marvell: add support for MV88E6250 family internal PHYs

The embedded PHYs of the 88E6250 family switches are very basic - they
do not even have an Extended Address / Page register.

This adds support for the PHYs to the driver to set up PHY interrupts
and retrieve error stats. To deal with PHYs without a page register,
"simple" variants of all stat handling functions are introduced.

The code should work with all 88E6250 family switches (6250/6220/6071/
6070/6020). The PHY ID 0x01410db0 was read from a 88E6020, under the
assumption that all switches of this family use the same ID. The spec
only lists the prefix 0x01410c00 and leaves the last 10 bits as reserved,
but that seems too unspecific to be useful, as it would cover several
existing PHY IDs already supported by the driver; therefore, the ID read
from the actual hardware is used.
Signed-off-by: default avatarMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/0695f699cd942e6e06da9d30daeedfd47785bc01.1714643285.git.matthias.schiffer@ew.tq-group.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 71dd027a
...@@ -301,6 +301,7 @@ ...@@ -301,6 +301,7 @@
#define LPA_PAUSE_ASYM_FIBER 0x100 #define LPA_PAUSE_ASYM_FIBER 0x100
#define NB_FIBER_STATS 1 #define NB_FIBER_STATS 1
#define NB_STAT_MAX 3
MODULE_DESCRIPTION("Marvell PHY driver"); MODULE_DESCRIPTION("Marvell PHY driver");
MODULE_AUTHOR("Andy Fleming"); MODULE_AUTHOR("Andy Fleming");
...@@ -319,6 +320,23 @@ static const struct marvell_hw_stat marvell_hw_stats[] = { ...@@ -319,6 +320,23 @@ static const struct marvell_hw_stat marvell_hw_stats[] = {
{ "phy_receive_errors_fiber", 1, 21, 16}, { "phy_receive_errors_fiber", 1, 21, 16},
}; };
static_assert(ARRAY_SIZE(marvell_hw_stats) <= NB_STAT_MAX);
/* "simple" stat list + corresponding marvell_get_*_simple functions are used
* on PHYs without a page register
*/
struct marvell_hw_stat_simple {
const char *string;
u8 reg;
u8 bits;
};
static const struct marvell_hw_stat_simple marvell_hw_stats_simple[] = {
{ "phy_receive_errors", 21, 16},
};
static_assert(ARRAY_SIZE(marvell_hw_stats_simple) <= NB_STAT_MAX);
enum { enum {
M88E3082_VCT_OFF, M88E3082_VCT_OFF,
M88E3082_VCT_PHASE1, M88E3082_VCT_PHASE1,
...@@ -326,7 +344,7 @@ enum { ...@@ -326,7 +344,7 @@ enum {
}; };
struct marvell_priv { struct marvell_priv {
u64 stats[ARRAY_SIZE(marvell_hw_stats)]; u64 stats[NB_STAT_MAX];
char *hwmon_name; char *hwmon_name;
struct device *hwmon_dev; struct device *hwmon_dev;
bool cable_test_tdr; bool cable_test_tdr;
...@@ -1978,6 +1996,11 @@ static int marvell_get_sset_count(struct phy_device *phydev) ...@@ -1978,6 +1996,11 @@ static int marvell_get_sset_count(struct phy_device *phydev)
return ARRAY_SIZE(marvell_hw_stats) - NB_FIBER_STATS; return ARRAY_SIZE(marvell_hw_stats) - NB_FIBER_STATS;
} }
static int marvell_get_sset_count_simple(struct phy_device *phydev)
{
return ARRAY_SIZE(marvell_hw_stats_simple);
}
static void marvell_get_strings(struct phy_device *phydev, u8 *data) static void marvell_get_strings(struct phy_device *phydev, u8 *data)
{ {
int count = marvell_get_sset_count(phydev); int count = marvell_get_sset_count(phydev);
...@@ -1989,6 +2012,17 @@ static void marvell_get_strings(struct phy_device *phydev, u8 *data) ...@@ -1989,6 +2012,17 @@ static void marvell_get_strings(struct phy_device *phydev, u8 *data)
} }
} }
static void marvell_get_strings_simple(struct phy_device *phydev, u8 *data)
{
int count = marvell_get_sset_count_simple(phydev);
int i;
for (i = 0; i < count; i++) {
strscpy(data + i * ETH_GSTRING_LEN,
marvell_hw_stats_simple[i].string, ETH_GSTRING_LEN);
}
}
static u64 marvell_get_stat(struct phy_device *phydev, int i) static u64 marvell_get_stat(struct phy_device *phydev, int i)
{ {
struct marvell_hw_stat stat = marvell_hw_stats[i]; struct marvell_hw_stat stat = marvell_hw_stats[i];
...@@ -2008,6 +2042,25 @@ static u64 marvell_get_stat(struct phy_device *phydev, int i) ...@@ -2008,6 +2042,25 @@ static u64 marvell_get_stat(struct phy_device *phydev, int i)
return ret; return ret;
} }
static u64 marvell_get_stat_simple(struct phy_device *phydev, int i)
{
struct marvell_hw_stat_simple stat = marvell_hw_stats_simple[i];
struct marvell_priv *priv = phydev->priv;
int val;
u64 ret;
val = phy_read(phydev, stat.reg);
if (val < 0) {
ret = U64_MAX;
} else {
val = val & ((1 << stat.bits) - 1);
priv->stats[i] += val;
ret = priv->stats[i];
}
return ret;
}
static void marvell_get_stats(struct phy_device *phydev, static void marvell_get_stats(struct phy_device *phydev,
struct ethtool_stats *stats, u64 *data) struct ethtool_stats *stats, u64 *data)
{ {
...@@ -2018,6 +2071,16 @@ static void marvell_get_stats(struct phy_device *phydev, ...@@ -2018,6 +2071,16 @@ static void marvell_get_stats(struct phy_device *phydev,
data[i] = marvell_get_stat(phydev, i); data[i] = marvell_get_stat(phydev, i);
} }
static void marvell_get_stats_simple(struct phy_device *phydev,
struct ethtool_stats *stats, u64 *data)
{
int count = marvell_get_sset_count_simple(phydev);
int i;
for (i = 0; i < count; i++)
data[i] = marvell_get_stat_simple(phydev, i);
}
static int m88e1510_loopback(struct phy_device *phydev, bool enable) static int m88e1510_loopback(struct phy_device *phydev, bool enable)
{ {
int err; int err;
...@@ -3924,6 +3987,21 @@ static struct phy_driver marvell_drivers[] = { ...@@ -3924,6 +3987,21 @@ static struct phy_driver marvell_drivers[] = {
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
}, },
{
.phy_id = MARVELL_PHY_ID_88E6250_FAMILY,
.phy_id_mask = MARVELL_PHY_ID_MASK,
.name = "Marvell 88E6250 Family",
/* PHY_BASIC_FEATURES */
.probe = marvell_probe,
.aneg_done = marvell_aneg_done,
.config_intr = marvell_config_intr,
.handle_interrupt = marvell_handle_interrupt,
.resume = genphy_resume,
.suspend = genphy_suspend,
.get_sset_count = marvell_get_sset_count_simple,
.get_strings = marvell_get_strings_simple,
.get_stats = marvell_get_stats_simple,
},
{ {
.phy_id = MARVELL_PHY_ID_88E6341_FAMILY, .phy_id = MARVELL_PHY_ID_88E6341_FAMILY,
.phy_id_mask = MARVELL_PHY_ID_MASK, .phy_id_mask = MARVELL_PHY_ID_MASK,
...@@ -4072,6 +4150,7 @@ static struct mdio_device_id __maybe_unused marvell_tbl[] = { ...@@ -4072,6 +4150,7 @@ static struct mdio_device_id __maybe_unused marvell_tbl[] = {
{ MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK },
{ MARVELL_PHY_ID_88E1545, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1545, MARVELL_PHY_ID_MASK },
{ MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
{ MARVELL_PHY_ID_88E6250_FAMILY, MARVELL_PHY_ID_MASK },
{ MARVELL_PHY_ID_88E6341_FAMILY, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E6341_FAMILY, MARVELL_PHY_ID_MASK },
{ MARVELL_PHY_ID_88E6390_FAMILY, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E6390_FAMILY, MARVELL_PHY_ID_MASK },
{ MARVELL_PHY_ID_88E6393_FAMILY, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E6393_FAMILY, MARVELL_PHY_ID_MASK },
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
/* Marvel 88E1111 in Finisar SFP module with modified PHY ID */ /* Marvel 88E1111 in Finisar SFP module with modified PHY ID */
#define MARVELL_PHY_ID_88E1111_FINISAR 0x01ff0cc0 #define MARVELL_PHY_ID_88E1111_FINISAR 0x01ff0cc0
/* ID from 88E6020, assumed to be the same for the whole 6250 family */
#define MARVELL_PHY_ID_88E6250_FAMILY 0x01410db0
/* These Ethernet switch families contain embedded PHYs, but they do /* These Ethernet switch families contain embedded PHYs, but they do
* not have a model ID. So the switch driver traps reads to the ID2 * not have a model ID. So the switch driver traps reads to the ID2
* register and returns the switch family ID * register and returns the switch family ID
......
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