summaryrefslogtreecommitdiff
path: root/drivers/crypto
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@kernel.org>2026-05-30 13:26:24 -0700
committerHerbert Xu <herbert@gondor.apana.org.au>2026-06-11 14:02:58 +0800
commitffbb2ebd0c3a7ead6c9128bbbb62fc6d851779bb (patch)
treef9f7efdc1d7aa6f6129f631dec34a85fd97ce1f1 /drivers/crypto
parent216a7795ec210bdabd5dad42323eee70bbfc8d90 (diff)
hwrng: hisi-trng - Move hisi-trng into drivers/char/hw_random/
Since this file just implements a hwrng driver, move it into drivers/char/hw_random/. Rename the kconfig option accordingly as well. Note that this moves the file back to its original location. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/hisilicon/Kconfig7
-rw-r--r--drivers/crypto/hisilicon/Makefile1
-rw-r--r--drivers/crypto/hisilicon/trng/Makefile2
-rw-r--r--drivers/crypto/hisilicon/trng/trng.c98
4 files changed, 0 insertions, 108 deletions
diff --git a/drivers/crypto/hisilicon/Kconfig b/drivers/crypto/hisilicon/Kconfig
index 8aa23c939775..aeff08ccbadd 100644
--- a/drivers/crypto/hisilicon/Kconfig
+++ b/drivers/crypto/hisilicon/Kconfig
@@ -75,10 +75,3 @@ config CRYPTO_DEV_HISI_HPRE
help
Support for HiSilicon HPRE(High Performance RSA Engine)
accelerator, which can accelerate RSA and DH algorithms.
-
-config CRYPTO_DEV_HISI_TRNG
- tristate "Support for HISI TRNG Driver"
- depends on ARM64 && ACPI
- select HW_RANDOM
- help
- Support for HiSilicon TRNG Driver.
diff --git a/drivers/crypto/hisilicon/Makefile b/drivers/crypto/hisilicon/Makefile
index 8595a5a5d228..e1068ee9f973 100644
--- a/drivers/crypto/hisilicon/Makefile
+++ b/drivers/crypto/hisilicon/Makefile
@@ -5,4 +5,3 @@ 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/
diff --git a/drivers/crypto/hisilicon/trng/Makefile b/drivers/crypto/hisilicon/trng/Makefile
deleted file mode 100644
index d909079f351c..000000000000
--- a/drivers/crypto/hisilicon/trng/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-$(CONFIG_CRYPTO_DEV_HISI_TRNG) += hisi-trng-v2.o
-hisi-trng-v2-objs = trng.o
diff --git a/drivers/crypto/hisilicon/trng/trng.c b/drivers/crypto/hisilicon/trng/trng.c
deleted file mode 100644
index 6584ed051e09..000000000000
--- a/drivers/crypto/hisilicon/trng/trng.c
+++ /dev/null
@@ -1,98 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (c) 2019 HiSilicon Limited. */
-
-#include <linux/acpi.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/platform_device.h>
-#include <linux/random.h>
-
-#define HISI_TRNG_REG 0x00F0
-#define HISI_TRNG_BYTES 4
-#define HISI_TRNG_QUALITY 512
-#define SLEEP_US 10
-#define TIMEOUT_US 10000
-
-struct hisi_trng {
- void __iomem *base;
- struct hwrng rng;
-};
-
-static int hisi_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
-{
- struct hisi_trng *trng;
- int currsize = 0;
- u32 val = 0;
- int ret;
-
- trng = container_of(rng, struct hisi_trng, rng);
-
- do {
- ret = readl_poll_timeout(trng->base + HISI_TRNG_REG, val,
- val, SLEEP_US, TIMEOUT_US);
- if (ret)
- return currsize;
-
- if (max - currsize >= HISI_TRNG_BYTES) {
- memcpy(buf + currsize, &val, HISI_TRNG_BYTES);
- currsize += HISI_TRNG_BYTES;
- if (currsize == max)
- return currsize;
- continue;
- }
-
- /* copy remaining bytes */
- memcpy(buf + currsize, &val, max - currsize);
- currsize = max;
- } while (currsize < max);
-
- return currsize;
-}
-
-static int hisi_trng_probe(struct platform_device *pdev)
-{
- struct hisi_trng *trng;
- int ret;
-
- trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
- if (!trng)
- return -ENOMEM;
-
- trng->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(trng->base))
- return PTR_ERR(trng->base);
-
- trng->rng.name = pdev->name;
- trng->rng.read = hisi_trng_read;
- trng->rng.quality = HISI_TRNG_QUALITY;
-
- ret = devm_hwrng_register(&pdev->dev, &trng->rng);
- if (ret)
- dev_err(&pdev->dev, "failed to register hwrng: %d!\n", ret);
- return ret;
-}
-
-static const struct acpi_device_id hisi_trng_acpi_match[] = {
- { "HISI02B3", 0 },
- { }
-};
-MODULE_DEVICE_TABLE(acpi, hisi_trng_acpi_match);
-
-static struct platform_driver hisi_trng_driver = {
- .probe = hisi_trng_probe,
- .driver = {
- .name = "hisi-trng-v2",
- .acpi_match_table = ACPI_PTR(hisi_trng_acpi_match),
- },
-};
-
-module_platform_driver(hisi_trng_driver);
-
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Weili Qian <qianweili@huawei.com>");
-MODULE_AUTHOR("Zaibo Xu <xuzaibo@huawei.com>");
-MODULE_DESCRIPTION("HiSilicon true random number generator V2 driver");