blob: f59ec58083f8b41545665a0dfab1492bfd1d3007 [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>
19
20#include <asm/oplib.h>
21#include <asm/setup.h>
22#include <asm/contregs.h>
23#include <asm/movs.h>
24#include <asm/pgtable.h>
Roman Zippel12d810c2007-05-31 00:40:54 -070025#include <asm/pgalloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/sun3-head.h>
27#include <asm/sun3mmu.h>
28#include <asm/rtc.h>
29#include <asm/machdep.h>
Geert Uytterhoevenc85627f2008-12-21 12:03:37 +010030#include <asm/idprom.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <asm/intersil.h>
32#include <asm/irq.h>
Geert Uytterhoevenc85627f2008-12-21 12:03:37 +010033#include <asm/sections.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <asm/segment.h>
35#include <asm/sun3ints.h>
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
38
Stephen Warrenc8d5ba12012-11-08 11:34:55 -070039extern u32 sun3_gettimeoffset(void);
Adrian Bunk07b81252008-07-17 21:16:27 +020040static void sun3_sched_init(irq_handler_t handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -070041extern void sun3_get_model (char* model);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042extern int sun3_hwclk(int set, struct rtc_time *t);
43
44volatile char* clock_va;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045extern unsigned long availmem;
46unsigned long num_pages;
47
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040048static void sun3_get_hardware_list(struct seq_file *m)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
Alexey Dobriyan813dcf72008-10-03 22:42:36 +040050 seq_printf(m, "PROM Revision:\t%s\n", romvec->pv_monid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051}
52
53void __init sun3_init(void)
54{
55 unsigned char enable_register;
56 int i;
57
58 m68k_machtype= MACH_SUN3;
59 m68k_cputype = CPU_68020;
60 m68k_fputype = FPU_68881; /* mc68881 actually */
61 m68k_mmutype = MMU_SUN3;
62 clock_va = (char *) 0xfe06000; /* dark */
63 sun3_intreg = (unsigned char *) 0xfe0a000; /* magic */
64 sun3_disable_interrupts();
65
66 prom_init((void *)LINUX_OPPROM_BEGVM);
67
68 GET_CONTROL_BYTE(AC_SENABLE,enable_register);
69 enable_register |= 0x50; /* Enable FPU */
70 SET_CONTROL_BYTE(AC_SENABLE,enable_register);
71 GET_CONTROL_BYTE(AC_SENABLE,enable_register);
72
73 /* This code looks suspicious, because it doesn't subtract
74 memory belonging to the kernel from the available space */
75
76
77 memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg));
78
79 /* Reserve important PMEGS */
80 /* FIXME: These should be probed instead of hardcoded */
81
82 for (i=0; i<8; i++) /* Kernel PMEGs */
83 sun3_reserved_pmeg[i] = 1;
84
85 sun3_reserved_pmeg[247] = 1; /* ROM mapping */
86 sun3_reserved_pmeg[248] = 1; /* AMD Ethernet */
87 sun3_reserved_pmeg[251] = 1; /* VB area */
88 sun3_reserved_pmeg[254] = 1; /* main I/O */
89
90 sun3_reserved_pmeg[249] = 1;
91 sun3_reserved_pmeg[252] = 1;
92 sun3_reserved_pmeg[253] = 1;
93 set_fs(KERNEL_DS);
94}
95
96/* Without this, Bad Things happen when something calls arch_reset. */
97static void sun3_reboot (void)
98{
99 prom_reboot ("vmlinux");
100}
101
102static void sun3_halt (void)
103{
104 prom_halt ();
105}
106
107/* sun3 bootmem allocation */
108
Adrian Bunk07b81252008-07-17 21:16:27 +0200109static void __init sun3_bootmem_alloc(unsigned long memory_start,
110 unsigned long memory_end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111{
112 unsigned long start_page;
113
114 /* align start/end to page boundaries */
115 memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK);
116 memory_end = memory_end & PAGE_MASK;
117
118 start_page = __pa(memory_start) >> PAGE_SHIFT;
119 num_pages = __pa(memory_end) >> PAGE_SHIFT;
120
121 high_memory = (void *)memory_end;
122 availmem = memory_start;
123
Roman Zippel12d810c2007-05-31 00:40:54 -0700124 m68k_setup_node(0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages);
126 availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
127
128 free_bootmem(__pa(availmem), memory_end - (availmem));
129}
130
131
132void __init config_sun3(void)
133{
134 unsigned long memory_start, memory_end;
135
136 printk("ARCH: SUN3\n");
137 idprom_init();
138
139 /* Subtract kernel memory from available memory */
140
141 mach_sched_init = sun3_sched_init;
142 mach_init_IRQ = sun3_init_IRQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 mach_reset = sun3_reboot;
Stephen Warrenc8d5ba12012-11-08 11:34:55 -0700144 arch_gettimeoffset = sun3_gettimeoffset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 mach_get_model = sun3_get_model;
146 mach_hwclk = sun3_hwclk;
147 mach_halt = sun3_halt;
148 mach_get_hardware_list = sun3_get_hardware_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Geert Uytterhoevenc85627f2008-12-21 12:03:37 +0100150 memory_start = ((((unsigned long)_end) + 0x2000) & ~0x1fff);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151// PROM seems to want the last couple of physical pages. --m
152 memory_end = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE;
153
154 m68k_num_memory=1;
155 m68k_memory[0].size=*(romvec->pv_sun3mem);
156
157 sun3_bootmem_alloc(memory_start, memory_end);
158}
159
Adrian Bunk07b81252008-07-17 21:16:27 +0200160static void __init sun3_sched_init(irq_handler_t timer_routine)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
162 sun3_disable_interrupts();
163 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
164 intersil_clock->int_reg=INTERSIL_HZ_100_MASK;
165 intersil_clear();
166 sun3_enable_irq(5);
167 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE);
168 sun3_enable_interrupts();
169 intersil_clear();
170}
171