Skip to content

Commit db79e78

Browse files
maass-hamburgdkalowsk
authored andcommitted
net: mii: use BIT() macro in mii.h
use BIT() macro in mii.h. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
1 parent 8ed5f03 commit db79e78

File tree

1 file changed

+48
-46
lines changed

1 file changed

+48
-46
lines changed

include/zephyr/net/mii.h

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#ifndef ZEPHYR_INCLUDE_NET_MII_H_
1313
#define ZEPHYR_INCLUDE_NET_MII_H_
1414

15+
#include <zephyr/sys/util_macro.h>
16+
1517
/**
1618
* @brief Ethernet MII (media independent interface) functions
1719
* @defgroup ethernet_mii Ethernet MII Support Functions
@@ -41,9 +43,9 @@
4143
/** Auto-Negotiation Link Partner Received Next Page Reg */
4244
#define MII_ANLPRNPR 0x8
4345
/** 1000BASE-T Control Register */
44-
#define MII_1KTCR 0x9
46+
#define MII_1KTCR 0x9
4547
/** 1000BASE-T Status Register */
46-
#define MII_1KSTSR 0xa
48+
#define MII_1KSTSR 0xa
4749
/** MMD Access Control Register */
4850
#define MII_MMD_ACR 0xd
4951
/** MMD Access Address Data Register */
@@ -53,96 +55,96 @@
5355

5456
/* Basic Mode Control Register (BMCR) bit definitions */
5557
/** PHY reset */
56-
#define MII_BMCR_RESET (1 << 15)
58+
#define MII_BMCR_RESET BIT(15)
5759
/** enable loopback mode */
58-
#define MII_BMCR_LOOPBACK (1 << 14)
60+
#define MII_BMCR_LOOPBACK BIT(14)
5961
/** 10=1000Mbps 01=100Mbps; 00=10Mbps */
60-
#define MII_BMCR_SPEED_LSB (1 << 13)
62+
#define MII_BMCR_SPEED_LSB BIT(13)
6163
/** Auto-Negotiation enable */
62-
#define MII_BMCR_AUTONEG_ENABLE (1 << 12)
64+
#define MII_BMCR_AUTONEG_ENABLE BIT(12)
6365
/** power down mode */
64-
#define MII_BMCR_POWER_DOWN (1 << 11)
66+
#define MII_BMCR_POWER_DOWN BIT(11)
6567
/** isolate electrically PHY from MII */
66-
#define MII_BMCR_ISOLATE (1 << 10)
68+
#define MII_BMCR_ISOLATE BIT(10)
6769
/** restart auto-negotiation */
68-
#define MII_BMCR_AUTONEG_RESTART (1 << 9)
70+
#define MII_BMCR_AUTONEG_RESTART BIT(9)
6971
/** full duplex mode */
70-
#define MII_BMCR_DUPLEX_MODE (1 << 8)
72+
#define MII_BMCR_DUPLEX_MODE BIT(8)
7173
/** 10=1000Mbps 01=100Mbps; 00=10Mbps */
72-
#define MII_BMCR_SPEED_MSB (1 << 6)
74+
#define MII_BMCR_SPEED_MSB BIT(6)
7375
/** Link Speed Field */
74-
#define MII_BMCR_SPEED_MASK (1 << 6 | 1 << 13)
76+
#define MII_BMCR_SPEED_MASK (BIT(6) | BIT(13))
7577
/** select speed 10 Mb/s */
76-
#define MII_BMCR_SPEED_10 (0 << 6 | 0 << 13)
78+
#define MII_BMCR_SPEED_10 0
7779
/** select speed 100 Mb/s */
78-
#define MII_BMCR_SPEED_100 (0 << 6 | 1 << 13)
80+
#define MII_BMCR_SPEED_100 BIT(13)
7981
/** select speed 1000 Mb/s */
80-
#define MII_BMCR_SPEED_1000 (1 << 6 | 0 << 13)
82+
#define MII_BMCR_SPEED_1000 BIT(6)
8183

8284
/* Basic Mode Status Register (BMSR) bit definitions */
8385
/** 100BASE-T4 capable */
84-
#define MII_BMSR_100BASE_T4 (1 << 15)
86+
#define MII_BMSR_100BASE_T4 BIT(15)
8587
/** 100BASE-X full duplex capable */
86-
#define MII_BMSR_100BASE_X_FULL (1 << 14)
88+
#define MII_BMSR_100BASE_X_FULL BIT(14)
8789
/** 100BASE-X half duplex capable */
88-
#define MII_BMSR_100BASE_X_HALF (1 << 13)
90+
#define MII_BMSR_100BASE_X_HALF BIT(13)
8991
/** 10 Mb/s full duplex capable */
90-
#define MII_BMSR_10_FULL (1 << 12)
92+
#define MII_BMSR_10_FULL BIT(12)
9193
/** 10 Mb/s half duplex capable */
92-
#define MII_BMSR_10_HALF (1 << 11)
94+
#define MII_BMSR_10_HALF BIT(11)
9395
/** 100BASE-T2 full duplex capable */
94-
#define MII_BMSR_100BASE_T2_FULL (1 << 10)
96+
#define MII_BMSR_100BASE_T2_FULL BIT(10)
9597
/** 100BASE-T2 half duplex capable */
96-
#define MII_BMSR_100BASE_T2_HALF (1 << 9)
98+
#define MII_BMSR_100BASE_T2_HALF BIT(9)
9799
/** extend status information in reg 15 */
98-
#define MII_BMSR_EXTEND_STATUS (1 << 8)
100+
#define MII_BMSR_EXTEND_STATUS BIT(8)
99101
/** 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)
101103
/** Auto-negotiation process completed */
102-
#define MII_BMSR_AUTONEG_COMPLETE (1 << 5)
104+
#define MII_BMSR_AUTONEG_COMPLETE BIT(5)
103105
/** remote fault detected */
104-
#define MII_BMSR_REMOTE_FAULT (1 << 4)
106+
#define MII_BMSR_REMOTE_FAULT BIT(4)
105107
/** PHY is able to perform Auto-Negotiation */
106-
#define MII_BMSR_AUTONEG_ABILITY (1 << 3)
108+
#define MII_BMSR_AUTONEG_ABILITY BIT(3)
107109
/** link is up */
108-
#define MII_BMSR_LINK_STATUS (1 << 2)
110+
#define MII_BMSR_LINK_STATUS BIT(2)
109111
/** jabber condition detected */
110-
#define MII_BMSR_JABBER_DETECT (1 << 1)
112+
#define MII_BMSR_JABBER_DETECT BIT(1)
111113
/** extended register capabilities */
112-
#define MII_BMSR_EXTEND_CAPAB (1 << 0)
114+
#define MII_BMSR_EXTEND_CAPAB BIT(0)
113115

114116
/* Auto-negotiation Advertisement Register (ANAR) bit definitions */
115117
/* Auto-negotiation Link Partner Ability Register (ANLPAR) bit definitions */
116118
/** next page */
117-
#define MII_ADVERTISE_NEXT_PAGE (1 << 15)
119+
#define MII_ADVERTISE_NEXT_PAGE BIT(15)
118120
/** link partner acknowledge response */
119-
#define MII_ADVERTISE_LPACK (1 << 14)
121+
#define MII_ADVERTISE_LPACK BIT(14)
120122
/** remote fault */
121-
#define MII_ADVERTISE_REMOTE_FAULT (1 << 13)
123+
#define MII_ADVERTISE_REMOTE_FAULT BIT(13)
122124
/** try for asymmetric pause */
123-
#define MII_ADVERTISE_ASYM_PAUSE (1 << 11)
125+
#define MII_ADVERTISE_ASYM_PAUSE BIT(11)
124126
/** try for pause */
125-
#define MII_ADVERTISE_PAUSE (1 << 10)
127+
#define MII_ADVERTISE_PAUSE BIT(10)
126128
/** try for 100BASE-T4 support */
127-
#define MII_ADVERTISE_100BASE_T4 (1 << 9)
129+
#define MII_ADVERTISE_100BASE_T4 BIT(9)
128130
/** try for 100BASE-X full duplex support */
129-
#define MII_ADVERTISE_100_FULL (1 << 8)
131+
#define MII_ADVERTISE_100_FULL BIT(8)
130132
/** try for 100BASE-X support */
131-
#define MII_ADVERTISE_100_HALF (1 << 7)
133+
#define MII_ADVERTISE_100_HALF BIT(7)
132134
/** try for 10 Mb/s full duplex support */
133-
#define MII_ADVERTISE_10_FULL (1 << 6)
135+
#define MII_ADVERTISE_10_FULL BIT(6)
134136
/** try for 10 Mb/s half duplex support */
135-
#define MII_ADVERTISE_10_HALF (1 << 5)
137+
#define MII_ADVERTISE_10_HALF BIT(5)
136138
/** Selector Field Mask */
137139
#define MII_ADVERTISE_SEL_MASK (0x1F << 0)
138140
/** Selector Field */
139141
#define MII_ADVERTISE_SEL_IEEE_802_3 0x01
140142

141143
/* 1000BASE-T Control Register bit definitions */
142144
/** try for 1000BASE-T full duplex support */
143-
#define MII_ADVERTISE_1000_FULL (1 << 9)
145+
#define MII_ADVERTISE_1000_FULL BIT(9)
144146
/** try for 1000BASE-T half duplex support */
145-
#define MII_ADVERTISE_1000_HALF (1 << 8)
147+
#define MII_ADVERTISE_1000_HALF BIT(8)
146148

147149
/** Advertise all speeds */
148150
#define MII_ADVERTISE_ALL (MII_ADVERTISE_10_HALF | MII_ADVERTISE_10_FULL |\
@@ -151,13 +153,13 @@
151153

152154
/* Extended Status Register bit definitions */
153155
/** 1000BASE-X full-duplex capable */
154-
#define MII_ESTAT_1000BASE_X_FULL (1 << 15)
156+
#define MII_ESTAT_1000BASE_X_FULL BIT(15)
155157
/** 1000BASE-X half-duplex capable */
156-
#define MII_ESTAT_1000BASE_X_HALF (1 << 14)
158+
#define MII_ESTAT_1000BASE_X_HALF BIT(14)
157159
/** 1000BASE-T full-duplex capable */
158-
#define MII_ESTAT_1000BASE_T_FULL (1 << 13)
160+
#define MII_ESTAT_1000BASE_T_FULL BIT(13)
159161
/** 1000BASE-T half-duplex capable */
160-
#define MII_ESTAT_1000BASE_T_HALF (1 << 12)
162+
#define MII_ESTAT_1000BASE_T_HALF BIT(12)
161163

162164
/* MMD Access Control Register (MII_MMD_ACR) Register bit definitions */
163165
/** DEVAD Mask */

0 commit comments

Comments
 (0)