AM64x MCU+ SDK  08.02.00
icss_eip_driver.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 #ifndef ICSS_EIP_DRIVER_H_
33 #define ICSS_EIP_DRIVER_H_
34 
35 /* ========================================================================== */
36 /* Doxygen */
37 /* ========================================================================== */
38 
59 /* ========================================================================== */
60 /* Include Files */
61 /* ========================================================================== */
62 #include <stdint.h>
63 #include "icss_dlr.h"
65 
66 /* ========================================================================== */
67 /* Macros & Typedefs */
68 /* ========================================================================== */
69 /*Use compare reg 4*/
70 #define IEP_CMP_DEFAULT_VAL 0x11
71 #define IEP_CMP4_DEFAULT_VAL 0x5000
72 #define IEP_CMP0_DEFAULT_VAL 0xffffffff
73 
75 #define PRU_IEP_CMP_CFG_REG 0x40
76 /*Compare 0 register*/
77 #define PRU_IEP_CMP0_REG 0x48
78 
80 #define EIP_TICK_PERIOD 1 /*in milliseconds*/
81 #define LOOPBK_PKT_SEND_PERIOD 1000
82 
83 #define DEFAULT_BC_PKT_SIZE 60
84 
85 #define ONE_SECOND_INTERVAL 1000 /*in milliseconds*/
86 #define TWO_MINUTE_INTERVAL 120000 /*in milliseconds*/
87 
89 #define CRS_STATUS_MASK 0x2
90 
91 #define CRS_STATUS_SHIFT 0x1
92 
94 #define PTP_PROT_TYPE 0x88F7
95 #define DLR_MDIO_PHY0 1
96 #define DLR_MDIO_PHY1 2
97 
98 /*DLR port 0 Interrupt*/
99 #define PHYBMSR_OFFSET 0x1
100 #define PHYSTS_OFFSET 0x10
101 
102 #define PHY_LINK_STATUS_MASK 0x4
103 #define PHY_LINK_STATUS_SHIFT 0x2
104 
105 typedef struct eip_Config_s *EIP_Handle;
106 
110 typedef enum
111 {
117  BOUNDARY_CLOCK = 2
118 
120 
121 /* ========================================================================== */
122 /* Structure Declarations */
123 /* ========================================================================== */
124 
128 typedef struct
129 {
131  uint8_t clockIdentity[8];
133  uint16_t clockClass;
135  uint16_t timeAccuracy;
147  uint16_t timeSource;
148 
152 
156 
157 } clockClass_t;
158 
162 typedef struct
163 {
165  uint32_t size;
167  uint8_t descr[32];
168 } descr_t;
169 
173 typedef struct
174 {
175  uint8_t portProfileIdentity[8];
177 
183 typedef struct
184 {
185  uint8_t physicalProtocol[16];
186  uint16_t sizeOfAddress;
187  uint8_t portPhysicalAddress[16];
189 
194 typedef struct
195 {
196  uint16_t portNumber;
197  uint16_t networkProtocol;
198  uint16_t addressSize;
199  uint8_t portProtocolAddress[16];
201 
206 typedef struct
207 {
208  uint64_t systemTime;
209  uint64_t systemOffset;
211 
216 typedef struct
217 {
219  uint8_t ifPTPEnable;
221  uint8_t IsSynchronized;
239  uint16_t numberOfPorts;
241  /*TODO: Review ICSS_EMAC_MAX_PORTS_PER_INSTANCE -> ICSS_EMAC_MAX_PORTS_PER_INSTANCE*/
244  uint16_t portEnable[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
247  uint16_t portLogAnnounceInterval[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
250  uint16_t portLogSyncInterval[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
251 
254  uint8_t priority1;
256  uint8_t priority2;
257 
259  uint8_t domainNumber;
263  uint8_t manufacturerIdentity[4];
270 
277 
280  uint16_t stepsRemoved;
283 
285 
286 /*
287 * \brief EIP Config
288 * Structure storing the EIP info
289 */
290 typedef struct eip_Config_s
291 {
297  uint8_t tempFrame[ICSS_EMAC_MAXMTU];
299 } eip_Config;
300 
301 /* ========================================================================== */
302 /* Function Declarations */
303 /* ========================================================================== */
304 
320 void EIP_drvInit(EIP_Handle icssEipHandle);
329 void EIP_drvStop(EIP_Handle icssEipHandle);
338 void EIP_drvStart(EIP_Handle icssEipHandle);
350 void EIP_processProtocolFrames(uint32_t *queue_number, void *userArg);
351 
362 int8_t EIP_initializeCIPSync(EIP_Handle icssEipHandle);
363 
370 #endif /* ICSS_EIP_DRIVER_H_ */
clockType
clockType
Type of clock supported by PTP Implementation. This is not specified by standard.
Definition: icss_eip_driver.h:111
clockClass_t::currentUTCOffset
uint16_t currentUTCOffset
Definition: icss_eip_driver.h:143
portProtAddr_t::networkProtocol
uint16_t networkProtocol
Definition: icss_eip_driver.h:197
eip_Config::timeSyncHandle
TimeSync_ParamsHandle_t timeSyncHandle
Definition: icss_eip_driver.h:294
ICSS_EMAC_Handle
struct ICSS_EMAC_Config_s * ICSS_EMAC_Handle
Alias for ICSS EMAC Handle containing base addresses and modules.
Definition: icss_emac.h:368
portProtAddr_t::portNumber
uint16_t portNumber
Definition: icss_eip_driver.h:196
port_State
port_State
Port States, from IEEE 1588v2.
Definition: icss_timeSyncApi.h:142
cipSyncConfig_t::parentClkInfo
clockClass_t parentClkInfo
Definition: icss_eip_driver.h:235
cipSyncConfig_t::timeOffset
sysTimeOffset_t timeOffset
Definition: icss_eip_driver.h:282
EIP_drvInit
void EIP_drvInit(EIP_Handle icssEipHandle)
Initialization routine for Ethernet/IP driver functions.
EIP_DLRHandle
struct dlr_Config_s * EIP_DLRHandle
Definition: icss_dlr.h:202
eip_Config::pruicssHandle
PRUICSS_Handle pruicssHandle
Definition: icss_eip_driver.h:292
EIP_Handle
struct eip_Config_s * EIP_Handle
Definition: icss_eip_driver.h:105
cipSyncConfig_t
CIP Sync configuration. Instance Attribute for PTP Class (Class Code 0x43. CIP Spec Vol 1)
Definition: icss_eip_driver.h:217
cipSyncConfig_t::numberOfPorts
uint16_t numberOfPorts
Definition: icss_eip_driver.h:239
sysTimeOffset_t::systemOffset
uint64_t systemOffset
Definition: icss_eip_driver.h:209
cipSyncConfig_t::domainNumber
uint8_t domainNumber
Definition: icss_eip_driver.h:259
portPhysAddr_t
Specifies the physical protocol and physical address (e.g. IEEE 802.3) of each port of the device (e....
Definition: icss_eip_driver.h:184
EIP_initializeCIPSync
int8_t EIP_initializeCIPSync(EIP_Handle icssEipHandle)
API to initialize the CIP Sync objects in the EIP handle Initialize CIP Sync member variables based o...
descr_t::size
uint32_t size
Definition: icss_eip_driver.h:165
eip_Config
Definition: icss_eip_driver.h:291
clockClass_t::observedOffsetScaledLogVariance
uint16_t observedOffsetScaledLogVariance
Definition: icss_eip_driver.h:151
EIP_drvStart
void EIP_drvStart(EIP_Handle icssEipHandle)
EIP driver start API.
portPhysAddr_t::sizeOfAddress
uint16_t sizeOfAddress
Definition: icss_eip_driver.h:186
cipSyncConfig_t::meanPathDelayToMaster
int64_t meanPathDelayToMaster
Definition: icss_eip_driver.h:231
EIP_drvStop
void EIP_drvStop(EIP_Handle icssEipHandle)
EIP driver stop API.
clockClass_t::timeAccuracy
uint16_t timeAccuracy
Definition: icss_eip_driver.h:135
clockClass_t::offsetScaledLogVariance
uint16_t offsetScaledLogVariance
Definition: icss_eip_driver.h:138
cipSyncConfig_t::revData
descr_t revData
Definition: icss_eip_driver.h:267
cipSyncConfig_t::localClkInfo
clockClass_t localClkInfo
Definition: icss_eip_driver.h:237
clockClass_t::timeSource
uint16_t timeSource
Definition: icss_eip_driver.h:147
ICSS_EMAC_MAXMTU
#define ICSS_EMAC_MAXMTU
Maximum Valid size (incl header + VLAN TAG..., no CRC)
Definition: icss_emac.h:176
clockClass_t::timePropertyFlags
uint16_t timePropertyFlags
Definition: icss_eip_driver.h:145
BOUNDARY_CLOCK
@ BOUNDARY_CLOCK
Definition: icss_eip_driver.h:117
cipSyncConfig_t::IsSynchronized
uint8_t IsSynchronized
Definition: icss_eip_driver.h:221
EIP_processProtocolFrames
void EIP_processProtocolFrames(uint32_t *queue_number, void *userArg)
API to process the real time Packets.
cipSyncConfig_t::systemTimeMicrosec
uint64_t systemTimeMicrosec
Definition: icss_eip_driver.h:223
cipSyncConfig_t::grandMasterClkInfo
clockClass_t grandMasterClkInfo
Definition: icss_eip_driver.h:233
TRANSPARENT_CLOCK
@ TRANSPARENT_CLOCK
Definition: icss_eip_driver.h:115
eip_Config::emacHandle
ICSS_EMAC_Handle emacHandle
Definition: icss_eip_driver.h:293
cipSyncConfig_t::systemTimeNanosec
uint64_t systemTimeNanosec
Definition: icss_eip_driver.h:225
cipSyncConfig_t::maxOffsetFromMaster
uint64_t maxOffsetFromMaster
Definition: icss_eip_driver.h:229
cipSyncConfig_t::priority2
uint8_t priority2
Definition: icss_eip_driver.h:256
clockClass_t
Specifies the properties of a clock.
Definition: icss_eip_driver.h:129
eip_Config::dlrHandle
EIP_DLRHandle dlrHandle
Definition: icss_eip_driver.h:298
cipSyncConfig_t::ifPTPEnable
uint8_t ifPTPEnable
Definition: icss_eip_driver.h:219
sysTimeOffset_t
Specifies the system time in microseconds and the Offset to the local clock value.
Definition: icss_eip_driver.h:207
cipSyncConfig_t::clockType
clockType clockType
Definition: icss_eip_driver.h:261
sysTimeOffset_t::systemTime
uint64_t systemTime
Definition: icss_eip_driver.h:208
clockClass_t::clockClass
uint16_t clockClass
Definition: icss_eip_driver.h:133
eip_Config::cipSyncObj
cipSyncConfig_t cipSyncObj
Definition: icss_eip_driver.h:295
descr_t
Description in unicode.
Definition: icss_eip_driver.h:163
clockClass_t::observedPhaseChangeRate
uint16_t observedPhaseChangeRate
Definition: icss_eip_driver.h:155
cipSyncConfig_t::userDesc
descr_t userDesc
Definition: icss_eip_driver.h:269
portProtAddr_t::addressSize
uint16_t addressSize
Definition: icss_eip_driver.h:198
cipSyncConfig_t::priority1
uint8_t priority1
Definition: icss_eip_driver.h:254
icss_timeSyncApi.h
ORDINARY_CLOCK
@ ORDINARY_CLOCK
Definition: icss_eip_driver.h:113
cipSyncConfig_t::productType
descr_t productType
Definition: icss_eip_driver.h:265
portProtAddr_t
Specifies the specifies the network and protocol address of each port of the device (e....
Definition: icss_eip_driver.h:195
icss_dlr.h
TimeSync_ParamsHandle_t
struct TimeSync_ParamsHandle_s * TimeSync_ParamsHandle_t
Definition: icss_timeSyncApi.h:1016
portProfileIdentity_t
Specifies the PTP profile of each port of the device.
Definition: icss_eip_driver.h:174
cipSyncConfig_t::stepsRemoved
uint16_t stepsRemoved
Definition: icss_eip_driver.h:280
PRUICSS_Handle
struct PRUICSS_Config_s * PRUICSS_Handle
A handle that is returned from a PRUICSS_open() call. This handle is required for calling other APIs.
Definition: pruicss/g_v0/pruicss.h:234
cipSyncConfig_t::offsetFromMaster
int64_t offsetFromMaster
Definition: icss_eip_driver.h:227
ICSS_EMAC_MAX_PORTS_PER_INSTANCE
#define ICSS_EMAC_MAX_PORTS_PER_INSTANCE
Maximum number of Ports in a single ICSS
Definition: icss_emac.h:66