mdio: Add generic MDIO (clause 45) support functions
These roughly mirror many of the MII library functions and are based on code from the sfc driver. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
52c94dfae1
commit
1b1c2e9510
@@ -234,4 +234,70 @@ static inline __u16 mdio_phy_id_devad(int phy_id)
|
||||
return phy_id & MDIO_PHY_ID_DEVAD;
|
||||
}
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/**
|
||||
* struct mdio_if_info - Ethernet controller MDIO interface
|
||||
* @prtad: PRTAD of the PHY (%MDIO_PRTAD_NONE if not present/unknown)
|
||||
* @mmds: Mask of MMDs expected to be present in the PHY. This must be
|
||||
* non-zero unless @prtad = %MDIO_PRTAD_NONE.
|
||||
* @mode_support: MDIO modes supported. If %MDIO_SUPPORTS_C22 is set then
|
||||
* MII register access will be passed through with @devad =
|
||||
* %MDIO_DEVAD_NONE. If %MDIO_EMULATE_C22 is set then access to
|
||||
* commonly used clause 22 registers will be translated into
|
||||
* clause 45 registers.
|
||||
* @dev: Net device structure
|
||||
* @mdio_read: Register read function; returns value or negative error code
|
||||
* @mdio_write: Register write function; returns 0 or negative error code
|
||||
*/
|
||||
struct mdio_if_info {
|
||||
int prtad;
|
||||
u32 __bitwise mmds;
|
||||
unsigned mode_support;
|
||||
|
||||
struct net_device *dev;
|
||||
int (*mdio_read)(struct net_device *dev, int prtad, int devad,
|
||||
u16 addr);
|
||||
int (*mdio_write)(struct net_device *dev, int prtad, int devad,
|
||||
u16 addr, u16 val);
|
||||
};
|
||||
|
||||
#define MDIO_PRTAD_NONE (-1)
|
||||
#define MDIO_DEVAD_NONE (-1)
|
||||
#define MDIO_SUPPORTS_C22 1
|
||||
#define MDIO_SUPPORTS_C45 2
|
||||
#define MDIO_EMULATE_C22 4
|
||||
|
||||
struct ethtool_cmd;
|
||||
struct ethtool_pauseparam;
|
||||
extern int mdio45_probe(struct mdio_if_info *mdio, int prtad);
|
||||
extern int mdio_set_flag(const struct mdio_if_info *mdio,
|
||||
int prtad, int devad, u16 addr, int mask,
|
||||
bool sense);
|
||||
extern int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmds);
|
||||
extern int mdio45_nway_restart(const struct mdio_if_info *mdio);
|
||||
extern void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
|
||||
struct ethtool_cmd *ecmd,
|
||||
u32 npage_adv, u32 npage_lpa);
|
||||
|
||||
/**
|
||||
* mdio45_ethtool_gset - get settings for ETHTOOL_GSET
|
||||
* @mdio: MDIO interface
|
||||
* @ecmd: Ethtool request structure
|
||||
*
|
||||
* Since the CSRs for auto-negotiation using next pages are not fully
|
||||
* standardised, this function does not attempt to decode them. Use
|
||||
* mdio45_ethtool_gset_npage() to specify advertisement bits from next
|
||||
* pages.
|
||||
*/
|
||||
static inline void mdio45_ethtool_gset(const struct mdio_if_info *mdio,
|
||||
struct ethtool_cmd *ecmd)
|
||||
{
|
||||
mdio45_ethtool_gset_npage(mdio, ecmd, 0, 0);
|
||||
}
|
||||
|
||||
extern int mdio_mii_ioctl(const struct mdio_if_info *mdio,
|
||||
struct mii_ioctl_data *mii_data, int cmd);
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* __LINUX_MDIO_H__ */
|
||||
|
||||
Reference in New Issue
Block a user