PDK API Guide for AM65xx
cpsw_tpr12_priv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020
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 
40 #ifndef CPSW_TPR12_PRIV_H_
41 #define CPSW_TPR12_PRIV_H_
42 
43 /* ========================================================================== */
44 /* Include Files */
45 /* ========================================================================== */
46 
47 #include <stdint.h>
48 #include <stdbool.h>
61 #if ENET_CFG_IS_ON(RM_PRESENT)
63 #endif
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /* ========================================================================== */
70 /* Macros */
71 /* ========================================================================== */
72 
74 #define CPSW_FEATURE_INTERVLAN (ENET_BIT(1U))
75 
76 /* TODO - Fix me */
77 //#define CPSW_MAC_PORT_NUM 1U
78 
80 #define CPSW_INTR_RX_THRESH (1U)
81 
83 #define CPSW_INTR_RX_PEND (2U)
84 
86 #define CPSW_INTR_TX_PEND (3U)
87 
89 #define CPSW_INTR_MISC_PEND (4U)
90 
91 /* ========================================================================== */
92 /* Structures and Enums */
93 /* ========================================================================== */
97 typedef struct Cpsw_MdioLinkIntCtx_s
98 {
100  uint32_t aliveMask;
101 
103  uint32_t linkedMask;
104 
106  uint32_t pollEnableMask;
107 
109  Cpsw_MdioLinkStateChangeCb linkStateChangeCb;
110 
112  void *linkStateChangeCbArg;
114 
118 typedef struct Cpsw_PortLinkState_s
119 {
121  uint32_t phyAddr;
122 
124  bool isOpen;
125 
127  bool isLinkUp;
128 
130  bool isPollEnabled;
131 
133  bool isTickEnabled;
135 
139 typedef struct Cpsw_Obj_s
140 {
142  EnetPer_Obj enetPer;
143 
145  CpswHostPort_Obj hostPortObj;
146 
148  CpswMacPort_Obj *macPortObj;
149 
151  uint32_t macPortNum;
152 
154  CpswAle_Obj aleObj;
155 
157  CpswCpts_Obj cptsObj;
158 
160  Mdio_Obj mdioObj;
161 
163  CpswStats_Obj statsObj;
164 
165 #if ENET_CFG_IS_ON(RM_PRESENT)
166 
167  EnetRm_Obj rmObj;
168 #endif
169 
171  EnetDma_Handle hDma;
172 
174  EnetMod_Handle hHostPort;
175 
178 
181 
183  EnetMod_Handle hAle;
184 
186  EnetMod_Handle hCpts;
187 
189  EnetMod_Handle hMdio;
190 
192  EnetMod_Handle hStats;
193 
195  EnetMod_Handle hRm;
196 
198  uint32_t selfCoreId;
199 
201  Cpsw_PortLinkState portLinkState[CPSW_MAC_PORT_NUM];
202 
204  CSL_Xge_cpsw_ss_sRegs *cpswSsRegs;
205 
207  CSL_Xge_cpswRegs *cpswRegs;
208 
211 
213  void *hDmaRxIntr;
214 
216  void *hDmaTxIntr;
217 
220 
222  Cpsw_MdioLinkIntCtx mdioLinkIntCtx;
223 
225  Cpsw_PortLinkStatusChangeCb portLinkStatusChangeCb;
226 
228  void *portLinkStatusChangeCbArg;
229 
231  uint32_t maxPerPrioMtu;
232 } Cpsw_Obj;
233 
238 
239 /* ========================================================================== */
240 /* Global Variables Declarations */
241 /* ========================================================================== */
242 
243 /* None */
244 
245 /* ========================================================================== */
246 /* Function Declarations */
247 /* ========================================================================== */
248 
261 void Cpsw_initCfg(EnetPer_Handle hPer,
262  Enet_Type enetType,
263  void *cfg,
264  uint32_t cfgSize);
265 
282 int32_t Cpsw_open(EnetPer_Handle hPer,
283  Enet_Type enetType,
284  uint32_t instId,
285  const void *cfg,
286  uint32_t cfgSize);
287 
303 int32_t Cpsw_rejoin(EnetPer_Handle hPer,
304  Enet_Type enetType,
305  uint32_t instId);
306 
314 void Cpsw_close(EnetPer_Handle hPer);
315 
327 int32_t Cpsw_ioctl(EnetPer_Handle hPer,
328  uint32_t cmd,
329  Enet_IoctlPrms *prms);
330 
342 void Cpsw_poll(EnetPer_Handle hPer,
343  Enet_Event evt,
344  const void *arg,
345  uint32_t argSize);
346 
356 
367 
368 /* ========================================================================== */
369 /* Deprecated Function Declarations */
370 /* ========================================================================== */
371 
372 /* None */
373 
374 /* ========================================================================== */
375 /* Static Function Definitions */
376 /* ========================================================================== */
377 
378 /* None */
379 
380 #ifdef __cplusplus
381 }
382 #endif
383 
384 #endif /* CPSW_TPR12_PRIV_H_ */
This file contains the type definitions and helper macros for the CPSW peripheral interface.
Enet_Type
Ethernet peripheral type.
Definition: enet_types.h:195
struct Enet_Obj_s * Enet_Handle
Ethernet driver handle.
Definition: enet_base.h:105
void Cpsw_close(EnetPer_Handle hPer)
Close the CPSW peripheral.
CPSW ALE object.
Definition: cpsw_ale_priv.h:84
void(* Cpsw_PortLinkStatusChangeCb)(Enet_MacPort macPort, bool isLinkUp, void *appArg)
CPSW port link status change callback function.
Definition: cpsw.h:463
This file contains the type definitions and helper macros for the CPSW CPTS module.
void * hDmaMiscIntr
Definition: cpsw_tpr12_priv.h:219
This file contains the basic types using across the Enet driver.
CPSW CPTS object.
Definition: cpsw_cpts_priv.h:174
Enet Resource Manager driver object.
Definition: enet_rm_priv.h:321
int32_t Cpsw_open(EnetPer_Handle hPer, Enet_Type enetType, uint32_t instId, const void *cfg, uint32_t cfgSize)
Open and initialize the CPSW Peripheral.
This file contains private type definitions and helper macros for the CPSW ALE module which are meant...
EnetDma_Handle Cpsw_getDmaHandle(const Enet_Handle hEnet)
Get DMA driver handle.
This file contains the type definitions and helper macros for the Enet Peripheral interface.
This file contains the type definitions and helper macros for the Enet Peripheral interface.
int32_t Cpsw_rejoin(EnetPer_Handle hPer, Enet_Type enetType, uint32_t instId)
Rejoin a running CPSW peripheral.
struct EnetUdma_DrvObj_s * EnetDma_Handle
Opaque handle for Enet UDMA driver object.
Definition: enet_udma_types.h:86
CSL_Xge_cpswRegs * cpswRegs
Definition: cpsw_tpr12_priv.h:207
CPSW host port object.
Definition: cpsw_hostport_priv.h:88
This file contains private type definitions and helper macros for the CPSW statistics module which ar...
#define CPSW_MAC_PORT_NUM
Definition: cpsw.h:97
void Cpsw_poll(EnetPer_Handle hPer, Enet_Event evt, const void *arg, uint32_t argSize)
Poll for Ethernet events.
Port link state (link up/down, tick enabled)
Definition: cpsw_priv.h:100
int32_t Cpsw_ioctl(EnetPer_Handle hPer, uint32_t cmd, Enet_IoctlPrms *prms)
Issue an operation on the CPSW peripheral.
void(* Cpsw_MdioLinkStateChangeCb)(Cpsw_MdioLinkStateChangeInfo *info, void *appArg)
CPSW PHY link state change callback function.
Definition: cpsw.h:453
CSL_Xge_cpsw_ss_sRegs * cpswSsRegs
Definition: cpsw_tpr12_priv.h:204
void * hDmaTxIntr
Definition: cpsw_tpr12_priv.h:216
This file contains the private type definitions and helper macros for Enet Resource Manager.
void * hDmaRxIntr
Definition: cpsw_tpr12_priv.h:213
CPSW MAC port object.
Definition: cpsw_macport_priv.h:257
Ethernet Peripheral object.
Definition: enet_per.h:461
Enet IOCTL param.
Definition: enet_ioctl.h:229
MDIO status change (MDIO_LINKINT) context.
Definition: cpsw_priv.h:79
Cpsw_Obj * Cpsw_Handle
CPSW peripheral handle.
Definition: cpsw_tpr12_priv.h:237
This file contains private type definitions and helper macros for the CPSW MAC port module which are ...
void Cpsw_periodicTick(EnetPer_Handle hPer)
Run periodic tick on the CPSW peripheral.
CPSW driver object.
Definition: cpsw_priv.h:121
Enet_Event
Ethernet events.
Definition: enet_types.h:258
struct EnetMod_Obj_s * EnetMod_Handle
Ethernet Module handle.
Definition: enet_mod.h:71
void * hDmaRxThreshIntr
Definition: cpsw_tpr12_priv.h:210
struct EnetPhy_Obj_s * EnetPhy_Handle
PHY driver object handle.
Definition: enetphy.h:641
void Cpsw_initCfg(EnetPer_Handle hPer, Enet_Type enetType, void *cfg, uint32_t cfgSize)
Initialize CPSW peripheral's configuration parameters.
CPSW statistics object.
Definition: cpsw_stats_priv.h:90
This file contains private type definitions and helper macros for the MDIO port module which are mean...
struct EnetPer_Obj_s * EnetPer_Handle
Ethernet Peripheral handle.
Definition: enet_per.h:299
This file contains the private top-level type definitions and helper macros.
MDIO port object.
Definition: mdio_priv.h:147
This file contains the type definitions and helper macros for the Ethernet PHY interface.
This file contains private type definitions and helper macros for the CPSW host port module which are...