|
12 | 12 | #ifndef ZEPHYR_INCLUDE_NET_MII_H_
|
13 | 13 | #define ZEPHYR_INCLUDE_NET_MII_H_
|
14 | 14 |
|
| 15 | +#include <zephyr/sys/util_macro.h> |
| 16 | + |
15 | 17 | /**
|
16 | 18 | * @brief Ethernet MII (media independent interface) functions
|
17 | 19 | * @defgroup ethernet_mii Ethernet MII Support Functions
|
|
41 | 43 | /** Auto-Negotiation Link Partner Received Next Page Reg */
|
42 | 44 | #define MII_ANLPRNPR 0x8
|
43 | 45 | /** 1000BASE-T Control Register */
|
44 |
| -#define MII_1KTCR 0x9 |
| 46 | +#define MII_1KTCR 0x9 |
45 | 47 | /** 1000BASE-T Status Register */
|
46 |
| -#define MII_1KSTSR 0xa |
| 48 | +#define MII_1KSTSR 0xa |
47 | 49 | /** MMD Access Control Register */
|
48 | 50 | #define MII_MMD_ACR 0xd
|
49 | 51 | /** MMD Access Address Data Register */
|
|
53 | 55 |
|
54 | 56 | /* Basic Mode Control Register (BMCR) bit definitions */
|
55 | 57 | /** PHY reset */
|
56 |
| -#define MII_BMCR_RESET (1 << 15) |
| 58 | +#define MII_BMCR_RESET BIT(15) |
57 | 59 | /** enable loopback mode */
|
58 |
| -#define MII_BMCR_LOOPBACK (1 << 14) |
| 60 | +#define MII_BMCR_LOOPBACK BIT(14) |
59 | 61 | /** 10=1000Mbps 01=100Mbps; 00=10Mbps */
|
60 |
| -#define MII_BMCR_SPEED_LSB (1 << 13) |
| 62 | +#define MII_BMCR_SPEED_LSB BIT(13) |
61 | 63 | /** Auto-Negotiation enable */
|
62 |
| -#define MII_BMCR_AUTONEG_ENABLE (1 << 12) |
| 64 | +#define MII_BMCR_AUTONEG_ENABLE BIT(12) |
63 | 65 | /** power down mode */
|
64 |
| -#define MII_BMCR_POWER_DOWN (1 << 11) |
| 66 | +#define MII_BMCR_POWER_DOWN BIT(11) |
65 | 67 | /** isolate electrically PHY from MII */
|
66 |
| -#define MII_BMCR_ISOLATE (1 << 10) |
| 68 | +#define MII_BMCR_ISOLATE BIT(10) |
67 | 69 | /** restart auto-negotiation */
|
68 |
| -#define MII_BMCR_AUTONEG_RESTART (1 << 9) |
| 70 | +#define MII_BMCR_AUTONEG_RESTART BIT(9) |
69 | 71 | /** full duplex mode */
|
70 |
| -#define MII_BMCR_DUPLEX_MODE (1 << 8) |
| 72 | +#define MII_BMCR_DUPLEX_MODE BIT(8) |
71 | 73 | /** 10=1000Mbps 01=100Mbps; 00=10Mbps */
|
72 |
| -#define MII_BMCR_SPEED_MSB (1 << 6) |
| 74 | +#define MII_BMCR_SPEED_MSB BIT(6) |
73 | 75 | /** Link Speed Field */
|
74 |
| -#define MII_BMCR_SPEED_MASK (1 << 6 | 1 << 13) |
| 76 | +#define MII_BMCR_SPEED_MASK (BIT(6) | BIT(13)) |
75 | 77 | /** select speed 10 Mb/s */
|
76 |
| -#define MII_BMCR_SPEED_10 (0 << 6 | 0 << 13) |
| 78 | +#define MII_BMCR_SPEED_10 0 |
77 | 79 | /** select speed 100 Mb/s */
|
78 |
| -#define MII_BMCR_SPEED_100 (0 << 6 | 1 << 13) |
| 80 | +#define MII_BMCR_SPEED_100 BIT(13) |
79 | 81 | /** select speed 1000 Mb/s */
|
80 |
| -#define MII_BMCR_SPEED_1000 (1 << 6 | 0 << 13) |
| 82 | +#define MII_BMCR_SPEED_1000 BIT(6) |
81 | 83 |
|
82 | 84 | /* Basic Mode Status Register (BMSR) bit definitions */
|
83 | 85 | /** 100BASE-T4 capable */
|
84 |
| -#define MII_BMSR_100BASE_T4 (1 << 15) |
| 86 | +#define MII_BMSR_100BASE_T4 BIT(15) |
85 | 87 | /** 100BASE-X full duplex capable */
|
86 |
| -#define MII_BMSR_100BASE_X_FULL (1 << 14) |
| 88 | +#define MII_BMSR_100BASE_X_FULL BIT(14) |
87 | 89 | /** 100BASE-X half duplex capable */
|
88 |
| -#define MII_BMSR_100BASE_X_HALF (1 << 13) |
| 90 | +#define MII_BMSR_100BASE_X_HALF BIT(13) |
89 | 91 | /** 10 Mb/s full duplex capable */
|
90 |
| -#define MII_BMSR_10_FULL (1 << 12) |
| 92 | +#define MII_BMSR_10_FULL BIT(12) |
91 | 93 | /** 10 Mb/s half duplex capable */
|
92 |
| -#define MII_BMSR_10_HALF (1 << 11) |
| 94 | +#define MII_BMSR_10_HALF BIT(11) |
93 | 95 | /** 100BASE-T2 full duplex capable */
|
94 |
| -#define MII_BMSR_100BASE_T2_FULL (1 << 10) |
| 96 | +#define MII_BMSR_100BASE_T2_FULL BIT(10) |
95 | 97 | /** 100BASE-T2 half duplex capable */
|
96 |
| -#define MII_BMSR_100BASE_T2_HALF (1 << 9) |
| 98 | +#define MII_BMSR_100BASE_T2_HALF BIT(9) |
97 | 99 | /** extend status information in reg 15 */
|
98 |
| -#define MII_BMSR_EXTEND_STATUS (1 << 8) |
| 100 | +#define MII_BMSR_EXTEND_STATUS BIT(8) |
99 | 101 | /** PHY accepts management frames with preamble suppressed */
|
100 |
| -#define MII_BMSR_MF_PREAMB_SUPPR (1 << 6) |
| 102 | +#define MII_BMSR_MF_PREAMB_SUPPR BIT(6) |
101 | 103 | /** Auto-negotiation process completed */
|
102 |
| -#define MII_BMSR_AUTONEG_COMPLETE (1 << 5) |
| 104 | +#define MII_BMSR_AUTONEG_COMPLETE BIT(5) |
103 | 105 | /** remote fault detected */
|
104 |
| -#define MII_BMSR_REMOTE_FAULT (1 << 4) |
| 106 | +#define MII_BMSR_REMOTE_FAULT BIT(4) |
105 | 107 | /** PHY is able to perform Auto-Negotiation */
|
106 |
| -#define MII_BMSR_AUTONEG_ABILITY (1 << 3) |
| 108 | +#define MII_BMSR_AUTONEG_ABILITY BIT(3) |
107 | 109 | /** link is up */
|
108 |
| -#define MII_BMSR_LINK_STATUS (1 << 2) |
| 110 | +#define MII_BMSR_LINK_STATUS BIT(2) |
109 | 111 | /** jabber condition detected */
|
110 |
| -#define MII_BMSR_JABBER_DETECT (1 << 1) |
| 112 | +#define MII_BMSR_JABBER_DETECT BIT(1) |
111 | 113 | /** extended register capabilities */
|
112 |
| -#define MII_BMSR_EXTEND_CAPAB (1 << 0) |
| 114 | +#define MII_BMSR_EXTEND_CAPAB BIT(0) |
113 | 115 |
|
114 | 116 | /* Auto-negotiation Advertisement Register (ANAR) bit definitions */
|
115 | 117 | /* Auto-negotiation Link Partner Ability Register (ANLPAR) bit definitions */
|
116 | 118 | /** next page */
|
117 |
| -#define MII_ADVERTISE_NEXT_PAGE (1 << 15) |
| 119 | +#define MII_ADVERTISE_NEXT_PAGE BIT(15) |
118 | 120 | /** link partner acknowledge response */
|
119 |
| -#define MII_ADVERTISE_LPACK (1 << 14) |
| 121 | +#define MII_ADVERTISE_LPACK BIT(14) |
120 | 122 | /** remote fault */
|
121 |
| -#define MII_ADVERTISE_REMOTE_FAULT (1 << 13) |
| 123 | +#define MII_ADVERTISE_REMOTE_FAULT BIT(13) |
122 | 124 | /** try for asymmetric pause */
|
123 |
| -#define MII_ADVERTISE_ASYM_PAUSE (1 << 11) |
| 125 | +#define MII_ADVERTISE_ASYM_PAUSE BIT(11) |
124 | 126 | /** try for pause */
|
125 |
| -#define MII_ADVERTISE_PAUSE (1 << 10) |
| 127 | +#define MII_ADVERTISE_PAUSE BIT(10) |
126 | 128 | /** try for 100BASE-T4 support */
|
127 |
| -#define MII_ADVERTISE_100BASE_T4 (1 << 9) |
| 129 | +#define MII_ADVERTISE_100BASE_T4 BIT(9) |
128 | 130 | /** try for 100BASE-X full duplex support */
|
129 |
| -#define MII_ADVERTISE_100_FULL (1 << 8) |
| 131 | +#define MII_ADVERTISE_100_FULL BIT(8) |
130 | 132 | /** try for 100BASE-X support */
|
131 |
| -#define MII_ADVERTISE_100_HALF (1 << 7) |
| 133 | +#define MII_ADVERTISE_100_HALF BIT(7) |
132 | 134 | /** try for 10 Mb/s full duplex support */
|
133 |
| -#define MII_ADVERTISE_10_FULL (1 << 6) |
| 135 | +#define MII_ADVERTISE_10_FULL BIT(6) |
134 | 136 | /** try for 10 Mb/s half duplex support */
|
135 |
| -#define MII_ADVERTISE_10_HALF (1 << 5) |
| 137 | +#define MII_ADVERTISE_10_HALF BIT(5) |
136 | 138 | /** Selector Field Mask */
|
137 | 139 | #define MII_ADVERTISE_SEL_MASK (0x1F << 0)
|
138 | 140 | /** Selector Field */
|
139 | 141 | #define MII_ADVERTISE_SEL_IEEE_802_3 0x01
|
140 | 142 |
|
141 | 143 | /* 1000BASE-T Control Register bit definitions */
|
142 | 144 | /** try for 1000BASE-T full duplex support */
|
143 |
| -#define MII_ADVERTISE_1000_FULL (1 << 9) |
| 145 | +#define MII_ADVERTISE_1000_FULL BIT(9) |
144 | 146 | /** try for 1000BASE-T half duplex support */
|
145 |
| -#define MII_ADVERTISE_1000_HALF (1 << 8) |
| 147 | +#define MII_ADVERTISE_1000_HALF BIT(8) |
146 | 148 |
|
147 | 149 | /** Advertise all speeds */
|
148 | 150 | #define MII_ADVERTISE_ALL (MII_ADVERTISE_10_HALF | MII_ADVERTISE_10_FULL |\
|
|
151 | 153 |
|
152 | 154 | /* Extended Status Register bit definitions */
|
153 | 155 | /** 1000BASE-X full-duplex capable */
|
154 |
| -#define MII_ESTAT_1000BASE_X_FULL (1 << 15) |
| 156 | +#define MII_ESTAT_1000BASE_X_FULL BIT(15) |
155 | 157 | /** 1000BASE-X half-duplex capable */
|
156 |
| -#define MII_ESTAT_1000BASE_X_HALF (1 << 14) |
| 158 | +#define MII_ESTAT_1000BASE_X_HALF BIT(14) |
157 | 159 | /** 1000BASE-T full-duplex capable */
|
158 |
| -#define MII_ESTAT_1000BASE_T_FULL (1 << 13) |
| 160 | +#define MII_ESTAT_1000BASE_T_FULL BIT(13) |
159 | 161 | /** 1000BASE-T half-duplex capable */
|
160 |
| -#define MII_ESTAT_1000BASE_T_HALF (1 << 12) |
| 162 | +#define MII_ESTAT_1000BASE_T_HALF BIT(12) |
161 | 163 |
|
162 | 164 | /* MMD Access Control Register (MII_MMD_ACR) Register bit definitions */
|
163 | 165 | /** DEVAD Mask */
|
|
0 commit comments