| Michael Buesch | d7174bc | 2006-06-26 00:25:02 -0700 | [diff] [blame] | 1 | /* | 
| Uwe Zeisberger | f30c226 | 2006-10-03 23:01:26 +0200 | [diff] [blame] | 2 | * drivers/char/hw_random/ixp4xx-rng.c | 
| Michael Buesch | d7174bc | 2006-06-26 00:25:02 -0700 | [diff] [blame] | 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> | 
| Michael Buesch | d7174bc | 2006-06-26 00:25:02 -0700 | [diff] [blame] | 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> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/hardware.h> | 
| Michael Buesch | d7174bc | 2006-06-26 00:25:02 -0700 | [diff] [blame] | 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 | rng_base = ioremap(0x70002100, 4); | 
|  | 49 | if (!rng_base) | 
|  | 50 | return -ENOMEM; | 
|  | 51 | ixp4xx_rng_ops.priv = (unsigned long)rng_base; | 
|  | 52 | err = hwrng_register(&ixp4xx_rng_ops); | 
|  | 53 | if (err) | 
|  | 54 | iounmap(rng_base); | 
|  | 55 |  | 
|  | 56 | return err; | 
|  | 57 | } | 
|  | 58 |  | 
|  | 59 | static void __exit ixp4xx_rng_exit(void) | 
|  | 60 | { | 
|  | 61 | void __iomem * rng_base = (void __iomem *)ixp4xx_rng_ops.priv; | 
|  | 62 |  | 
|  | 63 | hwrng_unregister(&ixp4xx_rng_ops); | 
|  | 64 | iounmap(rng_base); | 
|  | 65 | } | 
|  | 66 |  | 
| Michael Buesch | 56fb5fe | 2007-01-10 23:15:43 -0800 | [diff] [blame] | 67 | module_init(ixp4xx_rng_init); | 
| Michael Buesch | d7174bc | 2006-06-26 00:25:02 -0700 | [diff] [blame] | 68 | module_exit(ixp4xx_rng_exit); | 
|  | 69 |  | 
|  | 70 | MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>"); | 
|  | 71 | MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx"); | 
|  | 72 | MODULE_LICENSE("GPL"); |