Path: blob/master/drivers/char/hw_random/ixp4xx-rng.c
15111 views
/*1* drivers/char/hw_random/ixp4xx-rng.c2*3* RNG driver for Intel IXP4xx family of NPUs4*5* Author: Deepak Saxena <[email protected]>6*7* Copyright 2005 (c) MontaVista Software, Inc.8*9* Fixes by Michael Buesch10*11* This file is licensed under the terms of the GNU General Public12* License version 2. This program is licensed "as is" without any13* warranty of any kind, whether express or implied.14*/1516#include <linux/kernel.h>17#include <linux/types.h>18#include <linux/module.h>19#include <linux/moduleparam.h>20#include <linux/init.h>21#include <linux/bitops.h>22#include <linux/hw_random.h>2324#include <asm/io.h>25#include <mach/hardware.h>262728static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer)29{30void __iomem * rng_base = (void __iomem *)rng->priv;3132*buffer = __raw_readl(rng_base);3334return 4;35}3637static struct hwrng ixp4xx_rng_ops = {38.name = "ixp4xx",39.data_read = ixp4xx_rng_data_read,40};4142static int __init ixp4xx_rng_init(void)43{44void __iomem * rng_base;45int err;4647rng_base = ioremap(0x70002100, 4);48if (!rng_base)49return -ENOMEM;50ixp4xx_rng_ops.priv = (unsigned long)rng_base;51err = hwrng_register(&ixp4xx_rng_ops);52if (err)53iounmap(rng_base);5455return err;56}5758static void __exit ixp4xx_rng_exit(void)59{60void __iomem * rng_base = (void __iomem *)ixp4xx_rng_ops.priv;6162hwrng_unregister(&ixp4xx_rng_ops);63iounmap(rng_base);64}6566module_init(ixp4xx_rng_init);67module_exit(ixp4xx_rng_exit);6869MODULE_AUTHOR("Deepak Saxena <[email protected]>");70MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx");71MODULE_LICENSE("GPL");727374