setup.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 <asm/e820.h>
  12. #include <asm/setup.h>
  13. #include "cobalt.h"
  14. #include "piix4.h"
  15. int no_broadcast;
  16. char visws_board_type = -1;
  17. char visws_board_rev = -1;
  18. void __init visws_get_board_type_and_rev(void)
  19. {
  20. int raw;
  21. visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG)
  22. >> PIIX_GPI_BD_SHIFT;
  23. /*
  24. * Get Board rev.
  25. * First, we have to initialize the 307 part to allow us access
  26. * to the GPIO registers. Let's map them at 0x0fc0 which is right
  27. * after the PIIX4 PM section.
  28. */
  29. outb_p(SIO_DEV_SEL, SIO_INDEX);
  30. outb_p(SIO_GP_DEV, SIO_DATA); /* Talk to GPIO regs. */
  31. outb_p(SIO_DEV_MSB, SIO_INDEX);
  32. outb_p(SIO_GP_MSB, SIO_DATA); /* MSB of GPIO base address */
  33. outb_p(SIO_DEV_LSB, SIO_INDEX);
  34. outb_p(SIO_GP_LSB, SIO_DATA); /* LSB of GPIO base address */
  35. outb_p(SIO_DEV_ENB, SIO_INDEX);
  36. outb_p(1, SIO_DATA); /* Enable GPIO registers. */
  37. /*
  38. * Now, we have to map the power management section to write
  39. * a bit which enables access to the GPIO registers.
  40. * What lunatic came up with this shit?
  41. */
  42. outb_p(SIO_DEV_SEL, SIO_INDEX);
  43. outb_p(SIO_PM_DEV, SIO_DATA); /* Talk to GPIO regs. */
  44. outb_p(SIO_DEV_MSB, SIO_INDEX);
  45. outb_p(SIO_PM_MSB, SIO_DATA); /* MSB of PM base address */
  46. outb_p(SIO_DEV_LSB, SIO_INDEX);
  47. outb_p(SIO_PM_LSB, SIO_DATA); /* LSB of PM base address */
  48. outb_p(SIO_DEV_ENB, SIO_INDEX);
  49. outb_p(1, SIO_DATA); /* Enable PM registers. */
  50. /*
  51. * Now, write the PM register which enables the GPIO registers.
  52. */
  53. outb_p(SIO_PM_FER2, SIO_PM_INDEX);
  54. outb_p(SIO_PM_GP_EN, SIO_PM_DATA);
  55. /*
  56. * Now, initialize the GPIO registers.
  57. * We want them all to be inputs which is the
  58. * power on default, so let's leave them alone.
  59. * So, let's just read the board rev!
  60. */
  61. raw = inb_p(SIO_GP_DATA1);
  62. raw &= 0x7f; /* 7 bits of valid board revision ID. */
  63. if (visws_board_type == VISWS_320) {
  64. if (raw < 0x6) {
  65. visws_board_rev = 4;
  66. } else if (raw < 0xc) {
  67. visws_board_rev = 5;
  68. } else {
  69. visws_board_rev = 6;
  70. }
  71. } else if (visws_board_type == VISWS_540) {
  72. visws_board_rev = 2;
  73. } else {
  74. visws_board_rev = raw;
  75. }
  76. printk(KERN_INFO "Silicon Graphics Visual Workstation %s (rev %d) detected\n",
  77. (visws_board_type == VISWS_320 ? "320" :
  78. (visws_board_type == VISWS_540 ? "540" :
  79. "unknown")), visws_board_rev);
  80. }
  81. void __init pre_intr_init_hook(void)
  82. {
  83. init_VISWS_APIC_irqs();
  84. }
  85. void __init intr_init_hook(void)
  86. {
  87. #ifdef CONFIG_X86_LOCAL_APIC
  88. apic_intr_init();
  89. #endif
  90. }
  91. void __init pre_setup_arch_hook()
  92. {
  93. visws_get_board_type_and_rev();
  94. }
  95. static struct irqaction irq0 = {
  96. .handler = timer_interrupt,
  97. .flags = IRQF_DISABLED,
  98. .name = "timer",
  99. };
  100. void __init time_init_hook(void)
  101. {
  102. printk(KERN_INFO "Starting Cobalt Timer system clock\n");
  103. /* Set the countdown value */
  104. co_cpu_write(CO_CPU_TIMEVAL, CO_TIME_HZ/HZ);
  105. /* Start the timer */
  106. co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) | CO_CTRL_TIMERUN);
  107. /* Enable (unmask) the timer interrupt */
  108. co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) & ~CO_CTRL_TIMEMASK);
  109. /* Wire cpu IDT entry to s/w handler (and Cobalt APIC to IDT) */
  110. setup_irq(0, &irq0);
  111. }
  112. /* Hook for machine specific memory setup. */
  113. #define MB (1024 * 1024)
  114. unsigned long sgivwfb_mem_phys;
  115. unsigned long sgivwfb_mem_size;
  116. long long mem_size __initdata = 0;
  117. char * __init machine_specific_memory_setup(void)
  118. {
  119. long long gfx_mem_size = 8 * MB;
  120. mem_size = ALT_MEM_K;
  121. if (!mem_size) {
  122. printk(KERN_WARNING "Bootloader didn't set memory size, upgrade it !\n");
  123. mem_size = 128 * MB;
  124. }
  125. /*
  126. * this hardcodes the graphics memory to 8 MB
  127. * it really should be sized dynamically (or at least
  128. * set as a boot param)
  129. */
  130. if (!sgivwfb_mem_size) {
  131. printk(KERN_WARNING "Defaulting to 8 MB framebuffer size\n");
  132. sgivwfb_mem_size = 8 * MB;
  133. }
  134. /*
  135. * Trim to nearest MB
  136. */
  137. sgivwfb_mem_size &= ~((1 << 20) - 1);
  138. sgivwfb_mem_phys = mem_size - gfx_mem_size;
  139. add_memory_region(0, LOWMEMSIZE(), E820_RAM);
  140. add_memory_region(HIGH_MEMORY, mem_size - sgivwfb_mem_size - HIGH_MEMORY, E820_RAM);
  141. add_memory_region(sgivwfb_mem_phys, sgivwfb_mem_size, E820_RESERVED);
  142. return "PROM";
  143. }