1 // SPDX-License-Identifier: GPL-2.0
3 * drivers/char/hw_random/ixp4xx-rng.c
5 * RNG driver for Intel IXP4xx family of NPUs
7 * Author: Deepak Saxena <dsaxena@plexity.net>
9 * Copyright 2005 (c) MontaVista Software, Inc.
11 * Fixes by Michael Buesch
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/module.h>
17 #include <linux/moduleparam.h>
18 #include <linux/platform_device.h>
19 #include <linux/init.h>
20 #include <linux/bitops.h>
21 #include <linux/hw_random.h>
23 #include <linux/soc/ixp4xx/cpu.h>
27 static int ixp4xx_rng_data_read(struct hwrng
*rng
, u32
*buffer
)
29 void __iomem
* rng_base
= (void __iomem
*)rng
->priv
;
31 *buffer
= __raw_readl(rng_base
);
36 static struct hwrng ixp4xx_rng_ops
= {
38 .data_read
= ixp4xx_rng_data_read
,
41 static int ixp4xx_rng_probe(struct platform_device
*pdev
)
43 void __iomem
* rng_base
;
44 struct device
*dev
= &pdev
->dev
;
46 if (!cpu_is_ixp46x()) /* includes IXP455 */
49 rng_base
= devm_platform_ioremap_resource(pdev
, 0);
51 return PTR_ERR(rng_base
);
53 ixp4xx_rng_ops
.priv
= (unsigned long)rng_base
;
54 return devm_hwrng_register(dev
, &ixp4xx_rng_ops
);
57 static const struct of_device_id ixp4xx_rng_of_match
[] = {
59 .compatible
= "intel,ixp46x-rng",
63 MODULE_DEVICE_TABLE(of
, ixp4xx_rng_of_match
);
65 static struct platform_driver ixp4xx_rng_driver
= {
67 .name
= "ixp4xx-hwrandom",
68 .of_match_table
= ixp4xx_rng_of_match
,
70 .probe
= ixp4xx_rng_probe
,
72 module_platform_driver(ixp4xx_rng_driver
);
74 MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
75 MODULE_DESCRIPTION("H/W Pseudo-Random Number Generator (RNG) driver for IXP45x/46x");
76 MODULE_LICENSE("GPL");