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