setup.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Unmaintained SGI Visual Workstation support.
  3. * Split out from setup.c by davej@suse.de
  4. */
  5. #include <linux/smp.h>
  6. #include <linux/init.h>
  7. #include <linux/interrupt.h>
  8. #include <asm/fixmap.h>
  9. #include <asm/arch_hooks.h>
  10. #include <asm/io.h>
  11. #include "cobalt.h"
  12. #include "piix4.h"
  13. int no_broadcast;
  14. char visws_board_type = -1;
  15. char visws_board_rev = -1;
  16. void __init visws_get_board_type_and_rev(void)
  17. {
  18. int raw;
  19. visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG)
  20. >> PIIX_GPI_BD_SHIFT;
  21. /*
  22. * Get Board rev.
  23. * First, we have to initialize the 307 part to allow us access
  24. * to the GPIO registers. Let's map them at 0x0fc0 which is right
  25. * after the PIIX4 PM section.
  26. */
  27. outb_p(SIO_DEV_SEL, SIO_INDEX);
  28. outb_p(SIO_GP_DEV, SIO_DATA); /* Talk to GPIO regs. */
  29. outb_p(SIO_DEV_MSB, SIO_INDEX);
  30. outb_p(SIO_GP_MSB, SIO_DATA); /* MSB of GPIO base address */
  31. outb_p(SIO_DEV_LSB, SIO_INDEX);
  32. outb_p(SIO_GP_LSB, SIO_DATA); /* LSB of GPIO base address */
  33. outb_p(SIO_DEV_ENB, SIO_INDEX);
  34. outb_p(1, SIO_DATA); /* Enable GPIO registers. */
  35. /*
  36. * Now, we have to map the power management section to write
  37. * a bit which enables access to the GPIO registers.
  38. * What lunatic came up with this shit?
  39. */
  40. outb_p(SIO_DEV_SEL, SIO_INDEX);
  41. outb_p(SIO_PM_DEV, SIO_DATA); /* Talk to GPIO regs. */
  42. outb_p(SIO_DEV_MSB, SIO_INDEX);
  43. outb_p(SIO_PM_MSB, SIO_DATA); /* MSB of PM base address */
  44. outb_p(SIO_DEV_LSB, SIO_INDEX);
  45. outb_p(SIO_PM_LSB, SIO_DATA); /* LSB of PM base address */
  46. outb_p(SIO_DEV_ENB, SIO_INDEX);
  47. outb_p(1, SIO_DATA); /* Enable PM registers. */
  48. /*
  49. * Now, write the PM register which enables the GPIO registers.
  50. */
  51. outb_p(SIO_PM_FER2, SIO_PM_INDEX);
  52. outb_p(SIO_PM_GP_EN, SIO_PM_DATA);
  53. /*
  54. * Now, initialize the GPIO registers.
  55. * We want them all to be inputs which is the
  56. * power on default, so let's leave them alone.
  57. * So, let's just read the board rev!
  58. */
  59. raw = inb_p(SIO_GP_DATA1);
  60. raw &= 0x7f; /* 7 bits of valid board revision ID. */
  61. if (visws_board_type == VISWS_320) {
  62. if (raw < 0x6) {
  63. visws_board_rev = 4;
  64. } else if (raw < 0xc) {
  65. visws_board_rev = 5;
  66. } else {
  67. visws_board_rev = 6;
  68. }
  69. } else if (visws_board_type == VISWS_540) {
  70. visws_board_rev = 2;
  71. } else {
  72. visws_board_rev = raw;
  73. }
  74. printk(KERN_INFO "Silicon Graphics Visual Workstation %s (rev %d) detected\n",
  75. (visws_board_type == VISWS_320 ? "320" :
  76. (visws_board_type == VISWS_540 ? "540" :
  77. "unknown")), visws_board_rev);
  78. }
  79. void __init pre_intr_init_hook(void)
  80. {
  81. init_VISWS_APIC_irqs();
  82. }
  83. void __init intr_init_hook(void)
  84. {
  85. #ifdef CONFIG_X86_LOCAL_APIC
  86. apic_intr_init();
  87. #endif
  88. }
  89. void __init pre_setup_arch_hook()
  90. {
  91. visws_get_board_type_and_rev();
  92. }
  93. static struct irqaction irq0 = {
  94. .handler = timer_interrupt,
  95. .flags = SA_INTERRUPT,
  96. .name = "timer",
  97. };
  98. void __init time_init_hook(void)
  99. {
  100. printk(KERN_INFO "Starting Cobalt Timer system clock\n");
  101. /* Set the countdown value */
  102. co_cpu_write(CO_CPU_TIMEVAL, CO_TIME_HZ/HZ);
  103. /* Start the timer */
  104. co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) | CO_CTRL_TIMERUN);
  105. /* Enable (unmask) the timer interrupt */
  106. co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) & ~CO_CTRL_TIMEMASK);
  107. /* Wire cpu IDT entry to s/w handler (and Cobalt APIC to IDT) */
  108. setup_irq(0, &irq0);
  109. }