ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / kernel / setup.c
1 /*
2  *  linux/arch/m68knommu/kernel/setup.c
3  *
4  *  Copyright (C) 1999-2002  Greg Ungerer (gerg@snapgear.com)
5  *  Copyright (C) 1998,1999  D. Jeff Dionne <jeff@lineo.ca>
6  *  Copyleft  ()) 2000       James D. Schettine {james@telos-systems.com}
7  *  Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
8  *  Copyright (C) 1995       Hamish Macdonald
9  *  Copyright (C) 2000       Lineo Inc. (www.lineo.com) 
10  *  Copyright (C) 2001       Lineo, Inc. <www.lineo.com>
11  *
12  *  68VZ328 Fixes/support    Evan Stawnyczy <e@lineo.ca>
13  */
14
15 /*
16  * This file handles the architecture-dependent parts of system setup
17  */
18
19 #include <linux/config.h>
20 #include <linux/kernel.h>
21 #include <linux/sched.h>
22 #include <linux/delay.h>
23 #include <linux/interrupt.h>
24 #include <linux/fs.h>
25 #include <linux/fb.h>
26 #include <linux/console.h>
27 #include <linux/genhd.h>
28 #include <linux/errno.h>
29 #include <linux/string.h>
30 #include <linux/major.h>
31 #include <linux/bootmem.h>
32 #include <linux/seq_file.h>
33 #include <linux/root_dev.h>
34
35 #include <asm/setup.h>
36 #include <asm/irq.h>
37 #include <asm/machdep.h>
38
39 #ifdef CONFIG_BLK_DEV_INITRD
40 #include <asm/pgtable.h>
41 #endif
42
43 unsigned long rom_length;
44 unsigned long memory_start;
45 unsigned long memory_end;
46
47 char command_line[512];
48 char saved_command_line[512];
49
50 /* setup some dummy routines */
51 static void dummy_waitbut(void)
52 {
53 }
54
55 void (*mach_sched_init) (irqreturn_t (*handler)(int, void *, struct pt_regs *)) = NULL;
56 void (*mach_tick)( void ) = NULL;
57 /* machine dependent keyboard functions */
58 int (*mach_keyb_init) (void) = NULL;
59 int (*mach_kbdrate) (struct kbd_repeat *) = NULL;
60 void (*mach_kbd_leds) (unsigned int) = NULL;
61 /* machine dependent irq functions */
62 void (*mach_init_IRQ) (void) = NULL;
63 irqreturn_t (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL;
64 void (*mach_enable_irq) (unsigned int) = NULL;
65 void (*mach_disable_irq) (unsigned int) = NULL;
66 int (*mach_get_irq_list) (struct seq_file *, void *) = NULL;
67 void (*mach_process_int) (int irq, struct pt_regs *fp) = NULL;
68 void (*mach_trap_init) (void);
69 /* machine dependent timer functions */
70 unsigned long (*mach_gettimeoffset) (void) = NULL;
71 void (*mach_gettod) (int*, int*, int*, int*, int*, int*) = NULL;
72 int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
73 int (*mach_set_clock_mmss) (unsigned long) = NULL;
74 void (*mach_mksound)( unsigned int count, unsigned int ticks ) = NULL;
75 void (*mach_reset)( void ) = NULL;
76 void (*waitbut)(void) = dummy_waitbut;
77 void (*mach_debug_init)(void) = NULL;
78 void (*mach_halt)( void ) = NULL;
79 void (*mach_power_off)( void ) = NULL;
80
81
82 #ifdef CONFIG_M68000
83         #define CPU "MC68000"
84 #endif
85 #ifdef CONFIG_M68328
86         #define CPU "MC68328"
87 #endif
88 #ifdef CONFIG_M68EZ328
89         #define CPU "MC68EZ328"
90 #endif
91 #ifdef CONFIG_M68VZ328
92         #define CPU "MC68VZ328"
93 #endif
94 #ifdef CONFIG_M68332
95         #define CPU "MC68332"
96 #endif
97 #ifdef CONFIG_M68360
98         #define CPU "MC68360"
99 #endif
100 #if defined(CONFIG_M5206)
101         #define CPU "COLDFIRE(m5206)"
102 #endif
103 #if defined(CONFIG_M5206e)
104         #define CPU "COLDFIRE(m5206e)"
105 #endif
106 #if defined(CONFIG_M5249)
107         #define CPU "COLDFIRE(m5249)"
108 #endif
109 #if defined(CONFIG_M5272)
110         #define CPU "COLDFIRE(m5272)"
111 #endif
112 #if defined(CONFIG_M5282)
113         #define CPU "COLDFIRE(m5282)"
114 #endif
115 #if defined(CONFIG_M5307)
116         #define CPU "COLDFIRE(m5307)"
117 #endif
118 #if defined(CONFIG_M5407)
119         #define CPU "COLDFIRE(m5407)"
120 #endif
121 #ifndef CPU
122         #define CPU "UNKOWN"
123 #endif
124
125 /* (es) */
126 /* note: why is this defined here?  the must be a better place to put this */
127 #if defined( CONFIG_TELOS) || defined( CONFIG_UCDIMM ) || defined( CONFIG_UCSIMM ) || defined(CONFIG_DRAGEN2) || (defined( CONFIG_PILOT ) && defined( CONFIG_M68328 ))
128 #define CAT_ROMARRAY
129 #endif
130 /* (/es) */
131
132 extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
133 extern int _ramstart, _ramend;
134
135 void setup_arch(char **cmdline_p)
136 {
137         int bootmap_size;
138
139 #if defined(CAT_ROMARRAY) && defined(DEBUG)
140         extern int __data_rom_start;
141         extern int __data_start;
142         int *romarray = (int *)((int) &__data_rom_start +
143                               (int)&_edata - (int)&__data_start);
144 #endif
145
146         memory_start = PAGE_ALIGN(_ramstart);
147         memory_end = _ramend; /* by now the stack is part of the init task */
148
149         init_mm.start_code = (unsigned long) &_stext;
150         init_mm.end_code = (unsigned long) &_etext;
151         init_mm.end_data = (unsigned long) &_edata;
152         init_mm.brk = (unsigned long) 0; 
153
154         config_BSP(&command_line[0], sizeof(command_line));
155
156         printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n");
157
158 #ifdef CONFIG_UCDIMM
159         printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
160 #endif
161 #ifdef CONFIG_M68VZ328
162         printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
163 #endif
164 #ifdef CONFIG_COLDFIRE
165         printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
166 #ifdef CONFIG_M5307
167         printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
168 #endif
169 #ifdef CONFIG_ELITE
170         printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
171 #endif  
172 #ifdef CONFIG_TELOS
173         printk(KERN_INFO "Modified for Omnia ToolVox by James D. Schettine, james@telos-systems.com\n");
174 #endif
175 #endif
176         printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
177
178 #if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
179         printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
180 #endif
181
182 #if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
183         printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
184 #endif
185
186 #ifdef CONFIG_M68EZ328ADS
187         printk(KERN_INFO "M68EZ328ADS board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
188 #endif
189
190 #ifdef CONFIG_ALMA_ANS
191         printk(KERN_INFO "Alma Electronics board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
192 #endif
193 #if defined (CONFIG_M68360)
194         printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
195         printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
196 #endif
197 #ifdef CONFIG_DRAGEN2
198         printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
199 #endif
200
201 #ifdef DEBUG
202         printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
203                 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
204                 (int) &_sdata, (int) &_edata,
205                 (int) &_sbss, (int) &_ebss);
206         printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
207                 "STACK=0x%06x-0x%06x\n",
208 #ifdef CAT_ROMARRAY
209                 (int) romarray, ((int) romarray) + romarray[2],
210 #else
211                 (int) &_ebss, (int) memory_start,
212 #endif
213                 (int) memory_start, (int) memory_end,
214                 (int) memory_end, (int) _ramend);
215 #endif
216
217         /* Keep a copy of command line */
218         *cmdline_p = &command_line[0];
219         memcpy(saved_command_line, command_line, sizeof(saved_command_line));
220         saved_command_line[sizeof(saved_command_line)-1] = 0;
221
222 #ifdef DEBUG
223         if (strlen(*cmdline_p)) 
224                 printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
225 #endif
226
227 #if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
228         conswitchp = &dummy_con;
229 #endif
230
231         /*
232          * Give all the memory to the bootmap allocator, tell it to put the
233          * boot mem_map at the start of memory.
234          */
235         bootmap_size = init_bootmem_node(
236                         NODE_DATA(0),
237                         memory_start >> PAGE_SHIFT, /* map goes here */
238                         PAGE_OFFSET >> PAGE_SHIFT,      /* 0 on coldfire */
239                         memory_end >> PAGE_SHIFT);
240         /*
241          * Free the usable memory, we have to make sure we do not free
242          * the bootmem bitmap so we then reserve it after freeing it :-)
243          */
244         free_bootmem(memory_start, memory_end - memory_start);
245         reserve_bootmem(memory_start, bootmap_size);
246
247         /*
248          * Get kmalloc into gear.
249          */
250         paging_init();
251 }
252
253 int get_cpuinfo(char * buffer)
254 {
255     char *cpu, *mmu, *fpu;
256     u_long clockfreq;
257
258     cpu = CPU;
259     mmu = "none";
260     fpu = "none";
261
262 #ifdef CONFIG_COLDFIRE
263     clockfreq = (loops_per_jiffy*HZ)*3;
264 #else
265     clockfreq = (loops_per_jiffy*HZ)*16;
266 #endif
267
268     return(sprintf(buffer, "CPU:\t\t%s\n"
269                    "MMU:\t\t%s\n"
270                    "FPU:\t\t%s\n"
271                    "Clocking:\t%lu.%1luMHz\n"
272                    "BogoMips:\t%lu.%02lu\n"
273                    "Calibration:\t%lu loops\n",
274                    cpu, mmu, fpu,
275                    clockfreq/1000000,(clockfreq/100000)%10,
276                    (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
277                    (loops_per_jiffy*HZ)));
278
279 }
280
281 /*
282  *      Get CPU information for use by the procfs.
283  */
284
285 static int show_cpuinfo(struct seq_file *m, void *v)
286 {
287     char *cpu, *mmu, *fpu;
288     u_long clockfreq;
289
290     cpu = CPU;
291     mmu = "none";
292     fpu = "none";
293
294 #ifdef CONFIG_COLDFIRE
295     clockfreq = (loops_per_jiffy*HZ)*3;
296 #else
297     clockfreq = (loops_per_jiffy*HZ)*16;
298 #endif
299
300     seq_printf(m, "CPU:\t\t%s\n"
301                    "MMU:\t\t%s\n"
302                    "FPU:\t\t%s\n"
303                    "Clocking:\t%lu.%1luMHz\n"
304                    "BogoMips:\t%lu.%02lu\n"
305                    "Calibration:\t%lu loops\n",
306                    cpu, mmu, fpu,
307                    clockfreq/1000000,(clockfreq/100000)%10,
308                    (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
309                    (loops_per_jiffy*HZ));
310
311         return 0;
312 }
313
314 static void *c_start(struct seq_file *m, loff_t *pos)
315 {
316         return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
317 }
318
319 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
320 {
321         ++*pos;
322         return c_start(m, pos);
323 }
324
325 static void c_stop(struct seq_file *m, void *v)
326 {
327 }
328
329 struct seq_operations cpuinfo_op = {
330         .start  = c_start,
331         .next   = c_next,
332         .stop   = c_stop,
333         .show   = show_cpuinfo,
334 };
335
336 void arch_gettod(int *year, int *mon, int *day, int *hour,
337                  int *min, int *sec)
338 {
339         if (mach_gettod)
340                 mach_gettod(year, mon, day, hour, min, sec);
341         else
342                 *year = *mon = *day = *hour = *min = *sec = 0;
343 }
344