xref: /freebsd/sys/dev/mdio/mdio_if.m (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
1# $FreeBSD$
2
3#include <sys/bus.h>
4
5INTERFACE mdio;
6
7CODE {
8	#include <dev/mdio/mdio.h>
9
10	static int
11	mdio_null_readextreg(device_t dev, int phy, int devad, int reg)
12	{
13		if (devad == MDIO_DEVADDR_NONE)
14			return (MDIO_READREG(dev, phy, reg));
15		return (~0U);
16	}
17
18	static int
19	mdio_null_writeextreg(device_t dev, int phy, int devad, int reg,
20	    int val)
21	{
22		if (devad == MDIO_DEVADDR_NONE)
23			return (MDIO_WRITEREG(dev, phy, reg, val));
24
25		return (EINVAL);
26	}
27}
28
29/**
30 * @brief Read register from device on MDIO bus.
31 *
32 * @param dev	MDIO bus device.
33 * @param phy	PHY address.
34 * @param reg	The PHY register offset.
35 */
36METHOD int readreg {
37	device_t		dev;
38	int			phy;
39	int			reg;
40};
41
42/**
43 * @brief Write register to device on MDIO bus.
44 *
45 * @param dev	MDIO bus device.
46 * @param phy	PHY address.
47 * @param reg	The PHY register offset.
48 * @param val	The value to write at offset @p reg.
49 */
50METHOD int writereg {
51	device_t		dev;
52	int			phy;
53	int			reg;
54	int			val;
55};
56
57
58/**
59 * @brief Read extended register from device on MDIO bus.
60 *
61 * @param dev	MDIO bus device.
62 * @param phy	PHY address.
63 * @param devad The MDIO IEEE 802.3 Clause 45 device address, or
64 *		MDIO_DEVADDR_NONE to request Clause 22 register addressing.
65 * @param reg	The PHY register offset.
66 */
67METHOD int readextreg {
68	device_t		dev;
69	int			phy;
70	int			devad;
71	int			reg;
72} DEFAULT mdio_null_readextreg;
73
74
75/**
76 * @brief Write extended register to device on MDIO bus.
77 *
78 * @param dev	MDIO bus device.
79 * @param phy	PHY address.
80 * @param devad The MDIO IEEE 802.3 Clause 45 device address, or
81 *		MDIO_DEVADDR_NONE to request Clause 22 register addressing.
82 * @param reg	The PHY register offset.
83 * @param val	The value to write at offset @p reg.
84 */
85METHOD int writeextreg {
86	device_t		dev;
87	int			phy;
88	int			devad;
89	int			reg;
90	int			val;
91} DEFAULT mdio_null_writeextreg;
92