config.c 5.4 KB

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