aboutsummaryrefslogtreecommitdiff
path: root/drivers/rng
diff options
context:
space:
mode:
authorSughosh Ganu <sughosh.ganu@linaro.org>2019-12-28 23:58:27 +0530
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2020-01-07 18:08:21 +0100
commita2487684003b0bc380955e1a38cdd71da3ca4366 (patch)
tree16f94d87badaeae9d2cd6cb5c9bb4050ba9a82af /drivers/rng
parent8391f955494efc0dbe136e1557e9606bbf55d046 (diff)
downloadu-boot-a2487684003b0bc380955e1a38cdd71da3ca4366.zip
u-boot-a2487684003b0bc380955e1a38cdd71da3ca4366.tar.gz
u-boot-a2487684003b0bc380955e1a38cdd71da3ca4366.tar.bz2
dm: rng: Add random number generator(rng) uclass
Add a uclass for reading a random number seed from a random number generator device. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/rng')
-rw-r--r--drivers/rng/Kconfig7
-rw-r--r--drivers/rng/Makefile6
-rw-r--r--drivers/rng/rng-uclass.c23
3 files changed, 36 insertions, 0 deletions
diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig
new file mode 100644
index 0000000..dd44cc0
--- /dev/null
+++ b/drivers/rng/Kconfig
@@ -0,0 +1,7 @@
+config DM_RNG
+ bool "Driver support for Random Number Generator devices"
+ depends on DM
+ help
+ Enable driver model for random number generator(rng) devices.
+ This interface is used to initialise the rng device and to
+ read the random seed from the device.
diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile
new file mode 100644
index 0000000..311705b
--- /dev/null
+++ b/drivers/rng/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2019, Linaro Limited
+#
+
+obj-$(CONFIG_DM_RNG) += rng-uclass.o
diff --git a/drivers/rng/rng-uclass.c b/drivers/rng/rng-uclass.c
new file mode 100644
index 0000000..b6af3b8
--- /dev/null
+++ b/drivers/rng/rng-uclass.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2019, Linaro Limited
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <rng.h>
+
+int dm_rng_read(struct udevice *dev, void *buffer, size_t size)
+{
+ const struct dm_rng_ops *ops = device_get_ops(dev);
+
+ if (!ops->read)
+ return -ENOSYS;
+
+ return ops->read(dev, buffer, size);
+}
+
+UCLASS_DRIVER(rng) = {
+ .name = "rng",
+ .id = UCLASS_RNG,
+};