config.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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/types.h>
  11. #include <linux/kernel.h>
  12. #include <linux/mm.h>
  13. #include <linux/seq_file.h>
  14. #include <linux/tty.h>
  15. #include <linux/console.h>
  16. #include <linux/init.h>
  17. #include <linux/bootmem.h>
  18. #include <linux/platform_device.h>
  19. #include <asm/oplib.h>
  20. #include <asm/setup.h>
  21. #include <asm/contregs.h>
  22. #include <asm/movs.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/pgalloc.h>
  25. #include <asm/sun3-head.h>
  26. #include <asm/sun3mmu.h>
  27. #include <asm/machdep.h>
  28. #include <asm/machines.h>
  29. #include <asm/idprom.h>
  30. #include <asm/intersil.h>
  31. #include <asm/irq.h>
  32. #include <asm/sections.h>
  33. #include <asm/segment.h>
  34. #include <asm/sun3ints.h>
  35. char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
  36. extern u32 sun3_gettimeoffset(void);
  37. static void sun3_sched_init(irq_handler_t handler);
  38. extern void sun3_get_model (char* model);
  39. extern int sun3_hwclk(int set, struct rtc_time *t);
  40. volatile char* clock_va;
  41. extern unsigned long availmem;
  42. unsigned long num_pages;
  43. static void sun3_get_hardware_list(struct seq_file *m)
  44. {
  45. seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid);
  46. }
  47. void __init sun3_init(void)
  48. {
  49. unsigned char enable_register;
  50. int i;
  51. m68k_machtype= MACH_SUN3;
  52. m68k_cputype = CPU_68020;
  53. m68k_fputype = FPU_68881; /* mc68881 actually */
  54. m68k_mmutype = MMU_SUN3;
  55. clock_va = (char *) 0xfe06000; /* dark */
  56. sun3_intreg = (unsigned char *) 0xfe0a000; /* magic */
  57. sun3_disable_interrupts();
  58. prom_init((void *)LINUX_OPPROM_BEGVM);
  59. GET_CONTROL_BYTE(AC_SENABLE,enable_register);
  60. enable_register |= 0x50; /* Enable FPU */
  61. SET_CONTROL_BYTE(AC_SENABLE,enable_register);
  62. GET_CONTROL_BYTE(AC_SENABLE,enable_register);
  63. /* This code looks suspicious, because it doesn't subtract
  64. memory belonging to the kernel from the available space */
  65. memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg));
  66. /* Reserve important PMEGS */
  67. /* FIXME: These should be probed instead of hardcoded */
  68. for (i=0; i<8; i++) /* Kernel PMEGs */
  69. sun3_reserved_pmeg[i] = 1;
  70. sun3_reserved_pmeg[247] = 1; /* ROM mapping */
  71. sun3_reserved_pmeg[248] = 1; /* AMD Ethernet */
  72. sun3_reserved_pmeg[251] = 1; /* VB area */
  73. sun3_reserved_pmeg[254] = 1; /* main I/O */
  74. sun3_reserved_pmeg[249] = 1;
  75. sun3_reserved_pmeg[252] = 1;
  76. sun3_reserved_pmeg[253] = 1;
  77. set_fs(KERNEL_DS);
  78. }
  79. /* Without this, Bad Things happen when something calls arch_reset. */
  80. static void sun3_reboot (void)
  81. {
  82. prom_reboot ("vmlinux");
  83. }
  84. static void sun3_halt (void)
  85. {
  86. prom_halt ();
  87. }
  88. /* sun3 bootmem allocation */
  89. static void __init sun3_bootmem_alloc(unsigned long memory_start,
  90. unsigned long memory_end)
  91. {
  92. unsigned long start_page;
  93. /* align start/end to page boundaries */
  94. memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK);
  95. memory_end = memory_end & PAGE_MASK;
  96. start_page = __pa(memory_start) >> PAGE_SHIFT;
  97. max_pfn = num_pages = __pa(memory_end) >> PAGE_SHIFT;
  98. high_memory = (void *)memory_end;
  99. availmem = memory_start;
  100. m68k_setup_node(0);
  101. availmem += init_bootmem(start_page, num_pages);
  102. availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
  103. free_bootmem(__pa(availmem), memory_end - (availmem));
  104. }
  105. void __init config_sun3(void)
  106. {
  107. unsigned long memory_start, memory_end;
  108. printk("ARCH: SUN3\n");
  109. idprom_init();
  110. /* Subtract kernel memory from available memory */
  111. mach_sched_init = sun3_sched_init;
  112. mach_init_IRQ = sun3_init_IRQ;
  113. mach_reset = sun3_reboot;
  114. arch_gettimeoffset = sun3_gettimeoffset;
  115. mach_get_model = sun3_get_model;
  116. mach_hwclk = sun3_hwclk;
  117. mach_halt = sun3_halt;
  118. mach_get_hardware_list = sun3_get_hardware_list;
  119. memory_start = ((((unsigned long)_end) + 0x2000) & ~0x1fff);
  120. // PROM seems to want the last couple of physical pages. --m
  121. memory_end = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE;
  122. m68k_num_memory=1;
  123. m68k_memory[0].size=*(romvec->pv_sun3mem);
  124. sun3_bootmem_alloc(memory_start, memory_end);
  125. }
  126. static void __init sun3_sched_init(irq_handler_t timer_routine)
  127. {
  128. sun3_disable_interrupts();
  129. intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
  130. intersil_clock->int_reg=INTERSIL_HZ_100_MASK;
  131. intersil_clear();
  132. sun3_enable_irq(5);
  133. intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE);
  134. sun3_enable_interrupts();
  135. intersil_clear();
  136. }
  137. #if IS_ENABLED(CONFIG_SUN3_SCSI)
  138. static const struct resource sun3_scsi_vme_rsrc[] __initconst = {
  139. {
  140. .flags = IORESOURCE_IRQ,
  141. .start = SUN3_VEC_VMESCSI0,
  142. .end = SUN3_VEC_VMESCSI0,
  143. }, {
  144. .flags = IORESOURCE_MEM,
  145. .start = 0xff200000,
  146. .end = 0xff200021,
  147. }, {
  148. .flags = IORESOURCE_IRQ,
  149. .start = SUN3_VEC_VMESCSI1,
  150. .end = SUN3_VEC_VMESCSI1,
  151. }, {
  152. .flags = IORESOURCE_MEM,
  153. .start = 0xff204000,
  154. .end = 0xff204021,
  155. },
  156. };
  157. /*
  158. * Int: level 2 autovector
  159. * IO: type 1, base 0x00140000, 5 bits phys space: A<4..0>
  160. */
  161. static const struct resource sun3_scsi_rsrc[] __initconst = {
  162. {
  163. .flags = IORESOURCE_IRQ,
  164. .start = 2,
  165. .end = 2,
  166. }, {
  167. .flags = IORESOURCE_MEM,
  168. .start = 0x00140000,
  169. .end = 0x0014001f,
  170. },
  171. };
  172. int __init sun3_platform_init(void)
  173. {
  174. switch (idprom->id_machtype) {
  175. case SM_SUN3 | SM_3_160:
  176. case SM_SUN3 | SM_3_260:
  177. platform_device_register_simple("sun3_scsi_vme", -1,
  178. sun3_scsi_vme_rsrc, ARRAY_SIZE(sun3_scsi_vme_rsrc));
  179. break;
  180. case SM_SUN3 | SM_3_50:
  181. case SM_SUN3 | SM_3_60:
  182. platform_device_register_simple("sun3_scsi", -1,
  183. sun3_scsi_rsrc, ARRAY_SIZE(sun3_scsi_rsrc));
  184. break;
  185. }
  186. return 0;
  187. }
  188. arch_initcall(sun3_platform_init);
  189. #endif