Browse Source
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
9 changed files with 108 additions and 9 deletions
@ -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. |
@ -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); |
@ -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 |
Loading…
Reference in new issue