Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu: "API: - Allow DRBG testing through user-space af_alg - Add tcrypt speed testing support for keyed hashes - Add type-safe init/exit hooks for ahash Algorithms: - Mark arc4 as obsolete and pending for future removal - Mark anubis, khazad, sead and tea as obsolete - Improve boot-time xor benchmark - Add OSCCA SM2 asymmetric cipher algorithm and use it for integrity Drivers: - Fixes and enhancement for XTS in caam - Add support for XIP8001B hwrng in xiphera-trng - Add RNG and hash support in sun8i-ce/sun8i-ss - Allow imx-rngc to be used by kernel entropy pool - Use crypto engine in omap-sham - Add support for Ingenic X1830 with ingenic" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (205 commits) X.509: Fix modular build of public_key_sm2 crypto: xor - Remove unused variable count in do_xor_speed X.509: fix error return value on the failed path crypto: bcm - Verify GCM/CCM key length in setkey crypto: qat - drop input parameter from adf_enable_aer() crypto: qat - fix function parameters descriptions crypto: atmel-tdes - use semicolons rather than commas to separate statements crypto: drivers - use semicolons rather than commas to separate statements hwrng: mxc-rnga - use semicolons rather than commas to separate statements hwrng: iproc-rng200 - use semicolons rather than commas to separate statements hwrng: stm32 - use semicolons rather than commas to separate statements crypto: xor - use ktime for template benchmarking crypto: xor - defer load time benchmark to a later time crypto: hisilicon/zip - fix the uninitalized 'curr_qm_qp_num' crypto: hisilicon/zip - fix the return value when device is busy crypto: hisilicon/zip - fix zero length input in GZIP decompress crypto: hisilicon/zip - fix the uncleared debug registers lib/mpi: Fix unused variable warnings crypto: x86/poly1305 - Remove assignments with no effect hwrng: npcm - modify readl to readb ...
This commit is contained in:
@@ -282,6 +282,20 @@ config HW_RANDOM_INGENIC_RNG
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
config HW_RANDOM_INGENIC_TRNG
|
||||
tristate "Ingenic True Random Number Generator support"
|
||||
depends on HW_RANDOM
|
||||
depends on MACH_X1830
|
||||
default HW_RANDOM
|
||||
help
|
||||
This driver provides kernel-side support for the True Random Number Generator
|
||||
hardware found in ingenic X1830 SoC. YSH & ATIL CU1830-Neo uses X1830 SoC.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called ingenic-trng.
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
config HW_RANDOM_NOMADIK
|
||||
tristate "ST-Ericsson Nomadik Random Number Generator support"
|
||||
depends on ARCH_NOMADIK
|
||||
@@ -512,6 +526,16 @@ config HW_RANDOM_CCTRNG
|
||||
will be called cctrng.
|
||||
If unsure, say 'N'.
|
||||
|
||||
config HW_RANDOM_XIPHERA
|
||||
tristate "Xiphera FPGA based True Random Number Generator support"
|
||||
depends on HAS_IOMEM
|
||||
help
|
||||
This driver provides kernel-side support for Xiphera True Random
|
||||
Number Generator Intellectual Property Core.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called xiphera-trng.
|
||||
|
||||
endif # HW_RANDOM
|
||||
|
||||
config UML_RANDOM
|
||||
|
||||
@@ -24,6 +24,7 @@ obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o
|
||||
obj-$(CONFIG_HW_RANDOM_IMX_RNGC) += imx-rngc.o
|
||||
obj-$(CONFIG_HW_RANDOM_INGENIC_RNG) += ingenic-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_INGENIC_TRNG) += ingenic-trng.o
|
||||
obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o
|
||||
@@ -44,3 +45,4 @@ obj-$(CONFIG_HW_RANDOM_KEYSTONE) += ks-sa-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_OPTEE) += optee-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_NPCM) += npcm-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_CCTRNG) += cctrng.o
|
||||
obj-$(CONFIG_HW_RANDOM_XIPHERA) += xiphera-trng.o
|
||||
|
||||
@@ -463,11 +463,10 @@ static int cc_trng_clk_init(struct cctrng_drvdata *drvdata)
|
||||
int rc = 0;
|
||||
|
||||
clk = devm_clk_get_optional(dev, NULL);
|
||||
if (IS_ERR(clk)) {
|
||||
if (PTR_ERR(clk) != -EPROBE_DEFER)
|
||||
dev_err(dev, "Error getting clock: %pe\n", clk);
|
||||
return PTR_ERR(clk);
|
||||
}
|
||||
if (IS_ERR(clk))
|
||||
return dev_err_probe(dev, PTR_ERR(clk),
|
||||
"Error getting clock\n");
|
||||
|
||||
drvdata->clk = clk;
|
||||
|
||||
rc = clk_prepare_enable(drvdata->clk);
|
||||
|
||||
@@ -285,6 +285,7 @@ static int imx_rngc_probe(struct platform_device *pdev)
|
||||
rngc->rng.init = imx_rngc_init;
|
||||
rngc->rng.read = imx_rngc_read;
|
||||
rngc->rng.cleanup = imx_rngc_cleanup;
|
||||
rngc->rng.quality = 19;
|
||||
|
||||
rngc->dev = &pdev->dev;
|
||||
platform_set_drvdata(pdev, rngc);
|
||||
|
||||
161
drivers/char/hw_random/ingenic-trng.c
Normal file
161
drivers/char/hw_random/ingenic-trng.c
Normal file
@@ -0,0 +1,161 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Ingenic True Random Number Generator driver
|
||||
* Copyright (c) 2019 漆鹏振 (Qi Pengzhen) <aric.pzqi@ingenic.com>
|
||||
* Copyright (c) 2020 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
|
||||
*/
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/hw_random.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
/* DTRNG register offsets */
|
||||
#define TRNG_REG_CFG_OFFSET 0x00
|
||||
#define TRNG_REG_RANDOMNUM_OFFSET 0x04
|
||||
#define TRNG_REG_STATUS_OFFSET 0x08
|
||||
|
||||
/* bits within the CFG register */
|
||||
#define CFG_RDY_CLR BIT(12)
|
||||
#define CFG_INT_MASK BIT(11)
|
||||
#define CFG_GEN_EN BIT(0)
|
||||
|
||||
/* bits within the STATUS register */
|
||||
#define STATUS_RANDOM_RDY BIT(0)
|
||||
|
||||
struct ingenic_trng {
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
struct hwrng rng;
|
||||
};
|
||||
|
||||
static int ingenic_trng_init(struct hwrng *rng)
|
||||
{
|
||||
struct ingenic_trng *trng = container_of(rng, struct ingenic_trng, rng);
|
||||
unsigned int ctrl;
|
||||
|
||||
ctrl = readl(trng->base + TRNG_REG_CFG_OFFSET);
|
||||
ctrl |= CFG_GEN_EN;
|
||||
writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ingenic_trng_cleanup(struct hwrng *rng)
|
||||
{
|
||||
struct ingenic_trng *trng = container_of(rng, struct ingenic_trng, rng);
|
||||
unsigned int ctrl;
|
||||
|
||||
ctrl = readl(trng->base + TRNG_REG_CFG_OFFSET);
|
||||
ctrl &= ~CFG_GEN_EN;
|
||||
writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET);
|
||||
}
|
||||
|
||||
static int ingenic_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
|
||||
{
|
||||
struct ingenic_trng *trng = container_of(rng, struct ingenic_trng, rng);
|
||||
u32 *data = buf;
|
||||
u32 status;
|
||||
int ret;
|
||||
|
||||
ret = readl_poll_timeout(trng->base + TRNG_REG_STATUS_OFFSET, status,
|
||||
status & STATUS_RANDOM_RDY, 10, 1000);
|
||||
if (ret == -ETIMEDOUT) {
|
||||
pr_err("%s: Wait for DTRNG data ready timeout\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*data = readl(trng->base + TRNG_REG_RANDOMNUM_OFFSET);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
static int ingenic_trng_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct ingenic_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)) {
|
||||
pr_err("%s: Failed to map DTRNG registers\n", __func__);
|
||||
ret = PTR_ERR(trng->base);
|
||||
return PTR_ERR(trng->base);
|
||||
}
|
||||
|
||||
trng->clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(trng->clk)) {
|
||||
ret = PTR_ERR(trng->clk);
|
||||
pr_crit("%s: Cannot get DTRNG clock\n", __func__);
|
||||
return PTR_ERR(trng->clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(trng->clk);
|
||||
if (ret) {
|
||||
pr_crit("%s: Unable to enable DTRNG clock\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
trng->rng.name = pdev->name;
|
||||
trng->rng.init = ingenic_trng_init;
|
||||
trng->rng.cleanup = ingenic_trng_cleanup;
|
||||
trng->rng.read = ingenic_trng_read;
|
||||
|
||||
ret = hwrng_register(&trng->rng);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Failed to register hwrng\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, trng);
|
||||
|
||||
dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ingenic_trng_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct ingenic_trng *trng = platform_get_drvdata(pdev);
|
||||
unsigned int ctrl;
|
||||
|
||||
hwrng_unregister(&trng->rng);
|
||||
|
||||
ctrl = readl(trng->base + TRNG_REG_CFG_OFFSET);
|
||||
ctrl &= ~CFG_GEN_EN;
|
||||
writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET);
|
||||
|
||||
clk_disable_unprepare(trng->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id ingenic_trng_of_match[] = {
|
||||
{ .compatible = "ingenic,x1830-dtrng" },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ingenic_trng_of_match);
|
||||
|
||||
static struct platform_driver ingenic_trng_driver = {
|
||||
.probe = ingenic_trng_probe,
|
||||
.remove = ingenic_trng_remove,
|
||||
.driver = {
|
||||
.name = "ingenic-trng",
|
||||
.of_match_table = ingenic_trng_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(ingenic_trng_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("漆鹏振 (Qi Pengzhen) <aric.pzqi@ingenic.com>");
|
||||
MODULE_AUTHOR("周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>");
|
||||
MODULE_DESCRIPTION("Ingenic True Random Number Generator driver");
|
||||
@@ -330,7 +330,7 @@ static int __init mod_init(void)
|
||||
int err = -ENODEV;
|
||||
int i;
|
||||
struct pci_dev *dev = NULL;
|
||||
void __iomem *mem = mem;
|
||||
void __iomem *mem;
|
||||
u8 hw_status;
|
||||
struct intel_rng_hw *intel_rng_hw;
|
||||
|
||||
|
||||
@@ -195,10 +195,10 @@ static int iproc_rng200_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(priv->base);
|
||||
}
|
||||
|
||||
priv->rng.name = "iproc-rng200",
|
||||
priv->rng.read = iproc_rng200_read,
|
||||
priv->rng.init = iproc_rng200_init,
|
||||
priv->rng.cleanup = iproc_rng200_cleanup,
|
||||
priv->rng.name = "iproc-rng200";
|
||||
priv->rng.read = iproc_rng200_read;
|
||||
priv->rng.init = iproc_rng200_init;
|
||||
priv->rng.cleanup = iproc_rng200_cleanup;
|
||||
|
||||
/* Register driver */
|
||||
ret = devm_hwrng_register(dev, &priv->rng);
|
||||
|
||||
@@ -143,9 +143,9 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
|
||||
mxc_rng->dev = &pdev->dev;
|
||||
mxc_rng->rng.name = "mxc-rnga";
|
||||
mxc_rng->rng.init = mxc_rnga_init;
|
||||
mxc_rng->rng.cleanup = mxc_rnga_cleanup,
|
||||
mxc_rng->rng.data_present = mxc_rnga_data_present,
|
||||
mxc_rng->rng.data_read = mxc_rnga_data_read,
|
||||
mxc_rng->rng.cleanup = mxc_rnga_cleanup;
|
||||
mxc_rng->rng.data_present = mxc_rnga_data_present;
|
||||
mxc_rng->rng.data_read = mxc_rnga_data_read;
|
||||
|
||||
mxc_rng->clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(mxc_rng->clk)) {
|
||||
|
||||
@@ -58,24 +58,24 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
|
||||
|
||||
pm_runtime_get_sync((struct device *)priv->rng.priv);
|
||||
|
||||
while (max >= sizeof(u32)) {
|
||||
while (max) {
|
||||
if (wait) {
|
||||
if (readl_poll_timeout(priv->base + NPCM_RNGCS_REG,
|
||||
if (readb_poll_timeout(priv->base + NPCM_RNGCS_REG,
|
||||
ready,
|
||||
ready & NPCM_RNG_DATA_VALID,
|
||||
NPCM_RNG_POLL_USEC,
|
||||
NPCM_RNG_TIMEOUT_USEC))
|
||||
break;
|
||||
} else {
|
||||
if ((readl(priv->base + NPCM_RNGCS_REG) &
|
||||
if ((readb(priv->base + NPCM_RNGCS_REG) &
|
||||
NPCM_RNG_DATA_VALID) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
*(u32 *)buf = readl(priv->base + NPCM_RNGD_REG);
|
||||
retval += sizeof(u32);
|
||||
buf += sizeof(u32);
|
||||
max -= sizeof(u32);
|
||||
*(u8 *)buf = readb(priv->base + NPCM_RNGD_REG);
|
||||
retval++;
|
||||
buf++;
|
||||
max--;
|
||||
}
|
||||
|
||||
pm_runtime_mark_last_busy((struct device *)priv->rng.priv);
|
||||
|
||||
@@ -122,14 +122,14 @@ static int optee_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
|
||||
if (max > MAX_ENTROPY_REQ_SZ)
|
||||
max = MAX_ENTROPY_REQ_SZ;
|
||||
|
||||
while (read == 0) {
|
||||
while (read < max) {
|
||||
rng_size = get_optee_rng_data(pvt_data, data, (max - read));
|
||||
|
||||
data += rng_size;
|
||||
read += rng_size;
|
||||
|
||||
if (wait) {
|
||||
if (timeout-- == 0)
|
||||
if (wait && pvt_data->data_rate) {
|
||||
if ((timeout-- == 0) || (read == max))
|
||||
return read;
|
||||
msleep((1000 * (max - read)) / pvt_data->data_rate);
|
||||
} else {
|
||||
|
||||
@@ -145,12 +145,12 @@ static int stm32_rng_probe(struct platform_device *ofdev)
|
||||
|
||||
dev_set_drvdata(dev, priv);
|
||||
|
||||
priv->rng.name = dev_driver_string(dev),
|
||||
priv->rng.name = dev_driver_string(dev);
|
||||
#ifndef CONFIG_PM
|
||||
priv->rng.init = stm32_rng_init,
|
||||
priv->rng.cleanup = stm32_rng_cleanup,
|
||||
priv->rng.init = stm32_rng_init;
|
||||
priv->rng.cleanup = stm32_rng_cleanup;
|
||||
#endif
|
||||
priv->rng.read = stm32_rng_read,
|
||||
priv->rng.read = stm32_rng_read;
|
||||
priv->rng.priv = (unsigned long) dev;
|
||||
priv->rng.quality = 900;
|
||||
|
||||
|
||||
150
drivers/char/hw_random/xiphera-trng.c
Normal file
150
drivers/char/hw_random/xiphera-trng.c
Normal file
@@ -0,0 +1,150 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (C) 2020 Xiphera Ltd. */
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/hw_random.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define CONTROL_REG 0x00000000
|
||||
#define STATUS_REG 0x00000004
|
||||
#define RAND_REG 0x00000000
|
||||
|
||||
#define HOST_TO_TRNG_RESET 0x00000001
|
||||
#define HOST_TO_TRNG_RELEASE_RESET 0x00000002
|
||||
#define HOST_TO_TRNG_ENABLE 0x80000000
|
||||
#define HOST_TO_TRNG_ZEROIZE 0x80000004
|
||||
#define HOST_TO_TRNG_ACK_ZEROIZE 0x80000008
|
||||
#define HOST_TO_TRNG_READ 0x8000000F
|
||||
|
||||
/* trng statuses */
|
||||
#define TRNG_ACK_RESET 0x000000AC
|
||||
#define TRNG_SUCCESSFUL_STARTUP 0x00000057
|
||||
#define TRNG_FAILED_STARTUP 0x000000FA
|
||||
#define TRNG_NEW_RAND_AVAILABLE 0x000000ED
|
||||
|
||||
struct xiphera_trng {
|
||||
void __iomem *mem;
|
||||
struct hwrng rng;
|
||||
};
|
||||
|
||||
static int xiphera_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
|
||||
{
|
||||
struct xiphera_trng *trng = container_of(rng, struct xiphera_trng, rng);
|
||||
int ret = 0;
|
||||
|
||||
while (max >= sizeof(u32)) {
|
||||
/* check for data */
|
||||
if (readl(trng->mem + STATUS_REG) == TRNG_NEW_RAND_AVAILABLE) {
|
||||
*(u32 *)buf = readl(trng->mem + RAND_REG);
|
||||
/*
|
||||
* Inform the trng of the read
|
||||
* and re-enable it to produce a new random number
|
||||
*/
|
||||
writel(HOST_TO_TRNG_READ, trng->mem + CONTROL_REG);
|
||||
writel(HOST_TO_TRNG_ENABLE, trng->mem + CONTROL_REG);
|
||||
ret += sizeof(u32);
|
||||
buf += sizeof(u32);
|
||||
max -= sizeof(u32);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int xiphera_trng_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
struct xiphera_trng *trng;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct resource *res;
|
||||
|
||||
trng = devm_kzalloc(dev, sizeof(*trng), GFP_KERNEL);
|
||||
if (!trng)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
trng->mem = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(trng->mem))
|
||||
return PTR_ERR(trng->mem);
|
||||
|
||||
/*
|
||||
* the trng needs to be reset first which might not happen in time,
|
||||
* hence we incorporate a small delay to ensure proper behaviour
|
||||
*/
|
||||
writel(HOST_TO_TRNG_RESET, trng->mem + CONTROL_REG);
|
||||
usleep_range(100, 200);
|
||||
|
||||
if (readl(trng->mem + STATUS_REG) != TRNG_ACK_RESET) {
|
||||
/*
|
||||
* there is a small chance the trng is just not ready yet,
|
||||
* so we try one more time. If the second time fails, we give up
|
||||
*/
|
||||
usleep_range(100, 200);
|
||||
if (readl(trng->mem + STATUS_REG) != TRNG_ACK_RESET) {
|
||||
dev_err(dev, "failed to reset the trng ip\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* once again, to ensure proper behaviour we sleep
|
||||
* for a while after zeroizing the trng
|
||||
*/
|
||||
writel(HOST_TO_TRNG_RELEASE_RESET, trng->mem + CONTROL_REG);
|
||||
writel(HOST_TO_TRNG_ENABLE, trng->mem + CONTROL_REG);
|
||||
writel(HOST_TO_TRNG_ZEROIZE, trng->mem + CONTROL_REG);
|
||||
msleep(20);
|
||||
|
||||
if (readl(trng->mem + STATUS_REG) != TRNG_SUCCESSFUL_STARTUP) {
|
||||
/* diagnose the reason for the failure */
|
||||
if (readl(trng->mem + STATUS_REG) == TRNG_FAILED_STARTUP) {
|
||||
dev_err(dev, "trng ip startup-tests failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
dev_err(dev, "startup-tests yielded no response\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
writel(HOST_TO_TRNG_ACK_ZEROIZE, trng->mem + CONTROL_REG);
|
||||
|
||||
trng->rng.name = pdev->name;
|
||||
trng->rng.read = xiphera_trng_read;
|
||||
trng->rng.quality = 900;
|
||||
|
||||
ret = devm_hwrng_register(dev, &trng->rng);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to register rng device: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, trng);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id xiphera_trng_of_match[] = {
|
||||
{ .compatible = "xiphera,xip8001b-trng", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, xiphera_trng_of_match);
|
||||
|
||||
static struct platform_driver xiphera_trng_driver = {
|
||||
.driver = {
|
||||
.name = "xiphera-trng",
|
||||
.of_match_table = xiphera_trng_of_match,
|
||||
},
|
||||
.probe = xiphera_trng_probe,
|
||||
};
|
||||
|
||||
module_platform_driver(xiphera_trng_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Atte Tommiska");
|
||||
MODULE_DESCRIPTION("Xiphera FPGA-based true random number generator driver");
|
||||
Reference in New Issue
Block a user