Merge branch 'clksrc/cleanup' into next/multiplatform
[cascardo/linux.git] / arch / m68k / kernel / setup_no.c
1 /*
2  *  linux/arch/m68knommu/kernel/setup.c
3  *
4  *  Copyright (C) 1999-2007  Greg Ungerer (gerg@snapgear.com)
5  *  Copyright (C) 1998,1999  D. Jeff Dionne <jeff@uClinux.org>
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/kernel.h>
20 #include <linux/sched.h>
21 #include <linux/delay.h>
22 #include <linux/interrupt.h>
23 #include <linux/fb.h>
24 #include <linux/module.h>
25 #include <linux/mm.h>
26 #include <linux/console.h>
27 #include <linux/errno.h>
28 #include <linux/string.h>
29 #include <linux/bootmem.h>
30 #include <linux/seq_file.h>
31 #include <linux/init.h>
32 #include <linux/initrd.h>
33 #include <linux/root_dev.h>
34 #include <linux/rtc.h>
35
36 #include <asm/setup.h>
37 #include <asm/irq.h>
38 #include <asm/machdep.h>
39 #include <asm/pgtable.h>
40 #include <asm/sections.h>
41
42 unsigned long memory_start;
43 unsigned long memory_end;
44
45 EXPORT_SYMBOL(memory_start);
46 EXPORT_SYMBOL(memory_end);
47
48 char __initdata command_line[COMMAND_LINE_SIZE];
49
50 /* machine dependent timer functions */
51 void (*mach_sched_init)(irq_handler_t handler) __initdata = NULL;
52 int (*mach_set_clock_mmss)(unsigned long);
53 int (*mach_hwclk) (int, struct rtc_time*);
54
55 /* machine dependent reboot functions */
56 void (*mach_reset)(void);
57 void (*mach_halt)(void);
58 void (*mach_power_off)(void);
59
60 #ifdef CONFIG_M68000
61 #define CPU_NAME        "MC68000"
62 #endif
63 #ifdef CONFIG_M68328
64 #define CPU_NAME        "MC68328"
65 #endif
66 #ifdef CONFIG_M68EZ328
67 #define CPU_NAME        "MC68EZ328"
68 #endif
69 #ifdef CONFIG_M68VZ328
70 #define CPU_NAME        "MC68VZ328"
71 #endif
72 #ifdef CONFIG_M68360
73 #define CPU_NAME        "MC68360"
74 #endif
75 #ifndef CPU_NAME
76 #define CPU_NAME        "UNKNOWN"
77 #endif
78
79 /*
80  * Different cores have different instruction execution timings.
81  * The old/traditional 68000 cores are basically all the same, at 16.
82  * The ColdFire cores vary a little, their values are defined in their
83  * headers. We default to the standard 68000 value here.
84  */
85 #ifndef CPU_INSTR_PER_JIFFY
86 #define CPU_INSTR_PER_JIFFY     16
87 #endif
88
89 #if defined(CONFIG_UBOOT)
90 /*
91  * parse_uboot_commandline
92  *
93  * Copies u-boot commandline arguments and store them in the proper linux
94  * variables.
95  *
96  * Assumes:
97  *      _init_sp global contains the address in the stack pointer when the
98  *      kernel starts (see head.S::_start)
99  *
100  *      U-Boot calling convention:
101  *      (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
102  *
103  *      _init_sp can be parsed as such
104  *
105  *      _init_sp+00 = u-boot cmd after jsr into kernel (skip)
106  *      _init_sp+04 = &kernel board_info (residual data)
107  *      _init_sp+08 = &initrd_start
108  *      _init_sp+12 = &initrd_end
109  *      _init_sp+16 = &cmd_start
110  *      _init_sp+20 = &cmd_end
111  *
112  *      This also assumes that the memory locations pointed to are still
113  *      unmodified. U-boot places them near the end of external SDRAM.
114  *
115  * Argument(s):
116  *      commandp = the linux commandline arg container to fill.
117  *      size     = the sizeof commandp.
118  *
119  * Returns:
120  */
121 void parse_uboot_commandline(char *commandp, int size)
122 {
123         extern unsigned long _init_sp;
124         unsigned long *sp;
125         unsigned long uboot_kbd;
126         unsigned long uboot_initrd_start, uboot_initrd_end;
127         unsigned long uboot_cmd_start, uboot_cmd_end;
128
129
130         sp = (unsigned long *)_init_sp;
131         uboot_kbd = sp[1];
132         uboot_initrd_start = sp[2];
133         uboot_initrd_end = sp[3];
134         uboot_cmd_start = sp[4];
135         uboot_cmd_end = sp[5];
136
137         if (uboot_cmd_start && uboot_cmd_end)
138                 strncpy(commandp, (const char *)uboot_cmd_start, size);
139 #if defined(CONFIG_BLK_DEV_INITRD)
140         if (uboot_initrd_start && uboot_initrd_end &&
141                 (uboot_initrd_end > uboot_initrd_start)) {
142                 initrd_start = uboot_initrd_start;
143                 initrd_end = uboot_initrd_end;
144                 ROOT_DEV = Root_RAM0;
145                 printk(KERN_INFO "initrd at 0x%lx:0x%lx\n",
146                         initrd_start, initrd_end);
147         }
148 #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
149 }
150 #endif /* #if defined(CONFIG_UBOOT) */
151
152 void __init setup_arch(char **cmdline_p)
153 {
154         int bootmap_size;
155
156         memory_start = PAGE_ALIGN(_ramstart);
157         memory_end = _ramend;
158
159         init_mm.start_code = (unsigned long) &_stext;
160         init_mm.end_code = (unsigned long) &_etext;
161         init_mm.end_data = (unsigned long) &_edata;
162         init_mm.brk = (unsigned long) 0;
163
164         config_BSP(&command_line[0], sizeof(command_line));
165
166 #if defined(CONFIG_BOOTPARAM)
167         strncpy(&command_line[0], CONFIG_BOOTPARAM_STRING, sizeof(command_line));
168         command_line[sizeof(command_line) - 1] = 0;
169 #endif /* CONFIG_BOOTPARAM */
170
171 #if defined(CONFIG_UBOOT)
172         /* CONFIG_UBOOT and CONFIG_BOOTPARAM defined, concatenate cmdline */
173         #if defined(CONFIG_BOOTPARAM)
174                 /* Add the whitespace separator */
175                 command_line[strlen(CONFIG_BOOTPARAM_STRING)] = ' ';
176                 /* Parse uboot command line into the rest of the buffer */
177                 parse_uboot_commandline(
178                         &command_line[(strlen(CONFIG_BOOTPARAM_STRING)+1)],
179                         (sizeof(command_line) -
180                         (strlen(CONFIG_BOOTPARAM_STRING)+1)));
181         /* Only CONFIG_UBOOT defined, create cmdline */
182         #else
183                 parse_uboot_commandline(&command_line[0], sizeof(command_line));
184         #endif /* CONFIG_BOOTPARAM */
185         command_line[sizeof(command_line) - 1] = 0;
186 #endif /* CONFIG_UBOOT */
187
188         printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU_NAME "\n");
189
190 #ifdef CONFIG_UCDIMM
191         printk(KERN_INFO "uCdimm by Lineo, Inc. <www.lineo.com>\n");
192 #endif
193 #ifdef CONFIG_M68VZ328
194         printk(KERN_INFO "M68VZ328 support by Evan Stawnyczy <e@lineo.ca>\n");
195 #endif
196 #ifdef CONFIG_COLDFIRE
197         printk(KERN_INFO "COLDFIRE port done by Greg Ungerer, gerg@snapgear.com\n");
198 #ifdef CONFIG_M5307
199         printk(KERN_INFO "Modified for M5307 by Dave Miller, dmiller@intellistor.com\n");
200 #endif
201 #ifdef CONFIG_ELITE
202         printk(KERN_INFO "Modified for M5206eLITE by Rob Scott, rscott@mtrob.fdns.net\n");
203 #endif
204 #endif
205         printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
206
207 #if defined( CONFIG_PILOT ) && defined( CONFIG_M68328 )
208         printk(KERN_INFO "TRG SuperPilot FLASH card support <info@trgnet.com>\n");
209 #endif
210 #if defined( CONFIG_PILOT ) && defined( CONFIG_M68EZ328 )
211         printk(KERN_INFO "PalmV support by Lineo Inc. <jeff@uclinux.com>\n");
212 #endif
213 #if defined (CONFIG_M68360)
214         printk(KERN_INFO "QUICC port done by SED Systems <hamilton@sedsystems.ca>,\n");
215         printk(KERN_INFO "based on 2.0.38 port by Lineo Inc. <mleslie@lineo.com>.\n");
216 #endif
217 #ifdef CONFIG_DRAGEN2
218         printk(KERN_INFO "DragonEngine II board support by Georges Menie\n");
219 #endif
220 #ifdef CONFIG_M5235EVB
221         printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n");
222 #endif
223
224         pr_debug("KERNEL -> TEXT=0x%p-0x%p DATA=0x%p-0x%p BSS=0x%p-0x%p\n",
225                  _stext, _etext, _sdata, _edata, __bss_start, __bss_stop);
226         pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ",
227                  __bss_stop, memory_start, memory_start, memory_end);
228
229         /* Keep a copy of command line */
230         *cmdline_p = &command_line[0];
231         memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
232         boot_command_line[COMMAND_LINE_SIZE-1] = 0;
233
234 #if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
235         conswitchp = &dummy_con;
236 #endif
237
238         /*
239          * Give all the memory to the bootmap allocator, tell it to put the
240          * boot mem_map at the start of memory.
241          */
242         bootmap_size = init_bootmem_node(
243                         NODE_DATA(0),
244                         memory_start >> PAGE_SHIFT, /* map goes here */
245                         PAGE_OFFSET >> PAGE_SHIFT,      /* 0 on coldfire */
246                         memory_end >> PAGE_SHIFT);
247         /*
248          * Free the usable memory, we have to make sure we do not free
249          * the bootmem bitmap so we then reserve it after freeing it :-)
250          */
251         free_bootmem(memory_start, memory_end - memory_start);
252         reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
253
254 #if defined(CONFIG_UBOOT) && defined(CONFIG_BLK_DEV_INITRD)
255         if ((initrd_start > 0) && (initrd_start < initrd_end) &&
256                         (initrd_end < memory_end))
257                 reserve_bootmem(initrd_start, initrd_end - initrd_start,
258                                  BOOTMEM_DEFAULT);
259 #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
260
261         /*
262          * Get kmalloc into gear.
263          */
264         paging_init();
265 }
266
267 /*
268  *      Get CPU information for use by the procfs.
269  */
270 static int show_cpuinfo(struct seq_file *m, void *v)
271 {
272         char *cpu, *mmu, *fpu;
273         u_long clockfreq;
274
275         cpu = CPU_NAME;
276         mmu = "none";
277         fpu = "none";
278         clockfreq = (loops_per_jiffy * HZ) * CPU_INSTR_PER_JIFFY;
279
280         seq_printf(m, "CPU:\t\t%s\n"
281                       "MMU:\t\t%s\n"
282                       "FPU:\t\t%s\n"
283                       "Clocking:\t%lu.%1luMHz\n"
284                       "BogoMips:\t%lu.%02lu\n"
285                       "Calibration:\t%lu loops\n",
286                       cpu, mmu, fpu,
287                       clockfreq / 1000000,
288                       (clockfreq / 100000) % 10,
289                       (loops_per_jiffy * HZ) / 500000,
290                       ((loops_per_jiffy * HZ) / 5000) % 100,
291                       (loops_per_jiffy * HZ));
292
293         return 0;
294 }
295
296 static void *c_start(struct seq_file *m, loff_t *pos)
297 {
298         return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
299 }
300
301 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
302 {
303         ++*pos;
304         return c_start(m, pos);
305 }
306
307 static void c_stop(struct seq_file *m, void *v)
308 {
309 }
310
311 const struct seq_operations cpuinfo_op = {
312         .start  = c_start,
313         .next   = c_next,
314         .stop   = c_stop,
315         .show   = show_cpuinfo,
316 };
317