reset.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/jiffies.h>
  12. #include <asm/io.h>
  13. #include <asm/reboot.h>
  14. #include <cobalt.h>
  15. void cobalt_machine_halt(void)
  16. {
  17. int state, last, diff;
  18. unsigned long mark;
  19. /*
  20. * turn off bar on Qube, flash power off LED on RaQ (0.5Hz)
  21. *
  22. * restart if ENTER and SELECT are pressed
  23. */
  24. last = COBALT_KEY_PORT;
  25. for (state = 0;;) {
  26. state ^= COBALT_LED_POWER_OFF;
  27. COBALT_LED_PORT = state;
  28. diff = COBALT_KEY_PORT ^ last;
  29. last ^= diff;
  30. if((diff & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)) && !(~last & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)))
  31. COBALT_LED_PORT = COBALT_LED_RESET;
  32. for (mark = jiffies; jiffies - mark < HZ;)
  33. ;
  34. }
  35. }
  36. void cobalt_machine_restart(char *command)
  37. {
  38. COBALT_LED_PORT = COBALT_LED_RESET;
  39. /* we should never get here */
  40. cobalt_machine_halt();
  41. }
  42. /*
  43. * This triggers the luser mode device driver for the power switch ;-)
  44. */
  45. void cobalt_machine_power_off(void)
  46. {
  47. printk("You can switch the machine off now.\n");
  48. cobalt_machine_halt();
  49. }