setup.c 3.3 KB

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