From 229ec063537c85a2d095ddcf345cb7af52fccf57 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 2 Jul 2025 09:44:08 +0200 Subject: arm64: zynqmp: Enable rng-seed generation SOM has TPM with RNG in it that's why enable rng-seed generation. Acked-by: Ilias Apalodimas Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/0e55eb3eade94e9cd0ffe04da0618aa6b1589f01.1751442246.git.michal.simek@amd.com --- board/xilinx/common/board.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'board/xilinx/common/board.c') diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 8ffe7429901..ceb58da6d3c 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2014 - 2022, Xilinx, Inc. - * (C) Copyright 2022 - 2023, Advanced Micro Devices, Inc. + * (C) Copyright 2022 - 2025, Advanced Micro Devices, Inc. * * Michal Simek */ @@ -712,3 +712,34 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) } #endif + +#if IS_ENABLED(CONFIG_BOARD_RNG_SEED) +/* Use hardware rng to seed Linux random. */ +__weak int board_rng_seed(struct abuf *buf) +{ + struct udevice *dev; + ulong len = 64; + u64 *data; + + if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) { + printf("No RNG device\n"); + return -ENODEV; + } + + data = malloc(len); + if (!data) { + printf("Out of memory\n"); + return -ENOMEM; + } + + if (dm_rng_read(dev, data, len)) { + printf("Reading RNG failed\n"); + free(data); + return -EIO; + } + + abuf_init_set(buf, data, len); + + return 0; +} +#endif -- cgit v1.2.3