nas100d-power.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * arch/arm/mach-ixp4xx/nas100d-power.c
  3. *
  4. * NAS 100d Power/Reset driver
  5. *
  6. * Copyright (C) 2005 Tower Technologies
  7. *
  8. * based on nas100d-io.c
  9. * Copyright (C) 2004 Karen Spearel
  10. *
  11. * Author: Alessandro Zummo <a.zummo@towertech.it>
  12. * Maintainers: http://www.nslu2-linux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. *
  18. */
  19. #include <linux/module.h>
  20. #include <linux/reboot.h>
  21. #include <linux/interrupt.h>
  22. #include <asm/mach-types.h>
  23. extern void ctrl_alt_del(void);
  24. static irqreturn_t nas100d_reset_handler(int irq, void *dev_id, struct pt_regs *regs)
  25. {
  26. /* Signal init to do the ctrlaltdel action, this will bypass init if
  27. * it hasn't started and do a kernel_restart.
  28. */
  29. ctrl_alt_del();
  30. return IRQ_HANDLED;
  31. }
  32. static int __init nas100d_power_init(void)
  33. {
  34. if (!(machine_is_nas100d()))
  35. return 0;
  36. set_irq_type(NAS100D_RB_IRQ, IRQT_LOW);
  37. gpio_line_isr_clear(NAS100D_RB_GPIO);
  38. if (request_irq(NAS100D_RB_IRQ, &nas100d_reset_handler,
  39. SA_INTERRUPT, "NAS100D reset button", NULL) < 0) {
  40. printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
  41. NAS100D_RB_IRQ);
  42. return -EIO;
  43. }
  44. return 0;
  45. }
  46. static void __exit nas100d_power_exit(void)
  47. {
  48. free_irq(NAS100D_RB_IRQ, NULL);
  49. }
  50. module_init(nas100d_power_init);
  51. module_exit(nas100d_power_exit);
  52. MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
  53. MODULE_DESCRIPTION("NAS100D Power/Reset driver");
  54. MODULE_LICENSE("GPL");