blob: a5ac0d40fbec4c83a309b37af115512ca462b93e [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
Greg Ungerer2f75d102007-07-15 23:38:33 -070045void (*mach_trap_init)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047/* machine dependent timer functions */
Greg Ungerer2f75d102007-07-15 23:38:33 -070048void (*mach_sched_init)(irq_handler_t handler);
49void (*mach_tick)(void);
50void (*mach_gettod)(int*, int*, int*, int*, int*, int*);
51int (*mach_set_clock_mmss)(unsigned long);
52unsigned long (*mach_gettimeoffset)(void);
53
54/* machine dependent reboot functions */
55void (*mach_reset)(void);
56void (*mach_halt)(void);
57void (*mach_power_off)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59
60#ifdef CONFIG_M68000
61 #define CPU "MC68000"
62#endif
63#ifdef CONFIG_M68328
64 #define CPU "MC68328"
65#endif
66#ifdef CONFIG_M68EZ328
67 #define CPU "MC68EZ328"
68#endif
69#ifdef CONFIG_M68VZ328
70 #define CPU "MC68VZ328"
71#endif
72#ifdef CONFIG_M68332
73 #define CPU "MC68332"
74#endif
75#ifdef CONFIG_M68360
76 #define CPU "MC68360"
77#endif
78#if defined(CONFIG_M5206)
79 #define CPU "COLDFIRE(m5206)"
80#endif
81#if defined(CONFIG_M5206e)
82 #define CPU "COLDFIRE(m5206e)"
83#endif
Greg Ungerer54b03d12005-11-07 14:09:50 +100084#if defined(CONFIG_M520x)
85 #define CPU "COLDFIRE(m520x)"
86#endif
Greg Ungerere6070a12005-09-02 10:42:52 +100087#if defined(CONFIG_M523x)
88 #define CPU "COLDFIRE(m523x)"
89#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#if defined(CONFIG_M5249)
91 #define CPU "COLDFIRE(m5249)"
92#endif
Greg Ungerere6070a12005-09-02 10:42:52 +100093#if defined(CONFIG_M5271)
94 #define CPU "COLDFIRE(m5270/5271)"
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#endif
96#if defined(CONFIG_M5272)
97 #define CPU "COLDFIRE(m5272)"
98#endif
Greg Ungerere6070a12005-09-02 10:42:52 +100099#if defined(CONFIG_M5275)
100 #define CPU "COLDFIRE(m5274/5275)"
101#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102#if defined(CONFIG_M528x)
103 #define CPU "COLDFIRE(m5280/5282)"
104#endif
105#if defined(CONFIG_M5307)
106 #define CPU "COLDFIRE(m5307)"
107#endif
Greg Ungerer7877d012006-06-26 10:33:10 +1000108#if defined(CONFIG_M532x)
109 #define CPU "COLDFIRE(m532x)"
110#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#if defined(CONFIG_M5407)
112 #define CPU "COLDFIRE(m5407)"
113#endif
114#ifndef CPU
Greg Ungerer54b03d12005-11-07 14:09:50 +1000115 #define CPU "UNKNOWN"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#endif
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
119extern int _ramstart, _ramend;
120
121void setup_arch(char **cmdline_p)
122{
123 int bootmap_size;
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 memory_start = PAGE_ALIGN(_ramstart);
Greg Ungerer2f75d102007-07-15 23:38:33 -0700126 memory_end = _ramend;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 init_mm.start_code = (unsigned long) &_stext;
129 init_mm.end_code = (unsigned long) &_etext;
130 init_mm.end_data = (unsigned long) &_edata;
Greg Ungerere6070a12005-09-02 10:42:52 +1000131 init_mm.brk = (unsigned long) 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133 config_BSP(&command_line[0], sizeof(command_line));
134
Greg Ungererbc724502007-07-25 22:07:20 +1000135#if defined(CONFIG_BOOTPARAM)
136 strncpy(&command_line[0], CONFIG_BOOTPARAM_STRING, sizeof(command_line));
137 command_line[sizeof(command_line) - 1] = 0;
138#endif
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n");
141
142#ifdef CONFIG_UCDIMM
143 printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
144#endif
145#ifdef CONFIG_M68VZ328
146 printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
147#endif
148#ifdef CONFIG_COLDFIRE
149 printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
150#ifdef CONFIG_M5307
151 printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
152#endif
153#ifdef CONFIG_ELITE
154 printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
Greg Ungerere6070a12005-09-02 10:42:52 +1000155#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#ifdef CONFIG_TELOS
157 printk(KERN_INFO "Modified for Omnia ToolVox by James D. Schettine, james@telos-systems.com\n");
158#endif
159#endif
160 printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
161
162#if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
163 printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
164#endif
165
166#if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
167 printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
168#endif
169
170#ifdef CONFIG_M68EZ328ADS
171 printk(KERN_INFO "M68EZ328ADS board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
172#endif
173
174#ifdef CONFIG_ALMA_ANS
175 printk(KERN_INFO "Alma Electronics board support (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>\n");
176#endif
177#if defined (CONFIG_M68360)
178 printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
179 printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
180#endif
181#ifdef CONFIG_DRAGEN2
182 printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
183#endif
Greg Ungerere6070a12005-09-02 10:42:52 +1000184#ifdef CONFIG_M5235EVB
185 printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)");
186#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
188#ifdef DEBUG
189 printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
190 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
191 (int) &_sdata, (int) &_edata,
192 (int) &_sbss, (int) &_ebss);
193 printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
194 "STACK=0x%06x-0x%06x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 (int) &_ebss, (int) memory_start,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 (int) memory_start, (int) memory_end,
197 (int) memory_end, (int) _ramend);
198#endif
199
200 /* Keep a copy of command line */
201 *cmdline_p = &command_line[0];
Alon Bar-Levf2a09e12007-02-12 00:54:14 -0800202 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
203 boot_command_line[COMMAND_LINE_SIZE-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205#ifdef DEBUG
Greg Ungerere6070a12005-09-02 10:42:52 +1000206 if (strlen(*cmdline_p))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
208#endif
209
210#if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
211 conswitchp = &dummy_con;
212#endif
213
214 /*
215 * Give all the memory to the bootmap allocator, tell it to put the
216 * boot mem_map at the start of memory.
217 */
218 bootmap_size = init_bootmem_node(
219 NODE_DATA(0),
220 memory_start >> PAGE_SHIFT, /* map goes here */
221 PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
222 memory_end >> PAGE_SHIFT);
223 /*
224 * Free the usable memory, we have to make sure we do not free
225 * the bootmem bitmap so we then reserve it after freeing it :-)
226 */
227 free_bootmem(memory_start, memory_end - memory_start);
228 reserve_bootmem(memory_start, bootmap_size);
229
230 /*
231 * Get kmalloc into gear.
232 */
233 paging_init();
234}
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236/*
237 * Get CPU information for use by the procfs.
238 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239static int show_cpuinfo(struct seq_file *m, void *v)
240{
Greg Ungerer22982a52007-07-20 00:31:47 -0700241 char *cpu, *mmu, *fpu;
242 u_long clockfreq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
Greg Ungerer22982a52007-07-20 00:31:47 -0700244 cpu = CPU;
245 mmu = "none";
246 fpu = "none";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
248#ifdef CONFIG_COLDFIRE
Greg Ungerer22982a52007-07-20 00:31:47 -0700249 clockfreq = (loops_per_jiffy * HZ) * 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250#else
Greg Ungerer22982a52007-07-20 00:31:47 -0700251 clockfreq = (loops_per_jiffy * HZ) * 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252#endif
253
Greg Ungerer22982a52007-07-20 00:31:47 -0700254 seq_printf(m, "CPU:\t\t%s\n"
255 "MMU:\t\t%s\n"
256 "FPU:\t\t%s\n"
257 "Clocking:\t%lu.%1luMHz\n"
258 "BogoMips:\t%lu.%02lu\n"
259 "Calibration:\t%lu loops\n",
260 cpu, mmu, fpu,
261 clockfreq / 1000000,
262 (clockfreq / 100000) % 10,
263 (loops_per_jiffy * HZ) / 500000,
264 ((loops_per_jiffy * HZ) / 5000) % 100,
265 (loops_per_jiffy * HZ));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
267 return 0;
268}
269
270static void *c_start(struct seq_file *m, loff_t *pos)
271{
272 return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
273}
274
275static void *c_next(struct seq_file *m, void *v, loff_t *pos)
276{
277 ++*pos;
278 return c_start(m, pos);
279}
280
281static void c_stop(struct seq_file *m, void *v)
282{
283}
284
285struct seq_operations cpuinfo_op = {
286 .start = c_start,
287 .next = c_next,
288 .stop = c_stop,
289 .show = show_cpuinfo,
290};
291
292void arch_gettod(int *year, int *mon, int *day, int *hour,
293 int *min, int *sec)
294{
295 if (mach_gettod)
296 mach_gettod(year, mon, day, hour, min, sec);
297 else
298 *year = *mon = *day = *hour = *min = *sec = 0;
299}
300