ixp4xx-rng.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * drivers/char/hw_random/ixp4xx-rng.c
  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. #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>
  23. #include <asm/io.h>
  24. #include <mach/hardware.h>
  25. static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer)
  26. {
  27. void __iomem * rng_base = (void __iomem *)rng->priv;
  28. *buffer = __raw_readl(rng_base);
  29. return 4;
  30. }
  31. static struct hwrng ixp4xx_rng_ops = {
  32. .name = "ixp4xx",
  33. .data_read = ixp4xx_rng_data_read,
  34. };
  35. static int __init ixp4xx_rng_init(void)
  36. {
  37. void __iomem * rng_base;
  38. int err;
  39. rng_base = ioremap(0x70002100, 4);
  40. if (!rng_base)
  41. return -ENOMEM;
  42. ixp4xx_rng_ops.priv = (unsigned long)rng_base;
  43. err = hwrng_register(&ixp4xx_rng_ops);
  44. if (err)
  45. iounmap(rng_base);
  46. return err;
  47. }
  48. static void __exit ixp4xx_rng_exit(void)
  49. {
  50. void __iomem * rng_base = (void __iomem *)ixp4xx_rng_ops.priv;
  51. hwrng_unregister(&ixp4xx_rng_ops);
  52. iounmap(rng_base);
  53. }
  54. module_init(ixp4xx_rng_init);
  55. module_exit(ixp4xx_rng_exit);
  56. MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
  57. MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx");
  58. MODULE_LICENSE("GPL");