blob: 8133b1047353da6665fcf8966b374c6c9bbb6f44 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/kernel.h>
20#include <linux/sched.h>
21#include <linux/delay.h>
22#include <linux/interrupt.h>
23#include <linux/fs.h>
24#include <linux/fb.h>
Greg Ungerere6070a12005-09-02 10:42:52 +100025#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#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#include <linux/init.h>
35
36#include <asm/setup.h>
37#include <asm/irq.h>
38#include <asm/machdep.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <asm/pgtable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Linus Torvalds1da177e2005-04-16 15:20:36 -070041unsigned long memory_start;
42unsigned long memory_end;
43
Greg Ungerere6070a12005-09-02 10:42:52 +100044EXPORT_SYMBOL(memory_start);
45EXPORT_SYMBOL(memory_end);
46
Alon Bar-Levf2a09e12007-02-12 00:54:14 -080047char __initdata command_line[COMMAND_LINE_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49/* setup some dummy routines */
50static void dummy_waitbut(void)
51{
52}
53
Greg Ungerer1ed35e02007-03-07 11:28:13 +100054void (*mach_sched_init) (irq_handler_t handler);
Greg Ungerer7877d012006-06-26 10:33:10 +100055void (*mach_tick)( void );
Linus Torvalds1da177e2005-04-16 15:20:36 -070056/* machine dependent keyboard functions */
Greg Ungerer7877d012006-06-26 10:33:10 +100057int (*mach_keyb_init) (void);
58int (*mach_kbdrate) (struct kbd_repeat *);
59void (*mach_kbd_leds) (unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060/* machine dependent irq functions */
Greg Ungerer7877d012006-06-26 10:33:10 +100061void (*mach_init_IRQ) (void);
Greg Ungererace5f1d2006-11-20 15:46:22 +100062irq_handler_t mach_default_handler;
Greg Ungerer7877d012006-06-26 10:33:10 +100063int (*mach_get_irq_list) (struct seq_file *, void *);
64void (*mach_process_int) (int irq, struct pt_regs *fp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065void (*mach_trap_init) (void);
66/* machine dependent timer functions */
Greg Ungerer7877d012006-06-26 10:33:10 +100067unsigned long (*mach_gettimeoffset) (void);
68void (*mach_gettod) (int*, int*, int*, int*, int*, int*);
Greg Ungerer1ed35e02007-03-07 11:28:13 +100069int (*mach_hwclk) (int, struct rtc_time*);
Greg Ungerer7877d012006-06-26 10:33:10 +100070int (*mach_set_clock_mmss) (unsigned long);
71void (*mach_mksound)( unsigned int count, unsigned int ticks );
72void (*mach_reset)( void );
Linus Torvalds1da177e2005-04-16 15:20:36 -070073void (*waitbut)(void) = dummy_waitbut;
Greg Ungerer7877d012006-06-26 10:33:10 +100074void (*mach_debug_init)(void);
75void (*mach_halt)( void );
76void (*mach_power_off)( void );
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78
79#ifdef CONFIG_M68000
80 #define CPU "MC68000"
81#endif
82#ifdef CONFIG_M68328
83 #define CPU "MC68328"
84#endif
85#ifdef CONFIG_M68EZ328
86 #define CPU "MC68EZ328"
87#endif
88#ifdef CONFIG_M68VZ328
89 #define CPU "MC68VZ328"
90#endif
91#ifdef CONFIG_M68332
92 #define CPU "MC68332"
93#endif
94#ifdef CONFIG_M68360
95 #define CPU "MC68360"
96#endif
97#if defined(CONFIG_M5206)
98 #define CPU "COLDFIRE(m5206)"
99#endif
100#if defined(CONFIG_M5206e)
101 #define CPU "COLDFIRE(m5206e)"
102#endif
Greg Ungerer54b03d12005-11-07 14:09:50 +1000103#if defined(CONFIG_M520x)
104 #define CPU "COLDFIRE(m520x)"
105#endif
Greg Ungerere6070a12005-09-02 10:42:52 +1000106#if defined(CONFIG_M523x)
107 #define CPU "COLDFIRE(m523x)"
108#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#if defined(CONFIG_M5249)
110 #define CPU "COLDFIRE(m5249)"
111#endif
Greg Ungerere6070a12005-09-02 10:42:52 +1000112#if defined(CONFIG_M5271)
113 #define CPU "COLDFIRE(m5270/5271)"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114#endif
115#if defined(CONFIG_M5272)
116 #define CPU "COLDFIRE(m5272)"
117#endif
Greg Ungerere6070a12005-09-02 10:42:52 +1000118#if defined(CONFIG_M5275)
119 #define CPU "COLDFIRE(m5274/5275)"
120#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#if defined(CONFIG_M528x)
122 #define CPU "COLDFIRE(m5280/5282)"
123#endif
124#if defined(CONFIG_M5307)
125 #define CPU "COLDFIRE(m5307)"
126#endif
Greg Ungerer7877d012006-06-26 10:33:10 +1000127#if defined(CONFIG_M532x)
128 #define CPU "COLDFIRE(m532x)"
129#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130#if defined(CONFIG_M5407)
131 #define CPU "COLDFIRE(m5407)"
132#endif
133#ifndef CPU
Greg Ungerer54b03d12005-11-07 14:09:50 +1000134 #define CPU "UNKNOWN"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#endif
136
137/* (es) */
138/* note: why is this defined here? the must be a better place to put this */
139#if defined( CONFIG_TELOS) || defined( CONFIG_UCDIMM ) || defined( CONFIG_UCSIMM ) || defined(CONFIG_DRAGEN2) || (defined( CONFIG_PILOT ) && defined( CONFIG_M68328 ))
140#define CAT_ROMARRAY
141#endif
142/* (/es) */
143
144extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
145extern int _ramstart, _ramend;
146
147void setup_arch(char **cmdline_p)
148{
149 int bootmap_size;
150
151#if defined(CAT_ROMARRAY) && defined(DEBUG)
152 extern int __data_rom_start;
153 extern int __data_start;
154 int *romarray = (int *)((int) &__data_rom_start +
155 (int)&_edata - (int)&__data_start);
156#endif
157
158 memory_start = PAGE_ALIGN(_ramstart);
159 memory_end = _ramend; /* by now the stack is part of the init task */
160
161 init_mm.start_code = (unsigned long) &_stext;
162 init_mm.end_code = (unsigned long) &_etext;
163 init_mm.end_data = (unsigned long) &_edata;
Greg Ungerere6070a12005-09-02 10:42:52 +1000164 init_mm.brk = (unsigned long) 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
166 config_BSP(&command_line[0], sizeof(command_line));
167
168 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n");
169
170#ifdef CONFIG_UCDIMM
171 printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
172#endif
173#ifdef CONFIG_M68VZ328
174 printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
175#endif
176#ifdef CONFIG_COLDFIRE
177 printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
178#ifdef CONFIG_M5307
179 printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
180#endif
181#ifdef CONFIG_ELITE
182 printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
Greg Ungerere6070a12005-09-02 10:42:52 +1000183#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184#ifdef CONFIG_TELOS
185 printk(KERN_INFO "Modified for Omnia ToolVox by James D. Schettine, james@telos-systems.com\n");
186#endif
187#endif
188 printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
189
190#if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
191 printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
192#endif
193
194#if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
195 printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
196#endif
197
198#ifdef CONFIG_M68EZ328ADS
199 printk(KERN_INFO "M68EZ328ADS board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
200#endif
201
202#ifdef CONFIG_ALMA_ANS
203 printk(KERN_INFO "Alma Electronics board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
204#endif
205#if defined (CONFIG_M68360)
206 printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
207 printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
208#endif
209#ifdef CONFIG_DRAGEN2
210 printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
211#endif
Greg Ungerere6070a12005-09-02 10:42:52 +1000212#ifdef CONFIG_M5235EVB
213 printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)");
214#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216#ifdef DEBUG
217 printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
218 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
219 (int) &_sdata, (int) &_edata,
220 (int) &_sbss, (int) &_ebss);
221 printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
222 "STACK=0x%06x-0x%06x\n",
223#ifdef CAT_ROMARRAY
224 (int) romarray, ((int) romarray) + romarray[2],
225#else
226 (int) &_ebss, (int) memory_start,
227#endif
228 (int) memory_start, (int) memory_end,
229 (int) memory_end, (int) _ramend);
230#endif
231
232 /* Keep a copy of command line */
233 *cmdline_p = &command_line[0];
Alon Bar-Levf2a09e12007-02-12 00:54:14 -0800234 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
235 boot_command_line[COMMAND_LINE_SIZE-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237#ifdef DEBUG
Greg Ungerere6070a12005-09-02 10:42:52 +1000238 if (strlen(*cmdline_p))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
240#endif
241
242#if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
243 conswitchp = &dummy_con;
244#endif
245
246 /*
247 * Give all the memory to the bootmap allocator, tell it to put the
248 * boot mem_map at the start of memory.
249 */
250 bootmap_size = init_bootmem_node(
251 NODE_DATA(0),
252 memory_start >> PAGE_SHIFT, /* map goes here */
253 PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
254 memory_end >> PAGE_SHIFT);
255 /*
256 * Free the usable memory, we have to make sure we do not free
257 * the bootmem bitmap so we then reserve it after freeing it :-)
258 */
259 free_bootmem(memory_start, memory_end - memory_start);
260 reserve_bootmem(memory_start, bootmap_size);
261
262 /*
263 * Get kmalloc into gear.
264 */
265 paging_init();
266}
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268/*
269 * Get CPU information for use by the procfs.
270 */
271
272static int show_cpuinfo(struct seq_file *m, void *v)
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 seq_printf(m, "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 return 0;
299}
300
301static void *c_start(struct seq_file *m, loff_t *pos)
302{
303 return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
304}
305
306static void *c_next(struct seq_file *m, void *v, loff_t *pos)
307{
308 ++*pos;
309 return c_start(m, pos);
310}
311
312static void c_stop(struct seq_file *m, void *v)
313{
314}
315
316struct seq_operations cpuinfo_op = {
317 .start = c_start,
318 .next = c_next,
319 .stop = c_stop,
320 .show = show_cpuinfo,
321};
322
323void arch_gettod(int *year, int *mon, int *day, int *hour,
324 int *min, int *sec)
325{
326 if (mach_gettod)
327 mach_gettod(year, mon, day, hour, min, sec);
328 else
329 *year = *mon = *day = *hour = *min = *sec = 0;
330}
331