ixp4xx-rng.c 1.6 KB

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