Loading...
Searching...
No Matches
trng.h
1// THIS HEADER FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT
2
8#ifndef _HARDWARE_STRUCTS_TRNG_H
9#define _HARDWARE_STRUCTS_TRNG_H
10
14
16#include "hardware/regs/trng.h"
17
18// Reference to datasheet: https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf#tab-registerlist_trng
19//
20// The _REG_ macro is intended to help make the register navigable in your IDE (for example, using the "Go to Definition" feature)
21// _REG_(x) will link to the corresponding register in hardware/regs/trng.h.
22//
23// Bit-field descriptions are of the form:
24// BITMASK [BITRANGE] FIELDNAME (RESETVALUE) DESCRIPTION
25
26typedef struct {
27 _REG_(TRNG_RNG_IMR_OFFSET) // TRNG_RNG_IMR
28 // Interrupt masking
29 // 0x00000008 [3] VN_ERR_INT_MASK (1) Set to 1 to mask (disable) this interrupt: no interrupt...
30 // 0x00000004 [2] CRNGT_ERR_INT_MASK (1) Set to 1 to mask (disable) this interrupt: no interrupt...
31 // 0x00000002 [1] AUTOCORR_ERR_INT_MASK (1) Set to 1 to mask (disable) this interrupt: no interrupt...
32 // 0x00000001 [0] EHR_VALID_INT_MASK (1) Set to 1 to mask (disable) this interrupt: no interrupt...
33 io_rw_32 rng_imr;
34
35 _REG_(TRNG_RNG_ISR_OFFSET) // TRNG_RNG_ISR
36 // RNG status register
37 // 0x00000008 [3] VN_ERR (0) 1 indicates von Neumann error
38 // 0x00000004 [2] CRNGT_ERR (0) 1 indicates CRNGT in the RNG test failed
39 // 0x00000002 [1] AUTOCORR_ERR (0) 1 indicates Autocorrelation test failed four times in a row
40 // 0x00000001 [0] EHR_VALID (0) 1 indicates that 192 bits have been collected in the...
41 io_ro_32 rng_isr;
42
43 _REG_(TRNG_RNG_ICR_OFFSET) // TRNG_RNG_ICR
44 // Interrupt/status bit clear Register
45 // 0x00000008 [3] VN_ERR (0) Write 1 to clear corresponding bit in RNG_ISR
46 // 0x00000004 [2] CRNGT_ERR (0) Write 1 to clear corresponding bit in RNG_ISR
47 // 0x00000002 [1] AUTOCORR_ERR (0) Cannot be cleared by SW! Only RNG reset clears this bit
48 // 0x00000001 [0] EHR_VALID (0) Write 1 - clear corresponding bit in RNG_ISR
49 io_rw_32 rng_icr;
50
51 _REG_(TRNG_TRNG_CONFIG_OFFSET) // TRNG_TRNG_CONFIG
52 // Selecting the inverter-chain length
53 // 0x00000003 [1:0] RND_SRC_SEL (0x0) Selects the number of inverters (out of four possible...
54 io_rw_32 trng_config;
55
56 _REG_(TRNG_TRNG_VALID_OFFSET) // TRNG_TRNG_VALID
57 // 192 bit collection indication
58 // 0x00000001 [0] EHR_VALID (0) 1 indicates that collection of bits in the RNG is...
59 io_ro_32 trng_valid;
60
61 // (Description copied from array index 0 register TRNG_EHR_DATA0 applies similarly to other array indexes)
62 _REG_(TRNG_EHR_DATA0_OFFSET) // TRNG_EHR_DATA0
63 // RNG collected bits
64 // 0xffffffff [31:0] EHR_DATA0 (0x00000000) Bits [31:0] of Entropy Holding Register (EHR) - RNG...
65 io_ro_32 ehr_data[6];
66
67 _REG_(TRNG_RND_SOURCE_ENABLE_OFFSET) // TRNG_RND_SOURCE_ENABLE
68 // Enable signal for the random source
69 // 0x00000001 [0] RND_SRC_EN (0) * 1 - entropy source is enabled
70 io_rw_32 rnd_source_enable;
71
72 _REG_(TRNG_SAMPLE_CNT1_OFFSET) // TRNG_SAMPLE_CNT1
73 // Counts clocks between sampling of random bit
74 // 0xffffffff [31:0] SAMPLE_CNTR1 (0x0000ffff) Sets the number of rng_clk cycles between two...
75 io_rw_32 sample_cnt1;
76
77 _REG_(TRNG_AUTOCORR_STATISTIC_OFFSET) // TRNG_AUTOCORR_STATISTIC
78 // Statistics about autocorrelation test activations
79 // 0x003fc000 [21:14] AUTOCORR_FAILS (0x00) Count each time an autocorrelation test fails
80 // 0x00003fff [13:0] AUTOCORR_TRYS (0x0000) Count each time an autocorrelation test starts
81 io_rw_32 autocorr_statistic;
82
83 _REG_(TRNG_TRNG_DEBUG_CONTROL_OFFSET) // TRNG_TRNG_DEBUG_CONTROL
84 // Debug register
85 // 0x00000008 [3] AUTO_CORRELATE_BYPASS (0) When set, the autocorrelation test in the TRNG module is bypassed
86 // 0x00000004 [2] TRNG_CRNGT_BYPASS (0) When set, the CRNGT test in the RNG is bypassed
87 // 0x00000002 [1] VNC_BYPASS (0) When set, the Von-Neuman balancer is bypassed (including...
88 io_rw_32 trng_debug_control;
89
90 uint32_t _pad0;
91
92 _REG_(TRNG_TRNG_SW_RESET_OFFSET) // TRNG_TRNG_SW_RESET
93 // Generate internal SW reset within the RNG block
94 // 0x00000001 [0] TRNG_SW_RESET (0) Writing 1 to this register causes an internal RNG reset
95 io_rw_32 trng_sw_reset;
96
97 uint32_t _pad1[28];
98
99 _REG_(TRNG_RNG_DEBUG_EN_INPUT_OFFSET) // TRNG_RNG_DEBUG_EN_INPUT
100 // Enable the RNG debug mode
101 // 0x00000001 [0] RNG_DEBUG_EN (0) * 1 - debug mode is enabled
102 io_rw_32 rng_debug_en_input;
103
104 _REG_(TRNG_TRNG_BUSY_OFFSET) // TRNG_TRNG_BUSY
105 // RNG Busy indication
106 // 0x00000001 [0] TRNG_BUSY (0) Reflects rng_busy status
107 io_ro_32 trng_busy;
108
109 _REG_(TRNG_RST_BITS_COUNTER_OFFSET) // TRNG_RST_BITS_COUNTER
110 // Reset the counter of collected bits in the RNG
111 // 0x00000001 [0] RST_BITS_COUNTER (0) Writing any value to this address will reset the bits...
112 io_rw_32 rst_bits_counter;
113
114 _REG_(TRNG_RNG_VERSION_OFFSET) // TRNG_RNG_VERSION
115 // Displays the version settings of the TRNG
116 // 0x00000080 [7] RNG_USE_5_SBOXES (0) * 1 - 5 SBOX AES
117 // 0x00000040 [6] RESEEDING_EXISTS (0) * 1 - Exists
118 // 0x00000020 [5] KAT_EXISTS (0) * 1 - Exists
119 // 0x00000010 [4] PRNG_EXISTS (0) * 1 - Exists
120 // 0x00000008 [3] TRNG_TESTS_BYPASS_EN (0) * 1 - Exists
121 // 0x00000004 [2] AUTOCORR_EXISTS (0) * 1 - Exists
122 // 0x00000002 [1] CRNGT_EXISTS (0) * 1 - Exists
123 // 0x00000001 [0] EHR_WIDTH_192 (0) * 1 - 192-bit EHR
124 io_ro_32 rng_version;
125
126 uint32_t _pad2[7];
127
128 // (Description copied from array index 0 register TRNG_RNG_BIST_CNTR_0 applies similarly to other array indexes)
129 _REG_(TRNG_RNG_BIST_CNTR_0_OFFSET) // TRNG_RNG_BIST_CNTR_0
130 // Collected BIST results
131 // 0x003fffff [21:0] ROSC_CNTR_VAL (0x000000) Reflects the results of RNG BIST counter
132 io_ro_32 rng_bist_cntr[3];
133} trng_hw_t;
134
135#define trng_hw ((trng_hw_t *)(TRNG_BASE + TRNG_RNG_IMR_OFFSET))
136static_assert(sizeof (trng_hw_t) == 0x00ec, "");
137
138// provided as these older constants are used by the RP2350 bootrom, but there are now no "special" reserved bits
139// this maintains the pre-existing property that TRNG_FOO_RESERVED_BITS ^ TRNG_FOO_BITS = actual valid TRNG_FOO bits
140#define TRNG_TRNG_DEBUG_CONTROL_RESERVED_BITS 0
141#define TRNG_RND_SOURCE_ENABLE_RESERVED_BITS 0
142#define TRNG_RNG_ICR_RESERVED_BITS 0
143
144#endif // _HARDWARE_STRUCTS_TRNG_H
Definition trng.h:26