blob: b2355eb0a412fad3fd34884109b622ad80377e40 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/m68knommu/kernel/setup.c
3 *
Greg Ungerer2f75d102007-07-15 23:38:33 -07004 * Copyright (C) 1999-2007 Greg Ungerer (gerg@snapgear.com)
5 * Copyright (C) 1998,1999 D. Jeff Dionne <jeff@uClinux.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * 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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/fb.h>
Greg Ungerere6070a12005-09-02 10:42:52 +100024#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/console.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/errno.h>
27#include <linux/string.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/bootmem.h>
29#include <linux/seq_file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/init.h>
31
32#include <asm/setup.h>
33#include <asm/irq.h>
34#include <asm/machdep.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <asm/pgtable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037unsigned long memory_start;
38unsigned long memory_end;
39
Greg Ungerere6070a12005-09-02 10:42:52 +100040EXPORT_SYMBOL(memory_start);
41EXPORT_SYMBOL(memory_end);
42
Alon Bar-Levf2a09e12007-02-12 00:54:14 -080043char __initdata command_line[COMMAND_LINE_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Linus Torvalds1da177e2005-04-16 15:20:36 -070045/* machine dependent timer functions */
Greg Ungerer2f75d102007-07-15 23:38:33 -070046void (*mach_sched_init)(irq_handler_t handler);
47void (*mach_tick)(void);
48void (*mach_gettod)(int*, int*, int*, int*, int*, int*);
49int (*mach_set_clock_mmss)(unsigned long);
50unsigned long (*mach_gettimeoffset)(void);
51
52/* machine dependent reboot functions */
53void (*mach_reset)(void);
54void (*mach_halt)(void);
55void (*mach_power_off)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57
58#ifdef CONFIG_M68000
59 #define CPU "MC68000"
60#endif
61#ifdef CONFIG_M68328
62 #define CPU "MC68328"
63#endif
64#ifdef CONFIG_M68EZ328
65 #define CPU "MC68EZ328"
66#endif
67#ifdef CONFIG_M68VZ328
68 #define CPU "MC68VZ328"
69#endif
70#ifdef CONFIG_M68332
71 #define CPU "MC68332"
72#endif
73#ifdef CONFIG_M68360
74 #define CPU "MC68360"
75#endif
76#if defined(CONFIG_M5206)
77 #define CPU "COLDFIRE(m5206)"
78#endif
79#if defined(CONFIG_M5206e)
80 #define CPU "COLDFIRE(m5206e)"
81#endif
Greg Ungerer54b03d12005-11-07 14:09:50 +100082#if defined(CONFIG_M520x)
83 #define CPU "COLDFIRE(m520x)"
84#endif
Greg Ungerere6070a12005-09-02 10:42:52 +100085#if defined(CONFIG_M523x)
86 #define CPU "COLDFIRE(m523x)"
87#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#if defined(CONFIG_M5249)
89 #define CPU "COLDFIRE(m5249)"
90#endif
Greg Ungerere6070a12005-09-02 10:42:52 +100091#if defined(CONFIG_M5271)
92 #define CPU "COLDFIRE(m5270/5271)"
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#endif
94#if defined(CONFIG_M5272)
95 #define CPU "COLDFIRE(m5272)"
96#endif
Greg Ungerere6070a12005-09-02 10:42:52 +100097#if defined(CONFIG_M5275)
98 #define CPU "COLDFIRE(m5274/5275)"
99#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#if defined(CONFIG_M528x)
101 #define CPU "COLDFIRE(m5280/5282)"
102#endif
103#if defined(CONFIG_M5307)
104 #define CPU "COLDFIRE(m5307)"
105#endif
Greg Ungerer7877d012006-06-26 10:33:10 +1000106#if defined(CONFIG_M532x)
107 #define CPU "COLDFIRE(m532x)"
108#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#if defined(CONFIG_M5407)
110 #define CPU "COLDFIRE(m5407)"
111#endif
112#ifndef CPU
Greg Ungerer54b03d12005-11-07 14:09:50 +1000113 #define CPU "UNKNOWN"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114#endif
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
117extern int _ramstart, _ramend;
118
119void setup_arch(char **cmdline_p)
120{
121 int bootmap_size;
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 memory_start = PAGE_ALIGN(_ramstart);
Greg Ungerer2f75d102007-07-15 23:38:33 -0700124 memory_end = _ramend;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126 init_mm.start_code = (unsigned long) &_stext;
127 init_mm.end_code = (unsigned long) &_etext;
128 init_mm.end_data = (unsigned long) &_edata;
Greg Ungerere6070a12005-09-02 10:42:52 +1000129 init_mm.brk = (unsigned long) 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
131 config_BSP(&command_line[0], sizeof(command_line));
132
Greg Ungererbc724502007-07-25 22:07:20 +1000133#if defined(CONFIG_BOOTPARAM)
134 strncpy(&command_line[0], CONFIG_BOOTPARAM_STRING, sizeof(command_line));
135 command_line[sizeof(command_line) - 1] = 0;
136#endif
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n");
139
140#ifdef CONFIG_UCDIMM
141 printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
142#endif
143#ifdef CONFIG_M68VZ328
144 printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
145#endif
146#ifdef CONFIG_COLDFIRE
147 printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
148#ifdef CONFIG_M5307
149 printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
150#endif
151#ifdef CONFIG_ELITE
152 printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
Greg Ungerere6070a12005-09-02 10:42:52 +1000153#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#ifdef CONFIG_TELOS
155 printk(KERN_INFO "Modified for Omnia ToolVox by James D. Schettine, james@telos-systems.com\n");
156#endif
157#endif
158 printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
159
160#if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
161 printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
162#endif
163
164#if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
165 printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
166#endif
167
168#ifdef CONFIG_M68EZ328ADS
169 printk(KERN_INFO "M68EZ328ADS board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
170#endif
171
172#ifdef CONFIG_ALMA_ANS
173 printk(KERN_INFO "Alma Electronics board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
174#endif
175#if defined (CONFIG_M68360)
176 printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
177 printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
178#endif
179#ifdef CONFIG_DRAGEN2
180 printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
181#endif
Greg Ungerere6070a12005-09-02 10:42:52 +1000182#ifdef CONFIG_M5235EVB
183 printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)");
184#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186#ifdef DEBUG
187 printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
188 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
189 (int) &_sdata, (int) &_edata,
190 (int) &_sbss, (int) &_ebss);
Greg Ungerer775ecf82007-10-23 14:37:54 +1000191 printk(KERN_DEBUG "MEMORY -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x\n ",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 (int) &_ebss, (int) memory_start,
Greg Ungerer775ecf82007-10-23 14:37:54 +1000193 (int) memory_start, (int) memory_end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#endif
195
196 /* Keep a copy of command line */
197 *cmdline_p = &command_line[0];
Alon Bar-Levf2a09e12007-02-12 00:54:14 -0800198 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
199 boot_command_line[COMMAND_LINE_SIZE-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201#ifdef DEBUG
Greg Ungerere6070a12005-09-02 10:42:52 +1000202 if (strlen(*cmdline_p))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
204#endif
205
206#if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
207 conswitchp = &dummy_con;
208#endif
209
210 /*
211 * Give all the memory to the bootmap allocator, tell it to put the
212 * boot mem_map at the start of memory.
213 */
214 bootmap_size = init_bootmem_node(
215 NODE_DATA(0),
216 memory_start >> PAGE_SHIFT, /* map goes here */
217 PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
218 memory_end >> PAGE_SHIFT);
219 /*
220 * Free the usable memory, we have to make sure we do not free
221 * the bootmem bitmap so we then reserve it after freeing it :-)
222 */
223 free_bootmem(memory_start, memory_end - memory_start);
224 reserve_bootmem(memory_start, bootmap_size);
225
226 /*
227 * Get kmalloc into gear.
228 */
229 paging_init();
230}
231
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232/*
233 * Get CPU information for use by the procfs.
234 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235static int show_cpuinfo(struct seq_file *m, void *v)
236{
Greg Ungerer22982a52007-07-20 00:31:47 -0700237 char *cpu, *mmu, *fpu;
238 u_long clockfreq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239
Greg Ungerer22982a52007-07-20 00:31:47 -0700240 cpu = CPU;
241 mmu = "none";
242 fpu = "none";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244#ifdef CONFIG_COLDFIRE
Greg Ungerer22982a52007-07-20 00:31:47 -0700245 clockfreq = (loops_per_jiffy * HZ) * 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246#else
Greg Ungerer22982a52007-07-20 00:31:47 -0700247 clockfreq = (loops_per_jiffy * HZ) * 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248#endif
249
Greg Ungerer22982a52007-07-20 00:31:47 -0700250 seq_printf(m, "CPU:\t\t%s\n"
251 "MMU:\t\t%s\n"
252 "FPU:\t\t%s\n"
253 "Clocking:\t%lu.%1luMHz\n"
254 "BogoMips:\t%lu.%02lu\n"
255 "Calibration:\t%lu loops\n",
256 cpu, mmu, fpu,
257 clockfreq / 1000000,
258 (clockfreq / 100000) % 10,
259 (loops_per_jiffy * HZ) / 500000,
260 ((loops_per_jiffy * HZ) / 5000) % 100,
261 (loops_per_jiffy * HZ));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
263 return 0;
264}
265
266static void *c_start(struct seq_file *m, loff_t *pos)
267{
268 return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
269}
270
271static void *c_next(struct seq_file *m, void *v, loff_t *pos)
272{
273 ++*pos;
274 return c_start(m, pos);
275}
276
277static void c_stop(struct seq_file *m, void *v)
278{
279}
280
281struct seq_operations cpuinfo_op = {
282 .start = c_start,
283 .next = c_next,
284 .stop = c_stop,
285 .show = show_cpuinfo,
286};
287
288void arch_gettod(int *year, int *mon, int *day, int *hour,
289 int *min, int *sec)
290{
291 if (mach_gettod)
292 mach_gettod(year, mon, day, hour, min, sec);
293 else
294 *year = *mon = *day = *hour = *min = *sec = 0;
295}
296