xref: /freebsd/sys/dev/mdio/mdio_if.m (revision dd41de95a84d979615a2ef11df6850622bf6184e)
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 Read register from device on MDIO muxed bus.
44 *
45 * @param dev	MDIO bus device.
46 * @param bus	MDIO bus mux position
47 * @param phy	PHY address.
48 * @param reg	The PHY register offset.
49 */
50METHOD int readreg_mux {
51	device_t		dev;
52	int			bus;
53	int			phy;
54	int			reg;
55};
56
57/**
58 * @brief Write register to device on MDIO bus.
59 *
60 * @param dev	MDIO bus device.
61 * @param phy	PHY address.
62 * @param reg	The PHY register offset.
63 * @param val	The value to write at offset @p reg.
64 */
65METHOD int writereg {
66	device_t		dev;
67	int			phy;
68	int			reg;
69	int			val;
70};
71
72/**
73 * @brief Write register to device on MDIO muxed bus.
74 *
75 * @param dev	MDIO bus device.
76 * @param bus	MDIO bus mux position
77 * @param phy	PHY address.
78 * @param reg	The PHY register offset.
79 * @param val	The value to write at offset @p reg.
80 */
81METHOD int writereg_mux {
82	device_t		dev;
83	int			bus;
84	int			phy;
85	int			reg;
86	int			val;
87};
88
89
90/**
91 * @brief Read extended register from device on MDIO bus.
92 *
93 * @param dev	MDIO bus device.
94 * @param phy	PHY address.
95 * @param devad The MDIO IEEE 802.3 Clause 45 device address, or
96 *		MDIO_DEVADDR_NONE to request Clause 22 register addressing.
97 * @param reg	The PHY register offset.
98 */
99METHOD int readextreg {
100	device_t		dev;
101	int			phy;
102	int			devad;
103	int			reg;
104} DEFAULT mdio_null_readextreg;
105
106
107/**
108 * @brief Write extended register to device on MDIO bus.
109 *
110 * @param dev	MDIO bus device.
111 * @param phy	PHY address.
112 * @param devad The MDIO IEEE 802.3 Clause 45 device address, or
113 *		MDIO_DEVADDR_NONE to request Clause 22 register addressing.
114 * @param reg	The PHY register offset.
115 * @param val	The value to write at offset @p reg.
116 */
117METHOD int writeextreg {
118	device_t		dev;
119	int			phy;
120	int			devad;
121	int			reg;
122	int			val;
123} DEFAULT mdio_null_writeextreg;
124