Skip to content

Commit 5d58a89

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: phy: add phy_config_inband()
Add a method to configure the PHY's in-band mode. Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1c86828 commit 5d58a89

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

drivers/net/phy/phy.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,38 @@ unsigned int phy_inband_caps(struct phy_device *phydev,
10261026
}
10271027
EXPORT_SYMBOL_GPL(phy_inband_caps);
10281028

1029+
/**
1030+
* phy_config_inband - configure the desired PHY in-band mode
1031+
* @phydev: the phy_device struct
1032+
* @modes: in-band modes to configure
1033+
*
1034+
* Description: disables, enables or enables-with-bypass in-band signalling
1035+
* between the PHY and host system.
1036+
*
1037+
* Returns: zero on success, or negative errno value.
1038+
*/
1039+
int phy_config_inband(struct phy_device *phydev, unsigned int modes)
1040+
{
1041+
int err;
1042+
1043+
if (!!(modes & LINK_INBAND_DISABLE) +
1044+
!!(modes & LINK_INBAND_ENABLE) +
1045+
!!(modes & LINK_INBAND_BYPASS) != 1)
1046+
return -EINVAL;
1047+
1048+
mutex_lock(&phydev->lock);
1049+
if (!phydev->drv)
1050+
err = -EIO;
1051+
else if (!phydev->drv->config_inband)
1052+
err = -EOPNOTSUPP;
1053+
else
1054+
err = phydev->drv->config_inband(phydev, modes);
1055+
mutex_unlock(&phydev->lock);
1056+
1057+
return err;
1058+
}
1059+
EXPORT_SYMBOL(phy_config_inband);
1060+
10291061
/**
10301062
* _phy_start_aneg - start auto-negotiation for this PHY device
10311063
* @phydev: the phy_device struct

include/linux/phy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,11 @@ struct phy_driver {
982982
unsigned int (*inband_caps)(struct phy_device *phydev,
983983
phy_interface_t interface);
984984

985+
/**
986+
* @config_inband: configure in-band mode for the PHY
987+
*/
988+
int (*config_inband)(struct phy_device *phydev, unsigned int modes);
989+
985990
/**
986991
* @get_rate_matching: Get the supported type of rate matching for a
987992
* particular phy interface. This is used by phy consumers to determine
@@ -1846,6 +1851,7 @@ int phy_start_aneg(struct phy_device *phydev);
18461851
int phy_aneg_done(struct phy_device *phydev);
18471852
unsigned int phy_inband_caps(struct phy_device *phydev,
18481853
phy_interface_t interface);
1854+
int phy_config_inband(struct phy_device *phydev, unsigned int modes);
18491855
int phy_speed_down(struct phy_device *phydev, bool sync);
18501856
int phy_speed_up(struct phy_device *phydev);
18511857
bool phy_check_valid(int speed, int duplex, unsigned long *features);

0 commit comments

Comments
 (0)