AM263Px MCU+ SDK: generic_phy.h Source File

| AM263Px MCU+ SDK 26.00.00 |

generic_phy.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) Texas Instruments Incorporated 2021-2025
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
49 #ifndef GENERIC_PHY_H_
50 #define GENERIC_PHY_H_
51
52 /* ========================================================================== */
53 /* Include Files */
54 /* ========================================================================== */
55
56 #include <stdint.h>
57 #include <stdbool.h>
58 #include "phy_common.h"
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 /* ========================================================================== */
65 /* Macros */
66 /* ========================================================================== */
67
68
69 /* PHY Register Definitions */
70
72 #define PHY_BMCR (0x00U)
73
75 #define PHY_BMSR (0x01U)
76
78 #define PHY_PHYIDR1 (0x02U)
79
81 #define PHY_PHYIDR2 (0x03U)
82
84 #define PHY_ANAR (0x04U)
85
87 #define PHY_ANLPAR (0x05U)
88
90 #define PHY_ANER (0x06U)
91
93 #define PHY_ANNPTR (0x07U)
94
96 #define PHY_ANNPRR (0x08U)
97
99 #define PHY_GIGCR (0x09U)
100
102 #define PHY_GIGSR (0x0AU)
103
105 #define PHY_MMD_CR (0x0DU)
106
108 #define PHY_MMD_DR (0x0EU)
109
111 #define PHY_GIGESR (0x0FU)
112
113 /* BMCR register definitions */
114 #define BMCR_RESET PHY_BIT(15)
115 #define BMCR_LOOPBACK PHY_BIT(14)
116 #define BMCR_SPEED100 PHY_BIT(13)
117 #define BMCR_ANEN PHY_BIT(12)
118 #define BMCR_PWRDOWN PHY_BIT(11)
119 #define BMCR_ISOLATE PHY_BIT(10)
120 #define BMCR_ANRESTART PHY_BIT(9)
121 #define BMCR_FD PHY_BIT(8)
122 #define BMCR_SPEED1000 PHY_BIT(6)
123
124 /* BMSR register definitions */
125 #define BMSR_100FD PHY_BIT(14)
126 #define BMSR_100HD PHY_BIT(13)
127 #define BMSR_10FD PHY_BIT(12)
128 #define BMSR_10HD PHY_BIT(11)
129 #define BMSR_GIGEXTSTS PHY_BIT(8)
130 #define BMSR_ANCOMPLETE PHY_BIT(5)
131 #define BMSR_ANCAPABLE PHY_BIT(3)
132 #define BMSR_LINKSTS PHY_BIT(2)
133 #define BMSR_EXTCAP PHY_BIT(0)
134
135 /* PHYIDR1 register definitions */
136 #define PHYIDR1_OUI_OFFSET (6U)
137
138 /* PHYIDR2 register definitions */
139 #define PHYIDR2_OUI_MASK (0xFC00U)
140 #define PHYIDR2_VMDL_MASK (0x03F0U)
141 #define PHYIDR2_VREV_MASK (0x000FU)
142 #define PHYIDR2_OUI_OFFSET (10U)
143 #define PHYIDR2_VMDL_OFFSET (4U)
144 #define PHYIDR2_VREV_OFFSET (0U)
145
146 /* ANAR register definitions */
147 #define ANAR_100FD PHY_BIT(8)
148 #define ANAR_100HD PHY_BIT(7)
149 #define ANAR_10FD PHY_BIT(6)
150 #define ANAR_10HD PHY_BIT(5)
151 #define ANAR_802P3 PHY_BIT(0)
152 #define ANAR_100 (ANAR_100FD | ANAR_100HD)
153 #define ANAR_10 (ANAR_10FD | ANAR_10HD)
154
155 /* ANLPAR register definitions */
156 #define ANLPAR_100FD PHY_BIT(8)
157 #define ANLPAR_100HD PHY_BIT(7)
158 #define ANLPAR_10FD PHY_BIT(6)
159 #define ANLPAR_10HD PHY_BIT(5)
160 #define ANLPAR_100 (ANLPAR_100FD | ANLPAR_100HD)
161 #define ANLPAR_10 (ANLPAR_10FD | ANLPAR_10HD)
162
163 /* ANER register definitions */
164 #define ANER_LPISANABLE PHY_BIT(0)
165
166 /* GIGCR register definitions */
167 #define GIGCR_MASTERCFG PHY_BIT(12)
168 #define GIGCR_MASTEREN PHY_BIT(11)
169 #define GIGCR_1000FD PHY_BIT(9)
170 #define GIGCR_1000HD PHY_BIT(8)
171 #define GIGCR_1000 (GIGCR_1000FD | GIGCR_1000HD)
172
173 /* GIGSR register definitions */
174 #define GIGSR_MASTERRES PHY_BIT(14)
175 #define GIGSR_LOCALSTS PHY_BIT(13)
176 #define GIGSR_LPARSTS PHY_BIT(12)
177 #define GIGSR_1000FD PHY_BIT(11)
178 #define GIGSR_1000HD PHY_BIT(10)
179 #define GIGSR_1000 (GIGSR_1000FD | GIGSR_1000HD)
180
181 /* MMD_CR register definitions */
182 #define MMD_CR_ADDR (0x0000U)
183 #define MMD_CR_DATA_NOPOSTINC (0x4000U)
184 #define MMD_CR_DATA_POSTINC_RW (0x8000U)
185 #define MMD_CR_DATA_POSTINC_W (0xC000U)
186 #define MMD_CR_DEVADDR (0x001FU)
187
188 /* GIGESR register definitions */
189 #define GIGESR_1000FD PHY_BIT(13)
190 #define GIGESR_1000HD PHY_BIT(12)
191 #define GIGESR_1000 (GIGESR_1000FD | GIGESR_1000HD)
192
193 /* ========================================================================== */
194 /* Structures and Enums */
195 /* ========================================================================== */
196
197
198 /* ========================================================================== */
199 /* Global Variables Declarations */
200 /* ========================================================================== */
201
202 /* None */
203
204 /* ========================================================================== */
205 /* Function Declarations */
206 /* ========================================================================== */
207 void GenericPhy_reset(EthPhyDrv_Handle hPhy);
208
209 bool GenericPhy_isResetComplete(EthPhyDrv_Handle hPhy);
210
211 int32_t GenericPhy_readReg(EthPhyDrv_Handle hPhy,
212 uint32_t reg,
213 uint16_t *pVal);
214
215 int32_t GenericPhy_writeReg(EthPhyDrv_Handle hPhy,
216 uint32_t reg,
217 uint16_t val);
218
219 int32_t GenericPhy_readExtReg(EthPhyDrv_Handle hPhy,
220 uint32_t reg,
221 uint16_t* val);
222
223 int32_t GenericPhy_writeExtReg(EthPhyDrv_Handle hPhy,
224 uint32_t reg,
225 uint16_t val);
226
227 void GenericPhy_printRegs(EthPhyDrv_Handle hPhy);
228
229 int32_t GenericPhy_ctrlPowerDown(EthPhyDrv_Handle hPhy,
230 bool control);
231
232 int32_t GenericPhy_isPowerDownActive(EthPhyDrv_Handle hPhy,
233 bool *pActive);
234
235 int32_t GenericPhy_enableAdvertisement(EthPhyDrv_Handle hPhy,
236 uint32_t advertisement);
237
238 int32_t GenericPhy_disableAdvertisement(EthPhyDrv_Handle hPhy,
239 uint32_t advertisement);
240
241 int32_t GenericPhy_ctrlAutoNegotiation(EthPhyDrv_Handle hPhy,
242 uint32_t control);
243
244 int32_t GenericPhy_isLinkPartnerAutoNegotiationAble(EthPhyDrv_Handle hPhy,
245 bool *pAble);
246
247 int32_t GenericPhy_isAutoNegotiationEnabled(EthPhyDrv_Handle hPhy,
248 bool *pEnabled);
249
250 int32_t GenericPhy_isAutoNegotiationComplete(EthPhyDrv_Handle hPhy,
251 bool *pCompleted);
252
253 int32_t GenericPhy_isAutoNegotiationRestartComplete(EthPhyDrv_Handle hPhy,
254 bool *pCompleted);
255
256 int32_t GenericPhy_setSpeedDuplex(EthPhyDrv_Handle hPhy,
257 uint32_t settings);
258
259 int32_t GenericPhy_isLinkUp(EthPhyDrv_Handle hPhy,
260 bool *pLinkUp);
261
262 int32_t GenericPhy_getId(EthPhyDrv_Handle hPhy,
263 uint32_t *pId);
264
265 /* ========================================================================== */
266 /* Deprecated Function Declarations */
267 /* ========================================================================== */
268
269 /* None */
270
271 /* ========================================================================== */
272 /* Static Function Definitions */
273 /* ========================================================================== */
274
275 /* None */
276
277 #ifdef __cplusplus
278 }
279 #endif
280
281 #endif /* GENERIC_PHY_H_ */
282
GenericPhy_ctrlPowerDown
int32_t GenericPhy_ctrlPowerDown(EthPhyDrv_Handle hPhy, bool control)
GenericPhy_disableAdvertisement
int32_t GenericPhy_disableAdvertisement(EthPhyDrv_Handle hPhy, uint32_t advertisement)
GenericPhy_ctrlAutoNegotiation
int32_t GenericPhy_ctrlAutoNegotiation(EthPhyDrv_Handle hPhy, uint32_t control)
EthPhyDrv_Handle
uint8_t EthPhyDrv_Handle[ETHPHYDRV_MAX_OBJ_SIZE]
Definition: phy_common.h:302
GenericPhy_printRegs
void GenericPhy_printRegs(EthPhyDrv_Handle hPhy)
GenericPhy_isResetComplete
bool GenericPhy_isResetComplete(EthPhyDrv_Handle hPhy)
GenericPhy_isAutoNegotiationComplete
int32_t GenericPhy_isAutoNegotiationComplete(EthPhyDrv_Handle hPhy, bool *pCompleted)
GenericPhy_reset
void GenericPhy_reset(EthPhyDrv_Handle hPhy)
GenericPhy_writeExtReg
int32_t GenericPhy_writeExtReg(EthPhyDrv_Handle hPhy, uint32_t reg, uint16_t val)
GenericPhy_isLinkUp
int32_t GenericPhy_isLinkUp(EthPhyDrv_Handle hPhy, bool *pLinkUp)
GenericPhy_writeReg
int32_t GenericPhy_writeReg(EthPhyDrv_Handle hPhy, uint32_t reg, uint16_t val)
GenericPhy_getId
int32_t GenericPhy_getId(EthPhyDrv_Handle hPhy, uint32_t *pId)
GenericPhy_readReg
int32_t GenericPhy_readReg(EthPhyDrv_Handle hPhy, uint32_t reg, uint16_t *pVal)
GenericPhy_isAutoNegotiationRestartComplete
int32_t GenericPhy_isAutoNegotiationRestartComplete(EthPhyDrv_Handle hPhy, bool *pCompleted)
GenericPhy_readExtReg
int32_t GenericPhy_readExtReg(EthPhyDrv_Handle hPhy, uint32_t reg, uint16_t *val)
GenericPhy_isAutoNegotiationEnabled
int32_t GenericPhy_isAutoNegotiationEnabled(EthPhyDrv_Handle hPhy, bool *pEnabled)
phy_common.h
GenericPhy_enableAdvertisement
int32_t GenericPhy_enableAdvertisement(EthPhyDrv_Handle hPhy, uint32_t advertisement)
GenericPhy_isPowerDownActive
int32_t GenericPhy_isPowerDownActive(EthPhyDrv_Handle hPhy, bool *pActive)
GenericPhy_isLinkPartnerAutoNegotiationAble
int32_t GenericPhy_isLinkPartnerAutoNegotiationAble(EthPhyDrv_Handle hPhy, bool *pAble)
GenericPhy_setSpeedDuplex
int32_t GenericPhy_setSpeedDuplex(EthPhyDrv_Handle hPhy, uint32_t settings)