This source file includes following definitions.
- ixp4xx_rng_data_read
- ixp4xx_rng_init
- ixp4xx_rng_exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <linux/kernel.h>
18 #include <linux/types.h>
19 #include <linux/module.h>
20 #include <linux/moduleparam.h>
21 #include <linux/init.h>
22 #include <linux/bitops.h>
23 #include <linux/hw_random.h>
24
25 #include <asm/io.h>
26 #include <mach/hardware.h>
27
28
29 static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer)
30 {
31 void __iomem * rng_base = (void __iomem *)rng->priv;
32
33 *buffer = __raw_readl(rng_base);
34
35 return 4;
36 }
37
38 static struct hwrng ixp4xx_rng_ops = {
39 .name = "ixp4xx",
40 .data_read = ixp4xx_rng_data_read,
41 };
42
43 static int __init ixp4xx_rng_init(void)
44 {
45 void __iomem * rng_base;
46 int err;
47
48 if (!cpu_is_ixp46x())
49 return -ENOSYS;
50
51 rng_base = ioremap(0x70002100, 4);
52 if (!rng_base)
53 return -ENOMEM;
54 ixp4xx_rng_ops.priv = (unsigned long)rng_base;
55 err = hwrng_register(&ixp4xx_rng_ops);
56 if (err)
57 iounmap(rng_base);
58
59 return err;
60 }
61
62 static void __exit ixp4xx_rng_exit(void)
63 {
64 void __iomem * rng_base = (void __iomem *)ixp4xx_rng_ops.priv;
65
66 hwrng_unregister(&ixp4xx_rng_ops);
67 iounmap(rng_base);
68 }
69
70 module_init(ixp4xx_rng_init);
71 module_exit(ixp4xx_rng_exit);
72
73 MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
74 MODULE_DESCRIPTION("H/W Pseudo-Random Number Generator (RNG) driver for IXP45x/46x");
75 MODULE_LICENSE("GPL");