Commit 1b1c2e95 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

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: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 52c94dfa
......@@ -2443,6 +2443,9 @@ menuconfig NETDEV_10000
if NETDEV_10000
config MDIO
tristate
config CHELSIO_T1
tristate "Chelsio 10Gb Ethernet support"
depends on PCI
......
......@@ -95,6 +95,7 @@ obj-$(CONFIG_SH_ETH) += sh_eth.o
#
obj-$(CONFIG_MII) += mii.o
obj-$(CONFIG_MDIO) += mdio.o
obj-$(CONFIG_PHYLIB) += phy/
obj-$(CONFIG_SUNDANCE) += sundance.o
......
This diff is collapsed.
......@@ -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__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment