AM64x MCU+ SDK  08.01.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 crcOperationMode_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 crcChannel_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 crcIntrPriority_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 crcDataBusMask_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 crcSignature
248 {
249  uint32_t regL;
251  uint32_t regH;
254 
258 typedef struct crcSignatureRegAddr
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 CRCInitialize(uint32_t baseAddr,
326  crcChannel_t channel,
327  uint32_t crcWatchdogPreload,
328  uint32_t crcBlockPreload);
329 
352 int32_t CRCVerifyInitialize(uint32_t baseAddr,
353  crcChannel_t channel,
354  uint32_t crcWatchdogPreload,
355  uint32_t crcBlockPreload);
356 
375 int32_t CRCConfigure(uint32_t baseAddr,
376  crcChannel_t channel,
377  uint32_t crcPatternCount,
378  uint32_t crcSectorCount,
379  crcOperationMode_t crcMode);
380 
400 int32_t CRCVerifyConfigure(uint32_t baseAddr,
401  crcChannel_t channel,
402  uint32_t crcPatternCount,
403  uint32_t crcSectorCount,
404  crcOperationMode_t crcMode);
405 
418 int32_t CRCChannelReset(uint32_t baseAddr,
419  crcChannel_t channel);
420 
436 int32_t CRCGetPSASigRegAddr(uint32_t baseAddr,
437  crcChannel_t channel,
438  crcSignatureRegAddr_t *pCRCRegAddr);
439 
455 int32_t CRCGetPSASig(uint32_t baseAddr,
456  crcChannel_t channel,
457  crcSignature_t *pCRCPSASign);
458 
474 int32_t CRCSetPSASeedSig(uint32_t baseAddr,
475  crcChannel_t channel,
476  const crcSignature_t *pCRCPSASeedSign);
477 
493 int32_t CRCGetPSASectorSig(uint32_t baseAddr,
494  crcChannel_t channel,
495  crcSignature_t *pCRCSectorSign);
496 
510 int32_t CRCGetHighestPriorityIntrStatus(uint32_t baseAddr, uint32_t *pIntVecAddr);
511 
526 int32_t CRCGetIntrStatus(uint32_t baseAddr,
527  crcChannel_t channel,
528  uint32_t *pIntrStatus);
529 
543 int32_t CRCEnableIntr(uint32_t baseAddr,
544  crcChannel_t channel,
545  uint32_t intrMask);
546 
560 int32_t CRCDisableIntr(uint32_t baseAddr,
561  crcChannel_t channel,
562  uint32_t intrMask);
563 
577 int32_t CRCClearIntr(uint32_t baseAddr,
578  crcChannel_t channel,
579  uint32_t intrMask);
580 
594 int32_t CRCPowerDownCtrl(uint32_t baseAddr,
595  uint32_t ctrlFlag);
596 
618 int32_t CRCIsBusy(uint32_t baseAddr,
619  crcChannel_t channel,
620  uint32_t *pBusyFlag);
621 
639 int32_t CRCGetCurSecNum(uint32_t baseAddr,
640  crcChannel_t channel,
641  uint32_t *pCurSecNum);
642 
658 int32_t CRCGetCurPSASig(uint32_t baseAddr,
659  crcChannel_t channel,
660  crcSignature_t *pCurPSASig);
661 
676 int32_t CRCGetRawData(uint32_t baseAddr,
677  crcChannel_t channel,
678  crcSignature_t *pRawData);
679 
700 int32_t CRCDataBusTracingCtrl(uint32_t baseAddr,
701  uint32_t ctrlFlag,
702  crcDataBusMask_t dataBusMask,
703  crcDataBusMask_t busEnableMask);
704 
723 int32_t CRCVerifyBusTracingCtrl(uint32_t baseAddr,
724  uint32_t ctrlFlag,
725  crcDataBusMask_t dataBusMask,
726  crcDataBusMask_t busEnableMask);
727 
741 int32_t CRCReadStaticRegs(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 
crcSignatureRegAddr_t::regH
uint32_t regH
Definition: crc/v0/crc.h:262
CRCGetHighestPriorityIntrStatus
int32_t CRCGetHighestPriorityIntrStatus(uint32_t baseAddr, uint32_t *pIntVecAddr)
This API is used to get the pending interrupt with highest priority.
CRCEnableIntr
int32_t CRCEnableIntr(uint32_t baseAddr, crcChannel_t channel, uint32_t intrMask)
This API is used to enable interrupts for given Channel.
CRCPowerDownCtrl
int32_t CRCPowerDownCtrl(uint32_t baseAddr, uint32_t ctrlFlag)
This API is used to control the power down of the CRC module.
CRCSetPSASeedSig
int32_t CRCSetPSASeedSig(uint32_t baseAddr, crcChannel_t channel, const crcSignature_t *pCRCPSASeedSign)
This API is used to set the PSA seed value without compression for given Channel.
CRCVerifyConfigure
int32_t CRCVerifyConfigure(uint32_t baseAddr, crcChannel_t channel, uint32_t crcPatternCount, uint32_t crcSectorCount, crcOperationMode_t crcMode)
This API will verify the configure of CRC mode, pattern and sector count for given channel.
CRCReadStaticRegs
int32_t CRCReadStaticRegs(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
CRC static registers list.
Definition: crc/v0/crc.h:283
crcSignatureRegAddr_t
Structure for accessing CRC registers address which are 64 bit wide.
Definition: crc/v0/crc.h:259
crcSignatureRegAddr_t::regL
uint32_t regL
Definition: crc/v0/crc.h:260
CRCVerifyBusTracingCtrl
int32_t CRCVerifyBusTracingCtrl(uint32_t baseAddr, uint32_t ctrlFlag, crcDataBusMask_t dataBusMask, crcDataBusMask_t busEnableMask)
This API is used to verify the control the CRC data bus tracing.
crcOperationMode_t
uint32_t crcOperationMode_t
CRC operation mode supported. CRC can either operate in Semi-CPU, Full-CPU or Auto mode.
Definition: crc/v0/crc.h:129
CRCGetIntrStatus
int32_t CRCGetIntrStatus(uint32_t baseAddr, crcChannel_t channel, uint32_t *pIntrStatus)
This API is used to get the pending interrupts for given Channel.
CRCConfigure
int32_t CRCConfigure(uint32_t baseAddr, crcChannel_t channel, uint32_t crcPatternCount, uint32_t crcSectorCount, crcOperationMode_t crcMode)
This API will configure CRC mode, pattern and sector count for given channel.
Crc_ChannelStaticRegs::BCTOPLD
volatile uint32_t BCTOPLD
Definition: crc/v0/crc.h:276
CRCClearIntr
int32_t CRCClearIntr(uint32_t baseAddr, crcChannel_t channel, uint32_t intrMask)
This API is used to clear interrupts for given Channel.
crcChannel_t
uint32_t crcChannel_t
CRC channel supported.
Definition: crc/v0/crc.h:149
crcSignature_t::regH
uint32_t regH
Definition: crc/v0/crc.h:251
crcIntrPriority_t
uint32_t crcIntrPriority_t
The offset for the highest pending priority interrupt. These interrupt offset returned in CRCGetHighe...
Definition: crc/v0/crc.h:174
Crc_ChannelStaticRegs::SCOUNT
volatile uint32_t SCOUNT
Definition: crc/v0/crc.h:272
Crc_StaticRegs::BUS_SEL
volatile uint32_t BUS_SEL
Definition: crc/v0/crc.h:290
CRCChannelReset
int32_t CRCChannelReset(uint32_t baseAddr, crcChannel_t channel)
This API is used to reset the CRC channel.
crcSignature_t
Structure for accessing CRC register data which are 64 bit wide.
Definition: crc/v0/crc.h:248
CRC_MAX_NUM_OF_CHANNELS
#define CRC_MAX_NUM_OF_CHANNELS
Max number of channels supported in CRC.
Definition: crc/v0/crc.h:118
CRCGetPSASectorSig
int32_t CRCGetPSASectorSig(uint32_t baseAddr, crcChannel_t channel, crcSignature_t *pCRCSectorSign)
This API is used to get sector signature Value/ CRC value for given channel.
CRCDataBusTracingCtrl
int32_t CRCDataBusTracingCtrl(uint32_t baseAddr, uint32_t ctrlFlag, crcDataBusMask_t dataBusMask, crcDataBusMask_t busEnableMask)
This API is used to control the CRC data bus tracing.
crcSignature_t::regL
uint32_t regL
Definition: crc/v0/crc.h:249
CRCGetRawData
int32_t CRCGetRawData(uint32_t baseAddr, crcChannel_t channel, crcSignature_t *pRawData)
This API is used to get the uncompressed raw data value for given channel.
CRCGetCurSecNum
int32_t CRCGetCurSecNum(uint32_t baseAddr, crcChannel_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_ChannelStaticRegs
CRC channel static registers list.
Definition: crc/v0/crc.h:269
CRCGetPSASigRegAddr
int32_t CRCGetPSASigRegAddr(uint32_t baseAddr, crcChannel_t channel, crcSignatureRegAddr_t *pCRCRegAddr)
This API is used to get the PSA register address for given Channel.
CRCDisableIntr
int32_t CRCDisableIntr(uint32_t baseAddr, crcChannel_t channel, uint32_t intrMask)
This API is used to disable interrupts for given Channel.
CRCInitialize
int32_t CRCInitialize(uint32_t baseAddr, crcChannel_t channel, uint32_t crcWatchdogPreload, uint32_t crcBlockPreload)
Initialize CRC channel and will configure watchdog and block preload value for given channel.
Crc_ChannelStaticRegs::PCOUNT
volatile uint32_t PCOUNT
Definition: crc/v0/crc.h:270
crcDataBusMask_t
uint32_t crcDataBusMask_t
CRC data bus type mask selected for tracing control.
Definition: crc/v0/crc.h:226
Crc_ChannelStaticRegs::WDTOPLD
volatile uint32_t WDTOPLD
Definition: crc/v0/crc.h:274
CRCIsBusy
int32_t CRCIsBusy(uint32_t baseAddr, crcChannel_t channel, uint32_t *pBusyFlag)
This API is used to check if CRC is busy for given Channel.
CRCGetPSASig
int32_t CRCGetPSASig(uint32_t baseAddr, crcChannel_t channel, crcSignature_t *pCRCPSASign)
This API is used to get the PSA register value for given Channel.
CRCVerifyInitialize
int32_t CRCVerifyInitialize(uint32_t baseAddr, crcChannel_t channel, uint32_t crcWatchdogPreload, uint32_t crcBlockPreload)
Verify the CRC watchdog and block preload value initialized for given channel.
Crc_StaticRegs::CTRL1
volatile uint32_t CTRL1
Definition: crc/v0/crc.h:288
Crc_StaticRegs::CTRL0
volatile uint32_t CTRL0
Definition: crc/v0/crc.h:286
CRCGetCurPSASig
int32_t CRCGetCurPSASig(uint32_t baseAddr, crcChannel_t channel, crcSignature_t *pCurPSASig)
This API is used to get current known good signature value/ CRC value for given channel.