Skip to contentSkip to conversation

crypto: hisilicon/trng - add support for HiSTB TRNG

PATCH Superseded David Yang 2 participants 4 messages Mar 31, 2023 – Apr 3, 2023

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

David Yang

author
#0 lore raw

PATCH v4 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

 drivers/crypto/hisilicon/Kconfig         |   7 +
 drivers/crypto/hisilicon/Makefile        |   2 +-
 drivers/crypto/hisilicon/trng/Makefile   |   3 +
 drivers/crypto/hisilicon/trng/trng-stb.c | 186 +++++++++++++++++++++++
 4 files changed, 197 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 +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer
#1 lore raw

Review

Quoted 2 lines · David Yang
(quoted diff) +1 -0
+	struct histb_trng_priv *priv = (struct histb_trng_priv *) rng->priv;

Plesae don't use rng->priv at all. We're trying to phase it out because it encourages horrible casting like this.

Please follow the model used in the meson driver.

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 8 lines · Herbert Xu <[email protected]> 于2023年4月1日周六 16:07写道:
Quoted 2 lines · David Yang

+ struct histb_trng_priv *priv = (struct histb_trng_priv *) rng->priv;

Plesae don't use rng->priv at all. We're trying to phase it out because it encourages horrible casting like this.

Quoted 7 lines

Please follow the model used in the meson driver.

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

Which meson driver? I didn't find any rng module under amlogic/ dir.

maintainer
#3 lore raw
Quoted 2 lines · Yangfl

Which meson driver? I didn't find any rng module under amlogic/ dir.

drivers/char/hw_random/meson-rng.c

Cheers,

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