AM273x MCU+ SDK  08.02.00
crc/v1/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_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 
127 typedef uint32_t CRC_OperationMode_t;
128 #define CRC_OPERATION_MODE_FULLCPU (CRC_CTRL2_CH1_MODE_FULLCPU)
129 
140 typedef uint32_t CRC_Channel_t;
141 
142 #define CRC_CHANNEL_1 (0x1U)
143 
144 #define CRC_CHANNEL_2 (0x2U)
145 
156 typedef uint32_t CRC_Type_t;
157 
158 #define CRC_TYPE_16BIT (CRC_CTRL0_CH1_CRC_SEL_16BIT)
159 
160 #define CRC_TYPE_32BIT (CRC_CTRL0_CH1_CRC_SEL_32BIT)
161 
162 #define CRC_TYPE_64BIT (CRC_CTRL0_CH1_CRC_SEL_64BIT)
163 
174 typedef uint32_t CRC_DataLength_t;
175 
176 #define CRC_DATALENGTH_16BIT (CRC_CTRL0_CH1_DW_SEL_16BIT)
177 
178 #define CRC_DATALENGTH_32BIT (CRC_CTRL0_CH1_DW_SEL_32BIT)
179 
180 #define CRC_DATALENGTH_64BIT (CRC_CTRL0_CH1_DW_SEL_64BIT)
181 
192 typedef uint32_t CRC_BitSwap_t;
193 
194 #define CRC_BITSWAP_MSB (CRC_CTRL0_CH1_BIT_SWAP_MSB)
195 
196 #define CRC_BITSWAP_LSB (CRC_CTRL0_CH1_BIT_SWAP_LSB)
197 
208 typedef uint32_t CRC_ByteSwap_t;
209 
210 #define CRC_BYTESWAP_DISABLE (CRC_CTRL0_CH1_BTYE_SWAP_DISABLE)
211 
212 #define CRC_BYTESWAP_ENABLE (CRC_CTRL0_CH1_BTYE_SWAP_ENABLE)
213 
229 typedef uint32_t CRC_IntrPriority_t;
230 
231 #define CRC_INTR_PRIORITY_CH1_FAIL (0x1U)
232 
233 #define CRC_INTR_PRIORITY_CH2_FAIL (0x2U)
234 
235 #define CRC_INTR_PRIORITY_CH1_COMPRESSION_DONE (0x9U)
236 
237 #define CRC_INTR_PRIORITY_CH2_COMPRESSION_DONE (0xaU)
238 
239 #define CRC_INTR_PRIORITY_CH1_OVERRUN (0x11U)
240 
241 #define CRC_INTR_PRIORITY_CH2_OVERRUN (0x12U)
242 
243 #define CRC_INTR_PRIORITY_CH1_UNDERRUN (0x19U)
244 
245 #define CRC_INTR_PRIORITY_CH2_UNDERRUN (0x1aU)
246 
247 #define CRC_INTR_PRIORITY_CH1_TIMEOUT (0x21U)
248 
249 #define CRC_INTR_PRIORITY_CH2_TIMEOUT (0x22U)
250 
261 typedef uint32_t CRC_DataBusMask_t;
262 
263 #define CRC_DATA_BUS_ITCM_MASK (CRC_MCRC_BUS_SEL_ITC_MEN_MASK)
264 
265 #define CRC_DATA_BUS_DTCM_MASK (CRC_MCRC_BUS_SEL_DTC_MEN_MASK)
266 
267 #define CRC_DATA_BUS_VBUSM_MASK (CRC_MCRC_BUS_SEL_MEN_MASK)
268 
269 #define CRC_DATA_BUS_MASK_ALL (CRC_MCRC_BUS_SEL_ITC_MEN_MASK | \
270  CRC_MCRC_BUS_SEL_DTC_MEN_MASK | \
271  CRC_MCRC_BUS_SEL_MEN_MASK)
272 
275 /* ========================================================================== */
276 /* Structures and Enums */
277 /* ========================================================================== */
278 
282 typedef struct CRC_Config_s
283 {
294  uint32_t patternCount;
296  uint32_t sectorCount;
298 } CRC_Config;
299 
303 typedef struct CRC_Signature_s
304 {
305  uint32_t regL;
307  uint32_t regH;
310 
314 typedef struct CRC_SignatureRegAddr_s
315 {
316  uint32_t regL;
318  uint32_t regH;
321 
325 typedef struct
326 {
327  volatile uint32_t PCOUNT;
329  volatile uint32_t SCOUNT;
331  volatile uint32_t WDTOPLD;
333  volatile uint32_t BCTOPLD;
336 
340 typedef struct
341 {
344  volatile uint32_t CTRL0;
346  volatile uint32_t CTRL1;
348  volatile uint32_t BUS_SEL;
351 
352 /* ========================================================================== */
353 /* Global Variables Declarations */
354 /* ========================================================================== */
355 
356 /* None */
357 
358 /* ========================================================================== */
359 /* Function Declarations */
360 /* ========================================================================== */
361 
383 int32_t CRC_initialize(uint32_t baseAddr,
384  CRC_Channel_t channel,
385  uint32_t crcWatchdogPreload,
386  uint32_t crcBlockPreload);
387 
410 int32_t CRC_verifyInitialize(uint32_t baseAddr,
411  CRC_Channel_t channel,
412  uint32_t crcWatchdogPreload,
413  uint32_t crcBlockPreload);
414 
430 int32_t CRC_configure(uint32_t baseAddr,
431  CRC_Channel_t channel,
432  const CRC_Config *config);
433 
453 int32_t CRC_verifyConfigure(uint32_t baseAddr,
454  CRC_Channel_t channel,
455  uint32_t patternCount,
456  uint32_t sectorCount,
457  CRC_OperationMode_t mode);
458 
471 int32_t CRC_channelReset(uint32_t baseAddr,
472  CRC_Channel_t channel);
473 
489 int32_t CRC_getPSASigRegAddr(uint32_t baseAddr,
490  CRC_Channel_t channel,
491  CRC_SignatureRegAddr *pCRCRegAddr);
492 
508 int32_t CRC_getPSASig(uint32_t baseAddr,
509  CRC_Channel_t channel,
510  CRC_Signature *pCRCPSASign);
511 
527 int32_t CRC_setPSASeedSig(uint32_t baseAddr,
528  CRC_Channel_t channel,
529  const CRC_Signature *pCRCPSASeedSign);
530 
546 int32_t CRC_getPSASectorSig(uint32_t baseAddr,
547  CRC_Channel_t channel,
548  CRC_Signature *pCRCSectorSign);
549 
563 int32_t CRC_getHighestPriorityIntrStatus(uint32_t baseAddr, uint32_t *pIntVecAddr);
564 
579 int32_t CRC_getIntrStatus(uint32_t baseAddr,
580  CRC_Channel_t channel,
581  uint32_t *pIntrStatus);
582 
596 int32_t CRC_enableIntr(uint32_t baseAddr,
597  CRC_Channel_t channel,
598  uint32_t intrMask);
599 
613 int32_t CRC_disableIntr(uint32_t baseAddr,
614  CRC_Channel_t channel,
615  uint32_t intrMask);
616 
630 int32_t CRC_clearIntr(uint32_t baseAddr,
631  CRC_Channel_t channel,
632  uint32_t intrMask);
633 
647 int32_t CRC_powerDownCtrl(uint32_t baseAddr,
648  uint32_t ctrlFlag);
649 
671 int32_t CRC_isBusy(uint32_t baseAddr,
672  CRC_Channel_t channel,
673  uint32_t *pBusyFlag);
674 
692 int32_t CRC_getCurSecNum(uint32_t baseAddr,
693  CRC_Channel_t channel,
694  uint32_t *pCurSecNum);
695 
711 int32_t CRC_getCurPSASig(uint32_t baseAddr,
712  CRC_Channel_t channel,
713  CRC_Signature *pCurPSASig);
714 
729 int32_t CRC_getRawData(uint32_t baseAddr,
730  CRC_Channel_t channel,
731  CRC_Signature *pRawData);
732 
753 int32_t CRC_dataBusTracingCtrl(uint32_t baseAddr,
754  uint32_t ctrlFlag,
755  CRC_DataBusMask_t dataBusMask,
756  CRC_DataBusMask_t busEnableMask);
757 
776 int32_t CRC_verifyBusTracingCtrl(uint32_t baseAddr,
777  uint32_t ctrlFlag,
778  CRC_DataBusMask_t dataBusMask,
779  CRC_DataBusMask_t busEnableMask);
780 
794 int32_t CRC_readStaticRegs(uint32_t baseAddr, CRC_StaticRegs *pStaticRegs);
795 
796 /* ========================================================================== */
797 /* Static Function Definitions */
798 /* ========================================================================== */
799 
800 /* None */
801 
802 #ifdef __cplusplus
803 }
804 #endif
805 
806 #endif /* #ifndef CRC_V1_H_ */
807 
CRC_ChannelStaticRegs::BCTOPLD
volatile uint32_t BCTOPLD
Definition: crc/v1/crc.h:333
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:307
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:327
CRC_Channel_t
uint32_t CRC_Channel_t
CRC channel supported.
Definition: crc/v1/crc.h:140
CRC_Config::byteSwap
CRC_ByteSwap_t byteSwap
Definition: crc/v1/crc.h:292
CRC_SignatureRegAddr::regH
uint32_t regH
Definition: crc/v1/crc.h:318
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:127
CRC_Signature::regL
uint32_t regL
Definition: crc/v1/crc.h:305
CRC_Config::patternCount
uint32_t patternCount
Definition: crc/v1/crc.h:294
CRC_Signature
Structure for accessing CRC register data which are 64 bit wide.
Definition: crc/v1/crc.h:304
CRC_Config::sectorCount
uint32_t sectorCount
Definition: crc/v1/crc.h:296
CRC_ChannelStaticRegs::SCOUNT
volatile uint32_t SCOUNT
Definition: crc/v1/crc.h:329
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:229
CRC_StaticRegs
CRC static registers list.
Definition: crc/v1/crc.h:341
CRC_SignatureRegAddr
Structure for accessing CRC registers address which are 64 bit wide.
Definition: crc/v1/crc.h:315
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:344
CRC_BitSwap_t
uint32_t CRC_BitSwap_t
CRC Bit Swap supported.
Definition: crc/v1/crc.h:192
CRC_Config
CRC Configuration.
Definition: crc/v1/crc.h:283
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:261
CRC_ChannelStaticRegs
CRC channel static registers list.
Definition: crc/v1/crc.h:326
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:156
CRC_DataLength_t
uint32_t CRC_DataLength_t
CRC Data Length supported.
Definition: crc/v1/crc.h:174
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:284
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:346
CRC_Config::bitSwap
CRC_BitSwap_t bitSwap
Definition: crc/v1/crc.h:290
CRC_SignatureRegAddr::regL
uint32_t regL
Definition: crc/v1/crc.h:316
CRC_Config::dataLen
CRC_DataLength_t dataLen
Definition: crc/v1/crc.h:288
CRC_Config::type
CRC_Type_t type
Definition: crc/v1/crc.h:286
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:348
CRC_ChannelStaticRegs::WDTOPLD
volatile uint32_t WDTOPLD
Definition: crc/v1/crc.h:331
CRC_ByteSwap_t
uint32_t CRC_ByteSwap_t
CRC Byte Swap supported.
Definition: crc/v1/crc.h:208