RTEMS 6.1-rc5
Loading...
Searching...
No Matches
fsl_trng.h
1/*
2 * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2018, 2020-2022 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8#ifndef _FSL_TRNG_DRIVER_H_
9#define _FSL_TRNG_DRIVER_H_
10
11#include "fsl_common.h"
12
13#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && FSL_FEATURE_SOC_TRNG_COUNT
14
20/*******************************************************************************
21 * Definitions
22 *******************************************************************************/
23
66#define FSL_TRNG_DRIVER_VERSION (MAKE_VERSION(2, 0, 15))
70typedef enum _trng_sample_mode
71{
72 kTRNG_SampleModeVonNeumann = 0U,
73 kTRNG_SampleModeRaw = 1U,
74 kTRNG_SampleModeVonNeumannRaw =
75 2U
76} trng_sample_mode_t;
77
79typedef enum _trng_clock_mode
80{
81 kTRNG_ClockModeRingOscillator = 0U,
82 kTRNG_ClockModeSystem = 1U
84} trng_clock_mode_t;
85
87typedef enum _trng_ring_osc_div
88{
89 kTRNG_RingOscDiv0 = 0U,
90 kTRNG_RingOscDiv2 = 1U,
91 kTRNG_RingOscDiv4 = 2U,
92 kTRNG_RingOscDiv8 = 3U
93} trng_ring_osc_div_t;
94
96typedef struct _trng_statistical_check_limit
97{
98 uint32_t maximum;
99 uint32_t minimum;
100} trng_statistical_check_limit_t;
101
108typedef struct _trng_user_config
109{
110 bool lock;
111 trng_clock_mode_t clockMode;
112 trng_ring_osc_div_t ringOscDiv;
113 trng_sample_mode_t sampleMode;
114 /* Seed Control*/
115 uint16_t
116 entropyDelay;
117 uint16_t sampleSize;
119 uint16_t sparseBitLimit;
125 /* Statistical Check Parameters.*/
126 uint8_t retryCount;
128 uint8_t longRunMaxLimit;
130 trng_statistical_check_limit_t monobitLimit;
132 trng_statistical_check_limit_t runBit1Limit;
134 trng_statistical_check_limit_t runBit2Limit;
136 trng_statistical_check_limit_t runBit3Limit;
138 trng_statistical_check_limit_t runBit4Limit;
140 trng_statistical_check_limit_t runBit5Limit;
142 trng_statistical_check_limit_t runBit6PlusLimit;
145 trng_statistical_check_limit_t
146 pokerLimit;
147 trng_statistical_check_limit_t frequencyCountLimit;
149} trng_config_t;
150
151/*******************************************************************************
152 * API
153 *******************************************************************************/
154
155#if defined(__cplusplus)
156extern "C" {
157#endif
158
197status_t TRNG_GetDefaultConfig(trng_config_t *userConfig);
198
209status_t TRNG_Init(TRNG_Type *base, const trng_config_t *userConfig);
210
218void TRNG_Deinit(TRNG_Type *base);
219
230status_t TRNG_GetRandomData(TRNG_Type *base, void *data, size_t dataSize);
231
232#if defined(__cplusplus)
233}
234#endif
235
238#endif /* FSL_FEATURE_SOC_TRNG_COUNT */
239#endif /*_FSL_TRNG_H_*/
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
Definition: MIMXRT1052.h:43954