reset.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Reset a Jazz machine.
  3. *
  4. * We don't trust the firmware so we do it the classic way by poking and
  5. * stabbing at the keyboard controller ...
  6. */
  7. #include <linux/jiffies.h>
  8. #include <asm/jazz.h>
  9. #include <asm/io.h>
  10. #include <asm/system.h>
  11. #include <asm/reboot.h>
  12. #include <asm/delay.h>
  13. #define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
  14. static void jazz_write_output(unsigned char val)
  15. {
  16. int status;
  17. do {
  18. status = jazz_kh->command;
  19. } while (status & KBD_STAT_IBF);
  20. jazz_kh->data = val;
  21. }
  22. static void jazz_write_command(unsigned char val)
  23. {
  24. int status;
  25. do {
  26. status = jazz_kh->command;
  27. } while (status & KBD_STAT_IBF);
  28. jazz_kh->command = val;
  29. }
  30. static unsigned char jazz_read_status(void)
  31. {
  32. return jazz_kh->command;
  33. }
  34. static inline void kb_wait(void)
  35. {
  36. unsigned long start = jiffies;
  37. unsigned long timeout = start + HZ/2;
  38. do {
  39. if (! (jazz_read_status() & 0x02))
  40. return;
  41. } while (time_before_eq(jiffies, timeout));
  42. }
  43. void jazz_machine_restart(char *command)
  44. {
  45. while(1) {
  46. kb_wait();
  47. jazz_write_command (0xd1);
  48. kb_wait();
  49. jazz_write_output (0x00);
  50. }
  51. }
  52. void jazz_machine_halt(void)
  53. {
  54. }
  55. void jazz_machine_power_off(void)
  56. {
  57. /* Jazz machines don't have a software power switch */
  58. }