Commit | Line | Data |
---|---|---|
d7174bcb | 1 | /* |
f30c2269 | 2 | * drivers/char/hw_random/ixp4xx-rng.c |
d7174bcb MB |
3 | * |
4 | * RNG driver for Intel IXP4xx family of NPUs | |
5 | * | |
6 | * Author: Deepak Saxena <dsaxena@plexity.net> | |
7 | * | |
8 | * Copyright 2005 (c) MontaVista Software, Inc. | |
9 | * | |
10 | * Fixes by Michael Buesch | |
11 | * | |
12 | * This file is licensed under the terms of the GNU General Public | |
13 | * License version 2. This program is licensed "as is" without any | |
14 | * warranty of any kind, whether express or implied. | |
15 | */ | |
16 | ||
17 | #include <linux/kernel.h> | |
18 | #include <linux/config.h> | |
19 | #include <linux/types.h> | |
20 | #include <linux/module.h> | |
21 | #include <linux/moduleparam.h> | |
22 | #include <linux/init.h> | |
23 | #include <linux/bitops.h> | |
24 | #include <linux/hw_random.h> | |
25 | ||
26 | #include <asm/io.h> | |
27 | #include <asm/hardware.h> | |
28 | ||
29 | ||
30 | static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer) | |
31 | { | |
32 | void __iomem * rng_base = (void __iomem *)rng->priv; | |
33 | ||
34 | *buffer = __raw_readl(rng_base); | |
35 | ||
36 | return 4; | |
37 | } | |
38 | ||
39 | static struct hwrng ixp4xx_rng_ops = { | |
40 | .name = "ixp4xx", | |
41 | .data_read = ixp4xx_rng_data_read, | |
42 | }; | |
43 | ||
44 | static int __init ixp4xx_rng_init(void) | |
45 | { | |
46 | void __iomem * rng_base; | |
47 | int err; | |
48 | ||
49 | rng_base = ioremap(0x70002100, 4); | |
50 | if (!rng_base) | |
51 | return -ENOMEM; | |
52 | ixp4xx_rng_ops.priv = (unsigned long)rng_base; | |
53 | err = hwrng_register(&ixp4xx_rng_ops); | |
54 | if (err) | |
55 | iounmap(rng_base); | |
56 | ||
57 | return err; | |
58 | } | |
59 | ||
60 | static void __exit ixp4xx_rng_exit(void) | |
61 | { | |
62 | void __iomem * rng_base = (void __iomem *)ixp4xx_rng_ops.priv; | |
63 | ||
64 | hwrng_unregister(&ixp4xx_rng_ops); | |
65 | iounmap(rng_base); | |
66 | } | |
67 | ||
68 | subsys_initcall(ixp4xx_rng_init); | |
69 | module_exit(ixp4xx_rng_exit); | |
70 | ||
71 | MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>"); | |
72 | MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx"); | |
73 | MODULE_LICENSE("GPL"); |