Skip to content

Commit 9b0bf4f

Browse files
committed
Merge branch 'ksz9477-eee-support'
Oleksij Rempel says: ==================== net: add EEE support for KSZ9477 switch family changes v8: - fix comment for linkmode_to_mii_eee_cap1_t() function - add Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com> - add Reviewed-by: Alexander Duyck <alexanderduyck@fb.com> changes v7: - update documentation for genphy_c45_eee_is_active() - address review comments on "net: dsa: microchip: enable EEE support" patch changes v6: - split patch set and send only first 9 patches - Add Reviewed-by: Andrew Lunn <andrew@lunn.ch> - use 0xffff instead of GENMASK - Document @supported_eee - use "()" with function name in comments changes v5: - spell fixes - move part of genphy_c45_read_eee_abilities() to genphy_c45_read_eee_cap1() - validate MDIO_PCS_EEE_ABLE register against 0xffff val. - rename *eee_100_10000* to *eee_cap1* - use linkmode_intersects(phydev->supported, PHY_EEE_CAP1_FEATURES) instead of !linkmode_empty() - add documentation to linkmode/register helpers changes v4: - remove following helpers: mmd_eee_cap_to_ethtool_sup_t mmd_eee_adv_to_ethtool_adv_t ethtool_adv_to_mmd_eee_adv_t and port drivers from this helpers to linkmode helpers. - rebase against latest net-next - port phy_init_eee() to genphy_c45_eee_is_active() changes v3: - rework some parts of EEE infrastructure and move it to c45 code. - add supported_eee storage and start using it in EEE code and by the micrel driver. - add EEE support for ar8035 PHY - add SmartEEE support to FEC i.MX series. changes v2: - use phydev->supported instead of reading MII_BMSR regiaster - fix @get_eee > @set_eee With this patch series we provide EEE control for KSZ9477 family of switches and AR8035 with i.MX6 configuration. According to my tests, on a system with KSZ8563 switch and 100Mbit idle link, we consume 0,192W less power per port if EEE is enabled. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 79cdf17 + 8b68710 commit 9b0bf4f

File tree

8 files changed

+554
-137
lines changed

8 files changed

+554
-137
lines changed

drivers/net/dsa/microchip/ksz_common.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,6 +2673,70 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
26732673
return -EOPNOTSUPP;
26742674
}
26752675

2676+
static int ksz_validate_eee(struct dsa_switch *ds, int port)
2677+
{
2678+
struct ksz_device *dev = ds->priv;
2679+
2680+
if (!dev->info->internal_phy[port])
2681+
return -EOPNOTSUPP;
2682+
2683+
switch (dev->chip_id) {
2684+
case KSZ8563_CHIP_ID:
2685+
case KSZ9477_CHIP_ID:
2686+
case KSZ9563_CHIP_ID:
2687+
case KSZ9567_CHIP_ID:
2688+
case KSZ9893_CHIP_ID:
2689+
case KSZ9896_CHIP_ID:
2690+
case KSZ9897_CHIP_ID:
2691+
return 0;
2692+
}
2693+
2694+
return -EOPNOTSUPP;
2695+
}
2696+
2697+
static int ksz_get_mac_eee(struct dsa_switch *ds, int port,
2698+
struct ethtool_eee *e)
2699+
{
2700+
int ret;
2701+
2702+
ret = ksz_validate_eee(ds, port);
2703+
if (ret)
2704+
return ret;
2705+
2706+
/* There is no documented control of Tx LPI configuration. */
2707+
e->tx_lpi_enabled = true;
2708+
2709+
/* There is no documented control of Tx LPI timer. According to tests
2710+
* Tx LPI timer seems to be set by default to minimal value.
2711+
*/
2712+
e->tx_lpi_timer = 0;
2713+
2714+
return 0;
2715+
}
2716+
2717+
static int ksz_set_mac_eee(struct dsa_switch *ds, int port,
2718+
struct ethtool_eee *e)
2719+
{
2720+
struct ksz_device *dev = ds->priv;
2721+
int ret;
2722+
2723+
ret = ksz_validate_eee(ds, port);
2724+
if (ret)
2725+
return ret;
2726+
2727+
if (!e->tx_lpi_enabled) {
2728+
dev_err(dev->dev, "Disabling EEE Tx LPI is not supported\n");
2729+
return -EINVAL;
2730+
}
2731+
2732+
if (e->tx_lpi_timer) {
2733+
dev_err(dev->dev, "Setting EEE Tx LPI timer is not supported\n");
2734+
return -EINVAL;
2735+
}
2736+
2737+
return 0;
2738+
}
2739+
26762740
static void ksz_set_xmii(struct ksz_device *dev, int port,
26772741
phy_interface_t interface)
26782742
{
@@ -3130,6 +3194,8 @@ static const struct dsa_switch_ops ksz_switch_ops = {
31303194
.port_txtstamp = ksz_port_txtstamp,
31313195
.port_rxtstamp = ksz_port_rxtstamp,
31323196
.port_setup_tc = ksz_setup_tc,
3197+
.get_mac_eee = ksz_get_mac_eee,
3198+
.set_mac_eee = ksz_set_mac_eee,
31333199
};
31343200

31353201
struct ksz_device *ksz_switch_alloc(struct device *base, void *priv)

drivers/net/phy/micrel.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,26 @@ static int ksz9131_config_aneg(struct phy_device *phydev)
13921392
return genphy_config_aneg(phydev);
13931393
}
13941394

1395+
static int ksz9477_get_features(struct phy_device *phydev)
1396+
{
1397+
int ret;
1398+
1399+
ret = genphy_read_abilities(phydev);
1400+
if (ret)
1401+
return ret;
1402+
1403+
/* The "EEE control and capability 1" (Register 3.20) seems to be
1404+
* influenced by the "EEE advertisement 1" (Register 7.60). Changes
1405+
* on the 7.60 will affect 3.20. So, we need to construct our own list
1406+
* of caps.
1407+
* KSZ8563R should have 100BaseTX/Full only.
1408+
*/
1409+
linkmode_and(phydev->supported_eee, phydev->supported,
1410+
PHY_EEE_CAP1_FEATURES);
1411+
1412+
return 0;
1413+
}
1414+
13951415
#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
13961416
#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX BIT(6)
13971417
#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED BIT(4)
@@ -4172,6 +4192,7 @@ static struct phy_driver ksphy_driver[] = {
41724192
.handle_interrupt = kszphy_handle_interrupt,
41734193
.suspend = genphy_suspend,
41744194
.resume = genphy_resume,
4195+
.get_features = ksz9477_get_features,
41754196
} };
41764197

41774198
module_phy_driver(ksphy_driver);

0 commit comments

Comments
 (0)