Linux-2.6.12-rc2
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / m68k / sun3 / config.c
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/config.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/mm.h>
15 #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>
25 #include <asm/sun3-head.h>
26 #include <asm/sun3mmu.h>
27 #include <asm/rtc.h>
28 #include <asm/machdep.h>
29 #include <asm/intersil.h>
30 #include <asm/irq.h>
31 #include <asm/segment.h>
32 #include <asm/sun3ints.h>
33
34 extern char _text, _end;
35
36 char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
37
38 extern unsigned long sun3_gettimeoffset(void);
39 extern int show_sun3_interrupts (struct seq_file *, void *);
40 extern void sun3_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
41 extern void sun3_get_model (char* model);
42 extern void idprom_init (void);
43 extern int sun3_hwclk(int set, struct rtc_time *t);
44
45 volatile char* clock_va;
46 extern volatile unsigned char* sun3_intreg;
47 extern unsigned long availmem;
48 unsigned long num_pages;
49
50 static int sun3_get_hardware_list(char *buffer)
51 {
52
53 int len = 0;
54
55 len += sprintf(buffer + len, "PROM Revision:\t%s\n",
56 romvec->pv_monid);
57
58 return len;
59
60 }
61
62 void __init sun3_init(void)
63 {
64 unsigned char enable_register;
65 int i;
66
67 m68k_machtype= MACH_SUN3;
68 m68k_cputype = CPU_68020;
69 m68k_fputype = FPU_68881; /* mc68881 actually */
70 m68k_mmutype = MMU_SUN3;
71 clock_va = (char *) 0xfe06000; /* dark */
72 sun3_intreg = (unsigned char *) 0xfe0a000; /* magic */
73 sun3_disable_interrupts();
74
75 prom_init((void *)LINUX_OPPROM_BEGVM);
76
77 GET_CONTROL_BYTE(AC_SENABLE,enable_register);
78 enable_register |= 0x50; /* Enable FPU */
79 SET_CONTROL_BYTE(AC_SENABLE,enable_register);
80 GET_CONTROL_BYTE(AC_SENABLE,enable_register);
81
82 /* This code looks suspicious, because it doesn't subtract
83 memory belonging to the kernel from the available space */
84
85
86 memset(sun3_reserved_pmeg, 0, sizeof(sun3_reserved_pmeg));
87
88 /* Reserve important PMEGS */
89 /* FIXME: These should be probed instead of hardcoded */
90
91 for (i=0; i<8; i++) /* Kernel PMEGs */
92 sun3_reserved_pmeg[i] = 1;
93
94 sun3_reserved_pmeg[247] = 1; /* ROM mapping */
95 sun3_reserved_pmeg[248] = 1; /* AMD Ethernet */
96 sun3_reserved_pmeg[251] = 1; /* VB area */
97 sun3_reserved_pmeg[254] = 1; /* main I/O */
98
99 sun3_reserved_pmeg[249] = 1;
100 sun3_reserved_pmeg[252] = 1;
101 sun3_reserved_pmeg[253] = 1;
102 set_fs(KERNEL_DS);
103 }
104
105 /* Without this, Bad Things happen when something calls arch_reset. */
106 static void sun3_reboot (void)
107 {
108 prom_reboot ("vmlinux");
109 }
110
111 static void sun3_halt (void)
112 {
113 prom_halt ();
114 }
115
116 /* sun3 bootmem allocation */
117
118 void __init sun3_bootmem_alloc(unsigned long memory_start, unsigned long memory_end)
119 {
120 unsigned long start_page;
121
122 /* align start/end to page boundaries */
123 memory_start = ((memory_start + (PAGE_SIZE-1)) & PAGE_MASK);
124 memory_end = memory_end & PAGE_MASK;
125
126 start_page = __pa(memory_start) >> PAGE_SHIFT;
127 num_pages = __pa(memory_end) >> PAGE_SHIFT;
128
129 high_memory = (void *)memory_end;
130 availmem = memory_start;
131
132 availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages);
133 availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
134
135 free_bootmem(__pa(availmem), memory_end - (availmem));
136 }
137
138
139 void __init config_sun3(void)
140 {
141 unsigned long memory_start, memory_end;
142
143 printk("ARCH: SUN3\n");
144 idprom_init();
145
146 /* Subtract kernel memory from available memory */
147
148 mach_sched_init = sun3_sched_init;
149 mach_init_IRQ = sun3_init_IRQ;
150 mach_default_handler = &sun3_default_handler;
151 mach_request_irq = sun3_request_irq;
152 mach_free_irq = sun3_free_irq;
153 enable_irq = sun3_enable_irq;
154 disable_irq = sun3_disable_irq;
155 mach_process_int = sun3_process_int;
156 mach_get_irq_list = show_sun3_interrupts;
157 mach_reset = sun3_reboot;
158 mach_gettimeoffset = sun3_gettimeoffset;
159 mach_get_model = sun3_get_model;
160 mach_hwclk = sun3_hwclk;
161 mach_halt = sun3_halt;
162 mach_get_hardware_list = sun3_get_hardware_list;
163 #if defined(CONFIG_DUMMY_CONSOLE)
164 conswitchp = &dummy_con;
165 #endif
166
167 memory_start = ((((int)&_end) + 0x2000) & ~0x1fff);
168 // PROM seems to want the last couple of physical pages. --m
169 memory_end = *(romvec->pv_sun3mem) + PAGE_OFFSET - 2*PAGE_SIZE;
170
171 m68k_num_memory=1;
172 m68k_memory[0].size=*(romvec->pv_sun3mem);
173
174 sun3_bootmem_alloc(memory_start, memory_end);
175 }
176
177 void __init sun3_sched_init(irqreturn_t (*timer_routine)(int, void *, struct pt_regs *))
178 {
179 sun3_disable_interrupts();
180 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
181 intersil_clock->int_reg=INTERSIL_HZ_100_MASK;
182 intersil_clear();
183 sun3_enable_irq(5);
184 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_ENABLE|INTERSIL_24H_MODE);
185 sun3_enable_interrupts();
186 intersil_clear();
187 }
188