blob: 2a5f43a68ae3d73d22dd822a4da4996208543e7c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/types.h>
12#include <linux/kernel.h>
13#include <linux/mm.h>
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040014#include <linux/seq_file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/tty.h>
16#include <linux/console.h>
17#include <linux/init.h>
18#include <linux/bootmem.h>
Finn Thain0d31f872014-11-13 12:21:28 +110019#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#include <asm/oplib.h>
22#include <asm/setup.h>
23#include <asm/contregs.h>
24#include <asm/movs.h>
25#include <asm/pgtable.h>
Roman Zippel12d810c2007-05-31 00:40:54 -070026#include <asm/pgalloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <asm/sun3-head.h>
28#include <asm/sun3mmu.h>
29#include <asm/rtc.h>
30#include <asm/machdep.h>
Finn Thain0d31f872014-11-13 12:21:28 +110031#include <asm/machines.h>
Geert Uytterhoevenc85627f2008-12-21 12:03:37 +010032#include <asm/idprom.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/intersil.h>
34#include <asm/irq.h>
Geert Uytterhoevenc85627f2008-12-21 12:03:37 +010035#include <asm/sections.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <asm/segment.h>
37#include <asm/sun3ints.h>
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
40
Stephen Warrenc8d5ba12012-11-08 11:34:55 -070041extern u32 sun3_gettimeoffset(void);
Adrian Bunk07b81252008-07-17 21:16:27 +020042static void sun3_sched_init(irq_handler_t handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043extern void sun3_get_model (char* model);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044extern int sun3_hwclk(int set, struct rtc_time *t);
45
46volatile char* clock_va;
Linus Torvalds1da177e2005-04-16 15:20:36 -070047extern unsigned long availmem;
48unsigned long num_pages;
49
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040050static void sun3_get_hardware_list(struct seq_file *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040052 seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
55void __init sun3_init(void)
56{
57 unsigned char enable_register;
58 int i;
59
60 m68k_machtype= MACH_SUN3;
61 m68k_cputype = CPU_68020;
62 m68k_fputype = FPU_68881; /* mc68881 actually */
63 m68k_mmutype = MMU_SUN3;
64 clock_va = (char *) 0xfe06000; /* dark */
65 sun3_intreg = (unsigned char *) 0xfe0a000; /* magic */
66 sun3_disable_interrupts();
67
68 prom_init((void *)LINUX_OPPROM_BEGVM);
69
70 GET_CONTROL_BYTE(AC_SENABLE,enable_register);
71 enable_register |= 0x50; /* Enable FPU */
72 SET_CONTROL_BYTE(AC_SENABLE,enable_register);
73 GET_CONTROL_BYTE(AC_SENABLE,enable_register);
74
75 /* This code looks suspicious, because it doesn't subtract
76 memory belonging to the kernel from the available space */
77
78
79 memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg));
80
81 /* Reserve important PMEGS */
82 /* FIXME: These should be probed instead of hardcoded */
83
84 for (i=0; i<8; i++) /* Kernel PMEGs */
85 sun3_reserved_pmeg[i] = 1;
86
87 sun3_reserved_pmeg[247] = 1; /* ROM mapping */
88 sun3_reserved_pmeg[248] = 1; /* AMD Ethernet */
89 sun3_reserved_pmeg[251] = 1; /* VB area */
90 sun3_reserved_pmeg[254] = 1; /* main I/O */
91
92 sun3_reserved_pmeg[249] = 1;
93 sun3_reserved_pmeg[252] = 1;
94 sun3_reserved_pmeg[253] = 1;
95 set_fs(KERNEL_DS);
96}
97
98/* Without this, Bad Things happen when something calls arch_reset. */
99static void sun3_reboot (void)
100{
101 prom_reboot ("vmlinux");
102}
103
104static void sun3_halt (void)
105{
106 prom_halt ();
107}
108
109/* sun3 bootmem allocation */
110
Adrian Bunk07b81252008-07-17 21:16:27 +0200111static void __init sun3_bootmem_alloc(unsigned long memory_start,
112 unsigned long memory_end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113{
114 unsigned long start_page;
115
116 /* align start/end to page boundaries */
117 memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK);
118 memory_end = memory_end & PAGE_MASK;
119
120 start_page = __pa(memory_start) >> PAGE_SHIFT;
Geert Uytterhoevenc73ec312015-11-15 11:41:14 +0100121 max_pfn = num_pages = __pa(memory_end) >> PAGE_SHIFT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 high_memory = (void *)memory_end;
124 availmem = memory_start;
125
Roman Zippel12d810c2007-05-31 00:40:54 -0700126 m68k_setup_node(0);
Geert Uytterhoevenc73ec312015-11-15 11:41:14 +0100127 availmem += init_bootmem(start_page, num_pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
129
130 free_bootmem(__pa(availmem), memory_end - (availmem));
131}
132
133
134void __init config_sun3(void)
135{
136 unsigned long memory_start, memory_end;
137
138 printk("ARCH: SUN3\n");
139 idprom_init();
140
141 /* Subtract kernel memory from available memory */
142
143 mach_sched_init = sun3_sched_init;
144 mach_init_IRQ = sun3_init_IRQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 mach_reset = sun3_reboot;
Stephen Warrenc8d5ba12012-11-08 11:34:55 -0700146 arch_gettimeoffset = sun3_gettimeoffset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 mach_get_model = sun3_get_model;
148 mach_hwclk = sun3_hwclk;
149 mach_halt = sun3_halt;
150 mach_get_hardware_list = sun3_get_hardware_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
Geert Uytterhoevenc85627f2008-12-21 12:03:37 +0100152 memory_start = ((((unsigned long)_end) + 0x2000) & ~0x1fff);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153// PROM seems to want the last couple of physical pages. --m
154 memory_end = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE;
155
156 m68k_num_memory=1;
157 m68k_memory[0].size=*(romvec->pv_sun3mem);
158
159 sun3_bootmem_alloc(memory_start, memory_end);
160}
161
Adrian Bunk07b81252008-07-17 21:16:27 +0200162static void __init sun3_sched_init(irq_handler_t timer_routine)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163{
164 sun3_disable_interrupts();
165 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
166 intersil_clock->int_reg=INTERSIL_HZ_100_MASK;
167 intersil_clear();
168 sun3_enable_irq(5);
169 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE);
170 sun3_enable_interrupts();
171 intersil_clear();
172}
173
Finn Thain0d31f872014-11-13 12:21:28 +1100174#ifdef CONFIG_SUN3_SCSI
175
176static const struct resource sun3_scsi_vme_rsrc[] __initconst = {
177 {
178 .flags = IORESOURCE_IRQ,
179 .start = SUN3_VEC_VMESCSI0,
180 .end = SUN3_VEC_VMESCSI0,
181 }, {
182 .flags = IORESOURCE_MEM,
183 .start = 0xff200000,
184 .end = 0xff200021,
185 }, {
186 .flags = IORESOURCE_IRQ,
187 .start = SUN3_VEC_VMESCSI1,
188 .end = SUN3_VEC_VMESCSI1,
189 }, {
190 .flags = IORESOURCE_MEM,
191 .start = 0xff204000,
192 .end = 0xff204021,
193 },
194};
195
196/*
197 * Int: level 2 autovector
198 * IO: type 1, base 0x00140000, 5 bits phys space: A<4..0>
199 */
200static const struct resource sun3_scsi_rsrc[] __initconst = {
201 {
202 .flags = IORESOURCE_IRQ,
203 .start = 2,
204 .end = 2,
205 }, {
206 .flags = IORESOURCE_MEM,
207 .start = 0x00140000,
208 .end = 0x0014001f,
209 },
210};
211
212int __init sun3_platform_init(void)
213{
214 switch (idprom->id_machtype) {
215 case SM_SUN3 | SM_3_160:
216 case SM_SUN3 | SM_3_260:
217 platform_device_register_simple("sun3_scsi_vme", -1,
218 sun3_scsi_vme_rsrc, ARRAY_SIZE(sun3_scsi_vme_rsrc));
219 break;
220 case SM_SUN3 | SM_3_50:
221 case SM_SUN3 | SM_3_60:
222 platform_device_register_simple("sun3_scsi", -1,
223 sun3_scsi_rsrc, ARRAY_SIZE(sun3_scsi_rsrc));
224 break;
225 }
226 return 0;
227}
228
229arch_initcall(sun3_platform_init);
230
231#endif