AM263Px MCU+ SDK  10.00.00
ethphy.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
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 
44 #ifndef ETHPHY_H_
45 #define ETHPHY_H_
46 
47 /* ========================================================================== */
48 /* Include Files */
49 /* ========================================================================== */
50 
51 #include <stdint.h>
52 #include <kernel/dpl/SystemP.h>
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /* ========================================================================== */
59 /* Macros & Typedefs */
60 /* ========================================================================== */
61 
71 #define ETHPHY_CMD_ENABLE_MII (0U)
72 
75 #define ETHPHY_CMD_SOFT_RESTART (1U)
76 
77 #define ETHPHY_CMD_ENABLE_AUTO_MDIX (2U)
78 
81 #define ETHPHY_CMD_VERIFY_IDENTIFIER_REGISTER (3U)
82 
83 #define ETHPHY_CMD_DISABLE_1000M_ADVERTISEMENT (4U)
84 
89 #define ETHPHY_CMD_ENABLE_FAST_LINK_DOWN_DETECTION (5U)
90 
95 #define ETHPHY_CMD_CONFIGURE_LED_SOURCE (6U)
96 
101 #define ETHPHY_CMD_CONFIGURE_LED_BLINK_RATE (7U)
102 
103 #define ETHPHY_CMD_ENABLE_EXTENDED_FD_ABILITY (8U)
104 
105 #define ETHPHY_CMD_ENABLE_ODD_NIBBLE_DETECTION (9U)
106 
107 #define ETHPHY_CMD_ENABLE_ENHANCED_IPG_DETECTION (10U)
108 
109 #define ETHPHY_CMD_GET_LINK_STATUS (11U)
110 
114 #define ETHPHY_CMD_GET_SPEED_AND_DUPLEX_CONFIG (12U)
115 
119 #define ETHPHY_CMD_SET_SPEED_AND_DUPLEX_CONFIG (13U)
120 
121 #define ETHPHY_CMD_ENABLE_LOW_LATENCY_10M_100M_RGMII (14U)
122 
127 #define ETHPHY_CMD_SET_RX_HALF_FULL_THRESHOLD_RGMII (15U)
128 
133 #define ETHPHY_CMD_SET_TX_HALF_FULL_THRESHOLD_RGMII (16U)
134 
140 #define ETHPHY_CMD_GET_AUTONEG_COMPLETE_STATUS (17U)
141 
147 #define ETHPHY_CMD_GET_LINK_PARTNER_AUTONEG_ABILITY (18U)
148 
149 #define ETHPHY_CMD_ENABLE_IEEE_POWER_DOWN (19U)
150 
151 #define ETHPHY_CMD_DISABLE_IEEE_POWER_DOWN (20U)
152 
162 #define ETHPHY_SPEED_DUPLEX_CONFIG_AUTONEG (0U)
163 #define ETHPHY_SPEED_DUPLEX_CONFIG_10FD (1U)
164 #define ETHPHY_SPEED_DUPLEX_CONFIG_100FD (2U)
165 #define ETHPHY_SPEED_DUPLEX_CONFIG_1000FD (3U)
166 #define ETHPHY_SPEED_DUPLEX_CONFIG_10HD (4U)
167 #define ETHPHY_SPEED_DUPLEX_CONFIG_100HD (5U)
168 #define ETHPHY_SPEED_DUPLEX_CONFIG_1000HD (6U)
169 #define ETHPHY_SPEED_DUPLEX_CONFIG_INVALID (7U)
170 
173 typedef void *ETHPHY_Handle;
175 typedef struct ETHPHY_Config_s ETHPHY_Config;
177 typedef struct ETHPHY_Params_s ETHPHY_Params;
178 
196 typedef int32_t (*ETHPHY_OpenFxn)(ETHPHY_Config *config, const ETHPHY_Params *params);
197 
208 typedef void (*ETHPHY_CloseFxn)(ETHPHY_Config *config);
209 
224 typedef int32_t (*ETHPHY_CommandFxn)(ETHPHY_Config *config,
225  uint32_t command,
226  void *data,
227  uint32_t dataSize);
228 
231 /* ========================================================================== */
232 /* Structure Declarations */
233 /* ========================================================================== */
234 
238 typedef struct ETHPHY_Params_s
239 {
240  uint32_t reserved;
241 } ETHPHY_Params;
242 
246 typedef struct ETHPHY_Fxns_s
247 {
251 } ETHPHY_Fxns;
252 
257 typedef struct ETHPHY_Attrs_s
258 {
259  uint32_t mdioBaseAddress;
260  uint32_t phyAddress;
261 } ETHPHY_Attrs;
262 
267 typedef struct ETHPHY_Config_s
268 {
271  void *object;
272 } ETHPHY_Config;
273 
279 typedef struct ETHPHY_SpeedDuplexConfig_s
280 {
281  uint32_t config;
284 
285 /* ========================================================================== */
286 /* Function Declarations */
287 /* ========================================================================== */
288 
298 
313 ETHPHY_Handle ETHPHY_open(uint32_t instanceId, const ETHPHY_Params *params);
314 
321 
333  uint32_t command,
334  void *data,
335  uint32_t dataSize);
336 
344 const ETHPHY_Attrs *ETHPHY_getAttrs(uint32_t instanceId);
345 
346 /* ========================================================================== */
347 /* Internal/Private Structure Declarations */
348 /* ========================================================================== */
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 
354 #endif /* #ifndef ETHPHY_H_ */
355 
ETHPHY_Params
struct ETHPHY_Params_s ETHPHY_Params
Forward declaration of ETHPHY_Params.
Definition: ethphy.h:177
ETHPHY_Attrs::phyAddress
uint32_t phyAddress
Definition: ethphy.h:260
ETHPHY_getAttrs
const ETHPHY_Attrs * ETHPHY_getAttrs(uint32_t instanceId)
Return ETHPHY attributes.
ETHPHY_SpeedDuplexConfig
Data structure to be passed/returned when calling ETHPHY_command with ETHPHY_CMD_GET_SPEED_AND_DUPLEX...
Definition: ethphy.h:280
ETHPHY_OpenFxn
int32_t(* ETHPHY_OpenFxn)(ETHPHY_Config *config, const ETHPHY_Params *params)
Driver implementation to open a specific ETHPHY driver.
Definition: ethphy.h:196
SystemP.h
ETHPHY_Config::attrs
ETHPHY_Attrs * attrs
Definition: ethphy.h:269
ETHPHY_Attrs::mdioBaseAddress
uint32_t mdioBaseAddress
Definition: ethphy.h:259
ETHPHY_Params
Parameters passed during ETHPHY_open()
Definition: ethphy.h:239
ETHPHY_Config::object
void * object
Definition: ethphy.h:271
ETHPHY_SpeedDuplexConfig::config
uint32_t config
Definition: ethphy.h:281
ETHPHY_close
void ETHPHY_close(ETHPHY_Handle handle)
Close ETHPHY driver.
ETHPHY_Fxns::commandFxn
ETHPHY_CommandFxn commandFxn
Definition: ethphy.h:250
ETHPHY_Fxns::closeFxn
ETHPHY_CloseFxn closeFxn
Definition: ethphy.h:249
ETHPHY_CommandFxn
int32_t(* ETHPHY_CommandFxn)(ETHPHY_Config *config, uint32_t command, void *data, uint32_t dataSize)
Driver implementation to send command to the ETHPHY using specific ETHPHY driver.
Definition: ethphy.h:224
ETHPHY_Params_init
void ETHPHY_Params_init(ETHPHY_Params *params)
Set default parameters in the ETHPHY_Params structure.
ETHPHY_Attrs
ETHPHY device attributes. These are filled by SysCfg based on the PHY device that is selected.
Definition: ethphy.h:258
ETHPHY_Fxns
ETHPHY Driver implementation callbacks.
Definition: ethphy.h:247
ETHPHY_Config
ETHPHY driver configuration. These are filled by SysCfg based on the PHY device that is selected.
Definition: ethphy.h:268
ETHPHY_Config
struct ETHPHY_Config_s ETHPHY_Config
Forward declaration of ETHPHY_Config.
Definition: ethphy.h:175
ETHPHY_Fxns::openFxn
ETHPHY_OpenFxn openFxn
Definition: ethphy.h:248
ETHPHY_open
ETHPHY_Handle ETHPHY_open(uint32_t instanceId, const ETHPHY_Params *params)
Open ETHPHY driver.
ETHPHY_Config::fxns
ETHPHY_Fxns * fxns
Definition: ethphy.h:270
ETHPHY_command
int32_t ETHPHY_command(ETHPHY_Handle handle, uint32_t command, void *data, uint32_t dataSize)
Send a command to the ETHPHY.
ETHPHY_Handle
void * ETHPHY_Handle
Handle to the ETHPHY driver returned by ETHPHY_open()
Definition: ethphy.h:173
ETHPHY_Params::reserved
uint32_t reserved
Definition: ethphy.h:240
ETHPHY_CloseFxn
void(* ETHPHY_CloseFxn)(ETHPHY_Config *config)
Driver implementation to close a specific ETHPHY driver.
Definition: ethphy.h:208