mii.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
26 #ifndef MII_H
27 #define MII_H
28 
29 #include <stdbool.h>
30 #include <stdint.h>
31 
32 #include "bitarithm.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
47 #define MII_BMCR (0x00U)
48 #define MII_BMSR (0x01U)
49 #define MII_PHYID1 (0x02U)
50 #define MII_PHYID2 (0x03U)
51 #define MII_ADVERTISE (0x04U)
52 #define MII_LPA (0x05U)
53 #define MII_EXPANSION (0x06U)
54 #define MII_ESTATUS (0x0fU)
61 #define MII_BMCR_RESET BIT15
62 #define MII_BMCR_LOOP BIT14
63 #define MII_BMCR_AN_ENABLE BIT12
64 #define MII_BMCR_POWER_DOWN BIT11
65 #define MII_BMCR_ISOLATE BIT10
67 #define MII_BMCR_AN_RESTART BIT9
68 #define MII_BMCR_FULL_DPLX BIT8
69 #define MII_BMCR_HALF_DPLX (0)
70 #define MII_BMCR_COLL_TEST BIT7
71 #define MII_BMCR_SPEED_10 (0)
72 #define MII_BMCR_SPEED_100 BIT13
73 #define MII_BMCR_SPEED_1000 BIT6
80 #define MII_BMSR_100_T4 BIT15
81 #define MII_BMSR_100_TX_F BIT14
82 #define MII_BMSR_100_TX_H BIT13
83 #define MII_BMSR_10_F BIT12
84 #define MII_BMSR_10_H BIT11
85 #define MII_BMSR_100_T2_F BIT10
86 #define MII_BMSR_100_T2_H BIT9
87 #define MII_BMSR_ESTATUS BIT8
89 #define MII_BMSR_AN_DONE BIT5
90 #define MII_BMSR_FAULT BIT4
92 #define MII_BMSR_HAS_AN BIT3
93 #define MII_BMSR_LINK BIT2
94 #define MII_BMSR_JABBER BIT1
95 #define MII_BMSR_EXTENDED BIT0
102 #define MII_ADVERTISE_100_F BIT8
103 #define MII_ADVERTISE_100_H BIT7
104 #define MII_ADVERTISE_10_F BIT6
105 #define MII_ADVERTISE_10_H BIT5
106 #define MII_ADVERTISE_100 (BIT7 | BIT8)
107 #define MII_ADVERTISE_10 (BIT5 | BIT6)
114 #define MII_LPA_100_F BIT8
115 #define MII_LPA_100_H BIT7
116 #define MII_LPA_10_F BIT6
117 #define MII_LPA_10_H BIT5
118 #define MII_LPA_100 (BIT7 | BIT8)
119 #define MII_LPA_10 (BIT5 | BIT6)
130 static inline bool mii_can_100_mbps_full_dp(uint16_t bmsr)
131 {
132  return (bmsr & (MII_BMSR_100_TX_F | MII_BMSR_100_T2_F));
133 }
134 
143 static inline bool mii_can_100_mbps_half_dp(uint16_t bmsr)
144 {
146 }
147 
156 static inline bool mii_can_10_mbps_full_dp(uint16_t bmsr)
157 {
158  return (bmsr & MII_BMSR_10_F);
159 }
160 
169 static inline bool mii_can_10_mbps_half_dp(uint16_t bmsr)
170 {
171  return (bmsr & MII_BMSR_10_H);
172 }
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* MII_H */
179 
MII_BMSR_100_T4
#define MII_BMSR_100_T4
PHY supports 100BASE-T4 (half-duplex)
Definition: mii.h:80
MII_BMSR_100_TX_F
#define MII_BMSR_100_TX_F
PHY supports 100BASE-TX, full duplex.
Definition: mii.h:81
mii_can_10_mbps_half_dp
static bool mii_can_10_mbps_half_dp(uint16_t bmsr)
Check if an Ethernet PHY supports 10 Mbps at half duplex.
Definition: mii.h:169
MII_BMSR_100_T2_F
#define MII_BMSR_100_T2_F
PHY supports 100BASE-T2, full duplex.
Definition: mii.h:85
MII_BMSR_100_T2_H
#define MII_BMSR_100_T2_H
PHY supports 100BASE-T2, half duplex.
Definition: mii.h:86
mii_can_10_mbps_full_dp
static bool mii_can_10_mbps_full_dp(uint16_t bmsr)
Check if an Ethernet PHY supports 10 Mbps at full duplex.
Definition: mii.h:156
bitarithm.h
Helper functions for bit arithmetic.
MII_BMSR_10_H
#define MII_BMSR_10_H
PHY supports 10BASE-T, half duplex.
Definition: mii.h:84
MII_BMSR_10_F
#define MII_BMSR_10_F
PHY supports 10BASE-T, full duplex.
Definition: mii.h:83
MII_BMSR_100_TX_H
#define MII_BMSR_100_TX_H
PHY supports 100BASE-TX, half duplex.
Definition: mii.h:82
mii_can_100_mbps_half_dp
static bool mii_can_100_mbps_half_dp(uint16_t bmsr)
Check if an Ethernet PHY supports 100 Mbps at half duplex.
Definition: mii.h:143