AM273x MCU+ SDK  08.06.00
crc/v1/crc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021-2023 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_V1_H_
66 #define CRC_V1_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_INTR_CH1_FAILENR_MASK | \
88  (uint32_t)CRC_INTR_CH1_OVERENR_MASK | \
89  (uint32_t)CRC_INTR_CH1_UNDERENR_MASK | \
90  (uint32_t)CRC_INTR_CH1_TIME_OUT_ENR_MASK)
91 
95 #define CRC_PATTERN_COUNT_MAX (0x000FFFFFU)
96 
100 #define CRC_SECTOR_COUNT_MAX (0x0000FFFFU)
101 
106 #define CRC_BCTOPLD_MAX (0x00FFFFFFU)
107 
111 #define CRC_WDTOPLD_MAX (0x00FFFFFFU)
112 
116 #define CRC_MAX_NUM_OF_CHANNELS (2U)
117 
122 #define CRC_REG_OFFSET (0x40U)
123 
127 #define CRC_SHIFT_BY_EIGHT (0x08U)
128 
138 typedef uint32_t CRC_OperationMode_t;
139 #define CRC_OPERATION_MODE_FULLCPU (CRC_CTRL2_CH1_MODE_FULLCPU)
140 
151 typedef uint32_t CRC_Channel_t;
152 
153 #define CRC_CHANNEL_1 (0x1U)
154 
155 #define CRC_CHANNEL_2 (0x2U)
156 
167 typedef uint32_t CRC_Type_t;
168 
169 #define CRC_TYPE_16BIT (CRC_CTRL0_CH1_CRC_SEL_16BIT)
170 
171 #define CRC_TYPE_32BIT (CRC_CTRL0_CH1_CRC_SEL_32BIT)
172 
173 #define CRC_TYPE_64BIT (CRC_CTRL0_CH1_CRC_SEL_64BIT)
174 
185 typedef uint32_t CRC_DataLength_t;
186 
187 #define CRC_DATALENGTH_16BIT (CRC_CTRL0_CH1_DW_SEL_16BIT)
188 
189 #define CRC_DATALENGTH_32BIT (CRC_CTRL0_CH1_DW_SEL_32BIT)
190 
191 #define CRC_DATALENGTH_64BIT (CRC_CTRL0_CH1_DW_SEL_64BIT)
192 
203 typedef uint32_t CRC_BitSwap_t;
204 
205 #define CRC_BITSWAP_MSB (CRC_CTRL0_CH1_BIT_SWAP_MSB)
206 
207 #define CRC_BITSWAP_LSB (CRC_CTRL0_CH1_BIT_SWAP_LSB)
208 
219 typedef uint32_t CRC_ByteSwap_t;
220 
221 #define CRC_BYTESWAP_DISABLE (CRC_CTRL0_CH1_BTYE_SWAP_DISABLE)
222 
223 #define CRC_BYTESWAP_ENABLE (CRC_CTRL0_CH1_BTYE_SWAP_ENABLE)
224 
240 typedef uint32_t CRC_IntrPriority_t;
241 
242 #define CRC_INTR_PRIORITY_CH1_FAIL (0x1U)
243 
244 #define CRC_INTR_PRIORITY_CH2_FAIL (0x2U)
245 
246 #define CRC_INTR_PRIORITY_CH1_COMPRESSION_DONE (0x9U)
247 
248 #define CRC_INTR_PRIORITY_CH2_COMPRESSION_DONE (0xaU)
249 
250 #define CRC_INTR_PRIORITY_CH1_OVERRUN (0x11U)
251 
252 #define CRC_INTR_PRIORITY_CH2_OVERRUN (0x12U)
253 
254 #define CRC_INTR_PRIORITY_CH1_UNDERRUN (0x19U)
255 
256 #define CRC_INTR_PRIORITY_CH2_UNDERRUN (0x1aU)
257 
258 #define CRC_INTR_PRIORITY_CH1_TIMEOUT (0x21U)
259 
260 #define CRC_INTR_PRIORITY_CH2_TIMEOUT (0x22U)
261 
272 typedef uint32_t CRC_DataBusMask_t;
273 
274 #define CRC_DATA_BUS_ITCM_MASK (CRC_MCRC_BUS_SEL_ITC_MEN_MASK)
275 
276 #define CRC_DATA_BUS_DTCM_MASK (CRC_MCRC_BUS_SEL_DTC_MEN_MASK)
277 
278 #define CRC_DATA_BUS_VBUSM_MASK (CRC_MCRC_BUS_SEL_MEN_MASK)
279 
280 #define CRC_DATA_BUS_MASK_ALL (CRC_MCRC_BUS_SEL_ITC_MEN_MASK | \
281  CRC_MCRC_BUS_SEL_DTC_MEN_MASK | \
282  CRC_MCRC_BUS_SEL_MEN_MASK)
283 
286 /* ========================================================================== */
287 /* Structures and Enums */
288 /* ========================================================================== */
289 
293 typedef struct CRC_Config_s
294 {
305  uint32_t patternCount;
307  uint32_t sectorCount;
309 } CRC_Config;
310 
314 typedef struct CRC_Signature_s
315 {
316  uint32_t regL;
318  uint32_t regH;
321 
325 typedef struct CRC_SignatureRegAddr_s
326 {
327  uint32_t regL;
329  uint32_t regH;
332 
336 typedef struct
337 {
338  volatile uint32_t PCOUNT;
340  volatile uint32_t SCOUNT;
342  volatile uint32_t WDTOPLD;
344  volatile uint32_t BCTOPLD;
347 
351 typedef struct
352 {
355  volatile uint32_t CTRL0;
357  volatile uint32_t CTRL1;
359  volatile uint32_t BUS_SEL;
362 
363 /* ========================================================================== */
364 /* Global Variables Declarations */
365 /* ========================================================================== */
366 
367 /* None */
368 
369 /* ========================================================================== */
370 /* Function Declarations */
371 /* ========================================================================== */
372 
394 int32_t CRC_initialize(uint32_t baseAddr,
395  CRC_Channel_t channel,
396  uint32_t crcWatchdogPreload,
397  uint32_t crcBlockPreload);
398 
421 int32_t CRC_verifyInitialize(uint32_t baseAddr,
422  CRC_Channel_t channel,
423  uint32_t crcWatchdogPreload,
424  uint32_t crcBlockPreload);
425 
441 int32_t CRC_configure(uint32_t baseAddr,
442  CRC_Channel_t channel,
443  const CRC_Config *config);
444 
464 int32_t CRC_verifyConfigure(uint32_t baseAddr,
465  CRC_Channel_t channel,
466  uint32_t patternCount,
467  uint32_t sectorCount,
468  CRC_OperationMode_t mode);
469 
482 int32_t CRC_channelReset(uint32_t baseAddr,
483  CRC_Channel_t channel);
484 
500 int32_t CRC_getPSASigRegAddr(uint32_t baseAddr,
501  CRC_Channel_t channel,
502  CRC_SignatureRegAddr *pCRCRegAddr);
503 
519 int32_t CRC_getPSASig(uint32_t baseAddr,
520  CRC_Channel_t channel,
521  CRC_Signature *pCRCPSASign);
522 
538 int32_t CRC_setPSASeedSig(uint32_t baseAddr,
539  CRC_Channel_t channel,
540  const CRC_Signature *pCRCPSASeedSign);
541 
557 int32_t CRC_getPSASectorSig(uint32_t baseAddr,
558  CRC_Channel_t channel,
559  CRC_Signature *pCRCSectorSign);
560 
574 int32_t CRC_getHighestPriorityIntrStatus(uint32_t baseAddr, uint32_t *pIntVecAddr);
575 
590 int32_t CRC_getIntrStatus(uint32_t baseAddr,
591  CRC_Channel_t channel,
592  uint32_t *pIntrStatus);
593 
607 int32_t CRC_enableIntr(uint32_t baseAddr,
608  CRC_Channel_t channel,
609  uint32_t intrMask);
610 
624 int32_t CRC_disableIntr(uint32_t baseAddr,
625  CRC_Channel_t channel,
626  uint32_t intrMask);
627 
641 int32_t CRC_clearIntr(uint32_t baseAddr,
642  CRC_Channel_t channel,
643  uint32_t intrMask);
644 
658 int32_t CRC_powerDownCtrl(uint32_t baseAddr,
659  uint32_t ctrlFlag);
660 
682 int32_t CRC_isBusy(uint32_t baseAddr,
683  CRC_Channel_t channel,
684  uint32_t *pBusyFlag);
685 
703 int32_t CRC_getCurSecNum(uint32_t baseAddr,
704  CRC_Channel_t channel,
705  uint32_t *pCurSecNum);
706 
722 int32_t CRC_getCurPSASig(uint32_t baseAddr,
723  CRC_Channel_t channel,
724  CRC_Signature *pCurPSASig);
725 
740 int32_t CRC_getRawData(uint32_t baseAddr,
741  CRC_Channel_t channel,
742  CRC_Signature *pRawData);
743 
764 int32_t CRC_dataBusTracingCtrl(uint32_t baseAddr,
765  uint32_t ctrlFlag,
766  CRC_DataBusMask_t dataBusMask,
767  CRC_DataBusMask_t busEnableMask);
768 
787 int32_t CRC_verifyBusTracingCtrl(uint32_t baseAddr,
788  uint32_t ctrlFlag,
789  CRC_DataBusMask_t dataBusMask,
790  CRC_DataBusMask_t busEnableMask);
791 
805 int32_t CRC_readStaticRegs(uint32_t baseAddr, CRC_StaticRegs *pStaticRegs);
806 
807 /* ========================================================================== */
808 /* Static Function Definitions */
809 /* ========================================================================== */
810 
811 /* None */
812 
813 #ifdef __cplusplus
814 }
815 #endif
816 
817 #endif /* #ifndef CRC_V1_H_ */
818 
CRC_ChannelStaticRegs::BCTOPLD
volatile uint32_t BCTOPLD
Definition: crc/v1/crc.h:344
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/v1/crc.h:318
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/v1/crc.h:338
CRC_Channel_t
uint32_t CRC_Channel_t
CRC channel supported.
Definition: crc/v1/crc.h:151
CRC_Config::byteSwap
CRC_ByteSwap_t byteSwap
Definition: crc/v1/crc.h:303
CRC_SignatureRegAddr::regH
uint32_t regH
Definition: crc/v1/crc.h:329
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/v1/crc.h:138
CRC_Signature::regL
uint32_t regL
Definition: crc/v1/crc.h:316
CRC_Config::patternCount
uint32_t patternCount
Definition: crc/v1/crc.h:305
CRC_Signature
Structure for accessing CRC register data which are 64 bit wide.
Definition: crc/v1/crc.h:315
CRC_Config::sectorCount
uint32_t sectorCount
Definition: crc/v1/crc.h:307
CRC_ChannelStaticRegs::SCOUNT
volatile uint32_t SCOUNT
Definition: crc/v1/crc.h:340
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/v1/crc.h:240
CRC_StaticRegs
CRC static registers list.
Definition: crc/v1/crc.h:352
CRC_SignatureRegAddr
Structure for accessing CRC registers address which are 64 bit wide.
Definition: crc/v1/crc.h:326
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/v1/crc.h:355
CRC_BitSwap_t
uint32_t CRC_BitSwap_t
CRC Bit Swap supported.
Definition: crc/v1/crc.h:203
CRC_Config
CRC Configuration.
Definition: crc/v1/crc.h:294
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/v1/crc.h:116
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_configure
int32_t CRC_configure(uint32_t baseAddr, CRC_Channel_t channel, const CRC_Config *config)
This API will configure CRC mode, pattern and sector count for given channel.
CRC_DataBusMask_t
uint32_t CRC_DataBusMask_t
CRC data bus type mask selected for tracing control.
Definition: crc/v1/crc.h:272
CRC_ChannelStaticRegs
CRC channel static registers list.
Definition: crc/v1/crc.h:337
CRC_channelReset
int32_t CRC_channelReset(uint32_t baseAddr, CRC_Channel_t channel)
This API is used to reset the CRC channel.
CRC_Type_t
uint32_t CRC_Type_t
CRC Type supported.
Definition: crc/v1/crc.h:167
CRC_DataLength_t
uint32_t CRC_DataLength_t
CRC Data Length supported.
Definition: crc/v1/crc.h:185
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_Config::mode
CRC_OperationMode_t mode
Definition: crc/v1/crc.h:295
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/v1/crc.h:357
CRC_Config::bitSwap
CRC_BitSwap_t bitSwap
Definition: crc/v1/crc.h:301
CRC_SignatureRegAddr::regL
uint32_t regL
Definition: crc/v1/crc.h:327
CRC_Config::dataLen
CRC_DataLength_t dataLen
Definition: crc/v1/crc.h:299
CRC_Config::type
CRC_Type_t type
Definition: crc/v1/crc.h:297
CRC_verifyConfigure
int32_t CRC_verifyConfigure(uint32_t baseAddr, CRC_Channel_t channel, uint32_t patternCount, uint32_t sectorCount, CRC_OperationMode_t mode)
This API will verify the configure of CRC mode, pattern and sector count for given channel.
CRC_StaticRegs::BUS_SEL
volatile uint32_t BUS_SEL
Definition: crc/v1/crc.h:359
CRC_ChannelStaticRegs::WDTOPLD
volatile uint32_t WDTOPLD
Definition: crc/v1/crc.h:342
CRC_ByteSwap_t
uint32_t CRC_ByteSwap_t
CRC Byte Swap supported.
Definition: crc/v1/crc.h:219