Loading...
Searching...
No Matches
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
35extern "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)
55#define MII_IRQ (0x1bU)
62#define MII_BMCR_RESET BIT15
63#define MII_BMCR_LOOP BIT14
64#define MII_BMCR_AN_ENABLE BIT12
65#define MII_BMCR_POWER_DOWN BIT11
66#define MII_BMCR_ISOLATE BIT10
68#define MII_BMCR_AN_RESTART BIT9
69#define MII_BMCR_FULL_DPLX BIT8
70#define MII_BMCR_HALF_DPLX (0)
71#define MII_BMCR_COLL_TEST BIT7
72#define MII_BMCR_SPEED_10 (0)
73#define MII_BMCR_SPEED_100 BIT13
74#define MII_BMCR_SPEED_1000 BIT6
81#define MII_BMSR_100_T4 BIT15
82#define MII_BMSR_100_TX_F BIT14
83#define MII_BMSR_100_TX_H BIT13
84#define MII_BMSR_10_F BIT12
85#define MII_BMSR_10_H BIT11
86#define MII_BMSR_100_T2_F BIT10
87#define MII_BMSR_100_T2_H BIT9
88#define MII_BMSR_ESTATUS BIT8
90#define MII_BMSR_AN_DONE BIT5
91#define MII_BMSR_FAULT BIT4
93#define MII_BMSR_HAS_AN BIT3
94#define MII_BMSR_LINK BIT2
95#define MII_BMSR_JABBER BIT1
96#define MII_BMSR_EXTENDED BIT0
103#define MII_ADVERTISE_100_F BIT8
104#define MII_ADVERTISE_100_H BIT7
105#define MII_ADVERTISE_10_F BIT6
106#define MII_ADVERTISE_10_H BIT5
107#define MII_ADVERTISE_100 (BIT7 | BIT8)
108#define MII_ADVERTISE_10 (BIT5 | BIT6)
115#define MII_LPA_100_F BIT8
116#define MII_LPA_100_H BIT7
117#define MII_LPA_10_F BIT6
118#define MII_LPA_10_H BIT5
119#define MII_LPA_100 (BIT7 | BIT8)
120#define MII_LPA_10 (BIT5 | BIT6)
127#define MII_LPA_HAS_AN BIT0
134#define MII_IRQ_LINK_UP BIT0
135#define MII_IRQ_RMT_FAULT BIT1
136#define MII_IRQ_LINK_DOWN BIT2
137#define MII_IRQ_LPA_ACK BIT3
138#define MII_IRQ_PD_FAULT BIT4
139#define MII_IRQ_PAGE_RX BIT5
140#define MII_IRQ_RX_ERROR BIT6
141#define MII_IRQ_JABBER BIT7
142#define MII_IRQ_EN_LINK_UP BIT8
143#define MII_IRQ_EN_RMT_FAULT BIT9
144#define MII_IRQ_EN_LINK_DOWN BIT10
145#define MII_IRQ_EN_LPA_ACK BIT11
146#define MII_IRQ_EN_PD_FAULT BIT12
147#define MII_IRQ_EN_PAGE_RX BIT13
148#define MII_IRQ_EN_RX_ERROR BIT14
149#define MII_IRQ_EN_JABBER BIT15
160static inline bool mii_can_100_mbps_full_dp(uint16_t bmsr)
161{
162 return (bmsr & (MII_BMSR_100_TX_F | MII_BMSR_100_T2_F));
163}
164
173static inline bool mii_can_100_mbps_half_dp(uint16_t bmsr)
174{
176}
177
186static inline bool mii_can_10_mbps_full_dp(uint16_t bmsr)
187{
188 return (bmsr & MII_BMSR_10_F);
189}
190
199static inline bool mii_can_10_mbps_half_dp(uint16_t bmsr)
200{
201 return (bmsr & MII_BMSR_10_H);
202}
203
204#ifdef __cplusplus
205}
206#endif
207
208#endif /* MII_H */
Helper functions for bit arithmetic.
#define MII_BMSR_10_F
PHY supports 10BASE-T, full duplex.
Definition mii.h:84
#define MII_BMSR_100_T2_H
PHY supports 100BASE-T2, half duplex.
Definition mii.h:87
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:199
#define MII_BMSR_100_TX_H
PHY supports 100BASE-TX, half duplex.
Definition mii.h:83
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:173
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:186
#define MII_BMSR_100_T4
PHY supports 100BASE-T4 (half-duplex)
Definition mii.h:81
static bool mii_can_100_mbps_full_dp(uint16_t bmsr)
Check if an Ethernet PHY supports 100 Mbps at full duplex.
Definition mii.h:160
#define MII_BMSR_100_TX_F
PHY supports 100BASE-TX, full duplex.
Definition mii.h:82
#define MII_BMSR_10_H
PHY supports 10BASE-T, half duplex.
Definition mii.h:85
#define MII_BMSR_100_T2_F
PHY supports 100BASE-T2, full duplex.
Definition mii.h:86