AM64x MCU+ SDK  07.03.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 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 /* ========================================================================== */
80 /* Macros & Typedefs */
81 /* ========================================================================== */
82 
86 #define CRC_CHANNEL_IRQSTATUS_RAW_MAIN_ALL \
87  (uint32_t) ((uint32_t)CRC_INTS_CH1_CCITENS_MASK | \
88  (uint32_t)CRC_INTR_CH1_FAILENR_MASK | \
89  (uint32_t)CRC_INTR_CH1_OVERENR_MASK | \
90  (uint32_t)CRC_INTR_CH1_UNDERENR_MASK | \
91  (uint32_t)CRC_INTR_CH1_TIME_OUT_ENR_MASK)
92 
96 #define CRC_PATTERN_COUNT_MAX (0x000FFFFFU)
97 
101 #define CRC_SECTOR_COUNT_MAX (0x0000FFFFU)
102 
107 #define CRC_BCTOPLD_MAX (0x00FFFFFFU)
108 
112 #define CRC_WDTOPLD_MAX (0x00FFFFFFU)
113 
117 #define CRC_MAX_NUM_OF_CHANNELS (4U)
118 
128 typedef uint32_t crcOperationMode_t;
129 
130 #define CRC_OPERATION_MODE_DATA (CRC_CTRL2_CH1_MODE_DATA)
131 
132 #define CRC_OPERATION_MODE_AUTO (CRC_CTRL2_CH1_MODE_AUTO)
133 
134 #define CRC_OPERATION_MODE_SEMICPU (CRC_CTRL2_CH1_MODE_SEMICPU)
135 
136 #define CRC_OPERATION_MODE_FULLCPU (CRC_CTRL2_CH1_MODE_FULLCPU)
137 
148 typedef uint32_t crcChannel_t;
149 
150 #define CRC_CHANNEL_1 (0x1U)
151 
152 #define CRC_CHANNEL_2 (0x2U)
153 
154 #define CRC_CHANNEL_3 (0x3U)
155 
156 #define CRC_CHANNEL_4 (0x4U)
157 
173 typedef uint32_t crcIntrPriority_t;
174 
175 #define CRC_INTR_PRIORITY_CH1_FAIL (0x1U)
176 
177 #define CRC_INTR_PRIORITY_CH2_FAIL (0x2U)
178 
179 #define CRC_INTR_PRIORITY_CH3_FAIL (0x3U)
180 
181 #define CRC_INTR_PRIORITY_CH4_FAIL (0x4U)
182 
183 #define CRC_INTR_PRIORITY_CH1_COMPRESSION_DONE (0x9U)
184 
185 #define CRC_INTR_PRIORITY_CH2_COMPRESSION_DONE (0xaU)
186 
187 #define CRC_INTR_PRIORITY_CH3_COMPRESSION_DONE (0xbU)
188 
189 #define CRC_INTR_PRIORITY_CH4_COMPRESSION_DONE (0xcU)
190 
191 #define CRC_INTR_PRIORITY_CH1_OVERRUN (0x11U)
192 
193 #define CRC_INTR_PRIORITY_CH2_OVERRUN (0x12U)
194 
195 #define CRC_INTR_PRIORITY_CH3_OVERRUN (0x13U)
196 
197 #define CRC_INTR_PRIORITY_CH4_OVERRUN (0x14U)
198 
199 #define CRC_INTR_PRIORITY_CH1_UNDERRUN (0x19U)
200 
201 #define CRC_INTR_PRIORITY_CH2_UNDERRUN (0x1aU)
202 
203 #define CRC_INTR_PRIORITY_CH3_UNDERRUN (0x1bU)
204 
205 #define CRC_INTR_PRIORITY_CH4_UNDERRUN (0x1cU)
206 
207 #define CRC_INTR_PRIORITY_CH1_TIMEOUT (0x21U)
208 
209 #define CRC_INTR_PRIORITY_CH2_TIMEOUT (0x22U)
210 
211 #define CRC_INTR_PRIORITY_CH3_TIMEOUT (0x23U)
212 
213 #define CRC_INTR_PRIORITY_CH4_TIMEOUT (0x24U)
214 
225 typedef uint32_t crcDataBusMask_t;
226 
227 #define CRC_DATA_BUS_ITCM_MASK (CRC_MCRC_BUS_SEL_ITC_MEN_MASK)
228 
229 #define CRC_DATA_BUS_DTCM_MASK (CRC_MCRC_BUS_SEL_DTC_MEN_MASK)
230 
231 #define CRC_DATA_BUS_VBUSM_MASK (CRC_MCRC_BUS_SEL_MEN_MASK)
232 
233 #define CRC_DATA_BUS_MASK_ALL (CRC_MCRC_BUS_SEL_ITC_MEN_MASK | \
234  CRC_MCRC_BUS_SEL_DTC_MEN_MASK | \
235  CRC_MCRC_BUS_SEL_MEN_MASK)
236 
239 /* ========================================================================== */
240 /* Structures and Enums */
241 /* ========================================================================== */
242 
246 typedef struct crcSignature
247 {
248  uint32_t regL;
250  uint32_t regH;
253 
257 typedef struct crcSignatureRegAddr
258 {
259  uint32_t regL;
261  uint32_t regH;
264 
268 typedef struct {
269  volatile uint32_t PCOUNT;
271  volatile uint32_t SCOUNT;
273  volatile uint32_t WDTOPLD;
275  volatile uint32_t BCTOPLD;
278 
282 typedef struct {
285  volatile uint32_t CTRL0;
287  volatile uint32_t CTRL1;
289  volatile uint32_t BUS_SEL;
292 
293 /* ========================================================================== */
294 /* Global Variables Declarations */
295 /* ========================================================================== */
296 
297 /* None */
298 
299 /* ========================================================================== */
300 /* Function Declarations */
301 /* ========================================================================== */
302 
324 int32_t CRCInitialize(uint32_t baseAddr,
325  crcChannel_t channel,
326  uint32_t crcWatchdogPreload,
327  uint32_t crcBlockPreload);
328 
351 int32_t CRCVerifyInitialize(uint32_t baseAddr,
352  crcChannel_t channel,
353  uint32_t crcWatchdogPreload,
354  uint32_t crcBlockPreload);
355 
374 int32_t CRCConfigure(uint32_t baseAddr,
375  crcChannel_t channel,
376  uint32_t crcPatternCount,
377  uint32_t crcSectorCount,
378  crcOperationMode_t crcMode);
379 
399 int32_t CRCVerifyConfigure(uint32_t baseAddr,
400  crcChannel_t channel,
401  uint32_t crcPatternCount,
402  uint32_t crcSectorCount,
403  crcOperationMode_t crcMode);
404 
417 int32_t CRCChannelReset(uint32_t baseAddr,
418  crcChannel_t channel);
419 
435 int32_t CRCGetPSASigRegAddr(uint32_t baseAddr,
436  crcChannel_t channel,
437  crcSignatureRegAddr_t *pCRCRegAddr);
438 
454 int32_t CRCGetPSASig(uint32_t baseAddr,
455  crcChannel_t channel,
456  crcSignature_t *pCRCPSASign);
457 
473 int32_t CRCSetPSASeedSig(uint32_t baseAddr,
474  crcChannel_t channel,
475  const crcSignature_t *pCRCPSASeedSign);
476 
492 int32_t CRCGetPSASectorSig(uint32_t baseAddr,
493  crcChannel_t channel,
494  crcSignature_t *pCRCSectorSign);
495 
509 int32_t CRCGetHighestPriorityIntrStatus(uint32_t baseAddr, uint32_t *pIntVecAddr);
510 
525 int32_t CRCGetIntrStatus(uint32_t baseAddr,
526  crcChannel_t channel,
527  uint32_t *pIntrStatus);
528 
542 int32_t CRCEnableIntr(uint32_t baseAddr,
543  crcChannel_t channel,
544  uint32_t intrMask);
545 
559 int32_t CRCDisableIntr(uint32_t baseAddr,
560  crcChannel_t channel,
561  uint32_t intrMask);
562 
576 int32_t CRCClearIntr(uint32_t baseAddr,
577  crcChannel_t channel,
578  uint32_t intrMask);
579 
593 int32_t CRCPowerDownCtrl(uint32_t baseAddr,
594  uint32_t ctrlFlag);
595 
617 int32_t CRCIsBusy(uint32_t baseAddr,
618  crcChannel_t channel,
619  uint32_t *pBusyFlag);
620 
638 int32_t CRCGetCurSecNum(uint32_t baseAddr,
639  crcChannel_t channel,
640  uint32_t *pCurSecNum);
641 
657 int32_t CRCGetCurPSASig(uint32_t baseAddr,
658  crcChannel_t channel,
659  crcSignature_t *pCurPSASig);
660 
675 int32_t CRCGetRawData(uint32_t baseAddr,
676  crcChannel_t channel,
677  crcSignature_t *pRawData);
678 
699 int32_t CRCDataBusTracingCtrl(uint32_t baseAddr,
700  uint32_t ctrlFlag,
701  crcDataBusMask_t dataBusMask,
702  crcDataBusMask_t busEnableMask);
703 
722 int32_t CRCVerifyBusTracingCtrl(uint32_t baseAddr,
723  uint32_t ctrlFlag,
724  crcDataBusMask_t dataBusMask,
725  crcDataBusMask_t busEnableMask);
726 
740 int32_t CRCReadStaticRegs(uint32_t baseAddr, Crc_StaticRegs *pStaticRegs);
741 
742 /* ========================================================================== */
743 /* Static Function Definitions */
744 /* ========================================================================== */
745 
746 /* None */
747 
748 #ifdef __cplusplus
749 }
750 #endif
751 
752 #endif /* #ifndef CRC_V0_H_ */
753 
crcSignatureRegAddr_t::regH
uint32_t regH
Definition: crc/v0/crc.h:261
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:282
crcSignatureRegAddr_t
Structure for accessing CRC registers address which are 64 bit wide.
Definition: crc/v0/crc.h:258
crcSignatureRegAddr_t::regL
uint32_t regL
Definition: crc/v0/crc.h:259
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:128
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:275
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:148
crcSignature_t::regH
uint32_t regH
Definition: crc/v0/crc.h:250
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:173
Crc_ChannelStaticRegs::SCOUNT
volatile uint32_t SCOUNT
Definition: crc/v0/crc.h:271
Crc_StaticRegs::BUS_SEL
volatile uint32_t BUS_SEL
Definition: crc/v0/crc.h:289
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:247
CRC_MAX_NUM_OF_CHANNELS
#define CRC_MAX_NUM_OF_CHANNELS
Max number of channels supported in CRC.
Definition: crc/v0/crc.h:117
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:248
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:268
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:269
crcDataBusMask_t
uint32_t crcDataBusMask_t
CRC data bus type mask selected for tracing control.
Definition: crc/v0/crc.h:225
Crc_ChannelStaticRegs::WDTOPLD
volatile uint32_t WDTOPLD
Definition: crc/v0/crc.h:273
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:287
Crc_StaticRegs::CTRL0
volatile uint32_t CTRL0
Definition: crc/v0/crc.h:285
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.