Hi, On Fr, 2024-06-21 at 02:25 +0100, Daniel Golle wrote: > From: Aurelien Jarno <aurelien@xxxxxxxxxxx> > > Rockchip SoCs used to have a random number generator as part of their > crypto device, and support for it has to be added to the corresponding > driver. However newer Rockchip SoCs like the RK356x have an independent > True Random Number Generator device. This patch adds a driver for it, > greatly inspired from the downstream driver. > > The TRNG device does not seem to have a signal conditionner and the FIPS > 140-2 test returns a lot of failures. They can be reduced by increasing > RK_RNG_SAMPLE_CNT, in a tradeoff between quality and speed. This value > has been adjusted to get ~90% of successes and the quality value has > been set accordingly. > > Signed-off-by: Aurelien Jarno <aurelien@xxxxxxxxxxx> > [daniel@xxxxxxxxxxxxx: code style fixes] > Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx> > --- > MAINTAINERS | 1 + > drivers/char/hw_random/Kconfig | 14 ++ > drivers/char/hw_random/Makefile | 1 + > drivers/char/hw_random/rockchip-rng.c | 229 ++++++++++++++++++++++++++ > 4 files changed, 245 insertions(+) > create mode 100644 drivers/char/hw_random/rockchip-rng.c > [...] > diff --git a/drivers/char/hw_random/rockchip-rng.c b/drivers/char/hw_random/rockchip-rng.c > new file mode 100644 > index 000000000000..6070abb73847 > --- /dev/null > +++ b/drivers/char/hw_random/rockchip-rng.c > @@ -0,0 +1,229 @@ [...] > > +static int rk_rng_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct rk_rng *rk_rng; > + int ret; > + > + rk_rng = devm_kzalloc(dev, sizeof(*rk_rng), GFP_KERNEL); > + if (!rk_rng) > + return -ENOMEM; > + > + rk_rng->base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(rk_rng->base)) > + return PTR_ERR(rk_rng->base); > + > + rk_rng->clk_num = devm_clk_bulk_get_all(dev, &rk_rng->clk_bulks); > + if (rk_rng->clk_num < 0) > + return dev_err_probe(dev, rk_rng->clk_num, > + "Failed to get clks property\n"); > + > + rk_rng->rst = devm_reset_control_array_get(&pdev->dev, false, false); Please use devm_reset_control_array_get_exclusive() instead. regards Philipp