blob: beec1627db3c1b147fb4be577c61697ef2e1005f [file] [log] [blame]
Michael Bueschd7174bc2006-06-26 00:25:02 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * drivers/char/hw_random/ixp4xx-rng.c
Michael Bueschd7174bc2006-06-26 00:25:02 -07003 *
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>
Michael Bueschd7174bc2006-06-26 00:25:02 -070018#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>
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/hardware.h>
Michael Bueschd7174bc2006-06-26 00:25:02 -070027
28
29static 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
38static struct hwrng ixp4xx_rng_ops = {
39 .name = "ixp4xx",
40 .data_read = ixp4xx_rng_data_read,
41};
42
43static int __init ixp4xx_rng_init(void)
44{
45 void __iomem * rng_base;
46 int err;
47
Krzysztof Hałasa553da852010-03-23 20:22:13 +010048 if (!cpu_is_ixp46x()) /* includes IXP455 */
49 return -ENOSYS;
50
Michael Bueschd7174bc2006-06-26 00:25:02 -070051 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
62static 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
Michael Buesch56fb5fe2007-01-10 23:15:43 -080070module_init(ixp4xx_rng_init);
Michael Bueschd7174bc2006-06-26 00:25:02 -070071module_exit(ixp4xx_rng_exit);
72
73MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
Krzysztof Hałasa553da852010-03-23 20:22:13 +010074MODULE_DESCRIPTION("H/W Pseudo-Random Number Generator (RNG) driver for IXP45x/46x");
Michael Bueschd7174bc2006-06-26 00:25:02 -070075MODULE_LICENSE("GPL");