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