diff options
author | Etienne Carriere <etienne.carriere@st.com> | 2019-02-13 15:44:37 +0100 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2019-04-04 16:25:13 +0700 |
commit | f3c22059dfd02af1dceb7dd2db4a070a9641c502 (patch) | |
tree | f1ffc3b7302ba4b39209bcc3ed49b0df31b3bb34 /core/include | |
parent | 9f6d9163836374936970b939e18f1069c34a0f66 (diff) |
stm32_rng: driver for STM32 RNG
Drivers is embedded upon CFG_STM32_RNG=y.
The driver main API functions are:
- stm32_rng_read() to get a buffer of random bytes,
- stm32_rng_read_raw() to get a buffer of random bytes assuming the
RNG hardware is ready, i.e clock enabled.
The device driver is initialized from DT resource when a secure DTB,
currently the embedded DTB, is found.
STM32 RNG driver assumes the platform supports at most RNG instance
in the secure world.
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com>
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/include')
-rw-r--r-- | core/include/drivers/stm32_rng.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/include/drivers/stm32_rng.h b/core/include/drivers/stm32_rng.h new file mode 100644 index 00000000..f2be3cf7 --- /dev/null +++ b/core/include/drivers/stm32_rng.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright (c) 2018-2019, STMicroelectronics + */ + +#ifndef __STM32_RNG_H__ +#define __STM32_RNG_H__ + +#include <stdint.h> +#include <stddef.h> +#include <tee_api_types.h> +#include <types_ext.h> + +/* + * Fill buffer with bytes from the STM32_RNG + * @out: Output buffer + * @size: Byte size of the output buffer + * Return a TEE_Result compliant sttus + */ +TEE_Result stm32_rng_read(uint8_t *out, size_t size); + +/* + * As stm32_rng_read() but excluding clocks/reset dependencies. + * + * @rng_base: Caller provides the RNG interface base address + * @out: Output buffer + * @size: Pointer to input/output byte size of the output buffer + * Return a TEE_Result compliant sttus + * + * When successfully returning, @size stores the number of bytes + * effectively generated in the output buffer @out. The input value + * of @size gives the size available in buffer @out. + */ +TEE_Result stm32_rng_read_raw(vaddr_t rng_base, uint8_t *out, size_t *size); + +#endif /*__STM32_RNG_H__*/ |