1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Common boot and setup code for both 32-bit and 64-bit.
4 * Extracted from arch/powerpc/kernel/setup_64.c.
6 * Copyright (C) 2001 PPC64 Team, IBM Corp
11 #include <linux/export.h>
12 #include <linux/string.h>
13 #include <linux/sched.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/reboot.h>
17 #include <linux/delay.h>
18 #include <linux/initrd.h>
19 #include <linux/platform_device.h>
20 #include <linux/seq_file.h>
21 #include <linux/ioport.h>
22 #include <linux/console.h>
23 #include <linux/screen_info.h>
24 #include <linux/root_dev.h>
25 #include <linux/notifier.h>
26 #include <linux/cpu.h>
27 #include <linux/unistd.h>
28 #include <linux/serial.h>
29 #include <linux/serial_8250.h>
30 #include <linux/percpu.h>
31 #include <linux/memblock.h>
32 #include <linux/of_platform.h>
33 #include <linux/hugetlb.h>
34 #include <linux/pgtable.h>
35 #include <asm/debugfs.h>
39 #include <asm/processor.h>
40 #include <asm/vdso_datapage.h>
43 #include <asm/machdep.h>
45 #include <asm/cputable.h>
46 #include <asm/sections.h>
47 #include <asm/firmware.h>
48 #include <asm/btext.h>
49 #include <asm/nvram.h>
50 #include <asm/setup.h>
52 #include <asm/iommu.h>
53 #include <asm/serial.h>
54 #include <asm/cache.h>
58 #include <asm/cputhreads.h>
59 #include <mm/mmu_decl.h>
60 #include <asm/fadump.h>
62 #include <asm/hugetlb.h>
63 #include <asm/livepatch.h>
64 #include <asm/mmu_context.h>
65 #include <asm/cpu_has_feature.h>
66 #include <asm/kasan.h>
72 #define DBG(fmt...) udbg_printf(fmt)
77 /* The main machine-dep calls structure
79 struct machdep_calls ppc_md
;
80 EXPORT_SYMBOL(ppc_md
);
81 struct machdep_calls
*machine_id
;
82 EXPORT_SYMBOL(machine_id
);
85 EXPORT_SYMBOL_GPL(boot_cpuid
);
88 * These are used in binfmt_elf.c to put aux entries on the stack
89 * for each elf executable being started.
94 unsigned long klimit
= (unsigned long) _end
;
97 * This still seems to be needed... -- paulus
99 struct screen_info screen_info
= {
102 .orig_video_cols
= 80,
103 .orig_video_lines
= 25,
104 .orig_video_isVGA
= 1,
105 .orig_video_points
= 16
107 #if defined(CONFIG_FB_VGA16_MODULE)
108 EXPORT_SYMBOL(screen_info
);
111 /* Variables required to store legacy IO irq routing */
112 int of_i8042_kbd_irq
;
113 EXPORT_SYMBOL_GPL(of_i8042_kbd_irq
);
114 int of_i8042_aux_irq
;
115 EXPORT_SYMBOL_GPL(of_i8042_aux_irq
);
117 #ifdef __DO_IRQ_CANON
118 /* XXX should go elsewhere eventually */
119 int ppc_do_canonicalize_irqs
;
120 EXPORT_SYMBOL(ppc_do_canonicalize_irqs
);
123 #ifdef CONFIG_CRASH_CORE
124 /* This keeps a track of which one is the crashing cpu. */
125 int crashing_cpu
= -1;
128 /* also used by kexec */
129 void machine_shutdown(void)
132 * if fadump is active, cleanup the fadump registration before we
137 if (ppc_md
.machine_shutdown
)
138 ppc_md
.machine_shutdown();
141 static void machine_hang(void)
143 pr_emerg("System Halted, OK to turn off power\n");
149 void machine_restart(char *cmd
)
157 do_kernel_restart(cmd
);
163 void machine_power_off(void)
172 /* Used by the G5 thermal driver */
173 EXPORT_SYMBOL_GPL(machine_power_off
);
175 void (*pm_power_off
)(void);
176 EXPORT_SYMBOL_GPL(pm_power_off
);
178 void machine_halt(void)
189 DEFINE_PER_CPU(unsigned int, cpu_pvr
);
192 static void show_cpuinfo_summary(struct seq_file
*m
)
194 struct device_node
*root
;
195 const char *model
= NULL
;
196 unsigned long bogosum
= 0;
199 if (IS_ENABLED(CONFIG_SMP
) && IS_ENABLED(CONFIG_PPC32
)) {
200 for_each_online_cpu(i
)
201 bogosum
+= loops_per_jiffy
;
202 seq_printf(m
, "total bogomips\t: %lu.%02lu\n",
203 bogosum
/ (500000 / HZ
), bogosum
/ (5000 / HZ
) % 100);
205 seq_printf(m
, "timebase\t: %lu\n", ppc_tb_freq
);
207 seq_printf(m
, "platform\t: %s\n", ppc_md
.name
);
208 root
= of_find_node_by_path("/");
210 model
= of_get_property(root
, "model", NULL
);
212 seq_printf(m
, "model\t\t: %s\n", model
);
215 if (ppc_md
.show_cpuinfo
!= NULL
)
216 ppc_md
.show_cpuinfo(m
);
218 /* Display the amount of memory */
219 if (IS_ENABLED(CONFIG_PPC32
))
220 seq_printf(m
, "Memory\t\t: %d MB\n",
221 (unsigned int)(total_memory
/ (1024 * 1024)));
224 static int show_cpuinfo(struct seq_file
*m
, void *v
)
226 unsigned long cpu_id
= (unsigned long)v
- 1;
228 unsigned long proc_freq
;
233 pvr
= per_cpu(cpu_pvr
, cpu_id
);
235 pvr
= mfspr(SPRN_PVR
);
237 maj
= (pvr
>> 8) & 0xFF;
240 seq_printf(m
, "processor\t: %lu\n", cpu_id
);
241 seq_printf(m
, "cpu\t\t: ");
243 if (cur_cpu_spec
->pvr_mask
&& cur_cpu_spec
->cpu_name
)
244 seq_printf(m
, "%s", cur_cpu_spec
->cpu_name
);
246 seq_printf(m
, "unknown (%08x)", pvr
);
248 if (cpu_has_feature(CPU_FTR_ALTIVEC
))
249 seq_printf(m
, ", altivec supported");
254 if (cpu_has_feature(CPU_FTR_TAU
)) {
255 if (IS_ENABLED(CONFIG_TAU_AVERAGE
)) {
256 /* more straightforward, but potentially misleading */
257 seq_printf(m
, "temperature \t: %u C (uncalibrated)\n",
260 /* show the actual temp sensor range */
262 temp
= cpu_temp_both(cpu_id
);
263 seq_printf(m
, "temperature \t: %u-%u C (uncalibrated)\n",
264 temp
& 0xff, temp
>> 16);
267 #endif /* CONFIG_TAU */
270 * Platforms that have variable clock rates, should implement
271 * the method ppc_md.get_proc_freq() that reports the clock
272 * rate of a given cpu. The rest can use ppc_proc_freq to
273 * report the clock rate that is same across all cpus.
275 if (ppc_md
.get_proc_freq
)
276 proc_freq
= ppc_md
.get_proc_freq(cpu_id
);
278 proc_freq
= ppc_proc_freq
;
281 seq_printf(m
, "clock\t\t: %lu.%06luMHz\n",
282 proc_freq
/ 1000000, proc_freq
% 1000000);
284 if (ppc_md
.show_percpuinfo
!= NULL
)
285 ppc_md
.show_percpuinfo(m
, cpu_id
);
287 /* If we are a Freescale core do a simple check so
288 * we dont have to keep adding cases in the future */
289 if (PVR_VER(pvr
) & 0x8000) {
290 switch (PVR_VER(pvr
)) {
291 case 0x8000: /* 7441/7450/7451, Voyager */
292 case 0x8001: /* 7445/7455, Apollo 6 */
293 case 0x8002: /* 7447/7457, Apollo 7 */
294 case 0x8003: /* 7447A, Apollo 7 PM */
295 case 0x8004: /* 7448, Apollo 8 */
296 case 0x800c: /* 7410, Nitro */
297 maj
= ((pvr
>> 8) & 0xF);
300 default: /* e500/book-e */
306 switch (PVR_VER(pvr
)) {
307 case 0x1008: /* 740P/750P ?? */
308 maj
= ((pvr
>> 8) & 0xFF) - 1;
311 case 0x004e: /* POWER9 bits 12-15 give chip type */
312 case 0x0080: /* POWER10 bit 12 gives SMT8/4 */
313 maj
= (pvr
>> 8) & 0x0F;
317 maj
= (pvr
>> 8) & 0xFF;
323 seq_printf(m
, "revision\t: %hd.%hd (pvr %04x %04x)\n",
324 maj
, min
, PVR_VER(pvr
), PVR_REV(pvr
));
326 if (IS_ENABLED(CONFIG_PPC32
))
327 seq_printf(m
, "bogomips\t: %lu.%02lu\n", loops_per_jiffy
/ (500000 / HZ
),
328 (loops_per_jiffy
/ (5000 / HZ
)) % 100);
332 /* If this is the last cpu, print the summary */
333 if (cpumask_next(cpu_id
, cpu_online_mask
) >= nr_cpu_ids
)
334 show_cpuinfo_summary(m
);
339 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
341 if (*pos
== 0) /* just in case, cpu 0 is not the first */
342 *pos
= cpumask_first(cpu_online_mask
);
344 *pos
= cpumask_next(*pos
- 1, cpu_online_mask
);
345 if ((*pos
) < nr_cpu_ids
)
346 return (void *)(unsigned long)(*pos
+ 1);
350 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
353 return c_start(m
, pos
);
356 static void c_stop(struct seq_file
*m
, void *v
)
360 const struct seq_operations cpuinfo_op
= {
364 .show
= show_cpuinfo
,
367 void __init
check_for_initrd(void)
369 #ifdef CONFIG_BLK_DEV_INITRD
370 DBG(" -> check_for_initrd() initrd_start=0x%lx initrd_end=0x%lx\n",
371 initrd_start
, initrd_end
);
373 /* If we were passed an initrd, set the ROOT_DEV properly if the values
374 * look sensible. If not, clear initrd reference.
376 if (is_kernel_addr(initrd_start
) && is_kernel_addr(initrd_end
) &&
377 initrd_end
> initrd_start
)
378 ROOT_DEV
= Root_RAM0
;
380 initrd_start
= initrd_end
= 0;
383 pr_info("Found initrd at 0x%lx:0x%lx\n", initrd_start
, initrd_end
);
385 DBG(" <- check_for_initrd()\n");
386 #endif /* CONFIG_BLK_DEV_INITRD */
391 int threads_per_core
, threads_per_subcore
, threads_shift __read_mostly
;
392 cpumask_t threads_core_mask __read_mostly
;
393 EXPORT_SYMBOL_GPL(threads_per_core
);
394 EXPORT_SYMBOL_GPL(threads_per_subcore
);
395 EXPORT_SYMBOL_GPL(threads_shift
);
396 EXPORT_SYMBOL_GPL(threads_core_mask
);
398 static void __init
cpu_init_thread_core_maps(int tpc
)
402 threads_per_core
= tpc
;
403 threads_per_subcore
= tpc
;
404 cpumask_clear(&threads_core_mask
);
406 /* This implementation only supports power of 2 number of threads
407 * for simplicity and performance
409 threads_shift
= ilog2(tpc
);
410 BUG_ON(tpc
!= (1 << threads_shift
));
412 for (i
= 0; i
< tpc
; i
++)
413 cpumask_set_cpu(i
, &threads_core_mask
);
415 printk(KERN_INFO
"CPU maps initialized for %d thread%s per core\n",
416 tpc
, tpc
> 1 ? "s" : "");
417 printk(KERN_DEBUG
" (thread shift is %d)\n", threads_shift
);
421 u32
*cpu_to_phys_id
= NULL
;
424 * setup_cpu_maps - initialize the following cpu maps:
428 * Having the possible map set up early allows us to restrict allocations
429 * of things like irqstacks to nr_cpu_ids rather than NR_CPUS.
431 * We do not initialize the online map here; cpus set their own bits in
432 * cpu_online_mask as they come up.
434 * This function is valid only for Open Firmware systems. finish_device_tree
435 * must be called before using this.
437 * While we're here, we may as well set the "physical" cpu ids in the paca.
439 * NOTE: This must match the parsing done in early_init_dt_scan_cpus.
441 void __init
smp_setup_cpu_maps(void)
443 struct device_node
*dn
;
447 DBG("smp_setup_cpu_maps()\n");
449 cpu_to_phys_id
= memblock_alloc(nr_cpu_ids
* sizeof(u32
),
452 panic("%s: Failed to allocate %zu bytes align=0x%zx\n",
453 __func__
, nr_cpu_ids
* sizeof(u32
), __alignof__(u32
));
455 for_each_node_by_type(dn
, "cpu") {
456 const __be32
*intserv
;
460 DBG(" * %pOF...\n", dn
);
462 intserv
= of_get_property(dn
, "ibm,ppc-interrupt-server#s",
465 DBG(" ibm,ppc-interrupt-server#s -> %d threads\n",
468 DBG(" no ibm,ppc-interrupt-server#s -> 1 thread\n");
469 intserv
= of_get_property(dn
, "reg", &len
);
471 cpu_be
= cpu_to_be32(cpu
);
472 /* XXX: what is this? uninitialized?? */
473 intserv
= &cpu_be
; /* assume logical == phys */
478 nthreads
= len
/ sizeof(int);
480 for (j
= 0; j
< nthreads
&& cpu
< nr_cpu_ids
; j
++) {
483 DBG(" thread %d -> cpu %d (hard id %d)\n",
484 j
, cpu
, be32_to_cpu(intserv
[j
]));
486 avail
= of_device_is_available(dn
);
488 avail
= !of_property_match_string(dn
,
489 "enable-method", "spin-table");
491 set_cpu_present(cpu
, avail
);
492 set_cpu_possible(cpu
, true);
493 cpu_to_phys_id
[cpu
] = be32_to_cpu(intserv
[j
]);
497 if (cpu
>= nr_cpu_ids
) {
503 /* If no SMT supported, nthreads is forced to 1 */
504 if (!cpu_has_feature(CPU_FTR_SMT
)) {
505 DBG(" SMT disabled ! nthreads forced to 1\n");
511 * On pSeries LPAR, we need to know how many cpus
512 * could possibly be added to this partition.
514 if (firmware_has_feature(FW_FEATURE_LPAR
) &&
515 (dn
= of_find_node_by_path("/rtas"))) {
516 int num_addr_cell
, num_size_cell
, maxcpus
;
519 num_addr_cell
= of_n_addr_cells(dn
);
520 num_size_cell
= of_n_size_cells(dn
);
522 ireg
= of_get_property(dn
, "ibm,lrdr-capacity", NULL
);
527 maxcpus
= be32_to_cpup(ireg
+ num_addr_cell
+ num_size_cell
);
529 /* Double maxcpus for processors which have SMT capability */
530 if (cpu_has_feature(CPU_FTR_SMT
))
533 if (maxcpus
> nr_cpu_ids
) {
535 "Partition configured for %d cpus, "
536 "operating system maximum is %u.\n",
537 maxcpus
, nr_cpu_ids
);
538 maxcpus
= nr_cpu_ids
;
540 printk(KERN_INFO
"Partition configured for %d cpus.\n",
543 for (cpu
= 0; cpu
< maxcpus
; cpu
++)
544 set_cpu_possible(cpu
, true);
548 vdso_data
->processorCount
= num_present_cpus();
549 #endif /* CONFIG_PPC64 */
551 /* Initialize CPU <=> thread mapping/
553 * WARNING: We assume that the number of threads is the same for
554 * every CPU in the system. If that is not the case, then some code
555 * here will have to be reworked
557 cpu_init_thread_core_maps(nthreads
);
559 /* Now that possible cpus are set, set nr_cpu_ids for later use */
564 #endif /* CONFIG_SMP */
566 #ifdef CONFIG_PCSPKR_PLATFORM
567 static __init
int add_pcspkr(void)
569 struct device_node
*np
;
570 struct platform_device
*pd
;
573 np
= of_find_compatible_node(NULL
, NULL
, "pnpPNP,100");
578 pd
= platform_device_alloc("pcspkr", -1);
582 ret
= platform_device_add(pd
);
584 platform_device_put(pd
);
588 device_initcall(add_pcspkr
);
589 #endif /* CONFIG_PCSPKR_PLATFORM */
591 void probe_machine(void)
593 extern struct machdep_calls __machine_desc_start
;
594 extern struct machdep_calls __machine_desc_end
;
598 * Iterate all ppc_md structures until we find the proper
599 * one for the current machine type
601 DBG("Probing machine type ...\n");
604 * Check ppc_md is empty, if not we have a bug, ie, we setup an
605 * entry before probe_machine() which will be overwritten
607 for (i
= 0; i
< (sizeof(ppc_md
) / sizeof(void *)); i
++) {
608 if (((void **)&ppc_md
)[i
]) {
609 printk(KERN_ERR
"Entry %d in ppc_md non empty before"
610 " machine probe !\n", i
);
614 for (machine_id
= &__machine_desc_start
;
615 machine_id
< &__machine_desc_end
;
617 DBG(" %s ...", machine_id
->name
);
618 memcpy(&ppc_md
, machine_id
, sizeof(struct machdep_calls
));
619 if (ppc_md
.probe()) {
625 /* What can we do if we didn't find ? */
626 if (machine_id
>= &__machine_desc_end
) {
627 pr_err("No suitable machine description found !\n");
631 printk(KERN_INFO
"Using %s machine description\n", ppc_md
.name
);
634 /* Match a class of boards, not a specific device configuration. */
635 int check_legacy_ioport(unsigned long base_port
)
637 struct device_node
*parent
, *np
= NULL
;
642 if (!(np
= of_find_compatible_node(NULL
, NULL
, "pnpPNP,303")))
643 np
= of_find_compatible_node(NULL
, NULL
, "pnpPNP,f03");
645 parent
= of_get_parent(np
);
647 of_i8042_kbd_irq
= irq_of_parse_and_map(parent
, 0);
648 if (!of_i8042_kbd_irq
)
649 of_i8042_kbd_irq
= 1;
651 of_i8042_aux_irq
= irq_of_parse_and_map(parent
, 1);
652 if (!of_i8042_aux_irq
)
653 of_i8042_aux_irq
= 12;
659 np
= of_find_node_by_type(NULL
, "8042");
660 /* Pegasos has no device_type on its 8042 node, look for the
663 np
= of_find_node_by_name(NULL
, "8042");
665 of_i8042_kbd_irq
= 1;
666 of_i8042_aux_irq
= 12;
669 case FDC_BASE
: /* FDC1 */
670 np
= of_find_node_by_type(NULL
, "fdc");
673 /* ipmi is supposed to fail here */
678 parent
= of_get_parent(np
);
680 if (of_node_is_type(parent
, "isa"))
687 EXPORT_SYMBOL(check_legacy_ioport
);
689 static int ppc_panic_event(struct notifier_block
*this,
690 unsigned long event
, void *ptr
)
693 * panic does a local_irq_disable, but we really
694 * want interrupts to be hard disabled.
699 * If firmware-assisted dump has been registered then trigger
700 * firmware-assisted dump and let firmware handle everything else.
702 crash_fadump(NULL
, ptr
);
704 ppc_md
.panic(ptr
); /* May not return */
708 static struct notifier_block ppc_panic_block
= {
709 .notifier_call
= ppc_panic_event
,
710 .priority
= INT_MIN
/* may not return; must be done last */
714 * Dump out kernel offset information on panic.
716 static int dump_kernel_offset(struct notifier_block
*self
, unsigned long v
,
719 pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n",
720 kaslr_offset(), KERNELBASE
);
725 static struct notifier_block kernel_offset_notifier
= {
726 .notifier_call
= dump_kernel_offset
729 void __init
setup_panic(void)
731 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE
) && kaslr_offset() > 0)
732 atomic_notifier_chain_register(&panic_notifier_list
,
733 &kernel_offset_notifier
);
735 /* PPC64 always does a hard irq disable in its panic handler */
736 if (!IS_ENABLED(CONFIG_PPC64
) && !ppc_md
.panic
)
738 atomic_notifier_chain_register(&panic_notifier_list
, &ppc_panic_block
);
741 #ifdef CONFIG_CHECK_CACHE_COHERENCY
743 * For platforms that have configurable cache-coherency. This function
744 * checks that the cache coherency setting of the kernel matches the setting
745 * left by the firmware, as indicated in the device tree. Since a mismatch
746 * will eventually result in DMA failures, we print * and error and call
747 * BUG() in that case.
750 #define KERNEL_COHERENCY (!IS_ENABLED(CONFIG_NOT_COHERENT_CACHE))
752 static int __init
check_cache_coherency(void)
754 struct device_node
*np
;
756 bool devtree_coherency
;
758 np
= of_find_node_by_path("/");
759 prop
= of_get_property(np
, "coherency-off", NULL
);
762 devtree_coherency
= prop
? false : true;
764 if (devtree_coherency
!= KERNEL_COHERENCY
) {
766 "kernel coherency:%s != device tree_coherency:%s\n",
767 KERNEL_COHERENCY
? "on" : "off",
768 devtree_coherency
? "on" : "off");
775 late_initcall(check_cache_coherency
);
776 #endif /* CONFIG_CHECK_CACHE_COHERENCY */
778 #ifdef CONFIG_DEBUG_FS
779 struct dentry
*powerpc_debugfs_root
;
780 EXPORT_SYMBOL(powerpc_debugfs_root
);
782 static int powerpc_debugfs_init(void)
784 powerpc_debugfs_root
= debugfs_create_dir("powerpc", NULL
);
787 arch_initcall(powerpc_debugfs_init
);
790 void ppc_printk_progress(char *s
, unsigned short hex
)
795 static __init
void print_system_info(void)
797 pr_info("-----------------------------------------------------\n");
798 pr_info("phys_mem_size = 0x%llx\n",
799 (unsigned long long)memblock_phys_mem_size());
801 pr_info("dcache_bsize = 0x%x\n", dcache_bsize
);
802 pr_info("icache_bsize = 0x%x\n", icache_bsize
);
804 pr_info("cpu_features = 0x%016lx\n", cur_cpu_spec
->cpu_features
);
805 pr_info(" possible = 0x%016lx\n",
806 (unsigned long)CPU_FTRS_POSSIBLE
);
807 pr_info(" always = 0x%016lx\n",
808 (unsigned long)CPU_FTRS_ALWAYS
);
809 pr_info("cpu_user_features = 0x%08x 0x%08x\n",
810 cur_cpu_spec
->cpu_user_features
,
811 cur_cpu_spec
->cpu_user_features2
);
812 pr_info("mmu_features = 0x%08x\n", cur_cpu_spec
->mmu_features
);
814 pr_info("firmware_features = 0x%016lx\n", powerpc_firmware_features
);
815 #ifdef CONFIG_PPC_BOOK3S
816 pr_info("vmalloc start = 0x%lx\n", KERN_VIRT_START
);
817 pr_info("IO start = 0x%lx\n", KERN_IO_START
);
818 pr_info("vmemmap start = 0x%lx\n", (unsigned long)vmemmap
);
822 if (!early_radix_enabled())
823 print_system_hash_info();
825 if (PHYSICAL_START
> 0)
826 pr_info("physical_start = 0x%llx\n",
827 (unsigned long long)PHYSICAL_START
);
828 pr_info("-----------------------------------------------------\n");
832 static void smp_setup_pacas(void)
836 for_each_possible_cpu(cpu
) {
837 if (cpu
== smp_processor_id())
840 set_hard_smp_processor_id(cpu
, cpu_to_phys_id
[cpu
]);
843 memblock_free(__pa(cpu_to_phys_id
), nr_cpu_ids
* sizeof(u32
));
844 cpu_to_phys_id
= NULL
;
849 * Called into from start_kernel this initializes memblock, which is used
850 * to manage page allocation until mem_init is called.
852 void __init
setup_arch(char **cmdline_p
)
856 *cmdline_p
= boot_command_line
;
858 /* Set a half-reasonable default so udelay does something sensible */
859 loops_per_jiffy
= 500000000 / HZ
;
861 /* Unflatten the device-tree passed by prom_init or kexec */
862 unflatten_device_tree();
865 * Initialize cache line/block info from device-tree (on ppc64) or
866 * just cputable (on ppc32).
868 initialize_cache_info();
870 /* Initialize RTAS if available. */
873 /* Check if we have an initrd provided via the device-tree. */
876 /* Probe the machine type, establish ppc_md. */
879 /* Setup panic notifier if requested by the platform. */
883 * Configure ppc_md.power_save (ppc32 only, 64-bit machines do
884 * it from their respective probe() function.
888 /* Discover standard serial ports. */
889 find_legacy_serial_ports();
891 /* Register early console with the printk subsystem. */
892 register_early_udbg_console();
894 /* Setup the various CPU maps based on the device-tree. */
895 smp_setup_cpu_maps();
897 /* Initialize xmon. */
900 /* Check the SMT related command line arguments (ppc64). */
903 /* Parse memory topology */
904 mem_topology_setup();
907 * Release secondary cpus out of their spinloops at 0x60 now that
908 * we can map physical -> logical CPU ids.
910 * Freescale Book3e parts spin in a loop provided by firmware,
911 * so smp_release_cpus() does nothing for them.
916 /* On BookE, setup per-core TLB data structures. */
917 setup_tlb_core_data();
920 /* Print various info about the machine that has been gathered so far. */
923 /* Reserve large chunks of memory for use by CMA for KVM. */
926 /* Reserve large chunks of memory for us by CMA for hugetlb */
927 gigantic_hugetlb_cma_reserve();
929 klp_init_thread_info(&init_task
);
931 init_mm
.start_code
= (unsigned long)_stext
;
932 init_mm
.end_code
= (unsigned long) _etext
;
933 init_mm
.end_data
= (unsigned long) _edata
;
934 init_mm
.brk
= klimit
;
936 mm_iommu_init(&init_mm
);
937 irqstack_early_init();
938 exc_lvl_early_init();
939 emergency_stack_init();
945 early_memtest(min_low_pfn
<< PAGE_SHIFT
, max_low_pfn
<< PAGE_SHIFT
);
947 if (ppc_md
.setup_arch
)
950 setup_barrier_nospec();
955 /* Initialize the MMU context management stuff. */
958 /* Interrupt code needs to be 64K-aligned. */
959 if (IS_ENABLED(CONFIG_PPC64
) && (unsigned long)_stext
& 0xffff)
960 panic("Kernelbase not 64K-aligned (0x%lx)!\n",
961 (unsigned long)_stext
);