mach_reboot.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * arch/i386/mach-generic/mach_reboot.h
  3. *
  4. * Machine specific reboot functions for generic.
  5. * Split out from reboot.c by Osamu Tomita <tomita@cinet.co.jp>
  6. */
  7. #ifndef _MACH_REBOOT_H
  8. #define _MACH_REBOOT_H
  9. static inline void kb_wait(void)
  10. {
  11. int i;
  12. for (i = 0; i < 0x10000; i++)
  13. if ((inb_p(0x64) & 0x02) == 0)
  14. break;
  15. }
  16. static inline void mach_reboot(void)
  17. {
  18. int i;
  19. /* old method, works on most machines */
  20. for (i = 0; i < 10; i++) {
  21. kb_wait();
  22. udelay(50);
  23. outb(0xfe, 0x64); /* pulse reset low */
  24. udelay(50);
  25. }
  26. /* New method: sets the "System flag" which, when set, indicates
  27. * successful completion of the keyboard controller self-test (Basic
  28. * Assurance Test, BAT). This is needed for some machines with no
  29. * keyboard plugged in. This read-modify-write sequence sets only the
  30. * system flag
  31. */
  32. for (i = 0; i < 10; i++) {
  33. int cmd;
  34. outb(0x20, 0x64); /* read Controller Command Byte */
  35. udelay(50);
  36. kb_wait();
  37. udelay(50);
  38. cmd = inb(0x60);
  39. udelay(50);
  40. kb_wait();
  41. udelay(50);
  42. outb(0x60, 0x64); /* write Controller Command Byte */
  43. udelay(50);
  44. kb_wait();
  45. udelay(50);
  46. outb(cmd | 0x04, 0x60); /* set "System flag" */
  47. udelay(50);
  48. kb_wait();
  49. udelay(50);
  50. outb(0xfe, 0x64); /* pulse reset low */
  51. udelay(50);
  52. }
  53. }
  54. #endif /* !_MACH_REBOOT_H */