drivers: entropy: Add DTS support to native-posix fake entropy driver

Add a YAML and DTS node for fake entropy driver.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-04-01 10:31:43 -05:00 committed by Kumar Gala
commit 7879b67796
5 changed files with 24 additions and 1 deletions

View file

@ -6,3 +6,4 @@
#define DT_FLASH_DEV_NAME DT_LABEL(DT_INST(0, zephyr_sim_flash)) #define DT_FLASH_DEV_NAME DT_LABEL(DT_INST(0, zephyr_sim_flash))
#define DT_UART_0_DEV_NAME DT_ZEPHYR_NATIVE_POSIX_UART_UART_LABEL #define DT_UART_0_DEV_NAME DT_ZEPHYR_NATIVE_POSIX_UART_UART_LABEL
#define CONFIG_ENTROPY_NAME DT_LABEL(DT_INST(0, zephyr_native_posix_rng))

View file

@ -84,4 +84,11 @@
*/ */
current-speed = <0>; current-speed = <0>;
}; };
rng {
status = "okay";
compatible = "zephyr,native-posix-rng";
label = "ENTROPY_0";
};
}; };

View file

@ -4,6 +4,7 @@ config FAKE_ENTROPY_NATIVE_POSIX
bool "Native posix entropy driver" bool "Native posix entropy driver"
depends on ARCH_POSIX depends on ARCH_POSIX
select ENTROPY_HAS_DRIVER select ENTROPY_HAS_DRIVER
select HAS_DTS_ENTROPY
help help
This option enables the test random number generator for the This option enables the test random number generator for the
native_posix board (ARCH_POSIX). This is based on the host random() API. native_posix board (ARCH_POSIX). This is based on the host random() API.

View file

@ -11,6 +11,8 @@
* This entropy source should only be used for testing. * This entropy source should only be used for testing.
*/ */
#define DT_DRV_COMPAT zephyr_native_posix_rng
#include "device.h" #include "device.h"
#include <drivers/entropy.h> #include <drivers/entropy.h>
#include "init.h" #include "init.h"
@ -71,7 +73,7 @@ static const struct entropy_driver_api entropy_native_posix_api_funcs = {
.get_entropy_isr = entropy_native_posix_get_entropy_isr .get_entropy_isr = entropy_native_posix_get_entropy_isr
}; };
DEVICE_AND_API_INIT(entropy_native_posix, CONFIG_ENTROPY_NAME, DEVICE_AND_API_INIT(entropy_native_posix, DT_INST_LABEL(0),
entropy_native_posix_init, NULL, NULL, entropy_native_posix_init, NULL, NULL,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&entropy_native_posix_api_funcs); &entropy_native_posix_api_funcs);

View file

@ -0,0 +1,12 @@
# Copyright (c) 2020, Linaro Limited
# SPDX-License-Identifier: Apache-2.0
description: Native POSIX RNG/Entropy
compatible: "zephyr,native-posix-rng"
include: base.yaml
properties:
label:
required: true