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
Unified · Split
| @@ -74,6 +74,50 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev) · 73 unmodified lines | |||
| 74 | } | 74 | } |
| 75 | EXPORT_SYMBOL_GPL(genphy_c45_pma_setup_forced); | 75 | EXPORT_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 | */ | ||
| 86 | int 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 | } | ||
| 119 | EXPORT_SYMBOL_GPL(genphy_c45_an_config_aneg); | ||
| 120 | |||
| 77 | /** | 121 | /** |
| 78 | * genphy_c45_an_disable_aneg - disable auto-negotiation | 122 | * genphy_c45_an_disable_aneg - disable auto-negotiation |
| 79 | * @phydev: target phy_device struct | 123 | * @phydev: target phy_device struct |
| @@ -1101,6 +1101,7 @@ int genphy_c45_read_link(struct phy_device *phydev); · 1100 unmodified lines | |||
| 1101 | int genphy_c45_read_lpa(struct phy_device *phydev); | 1101 | int genphy_c45_read_lpa(struct phy_device *phydev); |
| 1102 | int genphy_c45_read_pma(struct phy_device *phydev); | 1102 | int genphy_c45_read_pma(struct phy_device *phydev); |
| 1103 | int genphy_c45_pma_setup_forced(struct phy_device *phydev); | 1103 | int genphy_c45_pma_setup_forced(struct phy_device *phydev); |
| 1104 | int genphy_c45_an_config_aneg(struct phy_device *phydev); | ||
| 1104 | int genphy_c45_an_disable_aneg(struct phy_device *phydev); | 1105 | int genphy_c45_an_disable_aneg(struct phy_device *phydev); |
| 1105 | int genphy_c45_read_mdix(struct phy_device *phydev); | 1106 | int genphy_c45_read_mdix(struct phy_device *phydev); |
| 1106 | int genphy_c45_pma_read_abilities(struct phy_device *phydev); | 1107 | int genphy_c45_pma_read_abilities(struct phy_device *phydev); |