AM64x MCU+ SDK  08.04.00
crc/v0/crc.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 
65 #ifndef CRC_V0_H_
66 #define CRC_V0_H_
67 
68 /* ========================================================================== */
69 /* Include Files */
70 /* ========================================================================== */
71 
72 #include <drivers/hw_include/cslr.h>
73 #include <drivers/hw_include/cslr_crc.h>
74 #include <drivers/hw_include/hw_types.h>
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 /* ========================================================================== */
81 /* Macros & Typedefs */
82 /* ========================================================================== */
83 
87 #define CRC_CHANNEL_IRQSTATUS_RAW_MAIN_ALL \
88  (uint32_t) ((uint32_t)CRC_INTS_CH1_CCITENS_MASK | \
89  (uint32_t)CRC_INTR_CH1_FAILENR_MASK | \
90  (uint32_t)CRC_INTR_CH1_OVERENR_MASK | \
91  (uint32_t)CRC_INTR_CH1_UNDERENR_MASK | \
92  (uint32_t)CRC_INTR_CH1_TIME_OUT_ENR_MASK)
93 
97 #define CRC_PATTERN_COUNT_MAX (0x000FFFFFU)
98 
102 #define CRC_SECTOR_COUNT_MAX (0x0000FFFFU)
103 
108 #define CRC_BCTOPLD_MAX (0x00FFFFFFU)
109 
113 #define CRC_WDTOPLD_MAX (0x00FFFFFFU)
114 
118 #define CRC_MAX_NUM_OF_CHANNELS (4U)
119 
129 typedef uint32_t CRC_OperationMode_t;
130 
131 #define CRC_OPERATION_MODE_DATA (CRC_CTRL2_CH1_MODE_DATA)
132 
133 #define CRC_OPERATION_MODE_AUTO (CRC_CTRL2_CH1_MODE_AUTO)
134 
135 #define CRC_OPERATION_MODE_SEMICPU (CRC_CTRL2_CH1_MODE_SEMICPU)
136 
137 #define CRC_OPERATION_MODE_FULLCPU (CRC_CTRL2_CH1_MODE_FULLCPU)
138 
149 typedef uint32_t CRC_Channel_t;
150 
151 #define CRC_CHANNEL_1 (0x1U)
152 
153 #define CRC_CHANNEL_2 (0x2U)
154 
155 #define CRC_CHANNEL_3 (0x3U)
156 
157 #define CRC_CHANNEL_4 (0x4U)
158 
174 typedef uint32_t CRC_IntrPriority_t;
175 
176 #define CRC_INTR_PRIORITY_CH1_FAIL (0x1U)
177 
178 #define CRC_INTR_PRIORITY_CH2_FAIL (0x2U)
179 
180 #define CRC_INTR_PRIORITY_CH3_FAIL (0x3U)
181 
182 #define CRC_INTR_PRIORITY_CH4_FAIL (0x4U)
183 
184 #define CRC_INTR_PRIORITY_CH1_COMPRESSION_DONE (0x9U)
185 
186 #define CRC_INTR_PRIORITY_CH2_COMPRESSION_DONE (0xaU)
187 
188 #define CRC_INTR_PRIORITY_CH3_COMPRESSION_DONE (0xbU)
189 
190 #define CRC_INTR_PRIORITY_CH4_COMPRESSION_DONE (0xcU)
191 
192 #define CRC_INTR_PRIORITY_CH1_OVERRUN (0x11U)
193 
194 #define CRC_INTR_PRIORITY_CH2_OVERRUN (0x12U)
195 
196 #define CRC_INTR_PRIORITY_CH3_OVERRUN (0x13U)
197 
198 #define CRC_INTR_PRIORITY_CH4_OVERRUN (0x14U)
199 
200 #define CRC_INTR_PRIORITY_CH1_UNDERRUN (0x19U)
201 
202 #define CRC_INTR_PRIORITY_CH2_UNDERRUN (0x1aU)
203 
204 #define CRC_INTR_PRIORITY_CH3_UNDERRUN (0x1bU)
205 
206 #define CRC_INTR_PRIORITY_CH4_UNDERRUN (0x1cU)
207 
208 #define CRC_INTR_PRIORITY_CH1_TIMEOUT (0x21U)
209 
210 #define CRC_INTR_PRIORITY_CH2_TIMEOUT (0x22U)
211 
212 #define CRC_INTR_PRIORITY_CH3_TIMEOUT (0x23U)
213 
214 #define CRC_INTR_PRIORITY_CH4_TIMEOUT (0x24U)
215 
226 typedef uint32_t CRC_DataBusMask_t;
227 
228 #define CRC_DATA_BUS_ITCM_MASK (CRC_MCRC_BUS_SEL_ITC_MEN_MASK)
229 
230 #define CRC_DATA_BUS_DTCM_MASK (CRC_MCRC_BUS_SEL_DTC_MEN_MASK)
231 
232 #define CRC_DATA_BUS_VBUSM_MASK (CRC_MCRC_BUS_SEL_MEN_MASK)
233 
234 #define CRC_DATA_BUS_MASK_ALL (CRC_MCRC_BUS_SEL_ITC_MEN_MASK | \
235  CRC_MCRC_BUS_SEL_DTC_MEN_MASK | \
236  CRC_MCRC_BUS_SEL_MEN_MASK)
237 
240 /* ========================================================================== */
241 /* Structures and Enums */
242 /* ========================================================================== */
243 
247 typedef struct CRC_Signature_s
248 {
249  uint32_t regL;
251  uint32_t regH;
254 
258 typedef struct CRC_SignatureRegAddr_s
259 {
260  uint32_t regL;
262  uint32_t regH;
265 
269 typedef struct {
270  volatile uint32_t PCOUNT;
272  volatile uint32_t SCOUNT;
274  volatile uint32_t WDTOPLD;
276  volatile uint32_t BCTOPLD;
279 
283 typedef struct {
286  volatile uint32_t CTRL0;
288  volatile uint32_t CTRL1;
290  volatile uint32_t BUS_SEL;
293 
294 /* ========================================================================== */
295 /* Global Variables Declarations */
296 /* ========================================================================== */
297 
298 /* None */
299 
300 /* ========================================================================== */
301 /* Function Declarations */
302 /* ========================================================================== */
303 
325 int32_t CRC_initialize(uint32_t baseAddr,
326  CRC_Channel_t channel,
327  uint32_t crcWatchdogPreload,
328  uint32_t crcBlockPreload);
329 
352 int32_t CRC_verifyInitialize(uint32_t baseAddr,
353  CRC_Channel_t channel,
354  uint32_t crcWatchdogPreload,
355  uint32_t crcBlockPreload);
356 
375 int32_t CRC_configure(uint32_t baseAddr,
376  CRC_Channel_t channel,
377  uint32_t crcPatternCount,
378  uint32_t crcSectorCount,
379  CRC_OperationMode_t crcMode);
380 
400 int32_t CRCVerifyConfigure(uint32_t baseAddr,
401  CRC_Channel_t channel,
402  uint32_t crcPatternCount,
403  uint32_t crcSectorCount,
404  CRC_OperationMode_t crcMode);
405 
418 int32_t CRC_channelReset(uint32_t baseAddr,
419  CRC_Channel_t channel);
420 
436 int32_t CRC_getPSASigRegAddr(uint32_t baseAddr,
437  CRC_Channel_t channel,
438  CRC_SignatureRegAddr *pCRCRegAddr);
439 
455 int32_t CRC_getPSASig(uint32_t baseAddr,
456  CRC_Channel_t channel,
457  CRC_Signature *pCRCPSASign);
458 
474 int32_t CRC_setPSASeedSig(uint32_t baseAddr,
475  CRC_Channel_t channel,
476  const CRC_Signature *pCRCPSASeedSign);
477 
493 int32_t CRC_getPSASectorSig(uint32_t baseAddr,
494  CRC_Channel_t channel,
495  CRC_Signature *pCRCSectorSign);
496 
510 int32_t CRC_getHighestPriorityIntrStatus(uint32_t baseAddr, uint32_t *pIntVecAddr);
511 
526 int32_t CRC_getIntrStatus(uint32_t baseAddr,
527  CRC_Channel_t channel,
528  uint32_t *pIntrStatus);
529 
543 int32_t CRC_enableIntr(uint32_t baseAddr,
544  CRC_Channel_t channel,
545  uint32_t intrMask);
546 
560 int32_t CRC_disableIntr(uint32_t baseAddr,
561  CRC_Channel_t channel,
562  uint32_t intrMask);
563 
577 int32_t CRC_clearIntr(uint32_t baseAddr,
578  CRC_Channel_t channel,
579  uint32_t intrMask);
580 
594 int32_t CRC_powerDownCtrl(uint32_t baseAddr,
595  uint32_t ctrlFlag);
596 
618 int32_t CRC_isBusy(uint32_t baseAddr,
619  CRC_Channel_t channel,
620  uint32_t *pBusyFlag);
621 
639 int32_t CRC_getCurSecNum(uint32_t baseAddr,
640  CRC_Channel_t channel,
641  uint32_t *pCurSecNum);
642 
658 int32_t CRC_getCurPSASig(uint32_t baseAddr,
659  CRC_Channel_t channel,
660  CRC_Signature *pCurPSASig);
661 
676 int32_t CRC_getRawData(uint32_t baseAddr,
677  CRC_Channel_t channel,
678  CRC_Signature *pRawData);
679 
700 int32_t CRC_dataBusTracingCtrl(uint32_t baseAddr,
701  uint32_t ctrlFlag,
702  CRC_DataBusMask_t dataBusMask,
703  CRC_DataBusMask_t busEnableMask);
704 
723 int32_t CRC_verifyBusTracingCtrl(uint32_t baseAddr,
724  uint32_t ctrlFlag,
725  CRC_DataBusMask_t dataBusMask,
726  CRC_DataBusMask_t busEnableMask);
727 
741 int32_t CRC_readStaticRegs(uint32_t baseAddr, CRC_StaticRegs *pStaticRegs);
742 
743 /* ========================================================================== */
744 /* Static Function Definitions */
745 /* ========================================================================== */
746 
747 /* None */
748 
749 #ifdef __cplusplus
750 }
751 #endif
752 
753 #endif /* #ifndef CRC_V0_H_ */
754 
CRC_ChannelStaticRegs::BCTOPLD
volatile uint32_t BCTOPLD
Definition: crc/v0/crc.h:276
CRC_dataBusTracingCtrl
int32_t CRC_dataBusTracingCtrl(uint32_t baseAddr, uint32_t ctrlFlag, CRC_DataBusMask_t dataBusMask, CRC_DataBusMask_t busEnableMask)
This API is used to control the CRC data bus tracing.
CRC_clearIntr
int32_t CRC_clearIntr(uint32_t baseAddr, CRC_Channel_t channel, uint32_t intrMask)
This API is used to clear interrupts for given Channel.
CRC_getPSASectorSig
int32_t CRC_getPSASectorSig(uint32_t baseAddr, CRC_Channel_t channel, CRC_Signature *pCRCSectorSign)
This API is used to get sector signature Value/ CRC value for given channel.
CRC_Signature::regH
uint32_t regH
Definition: crc/v0/crc.h:251
CRC_verifyBusTracingCtrl
int32_t CRC_verifyBusTracingCtrl(uint32_t baseAddr, uint32_t ctrlFlag, CRC_DataBusMask_t dataBusMask, CRC_DataBusMask_t busEnableMask)
This API is used to verify the control the CRC data bus tracing.
CRC_setPSASeedSig
int32_t CRC_setPSASeedSig(uint32_t baseAddr, CRC_Channel_t channel, const CRC_Signature *pCRCPSASeedSign)
This API is used to set the PSA seed value without compression for given Channel.
CRC_getIntrStatus
int32_t CRC_getIntrStatus(uint32_t baseAddr, CRC_Channel_t channel, uint32_t *pIntrStatus)
This API is used to get the pending interrupts for given Channel.
CRC_powerDownCtrl
int32_t CRC_powerDownCtrl(uint32_t baseAddr, uint32_t ctrlFlag)
This API is used to control the power down of the CRC module.
CRC_getRawData
int32_t CRC_getRawData(uint32_t baseAddr, CRC_Channel_t channel, CRC_Signature *pRawData)
This API is used to get the uncompressed raw data value for given channel.
CRC_ChannelStaticRegs::PCOUNT
volatile uint32_t PCOUNT
Definition: crc/v0/crc.h:270
CRC_Channel_t
uint32_t CRC_Channel_t
CRC channel supported.
Definition: crc/v0/crc.h:149
CRC_SignatureRegAddr::regH
uint32_t regH
Definition: crc/v0/crc.h:262
CRC_OperationMode_t
uint32_t CRC_OperationMode_t
CRC operation mode supported. CRC can either operate in Semi-CPU, Full-CPU or Auto mode.
Definition: crc/v0/crc.h:129
CRC_configure
int32_t CRC_configure(uint32_t baseAddr, CRC_Channel_t channel, uint32_t crcPatternCount, uint32_t crcSectorCount, CRC_OperationMode_t crcMode)
This API will configure CRC mode, pattern and sector count for given channel.
CRC_Signature::regL
uint32_t regL
Definition: crc/v0/crc.h:249
CRC_Signature
Structure for accessing CRC register data which are 64 bit wide.
Definition: crc/v0/crc.h:248
CRC_ChannelStaticRegs::SCOUNT
volatile uint32_t SCOUNT
Definition: crc/v0/crc.h:272
CRC_IntrPriority_t
uint32_t CRC_IntrPriority_t
The offset for the highest pending priority interrupt. These interrupt offset returned in CRC_getHigh...
Definition: crc/v0/crc.h:174
CRC_StaticRegs
CRC static registers list.
Definition: crc/v0/crc.h:283
CRC_SignatureRegAddr
Structure for accessing CRC registers address which are 64 bit wide.
Definition: crc/v0/crc.h:259
CRC_disableIntr
int32_t CRC_disableIntr(uint32_t baseAddr, CRC_Channel_t channel, uint32_t intrMask)
This API is used to disable interrupts for given Channel.
CRC_getCurPSASig
int32_t CRC_getCurPSASig(uint32_t baseAddr, CRC_Channel_t channel, CRC_Signature *pCurPSASig)
This API is used to get current known good signature value/ CRC value for given channel.
CRC_StaticRegs::CTRL0
volatile uint32_t CTRL0
Definition: crc/v0/crc.h:286
CRC_verifyInitialize
int32_t CRC_verifyInitialize(uint32_t baseAddr, CRC_Channel_t channel, uint32_t crcWatchdogPreload, uint32_t crcBlockPreload)
Verify the CRC watchdog and block preload value initialized for given channel.
CRC_MAX_NUM_OF_CHANNELS
#define CRC_MAX_NUM_OF_CHANNELS
Max number of channels supported in CRC.
Definition: crc/v0/crc.h:118
CRC_getCurSecNum
int32_t CRC_getCurSecNum(uint32_t baseAddr, CRC_Channel_t channel, uint32_t *pCurSecNum)
This API is used to get the current sector number of which the signature verification fails in AUTO m...
CRC_enableIntr
int32_t CRC_enableIntr(uint32_t baseAddr, CRC_Channel_t channel, uint32_t intrMask)
This API is used to enable interrupts for given Channel.
CRC_initialize
int32_t CRC_initialize(uint32_t baseAddr, CRC_Channel_t channel, uint32_t crcWatchdogPreload, uint32_t crcBlockPreload)
Initialize CRC channel and will configure watchdog and block preload value for given channel.
CRC_getPSASig
int32_t CRC_getPSASig(uint32_t baseAddr, CRC_Channel_t channel, CRC_Signature *pCRCPSASign)
This API is used to get the PSA register value for given Channel.
CRC_DataBusMask_t
uint32_t CRC_DataBusMask_t
CRC data bus type mask selected for tracing control.
Definition: crc/v0/crc.h:226
CRCVerifyConfigure
int32_t CRCVerifyConfigure(uint32_t baseAddr, CRC_Channel_t channel, uint32_t crcPatternCount, uint32_t crcSectorCount, CRC_OperationMode_t crcMode)
This API will verify the configure of CRC mode, pattern and sector count for given channel.
CRC_ChannelStaticRegs
CRC channel static registers list.
Definition: crc/v0/crc.h:269
CRC_channelReset
int32_t CRC_channelReset(uint32_t baseAddr, CRC_Channel_t channel)
This API is used to reset the CRC channel.
CRC_isBusy
int32_t CRC_isBusy(uint32_t baseAddr, CRC_Channel_t channel, uint32_t *pBusyFlag)
This API is used to check if CRC is busy for given Channel.
CRC_getHighestPriorityIntrStatus
int32_t CRC_getHighestPriorityIntrStatus(uint32_t baseAddr, uint32_t *pIntVecAddr)
This API is used to get the pending interrupt with highest priority.
CRC_getPSASigRegAddr
int32_t CRC_getPSASigRegAddr(uint32_t baseAddr, CRC_Channel_t channel, CRC_SignatureRegAddr *pCRCRegAddr)
This API is used to get the PSA register address for given Channel.
CRC_readStaticRegs
int32_t CRC_readStaticRegs(uint32_t baseAddr, CRC_StaticRegs *pStaticRegs)
This API is used to read static registers of CRC module. This API needs to be called after the initia...
CRC_StaticRegs::CTRL1
volatile uint32_t CTRL1
Definition: crc/v0/crc.h:288
CRC_SignatureRegAddr::regL
uint32_t regL
Definition: crc/v0/crc.h:260
CRC_StaticRegs::BUS_SEL
volatile uint32_t BUS_SEL
Definition: crc/v0/crc.h:290
CRC_ChannelStaticRegs::WDTOPLD
volatile uint32_t WDTOPLD
Definition: crc/v0/crc.h:274