Skip to content

Commit 7a32fed

Browse files
sanezekAlan C. Assis
authored andcommitted
arch/arm/stm32h7: support for /dev/random device
Enabling support for random device on stm32h7 arch. Driver copy pasted from arch/arm/stm32. Signed-off-by: sanezek <[email protected]>
1 parent 0c1f9d4 commit 7a32fed

File tree

4 files changed

+397
-0
lines changed

4 files changed

+397
-0
lines changed

arch/arm/src/stm32h7/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ config STM32H7_STM32H7X3XX
401401
select STM32H7_HAVE_SPI4
402402
select STM32H7_HAVE_SPI5 if !STM32H7_IO_CONFIG_V
403403
select STM32H7_HAVE_SPI6
404+
select STM32H7_HAVE_RNG
404405

405406
config STM32H7_STM32H7B3XX
406407
bool
@@ -414,6 +415,7 @@ config STM32H7_STM32H7B3XX
414415
select STM32H7_HAVE_SPI4
415416
select STM32H7_HAVE_SPI5 if !STM32H7_IO_CONFIG_V
416417
select STM32H7_HAVE_SPI6
418+
select STM32H7_HAVE_RNG
417419

418420
config STM32H7_STM32H7X5XX
419421
bool
@@ -430,6 +432,7 @@ config STM32H7_STM32H7X5XX
430432
select STM32H7_HAVE_SPI5 if !STM32H7_IO_CONFIG_V
431433
select STM32H7_HAVE_SPI6
432434
select STM32H7_HAVE_SMPS
435+
select STM32H7_HAVE_RNG
433436

434437
config STM32H7_STM32H7X7XX
435438
bool
@@ -445,6 +448,7 @@ config STM32H7_STM32H7X7XX
445448
select STM32H7_HAVE_SPI4
446449
select STM32H7_HAVE_SPI5
447450
select STM32H7_HAVE_SPI6
451+
select STM32H7_HAVE_RNG
448452

449453
config STM32H7_FLASH_CONFIG_B
450454
bool
@@ -655,6 +659,10 @@ config STM32H7_HAVE_FDCAN2
655659
bool
656660
default n
657661

662+
config STM32H7_HAVE_RNG
663+
bool
664+
default n
665+
658666
# These "hidden" settings are the OR of individual peripheral selections
659667
# indicating that the general capability is required.
660668

@@ -752,6 +760,12 @@ config STM32H7_ADC3
752760
default n
753761
select STM32H7_ADC
754762

763+
config STM32H7_RNG
764+
bool "RNG"
765+
default n
766+
depends on STM32H7_HAVE_RNG
767+
select ARCH_HAVE_RNG
768+
755769
config STM32H7_CRC
756770
bool "CRC"
757771
default n

arch/arm/src/stm32h7/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ ifeq ($(CONFIG_STM32H7_FDCAN),y)
7979
CHIP_CSRCS += stm32_fdcan_sock.c
8080
endif
8181

82+
ifeq ($(CONFIG_STM32H7_RNG),y)
83+
CHIP_CSRCS += stm32_rng.c
84+
endif
85+
8286
ifeq ($(CONFIG_STM32H7_BBSRAM),y)
8387
CHIP_CSRCS += stm32_bbsram.c
8488
endif
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/****************************************************************************
2+
* arch/arm/src/stm32h7/hardware/stm32_rng.h
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
#ifndef __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_RNG_H
24+
#define __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_RNG_H
25+
26+
/****************************************************************************
27+
* Included Files
28+
****************************************************************************/
29+
30+
#include <nuttx/config.h>
31+
#include "chip.h"
32+
33+
/****************************************************************************
34+
* Pre-processor Definitions
35+
****************************************************************************/
36+
37+
/* Register Offsets *********************************************************/
38+
39+
#define STM32_RNG_CR_OFFSET 0x0000 /* RNG Control Register */
40+
#define STM32_RNG_SR_OFFSET 0x0004 /* RNG Status Register */
41+
#define STM32_RNG_DR_OFFSET 0x0008 /* RNG Data Register */
42+
43+
/* Register Addresses *******************************************************/
44+
45+
#define STM32_RNG_CR (STM32_RNG_BASE+STM32_RNG_CR_OFFSET)
46+
#define STM32_RNG_SR (STM32_RNG_BASE+STM32_RNG_SR_OFFSET)
47+
#define STM32_RNG_DR (STM32_RNG_BASE+STM32_RNG_DR_OFFSET)
48+
49+
/* Register Bitfield Definitions ********************************************/
50+
51+
/* RNG Control Register */
52+
53+
#define RNG_CR_RNGEN (1 << 2) /* Bit 2: RNG enable */
54+
#define RNG_CR_IE (1 << 3) /* Bit 3: Interrupt enable */
55+
#define RNG_CR_CE (1 << 5) /* Bit 5: Clock error detection */
56+
57+
/* RNG Status Register */
58+
59+
#define RNG_SR_DRDY (1 << 0) /* Bit 0: Data ready */
60+
#define RNG_SR_CECS (1 << 1) /* Bit 1: Clock error current status */
61+
#define RNG_SR_SECS (1 << 2) /* Bit 2: Seed error current status */
62+
#define RNG_SR_CEIS (1 << 5) /* Bit 5: Clock error interrupt status */
63+
#define RNG_SR_SEIS (1 << 6) /* Bit 6: Seed error interrupt status */
64+
65+
#endif /* __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_RNG_H */

0 commit comments

Comments
 (0)