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