marvell10g tunable and power saving support
Subsystems (4)
Russell King - ARM Linux admin
maintainerv3 cover marvell10g tunable and power saving support
Hi,
This patch series adds support for:
- mdix configuration (auto, mdi, mdix)
- energy detect power down (edpd)
- placing in edpd mode at probe
for both the 88x3310 and 88x2110 PHYs.
Antione, could you test this for the 88x2110 PHY please?
v3: fix return code in get_tunable/set_tunable
v2: fix comments from Antione.
drivers/net/phy/marvell10g.c | 177 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 170 insertions(+), 7 deletions(-)
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
PATCH v3 1/3 net: phy: marvell10g: add mdix control
Add support for controlling the MDI-X state of the PHY.
--- drivers/net/phy/marvell10g.c | 61 ++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-)
drivers/net/phy/marvell10g.c +59 -2
@@ -23,6 +23,7 @@* link takes priority and the other port is completely locked out. */ #include <linux/ctype.h> +#include <linux/delay.h> #include <linux/hwmon.h> #include <linux/marvell_phy.h> #include <linux/phy.h>
@@ -39,6 +40,12 @@ enum {MV_PCS_BASE_R =0x1000 ,MV_PCS_1000BASEX =0x2000 , +MV_PCS_CSCR1 =0x8000 , +MV_PCS_CSCR1_MDIX_MASK =0x0060 , +MV_PCS_CSCR1_MDIX_MDI =0x0000 , +MV_PCS_CSCR1_MDIX_MDIX =0x0020 , +MV_PCS_CSCR1_MDIX_AUTO =0x0060 , +MV_PCS_CSSR1 =0x8008 ,MV_PCS_CSSR1_SPD1_MASK =0xc000 , MV_PCS_CSSR1_SPD1_SPD2 = 0xc000,
@@ -216,6 +223,26 @@ static int mv3310_hwmon_probe(struct phy_device *phydev) }#endif +static int mv3310_reset (struct phy_device *phydev,u32 unit) +{ +int retries, val, err; + + err =phy_modify_mmd (phydev,MDIO_MMD_PCS , unit +MDIO_CTRL1 , +MDIO_CTRL1_RESET ,MDIO_CTRL1_RESET ); +if (err <0 ) +return err; + + retries =20 ; +do { +msleep (5 ); + val =phy_read_mmd (phydev,MDIO_MMD_PCS , unit +MDIO_CTRL1 ); +if (val <0 ) +return val; + }while (val &MDIO_CTRL1_RESET && --retries); + +return val &MDIO_CTRL1_RESET ? -ETIMEDOUT :0 ; +} +static int mv3310_sfp_insert (void *upstream,const struct sfp_eeprom_id *id) {struct phy_device *phydev = upstream;
@@ -316,6 +343,8 @@ static int mv3310_config_init(struct phy_device *phydev) phydev->interface != PHY_INTERFACE_MODE_10GBASER) return -ENODEV; + phydev->mdix_ctrl =ETH_TP_MDI_AUTO ; +return 0 ; }
@@ -345,14 +374,42 @@ static int mv3310_get_features(struct phy_device *phydev)return 0 ; } +static int mv3310_config_mdix (struct phy_device *phydev) +{ +u16 val; +int err; + +switch (phydev->mdix_ctrl) { +case ETH_TP_MDI_AUTO : + val =MV_PCS_CSCR1_MDIX_AUTO ; +break ; +case ETH_TP_MDI_X : + val =MV_PCS_CSCR1_MDIX_MDIX ; +break ; +case ETH_TP_MDI : + val =MV_PCS_CSCR1_MDIX_MDI ; +break ; +default : +return -EINVAL ; + } + + err =phy_modify_mmd_changed (phydev,MDIO_MMD_PCS ,MV_PCS_CSCR1 , +MV_PCS_CSCR1_MDIX_MASK , val); +if (err >0 ) + err =mv3310_reset (phydev,MV_PCS_BASE_T ); + +return err; +} +static int mv3310_config_aneg (struct phy_device *phydev) {bool changed = false;u16 reg;int ret; -/* We don't support manual MDI control */ - phydev->mdix_ctrl =ETH_TP_MDI_AUTO ; + ret =mv3310_config_mdix (phydev); +if (ret <0 ) +return ret;if (phydev->autoneg ==AUTONEG_DISABLE )return genphy_c45_pma_setup_forced (phydev);
Signature · 1 line
2.20.1
Re: [PATCH net-next v3 1/3] net: phy: marvell10g: add mdix control
Quoted 3 lines · Russell King
Add support for controlling the MDI-X state of the PHY.
Signed-off-by Russell King <[email protected]>
Hi Russell, David
It would be nice to have Antoine test this before it get merged, but:
Andrew
David Miller
maintainerRe: [PATCH net-next v3 1/3] net: phy: marvell10g: add mdix control
From: Andrew Lunn <[email protected]>
Date: Tue, 3 Mar 2020 20:53:52 +0100
Quoted 3 lines
It would be nice to have Antoine test this before it get merged, but:
Reviewed-by Andrew Lunn <[email protected]>
Ok, I'll give Antoine a chance to test it out.
Russell King - ARM Linux admin
maintainerRe: [PATCH net-next v3 1/3] net: phy: marvell10g: add mdix control
Quoted 8 lines · David Miller
From: Andrew Lunn <[email protected]>
Date: Tue, 3 Mar 2020 20:53:52 +0100Quoted 3 lines
It would be nice to have Antoine test this before it get merged, but:
Reviewed-by Andrew Lunn <[email protected]>Ok, I'll give Antoine a chance to test it out.
Hi David,
Antoine has now tested it - do I need to resubmit now?
Thanks.
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
David Miller
maintainerRe: [PATCH net-next v3 1/3] net: phy: marvell10g: add mdix control
From: Russell King - ARM Linux admin <[email protected]>
Date: Sat, 7 Mar 2020 09:07:41 +0000
Quoted 6 lines · David Miller
Quoted 5 lines
From: Andrew Lunn <[email protected]>
Date: Tue, 3 Mar 2020 20:53:52 +0100Quoted 2 lines
It would be nice to have Antoine test this before it get merged, but:
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Reviewed-by Andrew Lunn <[email protected]>Ok, I'll give Antoine a chance to test it out.
Hi David,
Antoine has now tested it - do I need to resubmit now?
I am pretty sure I applied this series to net-next. :-)
PATCH v3 2/3 net: phy: marvell10g: add energy detect power down tunable
In reply to Russell King - ARM Linux adminAdd support for the energy detect power down tunable, which saves around 600mW when the link is down. The 88x3310 supports off, rx-only and NLP every second. Enable EDPD by default for 88x3310.
--- drivers/net/phy/marvell10g.c | 86 +++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-)
drivers/net/phy/marvell10g.c +85 -1
@@ -41,6 +41,10 @@ enum {MV_PCS_1000BASEX =0x2000 ,MV_PCS_CSCR1 =0x8000 , +MV_PCS_CSCR1_ED_MASK =0x0300 , +MV_PCS_CSCR1_ED_OFF =0x0000 , +MV_PCS_CSCR1_ED_RX =0x0200 , +MV_PCS_CSCR1_ED_NLP =0x0300 ,MV_PCS_CSCR1_MDIX_MASK =0x0060 ,MV_PCS_CSCR1_MDIX_MDI =0x0000 , MV_PCS_CSCR1_MDIX_MDIX = 0x0020,
@@ -243,6 +247,59 @@ static int mv3310_reset(struct phy_device *phydev, u32 unit)return val &MDIO_CTRL1_RESET ? -ETIMEDOUT :0 ; } +static int mv3310_get_edpd (struct phy_device *phydev,u16 *edpd) +{ +int val; + + val =phy_read_mmd (phydev,MDIO_MMD_PCS ,MV_PCS_CSCR1 ); +if (val <0 ) +return val; + +switch (val &MV_PCS_CSCR1_ED_MASK ) { +case MV_PCS_CSCR1_ED_NLP : + *edpd =1000 ; +break ; +case MV_PCS_CSCR1_ED_RX : + *edpd =ETHTOOL_PHY_EDPD_NO_TX ; +break ; +default : + *edpd =ETHTOOL_PHY_EDPD_DISABLE ; +break ; + } +return 0 ; +} + +static int mv3310_set_edpd (struct phy_device *phydev,u16 edpd) +{ +u16 val; +int err; + +switch (edpd) { +case 1000 : +case ETHTOOL_PHY_EDPD_DFLT_TX_MSECS : + val =MV_PCS_CSCR1_ED_NLP ; +break ; + +case ETHTOOL_PHY_EDPD_NO_TX : + val =MV_PCS_CSCR1_ED_RX ; +break ; + +case ETHTOOL_PHY_EDPD_DISABLE : + val =MV_PCS_CSCR1_ED_OFF ; +break ; + +default : +return -EINVAL ; + } + + err =phy_modify_mmd_changed (phydev,MDIO_MMD_PCS ,MV_PCS_CSCR1 , +MV_PCS_CSCR1_ED_MASK , val); +if (err >0 ) + err =mv3310_reset (phydev,MV_PCS_BASE_T ); + +return err; +} +static int mv3310_sfp_insert (void *upstream,const struct sfp_eeprom_id *id) {struct phy_device *phydev = upstream;
@@ -345,7 +402,8 @@ static int mv3310_config_init(struct phy_device *phydev) phydev->mdix_ctrl =ETH_TP_MDI_AUTO ; -return 0 ; +/* Enable EDPD mode - saving 600mW */ +return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS ); }static int mv3310_get_features (struct phy_device *phydev)
@@ -594,6 +652,28 @@ static int mv3310_read_status(struct phy_device *phydev)return 0 ; } +static int mv3310_get_tunable (struct phy_device *phydev, +struct ethtool_tunable *tuna,void *data) +{ +switch (tuna->id) { +case ETHTOOL_PHY_EDPD : +return mv3310_get_edpd (phydev, data); +default : +return -EOPNOTSUPP ; + } +} + +static int mv3310_set_tunable (struct phy_device *phydev, +struct ethtool_tunable *tuna,const void *data) +{ +switch (tuna->id) { +case ETHTOOL_PHY_EDPD : +return mv3310_set_edpd (phydev, *(u16 *)data); +default : +return -EOPNOTSUPP ; + } +} +static struct phy_driver mv3310_drivers[] = { { .phy_id =MARVELL_PHY_ID_88X3310 ,
@@ -608,6 +688,8 @@ static struct phy_driver mv3310_drivers[] = { .config_aneg = mv3310_config_aneg, .aneg_done = mv3310_aneg_done, .read_status = mv3310_read_status, + .get_tunable = mv3310_get_tunable, + .set_tunable = mv3310_set_tunable, }, { .phy_id = MARVELL_PHY_ID_88E2110,
@@ -621,6 +703,8 @@ static struct phy_driver mv3310_drivers[] = { .config_aneg = mv3310_config_aneg, .aneg_done = mv3310_aneg_done, .read_status = mv3310_read_status, + .get_tunable = mv3310_get_tunable, + .set_tunable = mv3310_set_tunable, }, };
Signature · 1 line
2.20.1
Re: [PATCH net-next v3 2/3] net: phy: marvell10g: add energy detect power down tunable
Quoted 5 lines · Russell King
Add support for the energy detect power down tunable, which saves around 600mW when the link is down. The 88x3310 supports off, rx-only and NLP every second. Enable EDPD by default for 88x3310.
Signed-off-by Russell King <[email protected]>
Andrew
PATCH v3 3/3 net: phy: marvell10g: place in powersave mode at probe
In reply to Russell King - ARM Linux adminPlace the 88x3310 into powersaving mode when probing, which saves 600mW per PHY. For both PHYs on the Macchiatobin double-shot, this saves about 10% of the board idle power.
--- drivers/net/phy/marvell10g.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/net/phy/marvell10g.c +26 -4
@@ -227,6 +227,18 @@ static int mv3310_hwmon_probe(struct phy_device *phydev) }#endif +static int mv3310_power_down (struct phy_device *phydev) +{ +return phy_set_bits_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL , +MV_V2_PORT_CTRL_PWRDOWN ); +} + +static int mv3310_power_up (struct phy_device *phydev) +{ +return phy_clear_bits_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL , +MV_V2_PORT_CTRL_PWRDOWN ); +} +static int mv3310_reset (struct phy_device *phydev,u32 unit) {int retries, val, err;
@@ -348,6 +360,11 @@ static int mv3310_probe(struct phy_device *phydev)dev_set_drvdata (&phydev->mdio.dev, priv); +/* Powering down the port when not in use saves about 600mW */ + ret =mv3310_power_down (phydev); +if (ret) +return ret; + ret =mv3310_hwmon_probe (phydev);if (ret)return ret;
@@ -357,16 +374,14 @@ static int mv3310_probe(struct phy_device *phydev)static int mv3310_suspend (struct phy_device *phydev) { -return phy_set_bits_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL , -MV_V2_PORT_CTRL_PWRDOWN ); +return mv3310_power_down (phydev); }static int mv3310_resume (struct phy_device *phydev) {int ret; - ret =phy_clear_bits_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL , -MV_V2_PORT_CTRL_PWRDOWN ); + ret =mv3310_power_up (phydev);if (ret)return ret;
@@ -392,6 +407,8 @@ static bool mv3310_has_pma_ngbaset_quirk(struct phy_device *phydev)static int mv3310_config_init (struct phy_device *phydev) { +int err; +/* Check that the PHY interface type is compatible */ if (phydev->interface != PHY_INTERFACE_MODE_SGMII && phydev->interface != PHY_INTERFACE_MODE_2500BASEX &&
@@ -402,6 +419,11 @@ static int mv3310_config_init(struct phy_device *phydev) phydev->mdix_ctrl =ETH_TP_MDI_AUTO ; +/* Power up so reset works */ + err =mv3310_power_up (phydev); +if (err) +return err; +/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS ); }
Signature · 1 line
2.20.1
Hello Russell,
Quoted 9 lines · Russell King - ARM Linux admin
This patch series adds support for:
- mdix configuration (auto, mdi, mdix)
- energy detect power down (edpd)
- placing in edpd mode at probefor both the 88x3310 and 88x2110 PHYs.
Antione, could you test this for the 88x2110 PHY please?
Thanks!
Antoine
Quoted 10 lines
v3: fix return code in get_tunable/set_tunable
v2: fix comments from Antione.drivers/net/phy/marvell10g.c | 177 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 170 insertions(+), 7 deletions(-)Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Signature · 3 lines
Antoine Ténart, Bootlin Embedded Linux and Kernel engineering https://bootlin.com