History

net: phy: add genphy_c45_an_config_aneg

C45 configuration of 10/100 and multi-giga bit auto negotiation advertisement is standardized. Configuration of 1000Base-T however appears to be vendor specific. Move the generic code out of the Marvell driver into the common phy-c45.c file. v2: - change function name to genphy_c45_an_config_aneg

Andrew Lunn committed 7 years ago

Commit 9a5dc8a1 parent 744e4582 files · +45 −0Browse files

Unified · Split

2 files
  1. drivers/net/phy/phy-c45.c +44 −0
  2. include/linux/phy.h +1 −0
drivers/net/phy/phy-c45.c+44−0
@@ -74,6 +74,50 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev) · 73 unmodified lines
74}74}
75EXPORT_SYMBOL_GPL(genphy_c45_pma_setup_forced);75EXPORT_SYMBOL_GPL(genphy_c45_pma_setup_forced);
76 76
77/**
78 * genphy_c45_an_config_aneg - configure advertisement registers
79 * @phydev: target phy_device struct
80 *
81 * Configure advertisement registers based on modes set in phydev->advertising
82 *
83 * Returns negative errno code on failure, 0 if advertisement didn't change,
84 * or 1 if advertised modes changed.
85 */
86int genphy_c45_an_config_aneg(struct phy_device *phydev)
87{
88 int changed = 0, ret;
89 u32 adv;
90
91 linkmode_and(phydev->advertising, phydev->advertising,
92 phydev->supported);
93
94 adv = linkmode_adv_to_mii_adv_t(phydev->advertising);
95
96 ret = phy_modify_mmd(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE,
97 ADVERTISE_ALL | ADVERTISE_100BASE4 |
98 ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM,
99 adv);
100 if (ret < 0)
101 return ret;
102 if (ret > 0)
103 changed = 1;
104
105 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising);
106
107 ret = phy_modify_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
108 MDIO_AN_10GBT_CTRL_ADV10G |
109 MDIO_AN_10GBT_CTRL_ADV5G |
110 MDIO_AN_10GBT_CTRL_ADV2_5G,
111 adv);
112 if (ret < 0)
113 return ret;
114 if (ret > 0)
115 changed = 1;
116
117 return changed;
118}
119EXPORT_SYMBOL_GPL(genphy_c45_an_config_aneg);
120
77/**121/**
78 * genphy_c45_an_disable_aneg - disable auto-negotiation122 * genphy_c45_an_disable_aneg - disable auto-negotiation
79 * @phydev: target phy_device struct123 * @phydev: target phy_device struct
include/linux/phy.h+1−0
@@ -1101,6 +1101,7 @@ int genphy_c45_read_link(struct phy_device *phydev); · 1100 unmodified lines
1101int genphy_c45_read_lpa(struct phy_device *phydev);1101int genphy_c45_read_lpa(struct phy_device *phydev);
1102int genphy_c45_read_pma(struct phy_device *phydev);1102int genphy_c45_read_pma(struct phy_device *phydev);
1103int genphy_c45_pma_setup_forced(struct phy_device *phydev);1103int genphy_c45_pma_setup_forced(struct phy_device *phydev);
1104int genphy_c45_an_config_aneg(struct phy_device *phydev);
1104int genphy_c45_an_disable_aneg(struct phy_device *phydev);1105int genphy_c45_an_disable_aneg(struct phy_device *phydev);
1105int genphy_c45_read_mdix(struct phy_device *phydev);1106int genphy_c45_read_mdix(struct phy_device *phydev);
1106int genphy_c45_pma_read_abilities(struct phy_device *phydev);1107int genphy_c45_pma_read_abilities(struct phy_device *phydev);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t