All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Morgan <macroalpha82@gmail.com>
To: u-boot@lists.denx.de
Cc: andre.przywara@arm.com, kever.yang@rock-chips.com,
	philipp.tomsich@vrull.eu, sjg@chromium.org, jagan@edgeble.ai,
	jonas@kwiboo.se, Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH V4 5/7] rockchip: board: Add board_rng_seed() for all Rockchip devices
Date: Tue,  2 Jan 2024 09:46:52 -0600	[thread overview]
Message-ID: <20240102154654.191055-6-macroalpha82@gmail.com> (raw)
In-Reply-To: <20240102154654.191055-1-macroalpha82@gmail.com>

From: Chris Morgan <macromorgan@hotmail.com>

Allow all rockchip devices to use the hardware RNG to seed Linux
RNG.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
 arch/arm/mach-rockchip/board.c             | 32 ++++++++++++++++++++++
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 29 --------------------
 2 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index 57f08e0be0..77145524ea 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -348,3 +348,35 @@ __weak int misc_init_r(void)
 	return ret;
 }
 #endif
+
+#if IS_ENABLED(CONFIG_BOARD_RNG_SEED) && IS_ENABLED(CONFIG_RNG_ROCKCHIP)
+#include <rng.h>
+
+/* Use hardware rng to seed Linux random. */
+__weak int board_rng_seed(struct abuf *buf)
+{
+	struct udevice *dev;
+	size_t len = 0x8;
+	u64 *data;
+
+	data = malloc(len);
+	if (!data) {
+		printf("Out of memory\n");
+		return -ENOMEM;
+	}
+
+	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
+		printf("No RNG device\n");
+		return -ENODEV;
+	}
+
+	if (dm_rng_read(dev, data, len)) {
+		printf("Reading RNG failed\n");
+		return -EIO;
+	}
+
+	abuf_init_set(buf, data, len);
+
+	return 0;
+}
+#endif
diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
index 45854709f5..7bef5a53f0 100644
--- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
@@ -17,7 +17,6 @@
 #include <mmc.h>
 #include <panel.h>
 #include <pwm.h>
-#include <rng.h>
 #include <stdlib.h>
 #include <video_bridge.h>
 
@@ -137,34 +136,6 @@ void spl_board_init(void)
 	       (GPIO0_BASE + GPIO_SWPORT_DR_H));
 }
 
-/* Use hardware rng to seed Linux random. */
-int board_rng_seed(struct abuf *buf)
-{
-	struct udevice *dev;
-	size_t len = 0x8;
-	u64 *data;
-
-	data = malloc(len);
-	if (!data) {
-		printf("Out of memory\n");
-		return -ENOMEM;
-	}
-
-	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-		printf("No RNG device\n");
-		return -ENODEV;
-	}
-
-	if (dm_rng_read(dev, data, len)) {
-		printf("Reading RNG failed\n");
-		return -EIO;
-	}
-
-	abuf_init_set(buf, data, len);
-
-	return 0;
-}
-
 /*
  * Buzz the buzzer so the user knows something is going on. Make it
  * optional in case PWM is disabled.
-- 
2.34.1


  parent reply	other threads:[~2024-01-02 15:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 15:46 [PATCH V4 0/7] Add Additional Boards and Features to RGxx3 Chris Morgan
2024-01-02 15:46 ` [PATCH V4 1/7] board: rockchip: Refactor panel auto-detect code Chris Morgan
2024-01-18  7:10   ` Kever Yang
2024-01-02 15:46 ` [PATCH V4 2/7] spl: Add Kconfig options for ADC Chris Morgan
2024-01-02 15:46 ` [PATCH V4 3/7] rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL Chris Morgan
2024-01-18  7:20   ` Kever Yang
2024-01-18 15:06     ` Chris Morgan
2024-01-19  9:01       ` Kever Yang
2024-01-24 22:55         ` Chris Morgan
     [not found]         ` <20240125065543.BA9B5440469@smtp.qiye.163.com>
2024-02-06  2:59           ` Kever Yang
2024-01-02 15:46 ` [PATCH V4 4/7] board: rockchip: Add Recovery Button for Anbernic RGxx3 Chris Morgan
2024-01-02 15:46 ` Chris Morgan [this message]
2024-01-18  7:21   ` [PATCH V4 5/7] rockchip: board: Add board_rng_seed() for all Rockchip devices Kever Yang
2024-01-02 15:46 ` [PATCH V4 6/7] board: rockchip: Add support for new boards to RGxx3 Chris Morgan
2024-01-18  7:21   ` Kever Yang
2024-01-02 15:46 ` [PATCH V4 7/7] doc: board: anbernic: Update rgxx3 to add new boards Chris Morgan
2024-01-18  7:30   ` Kever Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240102154654.191055-6-macroalpha82@gmail.com \
    --to=macroalpha82@gmail.com \
    --cc=andre.przywara@arm.com \
    --cc=jagan@edgeble.ai \
    --cc=jonas@kwiboo.se \
    --cc=kever.yang@rock-chips.com \
    --cc=macromorgan@hotmail.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.