reset.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Cobalt Reset operations
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
  9. * Copyright (C) 2001 by Liam Davies (ldavies@agile.tv)
  10. */
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <linux/jiffies.h>
  14. #include <linux/leds.h>
  15. #include <cobalt.h>
  16. #define RESET_PORT ((void __iomem *)CKSEG1ADDR(0x1c000000))
  17. #define RESET 0x0f
  18. DEFINE_LED_TRIGGER(power_off_led_trigger);
  19. static int __init ledtrig_power_off_init(void)
  20. {
  21. led_trigger_register_simple("power-off", &power_off_led_trigger);
  22. return 0;
  23. }
  24. device_initcall(ledtrig_power_off_init);
  25. void cobalt_machine_halt(void)
  26. {
  27. int state, last, diff;
  28. unsigned long mark;
  29. /*
  30. * turn on power off LED on RaQ
  31. *
  32. * restart if ENTER and SELECT are pressed
  33. */
  34. last = COBALT_KEY_PORT;
  35. led_trigger_event(power_off_led_trigger, LED_FULL);
  36. for (state = 0;;) {
  37. diff = COBALT_KEY_PORT ^ last;
  38. last ^= diff;
  39. if((diff & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)) && !(~last & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)))
  40. writeb(RESET, RESET_PORT);
  41. for (mark = jiffies; jiffies - mark < HZ;)
  42. ;
  43. }
  44. }
  45. void cobalt_machine_restart(char *command)
  46. {
  47. writeb(RESET, RESET_PORT);
  48. /* we should never get here */
  49. cobalt_machine_halt();
  50. }