config.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * linux/arch/m68k/sun3/config.c
  3. *
  4. * Copyright (C) 1996,1997 Pekka Pietik{inen
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/types.h>
  12. #include <linux/kernel.h>
  13. #include <linux/mm.h>
  14. #include <linux/tty.h>
  15. #include <linux/console.h>
  16. #include <linux/init.h>
  17. #include <linux/bootmem.h>
  18. #include <asm/oplib.h>
  19. #include <asm/setup.h>
  20. #include <asm/contregs.h>
  21. #include <asm/movs.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/sun3-head.h>
  24. #include <asm/sun3mmu.h>
  25. #include <asm/rtc.h>
  26. #include <asm/machdep.h>
  27. #include <asm/intersil.h>
  28. #include <asm/irq.h>
  29. #include <asm/segment.h>
  30. #include <asm/sun3ints.h>
  31. extern char _text, _end;
  32. char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
  33. extern unsigned long sun3_gettimeoffset(void);
  34. extern int show_sun3_interrupts (struct seq_file *, void *);
  35. extern void sun3_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
  36. extern void sun3_get_model (char* model);
  37. extern void idprom_init (void);
  38. extern int sun3_hwclk(int set, struct rtc_time *t);
  39. volatile char* clock_va;
  40. extern volatile unsigned char* sun3_intreg;
  41. extern unsigned long availmem;
  42. unsigned long num_pages;
  43. static int sun3_get_hardware_list(char *buffer)
  44. {
  45. int len = 0;
  46. len += sprintf(buffer + len, "PROM Revision:\t%s\n",
  47. romvec->pv_monid);
  48. return len;
  49. }
  50. void __init sun3_init(void)
  51. {
  52. unsigned char enable_register;
  53. int i;
  54. m68k_machtype= MACH_SUN3;
  55. m68k_cputype = CPU_68020;
  56. m68k_fputype = FPU_68881; /* mc68881 actually */
  57. m68k_mmutype = MMU_SUN3;
  58. clock_va = (char *) 0xfe06000; /* dark */
  59. sun3_intreg = (unsigned char *) 0xfe0a000; /* magic */
  60. sun3_disable_interrupts();
  61. prom_init((void *)LINUX_OPPROM_BEGVM);
  62. GET_CONTROL_BYTE(AC_SENABLE,enable_register);
  63. enable_register |= 0x50; /* Enable FPU */
  64. SET_CONTROL_BYTE(AC_SENABLE,enable_register);
  65. GET_CONTROL_BYTE(AC_SENABLE,enable_register);
  66. /* This code looks suspicious, because it doesn't subtract
  67. memory belonging to the kernel from the available space */
  68. memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg));
  69. /* Reserve important PMEGS */
  70. /* FIXME: These should be probed instead of hardcoded */
  71. for (i=0; i<8; i++) /* Kernel PMEGs */
  72. sun3_reserved_pmeg[i] = 1;
  73. sun3_reserved_pmeg[247] = 1; /* ROM mapping */
  74. sun3_reserved_pmeg[248] = 1; /* AMD Ethernet */
  75. sun3_reserved_pmeg[251] = 1; /* VB area */
  76. sun3_reserved_pmeg[254] = 1; /* main I/O */
  77. sun3_reserved_pmeg[249] = 1;
  78. sun3_reserved_pmeg[252] = 1;
  79. sun3_reserved_pmeg[253] = 1;
  80. set_fs(KERNEL_DS);
  81. }
  82. /* Without this, Bad Things happen when something calls arch_reset. */
  83. static void sun3_reboot (void)
  84. {
  85. prom_reboot ("vmlinux");
  86. }
  87. static void sun3_halt (void)
  88. {
  89. prom_halt ();
  90. }
  91. /* sun3 bootmem allocation */
  92. void __init sun3_bootmem_alloc(unsigned long memory_start, unsigned long memory_end)
  93. {
  94. unsigned long start_page;
  95. /* align start/end to page boundaries */
  96. memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK);
  97. memory_end = memory_end & PAGE_MASK;
  98. start_page = __pa(memory_start) >> PAGE_SHIFT;
  99. num_pages = __pa(memory_end) >> PAGE_SHIFT;
  100. high_memory = (void *)memory_end;
  101. availmem = memory_start;
  102. availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages);
  103. availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
  104. free_bootmem(__pa(availmem), memory_end - (availmem));
  105. }
  106. void __init config_sun3(void)
  107. {
  108. unsigned long memory_start, memory_end;
  109. printk("ARCH: SUN3\n");
  110. idprom_init();
  111. /* Subtract kernel memory from available memory */
  112. mach_sched_init = sun3_sched_init;
  113. mach_init_IRQ = sun3_init_IRQ;
  114. mach_default_handler = &sun3_default_handler;
  115. mach_request_irq = sun3_request_irq;
  116. mach_free_irq = sun3_free_irq;
  117. enable_irq = sun3_enable_irq;
  118. disable_irq = sun3_disable_irq;
  119. mach_process_int = sun3_process_int;
  120. mach_get_irq_list = show_sun3_interrupts;
  121. mach_reset = sun3_reboot;
  122. mach_gettimeoffset = sun3_gettimeoffset;
  123. mach_get_model = sun3_get_model;
  124. mach_hwclk = sun3_hwclk;
  125. mach_halt = sun3_halt;
  126. mach_get_hardware_list = sun3_get_hardware_list;
  127. #if defined(CONFIG_DUMMY_CONSOLE)
  128. conswitchp = &dummy_con;
  129. #endif
  130. memory_start = ((((int)&_end) + 0x2000) & ~0x1fff);
  131. // PROM seems to want the last couple of physical pages. --m
  132. memory_end = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE;
  133. m68k_num_memory=1;
  134. m68k_memory[0].size=*(romvec->pv_sun3mem);
  135. sun3_bootmem_alloc(memory_start, memory_end);
  136. }
  137. void __init sun3_sched_init(irqreturn_t (*timer_routine)(int, void *, struct pt_regs *))
  138. {
  139. sun3_disable_interrupts();
  140. intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
  141. intersil_clock->int_reg=INTERSIL_HZ_100_MASK;
  142. intersil_clear();
  143. sun3_enable_irq(5);
  144. intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE);
  145. sun3_enable_interrupts();
  146. intersil_clear();
  147. }