Browse Source

drivers: entropy: Initial support for trng driver of RA8

Initial commit for entropy support on RA8
- drivers: entropy: implementation for TRNG driver of RA8x1
- dts: arm: add device node for trng of RA8x1
- boards: arm: enable support zephyr_entropy for ek_ra8m1 and
update board documentation

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Signed-off-by: Duy Phuong Hoang. Nguyen <duy.nguyen.xa@renesas.com>
pull/77433/head
Duy Phuong Hoang. Nguyen 1 year ago committed by Anas Nashif
parent
commit
b9f31c0e40
  1. 2
      boards/renesas/ek_ra8m1/doc/index.rst
  2. 5
      boards/renesas/ek_ra8m1/ek_ra8m1.dts
  3. 19
      drivers/entropy/CMakeLists.txt
  4. 1
      drivers/entropy/Kconfig
  5. 13
      drivers/entropy/Kconfig.renesas_ra
  6. 49
      drivers/entropy/entropy_renesas_ra.c
  7. 4
      dts/arm/renesas/ra/ra8/ra8x1.dtsi
  8. 8
      dts/bindings/rng/renesas,ra-rsip-e51a-trng.yaml
  9. 16
      modules/Kconfig.renesas_fsp

2
boards/renesas/ek_ra8m1/doc/index.rst

@ -100,6 +100,8 @@ The below features are currently supported on Zephyr OS for EK-RA8M1 board: @@ -100,6 +100,8 @@ The below features are currently supported on Zephyr OS for EK-RA8M1 board:
+-----------+------------+----------------------+
| I2C | on-chip | i2c |
+-----------+------------+----------------------+
| ENTROPY | on-chip | entropy |
+-----------+------------+----------------------+
Other hardware features are currently not supported by the port.

5
boards/renesas/ek_ra8m1/ek_ra8m1.dts

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
zephyr,flash = &flash0;
zephyr,console = &uart9;
zephyr,shell-uart = &uart9;
zephyr,entropy = &trng;
};
leds {
@ -158,3 +159,7 @@ mikrobus_serial: &uart3 {}; @@ -158,3 +159,7 @@ mikrobus_serial: &uart3 {};
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
&trng {
status = "okay";
};

19
drivers/entropy/CMakeLists.txt

@ -25,14 +25,15 @@ if(CONFIG_FAKE_ENTROPY_NATIVE_POSIX) @@ -25,14 +25,15 @@ if(CONFIG_FAKE_ENTROPY_NATIVE_POSIX)
endif()
endif()
zephyr_library_sources_ifdef(CONFIG_USERSPACE entropy_handlers.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_RV32M1_TRNG entropy_rv32m1_trng.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_GECKO_TRNG entropy_gecko_trng.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_NEORV32_TRNG entropy_neorv32_trng.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_BT_HCI entropy_bt_hci.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_GECKO_SE entropy_gecko_se.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_PSA_CRYPTO_RNG entropy_psa_crypto.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_NPCX_DRBG entropy_npcx_drbg.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_MAX32_TRNG entropy_max32.c)
zephyr_library_sources_ifdef(CONFIG_USERSPACE entropy_handlers.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_RV32M1_TRNG entropy_rv32m1_trng.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_GECKO_TRNG entropy_gecko_trng.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_NEORV32_TRNG entropy_neorv32_trng.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_BT_HCI entropy_bt_hci.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_GECKO_SE entropy_gecko_se.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_PSA_CRYPTO_RNG entropy_psa_crypto.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_NPCX_DRBG entropy_npcx_drbg.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_MAX32_TRNG entropy_max32.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_RENESAS_RA_RSIP_E51A_TRNG entropy_renesas_ra.c)
zephyr_library_link_libraries_ifdef(CONFIG_BUILD_WITH_TFM tfm_api)

1
drivers/entropy/Kconfig

@ -37,6 +37,7 @@ source "drivers/entropy/Kconfig.bt_hci" @@ -37,6 +37,7 @@ source "drivers/entropy/Kconfig.bt_hci"
source "drivers/entropy/Kconfig.psa_crypto"
source "drivers/entropy/Kconfig.npcx"
source "drivers/entropy/Kconfig.max32"
source "drivers/entropy/Kconfig.renesas_ra"
config ENTROPY_HAS_DRIVER
bool

13
drivers/entropy/Kconfig.renesas_ra

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
# Copyright (c) 2024 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0
# Renesas RA entropy generator driver configuration
config ENTROPY_RENESAS_RA_RSIP_E51A_TRNG
bool "Renesas RA RSIP-E51A TRNG driver"
default y
depends on DT_HAS_RENESAS_RA_RSIP_E51A_TRNG_ENABLED
select ENTROPY_HAS_DRIVER
select USE_RA_FSP_SCE
help
This option enables the Renesas RA RSIP-E51A RNG.

49
drivers/entropy/entropy_renesas_ra.c

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 Renesas Electronics Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT renesas_ra_rsip_e51a_trng
#include <soc.h>
#include <zephyr/drivers/entropy.h>
#include "hw_sce_trng_private.h"
#include "hw_sce_private.h"
static int entropy_ra_rsip_trng_get_entropy(const struct device *dev, uint8_t *buf, uint16_t len)
{
ARG_UNUSED(dev);
if (buf == NULL) {
return -EINVAL;
}
while (len > 0) {
uint32_t n[4];
const uint32_t to_copy = MIN(sizeof(n), len);
if (FSP_SUCCESS != HW_SCE_RNG_Read(n)) {
return -ENODATA;
}
memcpy(buf, n, to_copy);
buf += to_copy;
len -= to_copy;
}
return 0;
}
static const struct entropy_driver_api entropy_ra_rsip_trng_api = {
.get_entropy = entropy_ra_rsip_trng_get_entropy,
};
static int entropy_ra_rsip_trng_init(const struct device *dev)
{
HW_SCE_McuSpecificInit();
return 0;
}
DEVICE_DT_INST_DEFINE(0, entropy_ra_rsip_trng_init, NULL, NULL, NULL, PRE_KERNEL_1,
CONFIG_ENTROPY_INIT_PRIORITY, &entropy_ra_rsip_trng_api);

4
dts/arm/renesas/ra/ra8/ra8x1.dtsi

@ -299,6 +299,10 @@ @@ -299,6 +299,10 @@
status = "disabled";
};
trng: trng {
compatible = "renesas,ra-rsip-e51a-trng";
};
option_setting_ofs: option_setting_ofs@300a100 {
compatible = "zephyr,memory-region";
reg = <0x0300a100 0x18>;

8
dts/bindings/rng/renesas,ra-rsip-e51a-trng.yaml

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
# Copyright (c) 2024 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0
description: Renesas RA RSIP-E51A TRNG
compatible: "renesas,ra-rsip-e51a-trng"
include: base.yaml

16
modules/Kconfig.renesas_fsp

@ -32,3 +32,19 @@ config USE_RA_FSP_ADC @@ -32,3 +32,19 @@ config USE_RA_FSP_ADC
bool
help
Enable RA FSP ADC driver
config USE_RA_FSP_SCE
bool
help
Enable RA FSP SCE driver
if USE_RA_FSP_SCE
config HAS_RENESAS_RA_RSIP_E51A
bool
default y
depends on ENTROPY_RENESAS_RA_RSIP_E51A_TRNG
help
Includes RSIP-E51A implementation for SCE driver
endif

Loading…
Cancel
Save