[mdio] Add MDIO support for "extended" registers as defined by IEEE 802.3 Clause 45.
IEEE 802.3 Clause 45 added backwards-compatible support for 2^16 PHY registers through the addition of an additional device address frame. Clause 45 addressing is used in 10Gbe PHYs, 802.3az EEE registers, etc. It may make sense to provide a similar extension to the miibus interface, but I've refrained from unilaterally doing so here. Submitted by: Landon Fuller <landon@landonf.org> Differential Revision: https://reviews.freebsd.org/D4607
This commit is contained in:
parent
1899507706
commit
e2db1d1f11
@ -83,6 +83,21 @@ mdio_writereg(device_t dev, int phy, int reg, int val)
|
|||||||
return (MDIO_WRITEREG(device_get_parent(dev), phy, reg, val));
|
return (MDIO_WRITEREG(device_get_parent(dev), phy, reg, val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
mdio_readextreg(device_t dev, int phy, int devad, int reg)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (MDIO_READEXTREG(device_get_parent(dev), phy, devad, reg));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
mdio_writeextreg(device_t dev, int phy, int devad, int reg,
|
||||||
|
int val)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (MDIO_WRITEEXTREG(device_get_parent(dev), phy, devad, reg, val));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mdio_hinted_child(device_t dev, const char *name, int unit)
|
mdio_hinted_child(device_t dev, const char *name, int unit)
|
||||||
{
|
{
|
||||||
@ -105,6 +120,8 @@ static device_method_t mdio_methods[] = {
|
|||||||
/* MDIO access */
|
/* MDIO access */
|
||||||
DEVMETHOD(mdio_readreg, mdio_readreg),
|
DEVMETHOD(mdio_readreg, mdio_readreg),
|
||||||
DEVMETHOD(mdio_writereg, mdio_writereg),
|
DEVMETHOD(mdio_writereg, mdio_writereg),
|
||||||
|
DEVMETHOD(mdio_readextreg, mdio_readextreg),
|
||||||
|
DEVMETHOD(mdio_writeextreg, mdio_writeextreg),
|
||||||
|
|
||||||
DEVMETHOD_END
|
DEVMETHOD_END
|
||||||
};
|
};
|
||||||
|
@ -32,4 +32,6 @@
|
|||||||
extern driver_t mdio_driver;
|
extern driver_t mdio_driver;
|
||||||
extern devclass_t mdio_devclass;
|
extern devclass_t mdio_devclass;
|
||||||
|
|
||||||
|
#define MDIO_DEVADDR_NONE -1 /**< Use clause 22 register access */
|
||||||
|
|
||||||
#endif /* __DEV_MDIO_MDIO_H__ */
|
#endif /* __DEV_MDIO_MDIO_H__ */
|
||||||
|
@ -4,21 +4,88 @@
|
|||||||
|
|
||||||
INTERFACE mdio;
|
INTERFACE mdio;
|
||||||
|
|
||||||
#
|
CODE {
|
||||||
# Read register from device on MDIO bus
|
#include <dev/mdio/mdio.h>
|
||||||
#
|
|
||||||
|
static int
|
||||||
|
mdio_null_readextreg(device_t dev, int phy, int devad, int reg)
|
||||||
|
{
|
||||||
|
if (devad == MDIO_DEVADDR_NONE)
|
||||||
|
return (MDIO_READREG(dev, phy, reg));
|
||||||
|
return (~0U);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
mdio_null_writeextreg(device_t dev, int phy, int devad, int reg,
|
||||||
|
int val)
|
||||||
|
{
|
||||||
|
if (devad == MDIO_DEVADDR_NONE)
|
||||||
|
return (MDIO_WRITEREG(dev, phy, reg, val));
|
||||||
|
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read register from device on MDIO bus.
|
||||||
|
*
|
||||||
|
* @param dev MDIO bus device.
|
||||||
|
* @param phy PHY address.
|
||||||
|
* @param reg The PHY register offset.
|
||||||
|
*/
|
||||||
METHOD int readreg {
|
METHOD int readreg {
|
||||||
device_t dev;
|
device_t dev;
|
||||||
int phy;
|
int phy;
|
||||||
int reg;
|
int reg;
|
||||||
};
|
};
|
||||||
|
|
||||||
#
|
/**
|
||||||
# Write register to device on MDIO bus
|
* @brief Write register to device on MDIO bus.
|
||||||
#
|
*
|
||||||
|
* @param dev MDIO bus device.
|
||||||
|
* @param phy PHY address.
|
||||||
|
* @param reg The PHY register offset.
|
||||||
|
* @param val The value to write at offset @p reg.
|
||||||
|
*/
|
||||||
METHOD int writereg {
|
METHOD int writereg {
|
||||||
device_t dev;
|
device_t dev;
|
||||||
int phy;
|
int phy;
|
||||||
int reg;
|
int reg;
|
||||||
int val;
|
int val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read extended register from device on MDIO bus.
|
||||||
|
*
|
||||||
|
* @param dev MDIO bus device.
|
||||||
|
* @param phy PHY address.
|
||||||
|
* @param devad The MDIO IEEE 802.3 Clause 45 device address, or
|
||||||
|
* MDIO_DEVADDR_NONE to request Clause 22 register addressing.
|
||||||
|
* @param reg The PHY register offset.
|
||||||
|
*/
|
||||||
|
METHOD int readextreg {
|
||||||
|
device_t dev;
|
||||||
|
int phy;
|
||||||
|
int devad;
|
||||||
|
int reg;
|
||||||
|
} DEFAULT mdio_null_readextreg;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write extended register to device on MDIO bus.
|
||||||
|
*
|
||||||
|
* @param dev MDIO bus device.
|
||||||
|
* @param phy PHY address.
|
||||||
|
* @param devad The MDIO IEEE 802.3 Clause 45 device address, or
|
||||||
|
* MDIO_DEVADDR_NONE to request Clause 22 register addressing.
|
||||||
|
* @param reg The PHY register offset.
|
||||||
|
* @param val The value to write at offset @p reg.
|
||||||
|
*/
|
||||||
|
METHOD int writeextreg {
|
||||||
|
device_t dev;
|
||||||
|
int phy;
|
||||||
|
int devad;
|
||||||
|
int reg;
|
||||||
|
int val;
|
||||||
|
} DEFAULT mdio_null_writeextreg;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user