// SPDX-License-Identifier: GPL-2.0-only /* * mdio.c: Generic support for MDIO-compatible transceivers * Copyright 2006-2009 Solarflare Communications Inc. */ #include <linux/kernel.h> #include <linux/capability.h> #include <linux/errno.h> #include <linux/ethtool.h> #include <linux/mdio.h> #include <linux/module.h> MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; /** * mdio45_probe - probe for an MDIO (clause 45) device * @mdio: MDIO interface * @prtad: Expected PHY address * * This sets @prtad and @mmds in the MDIO interface if successful. * Returns 0 on success, negative on error. */ int mdio45_probe(struct mdio_if_info *mdio, int prtad) { … } EXPORT_SYMBOL(…); /** * mdio_set_flag - set or clear flag in an MDIO register * @mdio: MDIO interface * @prtad: PHY address * @devad: MMD address * @addr: Register address * @mask: Mask for flag (single bit set) * @sense: New value of flag * * This debounces changes: it does not write the register if the flag * already has the proper value. Returns 0 on success, negative on error. */ int mdio_set_flag(const struct mdio_if_info *mdio, int prtad, int devad, u16 addr, int mask, bool sense) { … } EXPORT_SYMBOL(…); /** * mdio45_links_ok - is link status up/OK * @mdio: MDIO interface * @mmd_mask: Mask for MMDs to check * * Returns 1 if the PHY reports link status up/OK, 0 otherwise. * @mmd_mask is normally @mdio->mmds, but if loopback is enabled * the MMDs being bypassed should be excluded from the mask. */ int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmd_mask) { … } EXPORT_SYMBOL(…); /** * mdio45_nway_restart - restart auto-negotiation for this interface * @mdio: MDIO interface * * Returns 0 on success, negative on error. */ int mdio45_nway_restart(const struct mdio_if_info *mdio) { … } EXPORT_SYMBOL(…); static u32 mdio45_get_an(const struct mdio_if_info *mdio, u16 addr) { … } /** * mdio45_ethtool_gset_npage - get settings for ETHTOOL_GSET * @mdio: MDIO interface * @ecmd: Ethtool request structure * @npage_adv: Modes currently advertised on next pages * @npage_lpa: Modes advertised by link partner on next pages * * The @ecmd parameter is expected to have been cleared before calling * mdio45_ethtool_gset_npage(). * * Since the CSRs for auto-negotiation using next pages are not fully * standardised, this function does not attempt to decode them. The * caller must pass them in. */ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio, struct ethtool_cmd *ecmd, u32 npage_adv, u32 npage_lpa) { … } EXPORT_SYMBOL(…); /** * mdio45_ethtool_ksettings_get_npage - get settings for ETHTOOL_GLINKSETTINGS * @mdio: MDIO interface * @cmd: Ethtool request structure * @npage_adv: Modes currently advertised on next pages * @npage_lpa: Modes advertised by link partner on next pages * * The @cmd parameter is expected to have been cleared before calling * mdio45_ethtool_ksettings_get_npage(). * * Since the CSRs for auto-negotiation using next pages are not fully * standardised, this function does not attempt to decode them. The * caller must pass them in. */ void mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio, struct ethtool_link_ksettings *cmd, u32 npage_adv, u32 npage_lpa) { … } EXPORT_SYMBOL(…); /** * mdio_mii_ioctl - MII ioctl interface for MDIO (clause 22 or 45) PHYs * @mdio: MDIO interface * @mii_data: MII ioctl data structure * @cmd: MII ioctl command * * Returns 0 on success, negative on error. */ int mdio_mii_ioctl(const struct mdio_if_info *mdio, struct mii_ioctl_data *mii_data, int cmd) { … } EXPORT_SYMBOL(…);