]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - arch/powerpc/kernel/setup_32.c
powerpc: remove duplicate screen_info from setup_32.c
[mirror_ubuntu-zesty-kernel.git] / arch / powerpc / kernel / setup_32.c
CommitLineData
9b6b563c
PM
1/*
2 * Common prep/pmac/chrp boot and setup code.
3 */
4
5#include <linux/config.h>
6#include <linux/module.h>
7#include <linux/string.h>
8#include <linux/sched.h>
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/reboot.h>
12#include <linux/delay.h>
13#include <linux/initrd.h>
14#include <linux/ide.h>
15#include <linux/tty.h>
16#include <linux/bootmem.h>
17#include <linux/seq_file.h>
18#include <linux/root_dev.h>
19#include <linux/cpu.h>
20#include <linux/console.h>
21
22#include <asm/residual.h>
23#include <asm/io.h>
24#include <asm/prom.h>
25#include <asm/processor.h>
26#include <asm/pgtable.h>
9b6b563c
PM
27#include <asm/setup.h>
28#include <asm/amigappc.h>
29#include <asm/smp.h>
30#include <asm/elf.h>
31#include <asm/cputable.h>
32#include <asm/bootx.h>
33#include <asm/btext.h>
34#include <asm/machdep.h>
35#include <asm/uaccess.h>
36#include <asm/system.h>
37#include <asm/pmac_feature.h>
38#include <asm/sections.h>
39#include <asm/nvram.h>
40#include <asm/xmon.h>
6d7f58b0 41#include <asm/time.h>
9b6b563c 42
03501dab
PM
43#define DBG(fmt...)
44
9b6b563c
PM
45#if defined CONFIG_KGDB
46#include <asm/kgdb.h>
47#endif
48
49extern void platform_init(void);
50extern void bootx_init(unsigned long r4, unsigned long phys);
51
52extern void ppc6xx_idle(void);
53extern void power4_idle(void);
54
55boot_infos_t *boot_infos;
56struct ide_machdep_calls ppc_ide_md;
57
bbd0abda
PM
58/* XXX should go elsewhere */
59int __irq_offset_value;
60EXPORT_SYMBOL(__irq_offset_value);
61
9b6b563c
PM
62unsigned long ISA_DMA_THRESHOLD;
63unsigned int DMA_MODE_READ;
64unsigned int DMA_MODE_WRITE;
65
e574d238
PM
66int have_of = 1;
67
9b6b563c
PM
68#ifdef CONFIG_PPC_MULTIPLATFORM
69int _machine = 0;
70
71extern void prep_init(void);
72extern void pmac_init(void);
73extern void chrp_init(void);
74
75dev_t boot_dev;
76#endif /* CONFIG_PPC_MULTIPLATFORM */
77
78#ifdef CONFIG_MAGIC_SYSRQ
79unsigned long SYSRQ_KEY = 0x54;
80#endif /* CONFIG_MAGIC_SYSRQ */
81
82#ifdef CONFIG_VGA_CONSOLE
83unsigned long vgacon_remap_base;
84#endif
85
86struct machdep_calls ppc_md;
e574d238 87EXPORT_SYMBOL(ppc_md);
9b6b563c
PM
88
89/*
90 * These are used in binfmt_elf.c to put aux entries on the stack
91 * for each elf executable being started.
92 */
93int dcache_bsize;
94int icache_bsize;
95int ucache_bsize;
96
9b6b563c
PM
97/*
98 * We're called here very early in the boot. We determine the machine
99 * type and call the appropriate low-level setup functions.
100 * -- Cort <cort@fsmlabs.com>
101 *
102 * Note that the kernel may be running at an address which is different
103 * from the address that it was linked at, so we must use RELOC/PTRRELOC
104 * to access static data (including strings). -- paulus
105 */
106unsigned long __init early_init(unsigned long dt_ptr)
107{
108 unsigned long offset = reloc_offset();
109
dd184343
PM
110 /* First zero the BSS -- use memset_io, some platforms don't have
111 * caches on yet */
112 memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start);
113
9b6b563c
PM
114 /*
115 * Identify the CPU type and fix up code sections
116 * that depend on which cpu we have.
117 */
118 identify_cpu(offset, 0);
119 do_cpu_ftr_fixups(offset);
120
9b6b563c
PM
121 return KERNELBASE + offset;
122}
123
9b6b563c
PM
124#ifdef CONFIG_PPC_MULTIPLATFORM
125/*
126 * The PPC_MULTIPLATFORM version of platform_init...
127 */
128void __init platform_init(void)
129{
130 /* if we didn't get any bootinfo telling us what we are... */
131 if (_machine == 0) {
132 /* prep boot loader tells us if we're prep or not */
133 if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
134 _machine = _MACH_prep;
135 }
136
137#ifdef CONFIG_PPC_PREP
138 /* not much more to do here, if prep */
139 if (_machine == _MACH_prep) {
140 prep_init();
141 return;
142 }
143#endif
144
145#ifdef CONFIG_ADB
146 if (strstr(cmd_line, "adb_sync")) {
147 extern int __adb_probe_sync;
148 __adb_probe_sync = 1;
149 }
150#endif /* CONFIG_ADB */
151
152 switch (_machine) {
153#ifdef CONFIG_PPC_PMAC
154 case _MACH_Pmac:
155 pmac_init();
156 break;
157#endif
158#ifdef CONFIG_PPC_CHRP
159 case _MACH_chrp:
160 chrp_init();
161 break;
162#endif
163 }
164}
03501dab 165#endif
9b6b563c 166
9b6b563c
PM
167/*
168 * Find out what kind of machine we're on and save any data we need
169 * from the early boot process (devtree is copied on pmac by prom_init()).
170 * This is called very early on the boot process, after a minimal
171 * MMU environment has been set up but before MMU_init is called.
172 */
173void __init machine_init(unsigned long dt_ptr, unsigned long phys)
174{
175 early_init_devtree(__va(dt_ptr));
176
177#ifdef CONFIG_CMDLINE
178 strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
179#endif /* CONFIG_CMDLINE */
180
35499c01
PM
181 platform_init();
182
9b6b563c
PM
183#ifdef CONFIG_6xx
184 ppc_md.power_save = ppc6xx_idle;
185#endif
9b6b563c
PM
186
187 if (ppc_md.progress)
188 ppc_md.progress("id mach(): done", 0x200);
189}
190
191#ifdef CONFIG_BOOKE_WDT
192/* Checks wdt=x and wdt_period=xx command-line option */
193int __init early_parse_wdt(char *p)
194{
195 if (p && strncmp(p, "0", 1) != 0)
196 booke_wdt_enabled = 1;
197
198 return 0;
199}
200early_param("wdt", early_parse_wdt);
201
202int __init early_parse_wdt_period (char *p)
203{
204 if (p)
205 booke_wdt_period = simple_strtoul(p, NULL, 0);
206
207 return 0;
208}
209early_param("wdt_period", early_parse_wdt_period);
210#endif /* CONFIG_BOOKE_WDT */
211
212/* Checks "l2cr=xxxx" command-line option */
213int __init ppc_setup_l2cr(char *str)
214{
215 if (cpu_has_feature(CPU_FTR_L2CR)) {
216 unsigned long val = simple_strtoul(str, NULL, 0);
217 printk(KERN_INFO "l2cr set to %lx\n", val);
218 _set_L2CR(0); /* force invalidate by disable cache */
219 _set_L2CR(val); /* and enable it */
220 }
221 return 1;
222}
223__setup("l2cr=", ppc_setup_l2cr);
224
225#ifdef CONFIG_GENERIC_NVRAM
226
227/* Generic nvram hooks used by drivers/char/gen_nvram.c */
228unsigned char nvram_read_byte(int addr)
229{
230 if (ppc_md.nvram_read_val)
231 return ppc_md.nvram_read_val(addr);
232 return 0xff;
233}
234EXPORT_SYMBOL(nvram_read_byte);
235
236void nvram_write_byte(unsigned char val, int addr)
237{
238 if (ppc_md.nvram_write_val)
239 ppc_md.nvram_write_val(addr, val);
240}
241EXPORT_SYMBOL(nvram_write_byte);
242
243void nvram_sync(void)
244{
245 if (ppc_md.nvram_sync)
246 ppc_md.nvram_sync();
247}
248EXPORT_SYMBOL(nvram_sync);
249
250#endif /* CONFIG_NVRAM */
251
252static struct cpu cpu_devices[NR_CPUS];
253
254int __init ppc_init(void)
255{
256 int i;
257
258 /* clear the progress line */
259 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
260
261 /* register CPU devices */
262 for (i = 0; i < NR_CPUS; i++)
263 if (cpu_possible(i))
264 register_cpu(&cpu_devices[i], i, NULL);
265
266 /* call platform init */
267 if (ppc_md.init != NULL) {
268 ppc_md.init();
269 }
270 return 0;
271}
272
273arch_initcall(ppc_init);
274
275/* Warning, IO base is not yet inited */
276void __init setup_arch(char **cmdline_p)
277{
278 extern char *klimit;
279 extern void do_init_bootmem(void);
280
281 /* so udelay does something sensible, assume <= 1000 bogomips */
282 loops_per_jiffy = 500000000 / HZ;
283
9b6b563c
PM
284 unflatten_device_tree();
285 finish_device_tree();
286
30cd4a4e
PM
287#ifdef CONFIG_BOOTX_TEXT
288 init_boot_display();
289#endif
290
03501dab 291#ifdef CONFIG_PPC_PMAC
9b6b563c
PM
292 /* This could be called "early setup arch", it must be done
293 * now because xmon need it
294 */
295 if (_machine == _MACH_Pmac)
296 pmac_feature_init(); /* New cool way */
297#endif
298
299#ifdef CONFIG_XMON
300 xmon_map_scc();
301 if (strstr(cmd_line, "xmon"))
302 xmon(NULL);
303#endif /* CONFIG_XMON */
304 if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab);
305
306#if defined(CONFIG_KGDB)
307 if (ppc_md.kgdb_map_scc)
308 ppc_md.kgdb_map_scc();
309 set_debug_traps();
310 if (strstr(cmd_line, "gdb")) {
311 if (ppc_md.progress)
312 ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
313 printk("kgdb breakpoint activated\n");
314 breakpoint();
315 }
316#endif
317
318 /*
319 * Set cache line size based on type of cpu as a default.
320 * Systems with OF can look in the properties on the cpu node(s)
321 * for a possibly more accurate value.
322 */
323 if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
324 dcache_bsize = cur_cpu_spec->dcache_bsize;
325 icache_bsize = cur_cpu_spec->icache_bsize;
326 ucache_bsize = 0;
327 } else
328 ucache_bsize = dcache_bsize = icache_bsize
329 = cur_cpu_spec->dcache_bsize;
330
331 /* reboot on panic */
332 panic_timeout = 180;
333
334 init_mm.start_code = PAGE_OFFSET;
335 init_mm.end_code = (unsigned long) _etext;
336 init_mm.end_data = (unsigned long) _edata;
337 init_mm.brk = (unsigned long) klimit;
338
339 /* Save unparsed command line copy for /proc/cmdline */
340 strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
341 *cmdline_p = cmd_line;
342
343 parse_early_param();
344
345 /* set up the bootmem stuff with available memory */
346 do_init_bootmem();
347 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
348
349#ifdef CONFIG_PPC_OCP
350 /* Initialize OCP device list */
351 ocp_early_init();
352 if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab);
353#endif
354
355#ifdef CONFIG_DUMMY_CONSOLE
356 conswitchp = &dummy_con;
357#endif
358
359 ppc_md.setup_arch();
360 if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
361
362 paging_init();
363
364 /* this is for modules since _machine can be a define -- Cort */
365 ppc_md.ppc_machine = _machine;
366}