AM64x MCU+ SDK  07.03.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 
85 #define ETHPHY_CMD_ENABLE_FAST_LINK_DOWN_DETECTION (5U)
86 
87 #define ETHPHY_CMD_CONFIGURE_LED_SOURCE (6U)
88 
89 #define ETHPHY_CMD_CONFIGURE_LED_BLINK_RATE (7U)
90 
91 #define ETHPHY_CMD_ENABLE_EXTENDED_FD_ABILITY (8U)
92 
93 #define ETHPHY_CMD_ENABLE_ODD_NIBBLE_DETECTION (9U)
94 
95 #define ETHPHY_CMD_ENABLE_ENHANCED_IPG_DETECTION (10U)
96 
97 #define ETHPHY_CMD_GET_LINK_STATUS (11U)
98 
99 #define ETHPHY_CMD_GET_SPEED_AND_DUPLEXITY (12U)
100 
101 #define ETHPHY_CMD_SET_SPEED_AND_DUPLEXITY (13U)
102 
112 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_AUTONEG (0U)
113 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_10FD (1U)
114 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_100FD (2U)
115 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_1000FD (3U)
116 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_10HD (4U)
117 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_100HD (5U)
118 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_1000HD (6U)
119 #define ETHPHY_SPEED_DUPLEXITY_CONFIG_INVALID (7U)
120 
123 typedef void *ETHPHY_Handle;
125 typedef struct ETHPHY_Config_s ETHPHY_Config;
127 typedef struct ETHPHY_Params_s ETHPHY_Params;
128 
146 typedef int32_t (*ETHPHY_OpenFxn)(ETHPHY_Config *config, const ETHPHY_Params *params);
147 
158 typedef void (*ETHPHY_CloseFxn)(ETHPHY_Config *config);
159 
174 typedef int32_t (*ETHPHY_CommandFxn)(ETHPHY_Config *config,
175  uint32_t command,
176  void *data,
177  uint32_t dataSize);
178 
181 /* ========================================================================== */
182 /* Structure Declarations */
183 /* ========================================================================== */
184 
188 typedef struct ETHPHY_Params_s
189 {
190  uint32_t reserved;
191 } ETHPHY_Params;
192 
196 typedef struct ETHPHY_Fxns_s
197 {
201 } ETHPHY_Fxns;
202 
207 typedef struct ETHPHY_Attrs_s
208 {
209  uint32_t mdioBaseAddress;
210  uint32_t phyAddress;
211 } ETHPHY_Attrs;
212 
217 typedef struct ETHPHY_Config_s
218 {
221  void *object;
222 } ETHPHY_Config;
223 
229 typedef struct ETHPHY_SpeedDuplexityConfig_s
230 {
231  uint32_t config;
234 
235 /* ========================================================================== */
236 /* Device specific includes */
237 /* ========================================================================== */
238 #include <board/ethphy/ethphy_dp83869.h>
239 
240 /* ========================================================================== */
241 /* Function Declarations */
242 /* ========================================================================== */
243 
253 
268 ETHPHY_Handle ETHPHY_open(uint32_t instanceId, const ETHPHY_Params *params);
269 
276 
288  uint32_t command,
289  void *data,
290  uint32_t dataSize);
291 
299 const ETHPHY_Attrs *ETHPHY_getAttrs(uint32_t instanceId);
300 
301 /* ========================================================================== */
302 /* Internal/Private Structure Declarations */
303 /* ========================================================================== */
304 
305 #ifdef __cplusplus
306 }
307 #endif
308 
309 #endif /* #ifndef ETHPHY_H_ */
310 
ETHPHY_Params
struct ETHPHY_Params_s ETHPHY_Params
Forward declaration of ETHPHY_Params.
Definition: ethphy.h:127
ETHPHY_Attrs::phyAddress
uint32_t phyAddress
Definition: ethphy.h:210
ETHPHY_getAttrs
const ETHPHY_Attrs * ETHPHY_getAttrs(uint32_t instanceId)
Return ETHPHY attributes.
ETHPHY_OpenFxn
int32_t(* ETHPHY_OpenFxn)(ETHPHY_Config *config, const ETHPHY_Params *params)
Driver implementation to open a specific ETHPHY driver.
Definition: ethphy.h:146
SystemP.h
ETHPHY_Config::attrs
ETHPHY_Attrs * attrs
Definition: ethphy.h:219
ETHPHY_Attrs::mdioBaseAddress
uint32_t mdioBaseAddress
Definition: ethphy.h:209
data
uint32_t data
Definition: tisci_rm_psil.h:1
ETHPHY_Params
Parameters passed during ETHPHY_open()
Definition: ethphy.h:189
ETHPHY_SpeedDuplexityConfig::config
uint32_t config
Definition: ethphy.h:231
ETHPHY_Config::object
void * object
Definition: ethphy.h:221
ETHPHY_close
void ETHPHY_close(ETHPHY_Handle handle)
Close ETHPHY driver.
ETHPHY_Fxns::commandFxn
ETHPHY_CommandFxn commandFxn
Definition: ethphy.h:200
ETHPHY_Fxns::closeFxn
ETHPHY_CloseFxn closeFxn
Definition: ethphy.h:199
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:174
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:208
ETHPHY_Fxns
ETHPHY Driver implementation callbacks.
Definition: ethphy.h:197
ETHPHY_Config
ETHPHY driver configuration. These are filled by SysCfg based on the PHY device that is selected.
Definition: ethphy.h:218
ETHPHY_Config
struct ETHPHY_Config_s ETHPHY_Config
Forward declaration of ETHPHY_Config.
Definition: ethphy.h:125
ETHPHY_Fxns::openFxn
ETHPHY_OpenFxn openFxn
Definition: ethphy.h:198
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:220
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:123
ETHPHY_Params::reserved
uint32_t reserved
Definition: ethphy.h:190
ETHPHY_SpeedDuplexityConfig
Data structure to be passed/returned when calling ETHPHY_command with ETHPHY_CMD_GET_SPEED_AND_DUPLEX...
Definition: ethphy.h:230
ETHPHY_CloseFxn
void(* ETHPHY_CloseFxn)(ETHPHY_Config *config)
Driver implementation to close a specific ETHPHY driver.
Definition: ethphy.h:158