net: phy: Document core PHY structures
Add kerneldoc for the core PHY data structures, a few inline functions and exported functions which are not already documented. v2 Typos g/phy/PHY/s Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
39097ab66d
commit
4069a572d4
@ -134,6 +134,15 @@ PHY Support
|
|||||||
.. kernel-doc:: drivers/net/phy/phy.c
|
.. kernel-doc:: drivers/net/phy/phy.c
|
||||||
:internal:
|
:internal:
|
||||||
|
|
||||||
|
.. kernel-doc:: drivers/net/phy/phy-core.c
|
||||||
|
:export:
|
||||||
|
|
||||||
|
.. kernel-doc:: drivers/net/phy/phy-c45.c
|
||||||
|
:export:
|
||||||
|
|
||||||
|
.. kernel-doc:: include/linux/phy.h
|
||||||
|
:internal:
|
||||||
|
|
||||||
.. kernel-doc:: drivers/net/phy/phy_device.c
|
.. kernel-doc:: drivers/net/phy/phy_device.c
|
||||||
:export:
|
:export:
|
||||||
|
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
#include <linux/phy.h>
|
#include <linux/phy.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_speed_to_str - Return a string representing the PHY link speed
|
||||||
|
*
|
||||||
|
* @speed: Speed of the link
|
||||||
|
*/
|
||||||
const char *phy_speed_to_str(int speed)
|
const char *phy_speed_to_str(int speed)
|
||||||
{
|
{
|
||||||
BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 92,
|
BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 92,
|
||||||
@ -52,6 +57,11 @@ const char *phy_speed_to_str(int speed)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(phy_speed_to_str);
|
EXPORT_SYMBOL_GPL(phy_speed_to_str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_duplex_to_str - Return string describing the duplex
|
||||||
|
*
|
||||||
|
* @duplex: Duplex setting to describe
|
||||||
|
*/
|
||||||
const char *phy_duplex_to_str(unsigned int duplex)
|
const char *phy_duplex_to_str(unsigned int duplex)
|
||||||
{
|
{
|
||||||
if (duplex == DUPLEX_HALF)
|
if (duplex == DUPLEX_HALF)
|
||||||
@ -252,6 +262,16 @@ static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
|
|||||||
return __set_linkmode_max_speed(max_speed, phydev->supported);
|
return __set_linkmode_max_speed(max_speed, phydev->supported);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_set_max_speed - Set the maximum speed the PHY should support
|
||||||
|
*
|
||||||
|
* @phydev: The phy_device struct
|
||||||
|
* @max_speed: Maximum speed
|
||||||
|
*
|
||||||
|
* The PHY might be more capable than the MAC. For example a Fast Ethernet
|
||||||
|
* is connected to a 1G PHY. This function allows the MAC to indicate its
|
||||||
|
* maximum speed, and so limit what the PHY will advertise.
|
||||||
|
*/
|
||||||
int phy_set_max_speed(struct phy_device *phydev, u32 max_speed)
|
int phy_set_max_speed(struct phy_device *phydev, u32 max_speed)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@ -308,6 +328,16 @@ void of_set_phy_eee_broken(struct phy_device *phydev)
|
|||||||
phydev->eee_broken_modes = broken;
|
phydev->eee_broken_modes = broken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_resolve_aneg_pause - Determine pause autoneg results
|
||||||
|
*
|
||||||
|
* @phydev: The phy_device struct
|
||||||
|
*
|
||||||
|
* Once autoneg has completed the local pause settings can be
|
||||||
|
* resolved. Determine if pause and asymmetric pause should be used
|
||||||
|
* by the MAC.
|
||||||
|
*/
|
||||||
|
|
||||||
void phy_resolve_aneg_pause(struct phy_device *phydev)
|
void phy_resolve_aneg_pause(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
if (phydev->duplex == DUPLEX_FULL) {
|
if (phydev->duplex == DUPLEX_FULL) {
|
||||||
@ -321,7 +351,7 @@ void phy_resolve_aneg_pause(struct phy_device *phydev)
|
|||||||
EXPORT_SYMBOL_GPL(phy_resolve_aneg_pause);
|
EXPORT_SYMBOL_GPL(phy_resolve_aneg_pause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phy_resolve_aneg_linkmode - resolve the advertisements into phy settings
|
* phy_resolve_aneg_linkmode - resolve the advertisements into PHY settings
|
||||||
* @phydev: The phy_device struct
|
* @phydev: The phy_device struct
|
||||||
*
|
*
|
||||||
* Resolve our and the link partner advertisements into their corresponding
|
* Resolve our and the link partner advertisements into their corresponding
|
||||||
|
@ -456,7 +456,16 @@ int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_do_ioctl);
|
EXPORT_SYMBOL(phy_do_ioctl);
|
||||||
|
|
||||||
/* same as phy_do_ioctl, but ensures that net_device is running */
|
/**
|
||||||
|
* phy_do_ioctl_running - generic ndo_do_ioctl implementation but test first
|
||||||
|
*
|
||||||
|
* @dev: the net_device struct
|
||||||
|
* @ifr: &struct ifreq for socket ioctl's
|
||||||
|
* @cmd: ioctl cmd to execute
|
||||||
|
*
|
||||||
|
* Same as phy_do_ioctl, but ensures that net_device is running before
|
||||||
|
* handling the ioctl.
|
||||||
|
*/
|
||||||
int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
|
int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||||
{
|
{
|
||||||
if (!netif_running(dev))
|
if (!netif_running(dev))
|
||||||
@ -466,6 +475,12 @@ int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_do_ioctl_running);
|
EXPORT_SYMBOL(phy_do_ioctl_running);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_queue_state_machine - Trigger the state machine to run soon
|
||||||
|
*
|
||||||
|
* @phydev: the phy_device struct
|
||||||
|
* @jiffies: Run the state machine after these jiffies
|
||||||
|
*/
|
||||||
void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
|
void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
|
||||||
{
|
{
|
||||||
mod_delayed_work(system_power_efficient_wq, &phydev->state_queue,
|
mod_delayed_work(system_power_efficient_wq, &phydev->state_queue,
|
||||||
@ -473,6 +488,11 @@ void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_queue_state_machine);
|
EXPORT_SYMBOL(phy_queue_state_machine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_queue_state_machine - Trigger the state machine to run now
|
||||||
|
*
|
||||||
|
* @phydev: the phy_device struct
|
||||||
|
*/
|
||||||
static void phy_trigger_machine(struct phy_device *phydev)
|
static void phy_trigger_machine(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
phy_queue_state_machine(phydev, 0);
|
phy_queue_state_machine(phydev, 0);
|
||||||
@ -489,6 +509,12 @@ static void phy_abort_cable_test(struct phy_device *phydev)
|
|||||||
phydev_err(phydev, "Error while aborting cable test");
|
phydev_err(phydev, "Error while aborting cable test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_ethtool_get_strings - Get the statistic counter names
|
||||||
|
*
|
||||||
|
* @phydev: the phy_device struct
|
||||||
|
* @data: Where to put the strings
|
||||||
|
*/
|
||||||
int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
|
int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
|
||||||
{
|
{
|
||||||
if (!phydev->drv)
|
if (!phydev->drv)
|
||||||
@ -502,6 +528,11 @@ int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_ethtool_get_strings);
|
EXPORT_SYMBOL(phy_ethtool_get_strings);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_ethtool_get_sset_count - Get the number of statistic counters
|
||||||
|
*
|
||||||
|
* @phydev: the phy_device struct
|
||||||
|
*/
|
||||||
int phy_ethtool_get_sset_count(struct phy_device *phydev)
|
int phy_ethtool_get_sset_count(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -523,6 +554,13 @@ int phy_ethtool_get_sset_count(struct phy_device *phydev)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_ethtool_get_sset_count);
|
EXPORT_SYMBOL(phy_ethtool_get_sset_count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_ethtool_get_stats - Get the statistic counters
|
||||||
|
*
|
||||||
|
* @phydev: the phy_device struct
|
||||||
|
* @stats: What counters to get
|
||||||
|
* @data: Where to store the counters
|
||||||
|
*/
|
||||||
int phy_ethtool_get_stats(struct phy_device *phydev,
|
int phy_ethtool_get_stats(struct phy_device *phydev,
|
||||||
struct ethtool_stats *stats, u64 *data)
|
struct ethtool_stats *stats, u64 *data)
|
||||||
{
|
{
|
||||||
@ -537,6 +575,12 @@ int phy_ethtool_get_stats(struct phy_device *phydev,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_ethtool_get_stats);
|
EXPORT_SYMBOL(phy_ethtool_get_stats);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_start_cable_test - Start a cable test
|
||||||
|
*
|
||||||
|
* @phydev: the phy_device struct
|
||||||
|
* @extack: extack for reporting useful error messages
|
||||||
|
*/
|
||||||
int phy_start_cable_test(struct phy_device *phydev,
|
int phy_start_cable_test(struct phy_device *phydev,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
@ -600,6 +644,13 @@ out:
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_start_cable_test);
|
EXPORT_SYMBOL(phy_start_cable_test);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_start_cable_test_tdr - Start a raw TDR cable test
|
||||||
|
*
|
||||||
|
* @phydev: the phy_device struct
|
||||||
|
* @extack: extack for reporting useful error messages
|
||||||
|
* @config: Configuration of the test to run
|
||||||
|
*/
|
||||||
int phy_start_cable_test_tdr(struct phy_device *phydev,
|
int phy_start_cable_test_tdr(struct phy_device *phydev,
|
||||||
struct netlink_ext_ack *extack,
|
struct netlink_ext_ack *extack,
|
||||||
const struct phy_tdr_config *config)
|
const struct phy_tdr_config *config)
|
||||||
@ -1363,6 +1414,12 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_ethtool_set_eee);
|
EXPORT_SYMBOL(phy_ethtool_set_eee);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_ethtool_set_wol - Configure Wake On LAN
|
||||||
|
*
|
||||||
|
* @phydev: target phy_device struct
|
||||||
|
* @wol: Configuration requested
|
||||||
|
*/
|
||||||
int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
|
int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
|
||||||
{
|
{
|
||||||
if (phydev->drv && phydev->drv->set_wol)
|
if (phydev->drv && phydev->drv->set_wol)
|
||||||
@ -1372,6 +1429,12 @@ int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_ethtool_set_wol);
|
EXPORT_SYMBOL(phy_ethtool_set_wol);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_ethtool_get_wol - Get the current Wake On LAN configuration
|
||||||
|
*
|
||||||
|
* @phydev: target phy_device struct
|
||||||
|
* @wol: Store the current configuration here
|
||||||
|
*/
|
||||||
void phy_ethtool_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
|
void phy_ethtool_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
|
||||||
{
|
{
|
||||||
if (phydev->drv && phydev->drv->get_wol)
|
if (phydev->drv && phydev->drv->get_wol)
|
||||||
@ -1405,6 +1468,10 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_ethtool_set_link_ksettings);
|
EXPORT_SYMBOL(phy_ethtool_set_link_ksettings);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_ethtool_nway_reset - Restart auto negotiation
|
||||||
|
* @ndev: Network device to restart autoneg for
|
||||||
|
*/
|
||||||
int phy_ethtool_nway_reset(struct net_device *ndev)
|
int phy_ethtool_nway_reset(struct net_device *ndev)
|
||||||
{
|
{
|
||||||
struct phy_device *phydev = ndev->phydev;
|
struct phy_device *phydev = ndev->phydev;
|
||||||
|
@ -82,7 +82,39 @@ extern const int phy_10gbit_features_array[1];
|
|||||||
#define PHY_POLL_CABLE_TEST 0x00000004
|
#define PHY_POLL_CABLE_TEST 0x00000004
|
||||||
#define MDIO_DEVICE_IS_PHY 0x80000000
|
#define MDIO_DEVICE_IS_PHY 0x80000000
|
||||||
|
|
||||||
/* Interface Mode definitions */
|
/**
|
||||||
|
* enum phy_interface_t - Interface Mode definitions
|
||||||
|
*
|
||||||
|
* @PHY_INTERFACE_MODE_NA: Not Applicable - don't touch
|
||||||
|
* @PHY_INTERFACE_MODE_INTERNAL: No interface, MAC and PHY combined
|
||||||
|
* @PHY_INTERFACE_MODE_MII: Median-independent interface
|
||||||
|
* @PHY_INTERFACE_MODE_GMII: Gigabit median-independent interface
|
||||||
|
* @PHY_INTERFACE_MODE_SGMII: Serial gigabit media-independent interface
|
||||||
|
* @PHY_INTERFACE_MODE_TBI: Ten Bit Interface
|
||||||
|
* @PHY_INTERFACE_MODE_REVMII: Reverse Media Independent Interface
|
||||||
|
* @PHY_INTERFACE_MODE_RMII: Reduced Media Independent Interface
|
||||||
|
* @PHY_INTERFACE_MODE_RGMII: Reduced gigabit media-independent interface
|
||||||
|
* @PHY_INTERFACE_MODE_RGMII_ID: RGMII with Internal RX+TX delay
|
||||||
|
* @PHY_INTERFACE_MODE_RGMII_RXID: RGMII with Internal RX delay
|
||||||
|
* @PHY_INTERFACE_MODE_RGMII_TXID: RGMII with Internal RX delay
|
||||||
|
* @PHY_INTERFACE_MODE_RTBI: Reduced TBI
|
||||||
|
* @PHY_INTERFACE_MODE_SMII: ??? MII
|
||||||
|
* @PHY_INTERFACE_MODE_XGMII: 10 gigabit media-independent interface
|
||||||
|
* @PHY_INTERFACE_MODE_XLGMII:40 gigabit media-independent interface
|
||||||
|
* @PHY_INTERFACE_MODE_MOCA: Multimedia over Coax
|
||||||
|
* @PHY_INTERFACE_MODE_QSGMII: Quad SGMII
|
||||||
|
* @PHY_INTERFACE_MODE_TRGMII: Turbo RGMII
|
||||||
|
* @PHY_INTERFACE_MODE_1000BASEX: 1000 BaseX
|
||||||
|
* @PHY_INTERFACE_MODE_2500BASEX: 2500 BaseX
|
||||||
|
* @PHY_INTERFACE_MODE_RXAUI: Reduced XAUI
|
||||||
|
* @PHY_INTERFACE_MODE_XAUI: 10 Gigabit Attachment Unit Interface
|
||||||
|
* @PHY_INTERFACE_MODE_10GBASER: 10G BaseR
|
||||||
|
* @PHY_INTERFACE_MODE_USXGMII: Universal Serial 10GE MII
|
||||||
|
* @PHY_INTERFACE_MODE_10GKR: 10GBASE-KR - with Clause 73 AN
|
||||||
|
* @PHY_INTERFACE_MODE_MAX: Book keeping
|
||||||
|
*
|
||||||
|
* Describes the interface between the MAC and PHY.
|
||||||
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PHY_INTERFACE_MODE_NA,
|
PHY_INTERFACE_MODE_NA,
|
||||||
PHY_INTERFACE_MODE_INTERNAL,
|
PHY_INTERFACE_MODE_INTERNAL,
|
||||||
@ -116,8 +148,8 @@ typedef enum {
|
|||||||
} phy_interface_t;
|
} phy_interface_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phy_supported_speeds - return all speeds currently supported by a phy device
|
* phy_supported_speeds - return all speeds currently supported by a PHY device
|
||||||
* @phy: The phy device to return supported speeds of.
|
* @phy: The PHY device to return supported speeds of.
|
||||||
* @speeds: buffer to store supported speeds in.
|
* @speeds: buffer to store supported speeds in.
|
||||||
* @size: size of speeds buffer.
|
* @size: size of speeds buffer.
|
||||||
*
|
*
|
||||||
@ -134,9 +166,9 @@ unsigned int phy_supported_speeds(struct phy_device *phy,
|
|||||||
* phy_modes - map phy_interface_t enum to device tree binding of phy-mode
|
* phy_modes - map phy_interface_t enum to device tree binding of phy-mode
|
||||||
* @interface: enum phy_interface_t value
|
* @interface: enum phy_interface_t value
|
||||||
*
|
*
|
||||||
* Description: maps 'enum phy_interface_t' defined in this file
|
* Description: maps enum &phy_interface_t defined in this file
|
||||||
* into the device tree binding of 'phy-mode', so that Ethernet
|
* into the device tree binding of 'phy-mode', so that Ethernet
|
||||||
* device driver can get phy interface from device tree.
|
* device driver can get PHY interface from device tree.
|
||||||
*/
|
*/
|
||||||
static inline const char *phy_modes(phy_interface_t interface)
|
static inline const char *phy_modes(phy_interface_t interface)
|
||||||
{
|
{
|
||||||
@ -215,6 +247,14 @@ struct sfp_bus;
|
|||||||
struct sfp_upstream_ops;
|
struct sfp_upstream_ops;
|
||||||
struct sk_buff;
|
struct sk_buff;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct mdio_bus_stats - Statistics counters for MDIO busses
|
||||||
|
* @transfers: Total number of transfers, i.e. @writes + @reads
|
||||||
|
* @errors: Number of MDIO transfers that returned an error
|
||||||
|
* @writes: Number of write transfers
|
||||||
|
* @reads: Number of read transfers
|
||||||
|
* @syncp: Synchronisation for incrementing statistics
|
||||||
|
*/
|
||||||
struct mdio_bus_stats {
|
struct mdio_bus_stats {
|
||||||
u64_stats_t transfers;
|
u64_stats_t transfers;
|
||||||
u64_stats_t errors;
|
u64_stats_t errors;
|
||||||
@ -224,7 +264,15 @@ struct mdio_bus_stats {
|
|||||||
struct u64_stats_sync syncp;
|
struct u64_stats_sync syncp;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Represents a shared structure between different phydev's in the same
|
/**
|
||||||
|
* struct phy_package_shared - Shared information in PHY packages
|
||||||
|
* @addr: Common PHY address used to combine PHYs in one package
|
||||||
|
* @refcnt: Number of PHYs connected to this shared data
|
||||||
|
* @flags: Initialization of PHY package
|
||||||
|
* @priv_size: Size of the shared private data @priv
|
||||||
|
* @priv: Driver private data shared across a PHY package
|
||||||
|
*
|
||||||
|
* Represents a shared structure between different phydev's in the same
|
||||||
* package, for example a quad PHY. See phy_package_join() and
|
* package, for example a quad PHY. See phy_package_join() and
|
||||||
* phy_package_leave().
|
* phy_package_leave().
|
||||||
*/
|
*/
|
||||||
@ -247,7 +295,14 @@ struct phy_package_shared {
|
|||||||
#define PHY_SHARED_F_INIT_DONE 0
|
#define PHY_SHARED_F_INIT_DONE 0
|
||||||
#define PHY_SHARED_F_PROBE_DONE 1
|
#define PHY_SHARED_F_PROBE_DONE 1
|
||||||
|
|
||||||
/*
|
/**
|
||||||
|
* struct mii_bus - Represents an MDIO bus
|
||||||
|
*
|
||||||
|
* @owner: Who owns this device
|
||||||
|
* @name: User friendly name for this MDIO device, or driver name
|
||||||
|
* @id: Unique identifier for this bus, typical from bus hierarchy
|
||||||
|
* @priv: Driver private data
|
||||||
|
*
|
||||||
* The Bus class for PHYs. Devices which provide access to
|
* The Bus class for PHYs. Devices which provide access to
|
||||||
* PHYs should register using this structure
|
* PHYs should register using this structure
|
||||||
*/
|
*/
|
||||||
@ -256,49 +311,58 @@ struct mii_bus {
|
|||||||
const char *name;
|
const char *name;
|
||||||
char id[MII_BUS_ID_SIZE];
|
char id[MII_BUS_ID_SIZE];
|
||||||
void *priv;
|
void *priv;
|
||||||
|
/** @read: Perform a read transfer on the bus */
|
||||||
int (*read)(struct mii_bus *bus, int addr, int regnum);
|
int (*read)(struct mii_bus *bus, int addr, int regnum);
|
||||||
|
/** @write: Perform a write transfer on the bus */
|
||||||
int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
|
int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val);
|
||||||
|
/** @reset: Perform a reset of the bus */
|
||||||
int (*reset)(struct mii_bus *bus);
|
int (*reset)(struct mii_bus *bus);
|
||||||
|
|
||||||
|
/** @stats: Statistic counters per device on the bus */
|
||||||
struct mdio_bus_stats stats[PHY_MAX_ADDR];
|
struct mdio_bus_stats stats[PHY_MAX_ADDR];
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* A lock to ensure that only one thing can read/write
|
* @mdio_lock: A lock to ensure that only one thing can read/write
|
||||||
* the MDIO bus at a time
|
* the MDIO bus at a time
|
||||||
*/
|
*/
|
||||||
struct mutex mdio_lock;
|
struct mutex mdio_lock;
|
||||||
|
|
||||||
|
/** @parent: Parent device of this bus */
|
||||||
struct device *parent;
|
struct device *parent;
|
||||||
|
/** @state: State of bus structure */
|
||||||
enum {
|
enum {
|
||||||
MDIOBUS_ALLOCATED = 1,
|
MDIOBUS_ALLOCATED = 1,
|
||||||
MDIOBUS_REGISTERED,
|
MDIOBUS_REGISTERED,
|
||||||
MDIOBUS_UNREGISTERED,
|
MDIOBUS_UNREGISTERED,
|
||||||
MDIOBUS_RELEASED,
|
MDIOBUS_RELEASED,
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
|
/** @dev: Kernel device representation */
|
||||||
struct device dev;
|
struct device dev;
|
||||||
|
|
||||||
/* list of all PHYs on bus */
|
/** @mdio_map: list of all MDIO devices on bus */
|
||||||
struct mdio_device *mdio_map[PHY_MAX_ADDR];
|
struct mdio_device *mdio_map[PHY_MAX_ADDR];
|
||||||
|
|
||||||
/* PHY addresses to be ignored when probing */
|
/** @phy_mask: PHY addresses to be ignored when probing */
|
||||||
u32 phy_mask;
|
u32 phy_mask;
|
||||||
|
|
||||||
/* PHY addresses to ignore the TA/read failure */
|
/** @phy_ignore_ta_mask: PHY addresses to ignore the TA/read failure */
|
||||||
u32 phy_ignore_ta_mask;
|
u32 phy_ignore_ta_mask;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* An array of interrupts, each PHY's interrupt at the index
|
* @irq: An array of interrupts, each PHY's interrupt at the index
|
||||||
* matching its address
|
* matching its address
|
||||||
*/
|
*/
|
||||||
int irq[PHY_MAX_ADDR];
|
int irq[PHY_MAX_ADDR];
|
||||||
|
|
||||||
/* GPIO reset pulse width in microseconds */
|
/** @reset_delay_us: GPIO reset pulse width in microseconds */
|
||||||
int reset_delay_us;
|
int reset_delay_us;
|
||||||
/* GPIO reset deassert delay in microseconds */
|
/** @reset_post_delay_us: GPIO reset deassert delay in microseconds */
|
||||||
int reset_post_delay_us;
|
int reset_post_delay_us;
|
||||||
/* RESET GPIO descriptor pointer */
|
/** @reset_gpiod: Reset GPIO descriptor pointer */
|
||||||
struct gpio_desc *reset_gpiod;
|
struct gpio_desc *reset_gpiod;
|
||||||
|
|
||||||
/* bus capabilities, used for probing */
|
/** @probe_capabilities: bus capabilities, used for probing */
|
||||||
enum {
|
enum {
|
||||||
MDIOBUS_NO_CAP = 0,
|
MDIOBUS_NO_CAP = 0,
|
||||||
MDIOBUS_C22,
|
MDIOBUS_C22,
|
||||||
@ -306,15 +370,22 @@ struct mii_bus {
|
|||||||
MDIOBUS_C22_C45,
|
MDIOBUS_C22_C45,
|
||||||
} probe_capabilities;
|
} probe_capabilities;
|
||||||
|
|
||||||
/* protect access to the shared element */
|
/** @shared_lock: protect access to the shared element */
|
||||||
struct mutex shared_lock;
|
struct mutex shared_lock;
|
||||||
|
|
||||||
/* shared state across different PHYs */
|
/** @shared: shared state across different PHYs */
|
||||||
struct phy_package_shared *shared[PHY_MAX_ADDR];
|
struct phy_package_shared *shared[PHY_MAX_ADDR];
|
||||||
};
|
};
|
||||||
#define to_mii_bus(d) container_of(d, struct mii_bus, dev)
|
#define to_mii_bus(d) container_of(d, struct mii_bus, dev)
|
||||||
|
|
||||||
struct mii_bus *mdiobus_alloc_size(size_t);
|
struct mii_bus *mdiobus_alloc_size(size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mdiobus_alloc - Allocate an MDIO bus structure
|
||||||
|
*
|
||||||
|
* The internal state of the MDIO bus will be set of MDIOBUS_ALLOCATED ready
|
||||||
|
* for the driver to register the bus.
|
||||||
|
*/
|
||||||
static inline struct mii_bus *mdiobus_alloc(void)
|
static inline struct mii_bus *mdiobus_alloc(void)
|
||||||
{
|
{
|
||||||
return mdiobus_alloc_size(0);
|
return mdiobus_alloc_size(0);
|
||||||
@ -341,40 +412,41 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
|
|||||||
#define PHY_INTERRUPT_DISABLED false
|
#define PHY_INTERRUPT_DISABLED false
|
||||||
#define PHY_INTERRUPT_ENABLED true
|
#define PHY_INTERRUPT_ENABLED true
|
||||||
|
|
||||||
/* PHY state machine states:
|
/**
|
||||||
|
* enum phy_state - PHY state machine states:
|
||||||
*
|
*
|
||||||
* DOWN: PHY device and driver are not ready for anything. probe
|
* @PHY_DOWN: PHY device and driver are not ready for anything. probe
|
||||||
* should be called if and only if the PHY is in this state,
|
* should be called if and only if the PHY is in this state,
|
||||||
* given that the PHY device exists.
|
* given that the PHY device exists.
|
||||||
* - PHY driver probe function will set the state to READY
|
* - PHY driver probe function will set the state to @PHY_READY
|
||||||
*
|
*
|
||||||
* READY: PHY is ready to send and receive packets, but the
|
* @PHY_READY: PHY is ready to send and receive packets, but the
|
||||||
* controller is not. By default, PHYs which do not implement
|
* controller is not. By default, PHYs which do not implement
|
||||||
* probe will be set to this state by phy_probe().
|
* probe will be set to this state by phy_probe().
|
||||||
* - start will set the state to UP
|
* - start will set the state to UP
|
||||||
*
|
*
|
||||||
* UP: The PHY and attached device are ready to do work.
|
* @PHY_UP: The PHY and attached device are ready to do work.
|
||||||
* Interrupts should be started here.
|
* Interrupts should be started here.
|
||||||
* - timer moves to NOLINK or RUNNING
|
* - timer moves to @PHY_NOLINK or @PHY_RUNNING
|
||||||
*
|
*
|
||||||
* NOLINK: PHY is up, but not currently plugged in.
|
* @PHY_NOLINK: PHY is up, but not currently plugged in.
|
||||||
* - irq or timer will set RUNNING if link comes back
|
* - irq or timer will set @PHY_RUNNING if link comes back
|
||||||
* - phy_stop moves to HALTED
|
* - phy_stop moves to @PHY_HALTED
|
||||||
*
|
*
|
||||||
* RUNNING: PHY is currently up, running, and possibly sending
|
* @PHY_RUNNING: PHY is currently up, running, and possibly sending
|
||||||
* and/or receiving packets
|
* and/or receiving packets
|
||||||
* - irq or timer will set NOLINK if link goes down
|
* - irq or timer will set @PHY_NOLINK if link goes down
|
||||||
* - phy_stop moves to HALTED
|
* - phy_stop moves to @PHY_HALTED
|
||||||
*
|
*
|
||||||
* CABLETEST: PHY is performing a cable test. Packet reception/sending
|
* @PHY_CABLETEST: PHY is performing a cable test. Packet reception/sending
|
||||||
* is not expected to work, carrier will be indicated as down. PHY will be
|
* is not expected to work, carrier will be indicated as down. PHY will be
|
||||||
* poll once per second, or on interrupt for it current state.
|
* poll once per second, or on interrupt for it current state.
|
||||||
* Once complete, move to UP to restart the PHY.
|
* Once complete, move to UP to restart the PHY.
|
||||||
* - phy_stop aborts the running test and moves to HALTED
|
* - phy_stop aborts the running test and moves to @PHY_HALTED
|
||||||
*
|
*
|
||||||
* HALTED: PHY is up, but no polling or interrupts are done. Or
|
* @PHY_HALTED: PHY is up, but no polling or interrupts are done. Or
|
||||||
* PHY is in an error state.
|
* PHY is in an error state.
|
||||||
* - phy_start moves to UP
|
* - phy_start moves to @PHY_UP
|
||||||
*/
|
*/
|
||||||
enum phy_state {
|
enum phy_state {
|
||||||
PHY_DOWN = 0,
|
PHY_DOWN = 0,
|
||||||
@ -403,34 +475,67 @@ struct phy_c45_device_ids {
|
|||||||
struct macsec_context;
|
struct macsec_context;
|
||||||
struct macsec_ops;
|
struct macsec_ops;
|
||||||
|
|
||||||
/* phy_device: An instance of a PHY
|
/**
|
||||||
|
* struct phy_device - An instance of a PHY
|
||||||
*
|
*
|
||||||
* drv: Pointer to the driver for this PHY instance
|
* @mdio: MDIO bus this PHY is on
|
||||||
* phy_id: UID for this device found during discovery
|
* @drv: Pointer to the driver for this PHY instance
|
||||||
* c45_ids: 802.3-c45 Device Identifers if is_c45.
|
* @phy_id: UID for this device found during discovery
|
||||||
* is_c45: Set to true if this phy uses clause 45 addressing.
|
* @c45_ids: 802.3-c45 Device Identifiers if is_c45.
|
||||||
* is_internal: Set to true if this phy is internal to a MAC.
|
* @is_c45: Set to true if this PHY uses clause 45 addressing.
|
||||||
* is_pseudo_fixed_link: Set to true if this phy is an Ethernet switch, etc.
|
* @is_internal: Set to true if this PHY is internal to a MAC.
|
||||||
* is_gigabit_capable: Set to true if PHY supports 1000Mbps
|
* @is_pseudo_fixed_link: Set to true if this PHY is an Ethernet switch, etc.
|
||||||
* has_fixups: Set to true if this phy has fixups/quirks.
|
* @is_gigabit_capable: Set to true if PHY supports 1000Mbps
|
||||||
* suspended: Set to true if this phy has been suspended successfully.
|
* @has_fixups: Set to true if this PHY has fixups/quirks.
|
||||||
* suspended_by_mdio_bus: Set to true if this phy was suspended by MDIO bus.
|
* @suspended: Set to true if this PHY has been suspended successfully.
|
||||||
* sysfs_links: Internal boolean tracking sysfs symbolic links setup/removal.
|
* @suspended_by_mdio_bus: Set to true if this PHY was suspended by MDIO bus.
|
||||||
* loopback_enabled: Set true if this phy has been loopbacked successfully.
|
* @sysfs_links: Internal boolean tracking sysfs symbolic links setup/removal.
|
||||||
* downshifted_rate: Set true if link speed has been downshifted.
|
* @loopback_enabled: Set true if this PHY has been loopbacked successfully.
|
||||||
* state: state of the PHY for management purposes
|
* @downshifted_rate: Set true if link speed has been downshifted.
|
||||||
* dev_flags: Device-specific flags used by the PHY driver.
|
* @state: State of the PHY for management purposes
|
||||||
* irq: IRQ number of the PHY's interrupt (-1 if none)
|
* @dev_flags: Device-specific flags used by the PHY driver.
|
||||||
* phy_timer: The timer for handling the state machine
|
* @irq: IRQ number of the PHY's interrupt (-1 if none)
|
||||||
* sfp_bus_attached: flag indicating whether the SFP bus has been attached
|
* @phy_timer: The timer for handling the state machine
|
||||||
* sfp_bus: SFP bus attached to this PHY's fiber port
|
* @phylink: Pointer to phylink instance for this PHY
|
||||||
* attached_dev: The attached enet driver's device instance ptr
|
* @sfp_bus_attached: Flag indicating whether the SFP bus has been attached
|
||||||
* adjust_link: Callback for the enet controller to respond to
|
* @sfp_bus: SFP bus attached to this PHY's fiber port
|
||||||
* changes in the link state.
|
* @attached_dev: The attached enet driver's device instance ptr
|
||||||
* macsec_ops: MACsec offloading ops.
|
* @adjust_link: Callback for the enet controller to respond to changes: in the
|
||||||
|
* link state.
|
||||||
|
* @phy_link_change: Callback for phylink for notification of link change
|
||||||
|
* @macsec_ops: MACsec offloading ops.
|
||||||
*
|
*
|
||||||
* speed, duplex, pause, supported, advertising, lp_advertising,
|
* @speed: Current link speed
|
||||||
* and autoneg are used like in mii_if_info
|
* @duplex: Current duplex
|
||||||
|
* @pause: Current pause
|
||||||
|
* @asym_pause: Current asymmetric pause
|
||||||
|
* @supported: Combined MAC/PHY supported linkmodes
|
||||||
|
* @advertising: Currently advertised linkmodes
|
||||||
|
* @adv_old: Saved advertised while power saving for WoL
|
||||||
|
* @lp_advertising: Current link partner advertised linkmodes
|
||||||
|
* @eee_broken_modes: Energy efficient ethernet modes which should be prohibited
|
||||||
|
* @autoneg: Flag autoneg being used
|
||||||
|
* @link: Current link state
|
||||||
|
* @autoneg_complete: Flag auto negotiation of the link has completed
|
||||||
|
* @mdix: Current crossover
|
||||||
|
* @mdix_ctrl: User setting of crossover
|
||||||
|
* @interrupts: Flag interrupts have been enabled
|
||||||
|
* @interface: enum phy_interface_t value
|
||||||
|
* @skb: Netlink message for cable diagnostics
|
||||||
|
* @nest: Netlink nest used for cable diagnostics
|
||||||
|
* @ehdr: nNtlink header for cable diagnostics
|
||||||
|
* @phy_led_triggers: Array of LED triggers
|
||||||
|
* @phy_num_led_triggers: Number of triggers in @phy_led_triggers
|
||||||
|
* @led_link_trigger: LED trigger for link up/down
|
||||||
|
* @last_triggered: last LED trigger for link speed
|
||||||
|
* @master_slave_set: User requested master/slave configuration
|
||||||
|
* @master_slave_get: Current master/slave advertisement
|
||||||
|
* @master_slave_state: Current master/slave configuration
|
||||||
|
* @mii_ts: Pointer to time stamper callbacks
|
||||||
|
* @lock: Mutex for serialization access to PHY
|
||||||
|
* @state_queue: Work queue for state machine
|
||||||
|
* @shared: Pointer to private data shared by phys in one package
|
||||||
|
* @priv: Pointer to driver private data
|
||||||
*
|
*
|
||||||
* interrupts currently only supports enabled or disabled,
|
* interrupts currently only supports enabled or disabled,
|
||||||
* but could be changed in the future to support enabling
|
* but could be changed in the future to support enabling
|
||||||
@ -550,9 +655,18 @@ struct phy_device {
|
|||||||
#define to_phy_device(d) container_of(to_mdio_device(d), \
|
#define to_phy_device(d) container_of(to_mdio_device(d), \
|
||||||
struct phy_device, mdio)
|
struct phy_device, mdio)
|
||||||
|
|
||||||
/* A structure containing possible configuration parameters
|
/**
|
||||||
|
* struct phy_tdr_config - Configuration of a TDR raw test
|
||||||
|
*
|
||||||
|
* @first: Distance for first data collection point
|
||||||
|
* @last: Distance for last data collection point
|
||||||
|
* @step: Step between data collection points
|
||||||
|
* @pair: Bitmap of cable pairs to collect data for
|
||||||
|
*
|
||||||
|
* A structure containing possible configuration parameters
|
||||||
* for a TDR cable test. The driver does not need to implement
|
* for a TDR cable test. The driver does not need to implement
|
||||||
* all the parameters, but should report what is actually used.
|
* all the parameters, but should report what is actually used.
|
||||||
|
* All distances are in centimeters.
|
||||||
*/
|
*/
|
||||||
struct phy_tdr_config {
|
struct phy_tdr_config {
|
||||||
u32 first;
|
u32 first;
|
||||||
@ -562,18 +676,20 @@ struct phy_tdr_config {
|
|||||||
};
|
};
|
||||||
#define PHY_PAIR_ALL -1
|
#define PHY_PAIR_ALL -1
|
||||||
|
|
||||||
/* struct phy_driver: Driver structure for a particular PHY type
|
/**
|
||||||
|
* struct phy_driver - Driver structure for a particular PHY type
|
||||||
*
|
*
|
||||||
* driver_data: static driver data
|
* @mdiodrv: Data common to all MDIO devices
|
||||||
* phy_id: The result of reading the UID registers of this PHY
|
* @phy_id: The result of reading the UID registers of this PHY
|
||||||
* type, and ANDing them with the phy_id_mask. This driver
|
* type, and ANDing them with the phy_id_mask. This driver
|
||||||
* only works for PHYs with IDs which match this field
|
* only works for PHYs with IDs which match this field
|
||||||
* name: The friendly name of this PHY type
|
* @name: The friendly name of this PHY type
|
||||||
* phy_id_mask: Defines the important bits of the phy_id
|
* @phy_id_mask: Defines the important bits of the phy_id
|
||||||
* features: A mandatory list of features (speed, duplex, etc)
|
* @features: A mandatory list of features (speed, duplex, etc)
|
||||||
* supported by this PHY
|
* supported by this PHY
|
||||||
* flags: A bitfield defining certain other features this PHY
|
* @flags: A bitfield defining certain other features this PHY
|
||||||
* supports (like interrupts)
|
* supports (like interrupts)
|
||||||
|
* @driver_data: Static driver data
|
||||||
*
|
*
|
||||||
* All functions are optional. If config_aneg or read_status
|
* All functions are optional. If config_aneg or read_status
|
||||||
* are not implemented, the phy core uses the genphy versions.
|
* are not implemented, the phy core uses the genphy versions.
|
||||||
@ -592,151 +708,178 @@ struct phy_driver {
|
|||||||
u32 flags;
|
u32 flags;
|
||||||
const void *driver_data;
|
const void *driver_data;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Called to issue a PHY software reset
|
* @soft_reset: Called to issue a PHY software reset
|
||||||
*/
|
*/
|
||||||
int (*soft_reset)(struct phy_device *phydev);
|
int (*soft_reset)(struct phy_device *phydev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Called to initialize the PHY,
|
* @config_init: Called to initialize the PHY,
|
||||||
* including after a reset
|
* including after a reset
|
||||||
*/
|
*/
|
||||||
int (*config_init)(struct phy_device *phydev);
|
int (*config_init)(struct phy_device *phydev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Called during discovery. Used to set
|
* @probe: Called during discovery. Used to set
|
||||||
* up device-specific structures, if any
|
* up device-specific structures, if any
|
||||||
*/
|
*/
|
||||||
int (*probe)(struct phy_device *phydev);
|
int (*probe)(struct phy_device *phydev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Probe the hardware to determine what abilities it has.
|
* @get_features: Probe the hardware to determine what
|
||||||
* Should only set phydev->supported.
|
* abilities it has. Should only set phydev->supported.
|
||||||
*/
|
*/
|
||||||
int (*get_features)(struct phy_device *phydev);
|
int (*get_features)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* PHY Power Management */
|
/* PHY Power Management */
|
||||||
|
/** @suspend: Suspend the hardware, saving state if needed */
|
||||||
int (*suspend)(struct phy_device *phydev);
|
int (*suspend)(struct phy_device *phydev);
|
||||||
|
/** @resume: Resume the hardware, restoring state if needed */
|
||||||
int (*resume)(struct phy_device *phydev);
|
int (*resume)(struct phy_device *phydev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Configures the advertisement and resets
|
* @config_aneg: Configures the advertisement and resets
|
||||||
* autonegotiation if phydev->autoneg is on,
|
* autonegotiation if phydev->autoneg is on,
|
||||||
* forces the speed to the current settings in phydev
|
* forces the speed to the current settings in phydev
|
||||||
* if phydev->autoneg is off
|
* if phydev->autoneg is off
|
||||||
*/
|
*/
|
||||||
int (*config_aneg)(struct phy_device *phydev);
|
int (*config_aneg)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Determines the auto negotiation result */
|
/** @aneg_done: Determines the auto negotiation result */
|
||||||
int (*aneg_done)(struct phy_device *phydev);
|
int (*aneg_done)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Determines the negotiated speed and duplex */
|
/** @read_status: Determines the negotiated speed and duplex */
|
||||||
int (*read_status)(struct phy_device *phydev);
|
int (*read_status)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Clears any pending interrupts */
|
/** @ack_interrupt: Clears any pending interrupts */
|
||||||
int (*ack_interrupt)(struct phy_device *phydev);
|
int (*ack_interrupt)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Enables or disables interrupts */
|
/** @config_intr: Enables or disables interrupts */
|
||||||
int (*config_intr)(struct phy_device *phydev);
|
int (*config_intr)(struct phy_device *phydev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Checks if the PHY generated an interrupt.
|
* @did_interrupt: Checks if the PHY generated an interrupt.
|
||||||
* For multi-PHY devices with shared PHY interrupt pin
|
* For multi-PHY devices with shared PHY interrupt pin
|
||||||
* Set interrupt bits have to be cleared.
|
* Set interrupt bits have to be cleared.
|
||||||
*/
|
*/
|
||||||
int (*did_interrupt)(struct phy_device *phydev);
|
int (*did_interrupt)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Override default interrupt handling */
|
/** @handle_interrupt: Override default interrupt handling */
|
||||||
irqreturn_t (*handle_interrupt)(struct phy_device *phydev);
|
irqreturn_t (*handle_interrupt)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Clears up any memory if needed */
|
/** @remove: Clears up any memory if needed */
|
||||||
void (*remove)(struct phy_device *phydev);
|
void (*remove)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Returns true if this is a suitable driver for the given
|
/**
|
||||||
* phydev. If NULL, matching is based on phy_id and
|
* @match_phy_device: Returns true if this is a suitable
|
||||||
* phy_id_mask.
|
* driver for the given phydev. If NULL, matching is based on
|
||||||
|
* phy_id and phy_id_mask.
|
||||||
*/
|
*/
|
||||||
int (*match_phy_device)(struct phy_device *phydev);
|
int (*match_phy_device)(struct phy_device *phydev);
|
||||||
|
|
||||||
/* Some devices (e.g. qnap TS-119P II) require PHY register changes to
|
/**
|
||||||
* enable Wake on LAN, so set_wol is provided to be called in the
|
* @set_wol: Some devices (e.g. qnap TS-119P II) require PHY
|
||||||
* ethernet driver's set_wol function. */
|
* register changes to enable Wake on LAN, so set_wol is
|
||||||
|
* provided to be called in the ethernet driver's set_wol
|
||||||
|
* function.
|
||||||
|
*/
|
||||||
int (*set_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
|
int (*set_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
|
||||||
|
|
||||||
/* See set_wol, but for checking whether Wake on LAN is enabled. */
|
/**
|
||||||
|
* @get_wol: See set_wol, but for checking whether Wake on LAN
|
||||||
|
* is enabled.
|
||||||
|
*/
|
||||||
void (*get_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
|
void (*get_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Called to inform a PHY device driver when the core is about to
|
* @link_change_notify: Called to inform a PHY device driver
|
||||||
* change the link state. This callback is supposed to be used as
|
* when the core is about to change the link state. This
|
||||||
* fixup hook for drivers that need to take action when the link
|
* callback is supposed to be used as fixup hook for drivers
|
||||||
* state changes. Drivers are by no means allowed to mess with the
|
* that need to take action when the link state
|
||||||
|
* changes. Drivers are by no means allowed to mess with the
|
||||||
* PHY device structure in their implementations.
|
* PHY device structure in their implementations.
|
||||||
*/
|
*/
|
||||||
void (*link_change_notify)(struct phy_device *dev);
|
void (*link_change_notify)(struct phy_device *dev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Phy specific driver override for reading a MMD register.
|
* @read_mmd: PHY specific driver override for reading a MMD
|
||||||
* This function is optional for PHY specific drivers. When
|
* register. This function is optional for PHY specific
|
||||||
* not provided, the default MMD read function will be used
|
* drivers. When not provided, the default MMD read function
|
||||||
* by phy_read_mmd(), which will use either a direct read for
|
* will be used by phy_read_mmd(), which will use either a
|
||||||
* Clause 45 PHYs or an indirect read for Clause 22 PHYs.
|
* direct read for Clause 45 PHYs or an indirect read for
|
||||||
* devnum is the MMD device number within the PHY device,
|
* Clause 22 PHYs. devnum is the MMD device number within the
|
||||||
* regnum is the register within the selected MMD device.
|
* PHY device, regnum is the register within the selected MMD
|
||||||
|
* device.
|
||||||
*/
|
*/
|
||||||
int (*read_mmd)(struct phy_device *dev, int devnum, u16 regnum);
|
int (*read_mmd)(struct phy_device *dev, int devnum, u16 regnum);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Phy specific driver override for writing a MMD register.
|
* @write_mmd: PHY specific driver override for writing a MMD
|
||||||
* This function is optional for PHY specific drivers. When
|
* register. This function is optional for PHY specific
|
||||||
* not provided, the default MMD write function will be used
|
* drivers. When not provided, the default MMD write function
|
||||||
* by phy_write_mmd(), which will use either a direct write for
|
* will be used by phy_write_mmd(), which will use either a
|
||||||
* Clause 45 PHYs, or an indirect write for Clause 22 PHYs.
|
* direct write for Clause 45 PHYs, or an indirect write for
|
||||||
* devnum is the MMD device number within the PHY device,
|
* Clause 22 PHYs. devnum is the MMD device number within the
|
||||||
* regnum is the register within the selected MMD device.
|
* PHY device, regnum is the register within the selected MMD
|
||||||
* val is the value to be written.
|
* device. val is the value to be written.
|
||||||
*/
|
*/
|
||||||
int (*write_mmd)(struct phy_device *dev, int devnum, u16 regnum,
|
int (*write_mmd)(struct phy_device *dev, int devnum, u16 regnum,
|
||||||
u16 val);
|
u16 val);
|
||||||
|
|
||||||
|
/** @read_page: Return the current PHY register page number */
|
||||||
int (*read_page)(struct phy_device *dev);
|
int (*read_page)(struct phy_device *dev);
|
||||||
|
/** @write_page: Set the current PHY register page number */
|
||||||
int (*write_page)(struct phy_device *dev, int page);
|
int (*write_page)(struct phy_device *dev, int page);
|
||||||
|
|
||||||
/* Get the size and type of the eeprom contained within a plug-in
|
/**
|
||||||
* module */
|
* @module_info: Get the size and type of the eeprom contained
|
||||||
|
* within a plug-in module
|
||||||
|
*/
|
||||||
int (*module_info)(struct phy_device *dev,
|
int (*module_info)(struct phy_device *dev,
|
||||||
struct ethtool_modinfo *modinfo);
|
struct ethtool_modinfo *modinfo);
|
||||||
|
|
||||||
/* Get the eeprom information from the plug-in module */
|
/**
|
||||||
|
* @module_eeprom: Get the eeprom information from the plug-in
|
||||||
|
* module
|
||||||
|
*/
|
||||||
int (*module_eeprom)(struct phy_device *dev,
|
int (*module_eeprom)(struct phy_device *dev,
|
||||||
struct ethtool_eeprom *ee, u8 *data);
|
struct ethtool_eeprom *ee, u8 *data);
|
||||||
|
|
||||||
/* Start a cable test */
|
/** @cable_test_start: Start a cable test */
|
||||||
int (*cable_test_start)(struct phy_device *dev);
|
int (*cable_test_start)(struct phy_device *dev);
|
||||||
|
|
||||||
/* Start a raw TDR cable test */
|
/** @cable_test_tdr_start: Start a raw TDR cable test */
|
||||||
int (*cable_test_tdr_start)(struct phy_device *dev,
|
int (*cable_test_tdr_start)(struct phy_device *dev,
|
||||||
const struct phy_tdr_config *config);
|
const struct phy_tdr_config *config);
|
||||||
|
|
||||||
/* Once per second, or on interrupt, request the status of the
|
/**
|
||||||
* test.
|
* @cable_test_get_status: Once per second, or on interrupt,
|
||||||
|
* request the status of the test.
|
||||||
*/
|
*/
|
||||||
int (*cable_test_get_status)(struct phy_device *dev, bool *finished);
|
int (*cable_test_get_status)(struct phy_device *dev, bool *finished);
|
||||||
|
|
||||||
/* Get statistics from the phy using ethtool */
|
/* Get statistics from the PHY using ethtool */
|
||||||
|
/** @get_sset_count: Number of statistic counters */
|
||||||
int (*get_sset_count)(struct phy_device *dev);
|
int (*get_sset_count)(struct phy_device *dev);
|
||||||
|
/** @get_strings: Names of the statistic counters */
|
||||||
void (*get_strings)(struct phy_device *dev, u8 *data);
|
void (*get_strings)(struct phy_device *dev, u8 *data);
|
||||||
|
/** @get_stats: Return the statistic counter values */
|
||||||
void (*get_stats)(struct phy_device *dev,
|
void (*get_stats)(struct phy_device *dev,
|
||||||
struct ethtool_stats *stats, u64 *data);
|
struct ethtool_stats *stats, u64 *data);
|
||||||
|
|
||||||
/* Get and Set PHY tunables */
|
/* Get and Set PHY tunables */
|
||||||
|
/** @get_tunable: Return the value of a tunable */
|
||||||
int (*get_tunable)(struct phy_device *dev,
|
int (*get_tunable)(struct phy_device *dev,
|
||||||
struct ethtool_tunable *tuna, void *data);
|
struct ethtool_tunable *tuna, void *data);
|
||||||
|
/** @set_tunable: Set the value of a tunable */
|
||||||
int (*set_tunable)(struct phy_device *dev,
|
int (*set_tunable)(struct phy_device *dev,
|
||||||
struct ethtool_tunable *tuna,
|
struct ethtool_tunable *tuna,
|
||||||
const void *data);
|
const void *data);
|
||||||
|
/** @set_loopback: Set the loopback mood of the PHY */
|
||||||
int (*set_loopback)(struct phy_device *dev, bool enable);
|
int (*set_loopback)(struct phy_device *dev, bool enable);
|
||||||
|
/** @get_sqi: Get the signal quality indication */
|
||||||
int (*get_sqi)(struct phy_device *dev);
|
int (*get_sqi)(struct phy_device *dev);
|
||||||
|
/** @get_sqi_max: Get the maximum signal quality indication */
|
||||||
int (*get_sqi_max)(struct phy_device *dev);
|
int (*get_sqi_max)(struct phy_device *dev);
|
||||||
};
|
};
|
||||||
#define to_phy_driver(d) container_of(to_mdio_common_driver(d), \
|
#define to_phy_driver(d) container_of(to_mdio_common_driver(d), \
|
||||||
@ -890,6 +1033,24 @@ static inline int __phy_modify_changed(struct phy_device *phydev, u32 regnum,
|
|||||||
*/
|
*/
|
||||||
int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
|
int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phy_read_mmd_poll_timeout - Periodically poll a PHY register until a
|
||||||
|
* condition is met or a timeout occurs
|
||||||
|
*
|
||||||
|
* @phydev: The phy_device struct
|
||||||
|
* @devaddr: The MMD to read from
|
||||||
|
* @regnum: The register on the MMD to read
|
||||||
|
* @val: Variable to read the register into
|
||||||
|
* @cond: Break condition (usually involving @val)
|
||||||
|
* @sleep_us: Maximum time to sleep between reads in us (0
|
||||||
|
* tight-loops). Should be less than ~20ms since usleep_range
|
||||||
|
* is used (see Documentation/timers/timers-howto.rst).
|
||||||
|
* @timeout_us: Timeout in us, 0 means never timeout
|
||||||
|
* @sleep_before_read: if it is true, sleep @sleep_us before read.
|
||||||
|
* Returns 0 on success and -ETIMEDOUT upon a timeout. In either
|
||||||
|
* case, the last read value at @args is stored in @val. Must not
|
||||||
|
* be called from atomic context if sleep_us or timeout_us are used.
|
||||||
|
*/
|
||||||
#define phy_read_mmd_poll_timeout(phydev, devaddr, regnum, val, cond, \
|
#define phy_read_mmd_poll_timeout(phydev, devaddr, regnum, val, cond, \
|
||||||
sleep_us, timeout_us, sleep_before_read) \
|
sleep_us, timeout_us, sleep_before_read) \
|
||||||
({ \
|
({ \
|
||||||
@ -1161,7 +1322,7 @@ static inline bool phy_is_internal(struct phy_device *phydev)
|
|||||||
/**
|
/**
|
||||||
* phy_interface_mode_is_rgmii - Convenience function for testing if a
|
* phy_interface_mode_is_rgmii - Convenience function for testing if a
|
||||||
* PHY interface mode is RGMII (all variants)
|
* PHY interface mode is RGMII (all variants)
|
||||||
* @mode: the phy_interface_t enum
|
* @mode: the &phy_interface_t enum
|
||||||
*/
|
*/
|
||||||
static inline bool phy_interface_mode_is_rgmii(phy_interface_t mode)
|
static inline bool phy_interface_mode_is_rgmii(phy_interface_t mode)
|
||||||
{
|
{
|
||||||
@ -1170,11 +1331,11 @@ static inline bool phy_interface_mode_is_rgmii(phy_interface_t mode)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phy_interface_mode_is_8023z() - does the phy interface mode use 802.3z
|
* phy_interface_mode_is_8023z() - does the PHY interface mode use 802.3z
|
||||||
* negotiation
|
* negotiation
|
||||||
* @mode: one of &enum phy_interface_t
|
* @mode: one of &enum phy_interface_t
|
||||||
*
|
*
|
||||||
* Returns true if the phy interface mode uses the 16-bit negotiation
|
* Returns true if the PHY interface mode uses the 16-bit negotiation
|
||||||
* word as defined in 802.3z. (See 802.3-2015 37.2.1 Config_Reg encoding)
|
* word as defined in 802.3z. (See 802.3-2015 37.2.1 Config_Reg encoding)
|
||||||
*/
|
*/
|
||||||
static inline bool phy_interface_mode_is_8023z(phy_interface_t mode)
|
static inline bool phy_interface_mode_is_8023z(phy_interface_t mode)
|
||||||
@ -1193,7 +1354,7 @@ static inline bool phy_interface_is_rgmii(struct phy_device *phydev)
|
|||||||
return phy_interface_mode_is_rgmii(phydev->interface);
|
return phy_interface_mode_is_rgmii(phydev->interface);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* phy_is_pseudo_fixed_link - Convenience function for testing if this
|
* phy_is_pseudo_fixed_link - Convenience function for testing if this
|
||||||
* PHY is the CPU port facing side of an Ethernet switch, or similar.
|
* PHY is the CPU port facing side of an Ethernet switch, or similar.
|
||||||
* @phydev: the phy_device struct
|
* @phydev: the phy_device struct
|
||||||
|
Loading…
Reference in New Issue
Block a user