summaryrefslogtreecommitdiffstats
path: root/drivers
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
parent8391f955494efc0dbe136e1557e9606bbf55d046 (diff)
downloadu-boot-a2487684003b0bc380955e1a38cdd71da3ca4366.tar.gz
u-boot-a2487684003b0bc380955e1a38cdd71da3ca4366.tar.xz
u-boot-a2487684003b0bc380955e1a38cdd71da3ca4366.zip
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')
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/rng/Kconfig7
-rw-r--r--drivers/rng/Makefile6
-rw-r--r--drivers/rng/rng-uclass.c23
5 files changed, 39 insertions, 0 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 9d99ce0226..e34a22708c 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -90,6 +90,8 @@ source "drivers/remoteproc/Kconfig"
source "drivers/reset/Kconfig"
+source "drivers/rng/Kconfig"
+
source "drivers/rtc/Kconfig"
source "drivers/scsi/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index cb8c215e76..8eec4e8176 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -116,4 +116,5 @@ obj-$(CONFIG_W1_EEPROM) += w1-eeprom/
obj-$(CONFIG_MACH_PIC32) += ddr/microchip/
obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock/
+obj-$(CONFIG_DM_RNG) += rng/
endif
diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig
new file mode 100644
index 0000000000..dd44cc0242
--- /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 0000000000..311705b6e6
--- /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 0000000000..b6af3b8606
--- /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,
+};