Skip to contentSkip to conversation

crypto: hisilicon/trng - add support for HiSTB TRNG

PATCH In review David Yang 3 participants 5 messages Apr 1, 2023 – Apr 20, 2023

Subsystems (2)
lore
Share & tools
lore

David Yang

author
#0 lore raw

PATCH v5 1/1 crypto: hisilicon/trng - add support for HiSTB TRNG

HiSTB TRNG are found on some HiSilicon STB SoCs.

---
v2: fix typo
v3: add option for post process depth, adjust timeout
v4: do not case to __iomem, as requested
v5: do not use rng->priv at all

 drivers/crypto/hisilicon/Kconfig         |   7 +
 drivers/crypto/hisilicon/Makefile        |   2 +-
 drivers/crypto/hisilicon/trng/Makefile   |   3 +
 drivers/crypto/hisilicon/trng/trng-stb.c | 176 +++++++++++++++++++++++
 4 files changed, 187 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/hisilicon/trng/trng-stb.c
drivers/crypto/hisilicon/Kconfig +7 -0
index 4137a8bf131f..e8690c223584 100644
@@ -82,3 +82,10 @@ config CRYPTO_DEV_HISI_TRNG
 	select CRYPTO_RNG
 	help
 	  Support for HiSilicon TRNG Driver.
+
+config CRYPTO_DEV_HISTB_TRNG
+	tristate "Support for HiSTB TRNG Driver"
+	depends on ARCH_HISI || COMPILE_TEST
+	select HW_RANDOM
+	help
+	  Support for HiSTB TRNG Driver.
drivers/crypto/hisilicon/Makefile +1 -1
index 8595a5a5d228..fc51e0edec69 100644
@@ -5,4 +5,4 @@ obj-$(CONFIG_CRYPTO_DEV_HISI_SEC2) += sec2/
 obj-$(CONFIG_CRYPTO_DEV_HISI_QM) += hisi_qm.o
 hisi_qm-objs = qm.o sgl.o debugfs.o
 obj-$(CONFIG_CRYPTO_DEV_HISI_ZIP) += zip/
-obj-$(CONFIG_CRYPTO_DEV_HISI_TRNG) += trng/
+obj-y += trng/
drivers/crypto/hisilicon/trng/Makefile +3 -0
index d909079f351c..cf20b057c66b 100644
@@ -1,2 +1,5 @@
 obj-$(CONFIG_CRYPTO_DEV_HISI_TRNG) += hisi-trng-v2.o
 hisi-trng-v2-objs = trng.o
+
+obj-$(CONFIG_CRYPTO_DEV_HISTB_TRNG) += histb-trng.o
+histb-trng-objs += trng-stb.o
drivers/crypto/hisilicon/trng/trng-stb.c new file +176 -0

176 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 8 lines · David Yang

HiSTB TRNG are found on some HiSilicon STB SoCs.

---
v2: fix typo
v3: add option for post process depth, adjust timeout
v4: do not case to __iomem, as requested
v5: do not use rng->priv at all

Quoted 6 lines
 drivers/crypto/hisilicon/Kconfig         |   7 +
 drivers/crypto/hisilicon/Makefile        |   2 +-
 drivers/crypto/hisilicon/trng/Makefile   |   3 +
 drivers/crypto/hisilicon/trng/trng-stb.c | 176 +++++++++++++++++++++++
 4 files changed, 187 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/hisilicon/trng/trng-stb.c

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author
#2 lore raw
Quoted 17 lines · Herbert Xu <[email protected]> 于2023年4月6日周四 16:53写道:
Quoted 8 lines · David Yang

HiSTB TRNG are found on some HiSilicon STB SoCs.

---
v2: fix typo
v3: add option for post process depth, adjust timeout
v4: do not case to __iomem, as requested
v5: do not use rng->priv at all

Quoted 6 lines
 drivers/crypto/hisilicon/Kconfig         |   7 +
 drivers/crypto/hisilicon/Makefile        |   2 +-
 drivers/crypto/hisilicon/trng/Makefile   |   3 +
 drivers/crypto/hisilicon/trng/trng-stb.c | 176 +++++++++++++++++++++++
 4 files changed, 187 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/hisilicon/trng/trng-stb.c
Quoted 5 lines

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Thanks for merging this patch. But after considering your former reply about drivers/char/hw_random , I'm thinking if that is a better place for this driver. If that is the case I'd like to post a new version of patch.

Sorry for late reply.

maintainer
#3 lore raw
Quoted 7 lines · Yangfl

Thanks for merging this patch. But after considering your former reply about drivers/char/hw_random , I'm thinking if that is a better place for this driver. If that is the case I'd like to post a new version of patch.

Sorry for late reply.

If you need to move it please send an incremental patch.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#4 lore raw
In reply to David Yang
Quoted 63 lines · David Yang

HiSTB TRNG are found on some HiSilicon STB SoCs.

---
v2: fix typo
v3: add option for post process depth, adjust timeout
v4: do not case to __iomem, as requested
v5: do not use rng->priv at all

 drivers/crypto/hisilicon/Kconfig         |   7 +
 drivers/crypto/hisilicon/Makefile        |   2 +-
 drivers/crypto/hisilicon/trng/Makefile   |   3 +
 drivers/crypto/hisilicon/trng/trng-stb.c | 176 +++++++++++++++++++++++
 4 files changed, 187 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/hisilicon/trng/trng-stb.c
drivers/crypto/hisilicon/Kconfig +7 -0
index 4137a8bf131f..e8690c223584 100644
@@ -82,3 +82,10 @@ config CRYPTO_DEV_HISI_TRNG
 	select CRYPTO_RNG
 	help
 	  Support for HiSilicon TRNG Driver.
+
+config CRYPTO_DEV_HISTB_TRNG
+	tristate "Support for HiSTB TRNG Driver"
+	depends on ARCH_HISI || COMPILE_TEST
+	select HW_RANDOM
+	help
+	  Support for HiSTB TRNG Driver.
drivers/crypto/hisilicon/Makefile +1 -1
index 8595a5a5d228..fc51e0edec69 100644
@@ -5,4 +5,4 @@ obj-$(CONFIG_CRYPTO_DEV_HISI_SEC2) += sec2/
 obj-$(CONFIG_CRYPTO_DEV_HISI_QM) += hisi_qm.o
 hisi_qm-objs = qm.o sgl.o debugfs.o
 obj-$(CONFIG_CRYPTO_DEV_HISI_ZIP) += zip/
-obj-$(CONFIG_CRYPTO_DEV_HISI_TRNG) += trng/
+obj-y += trng/
drivers/crypto/hisilicon/trng/Makefile +3 -0
index d909079f351c..cf20b057c66b 100644
@@ -1,2 +1,5 @@
 obj-$(CONFIG_CRYPTO_DEV_HISI_TRNG) += hisi-trng-v2.o
 hisi-trng-v2-objs = trng.o
+
+obj-$(CONFIG_CRYPTO_DEV_HISTB_TRNG) += histb-trng.o
+histb-trng-objs += trng-stb.o
drivers/crypto/hisilicon/trng/trng-stb.c new file +7 -0
new file mode 100644
index 000000000000..29200a7d3d81
@@ -0,0 +1,176 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/*
+ * Device driver for True RNG in HiSTB SoCs
+ *
+ * Copyright (c) 2023 David Yang
+ */
+

drivers/crypto/hisilicon/trng/trng-stb.c line 17

Quoted 10 lines
drivers/crypto/hisilicon/trng/trng-stb.c new file +10 -0
+#include <crypto/internal/rng.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/hw_random.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of_device.h>

You don't need anything from this header...

You need platform_device.h and mod_devicetable.h

[...]

drivers/crypto/hisilicon/trng/trng-stb.c line 159

Quoted 2 lines
drivers/crypto/hisilicon/trng/trng-stb.c new file +2 -0
+static const struct of_device_id histb_trng_of_match[] = {
+	{ .compatible = "hisilicon,histb-trng", },

This binding isn't documented. Please submit a schema.

Rob