drivers: entropy: Port the LL rand driver to entropy

The rand driver present in the BLE Link Layer is able to provide
entropy for both threads and ISRs, and so it is more suited to be used
as a generic nRF5x entropy driver instead of the current one. This will
allow applications and the Link Layer to use the same driver without
duplicating it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Carles Cufi 2018-02-20 21:24:07 +01:00 committed by Carles Cufí
commit 813b41beec
3 changed files with 290 additions and 62 deletions

View file

@ -1,21 +1,21 @@
# Kconfig.nrf5 - nRF5 entropy generator driver configuration
#
# Copyright (c) 2017 Nordic Semiconductor ASA
# Copyright (c) 2018 Nordic Semiconductor ASA
# Copyright (c) 2017 Exati Tecnologia Ltda.
#
# SPDX-License-Identifier: Apache-2.0
menuconfig ENTROPY_NRF5_RNG
bool "nRF5 RNG driver"
# FIXME: nRF5 RNG driver can't co-exist with Bluetooth's HAL
# implementation yet
depends on ENTROPY_GENERATOR && !BT
depends on ENTROPY_GENERATOR
select ENTROPY_HAS_DRIVER
help
This option enables the RNG peripheral, which is a random number
generator, based on internal thermal noise, that provides a
random 8-bit value to the host when read.
if ENTROPY_NRF5_RNG
config ENTROPY_NRF5_BIAS_CORRECTION
bool "Enable bias correction (uniform distribution)"
depends on ENTROPY_NRF5_RNG
@ -23,3 +23,43 @@ config ENTROPY_NRF5_BIAS_CORRECTION
This option enables the RNG bias correction, which guarantees a
uniform distribution of 0 and 1. When this option is enabled, the time
to generate a byte cannot be guaranteed.
config ENTROPY_NRF5_THR_THRESHOLD
int "Thread-mode low-water threshold"
range 4 255
help
Low-water threshold in bytes to trigger entropy generation for
thread mode consumers.
config ENTROPY_NRF5_ISR_THRESHOLD
int "ISR low-water threshold"
range 12 255
help
Low-water threshold in bytes to trigger entropy generation for
ISR consumers.
config ENTROPY_NRF5_THR_BUF_LEN
int "Thread-mode buffer length"
range ENTROPY_NRF5_THR_THRESHOLD 255
help
Buffer length in bytes to pre-store entropy generation for
thread mode consumers.
config ENTROPY_NRF5_ISR_BUF_LEN
int "ISR buffer length"
range ENTROPY_NRF5_ISR_THRESHOLD 255
help
Buffer length in bytes to pre-store entropy generation for
ISR consumers.
config ENTROPY_NRF5_PRI
int "RNG interrupt priority"
depends on ENTROPY_NRF5_RNG
range 0 2 if SOC_SERIES_NRF51X
range 0 5 if SOC_SERIES_NRF52X
default 2 if SOC_SERIES_NRF51X
default 5 if SOC_SERIES_NRF52X
help
nRF5X RNG IRQ priority.
endif #ENTROPY_NRF5_RNG