setup.c 4.4 KB

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