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/panic_notifier.h>
13 #include <linux/string.h>
14 #include <linux/sched.h>
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 #include <linux/reboot.h>
18 #include <linux/delay.h>
19 #include <linux/initrd.h>
20 #include <linux/platform_device.h>
21 #include <linux/printk.h>
22 #include <linux/seq_file.h>
23 #include <linux/ioport.h>
24 #include <linux/console.h>
25 #include <linux/screen_info.h>
26 #include <linux/root_dev.h>
27 #include <linux/cpu.h>
28 #include <linux/unistd.h>
29 #include <linux/seq_buf.h>
30 #include <linux/serial.h>
31 #include <linux/serial_8250.h>
32 #include <linux/percpu.h>
33 #include <linux/memblock.h>
34 #include <linux/of_irq.h>
35 #include <linux/of_fdt.h>
36 #include <linux/of_platform.h>
37 #include <linux/hugetlb.h>
38 #include <linux/pgtable.h>
41 #include <asm/processor.h>
42 #include <asm/vdso_datapage.h>
45 #include <asm/machdep.h>
47 #include <asm/cputable.h>
48 #include <asm/sections.h>
49 #include <asm/firmware.h>
50 #include <asm/btext.h>
51 #include <asm/nvram.h>
52 #include <asm/setup.h>
54 #include <asm/iommu.h>
55 #include <asm/serial.h>
56 #include <asm/cache.h>
60 #include <asm/cputhreads.h>
61 #include <mm/mmu_decl.h>
62 #include <asm/fadump.h>
64 #include <asm/hugetlb.h>
65 #include <asm/livepatch.h>
66 #include <asm/mmu_context.h>
67 #include <asm/cpu_has_feature.h>
68 #include <asm/kasan.h>
74 #define DBG(fmt...) udbg_printf(fmt)
79 /* The main machine-dep calls structure
81 struct machdep_calls ppc_md;
82 EXPORT_SYMBOL(ppc_md);
83 struct machdep_calls *machine_id;
84 EXPORT_SYMBOL(machine_id);
87 EXPORT_SYMBOL_GPL(boot_cpuid);
90 int boot_cpu_hwid = -1;
94 * These are used in binfmt_elf.c to put aux entries on the stack
95 * for each elf executable being started.
101 * This still seems to be needed... -- paulus
103 struct screen_info screen_info = {
106 .orig_video_cols = 80,
107 .orig_video_lines = 25,
108 .orig_video_isVGA = 1,
109 .orig_video_points = 16
111 #if defined(CONFIG_FB_VGA16_MODULE)
112 EXPORT_SYMBOL(screen_info);
115 /* Variables required to store legacy IO irq routing */
116 int of_i8042_kbd_irq;
117 EXPORT_SYMBOL_GPL(of_i8042_kbd_irq);
118 int of_i8042_aux_irq;
119 EXPORT_SYMBOL_GPL(of_i8042_aux_irq);
121 #ifdef __DO_IRQ_CANON
122 /* XXX should go elsewhere eventually */
123 int ppc_do_canonicalize_irqs;
124 EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
127 #ifdef CONFIG_CRASH_CORE
128 /* This keeps a track of which one is the crashing cpu. */
129 int crashing_cpu = -1;
132 /* also used by kexec */
133 void machine_shutdown(void)
136 * if fadump is active, cleanup the fadump registration before we
141 if (ppc_md.machine_shutdown)
142 ppc_md.machine_shutdown();
145 static void machine_hang(void)
147 pr_emerg("System Halted, OK to turn off power\n");
153 void machine_restart(char *cmd)
161 do_kernel_restart(cmd);
167 void machine_power_off(void)
170 do_kernel_power_off();
174 /* Used by the G5 thermal driver */
175 EXPORT_SYMBOL_GPL(machine_power_off);
177 void (*pm_power_off)(void);
178 EXPORT_SYMBOL_GPL(pm_power_off);
180 size_t __must_check arch_get_random_seed_longs(unsigned long *v, size_t max_longs)
182 if (max_longs && ppc_md.get_random_seed && ppc_md.get_random_seed(v))
186 EXPORT_SYMBOL(arch_get_random_seed_longs);
188 void machine_halt(void)
199 DEFINE_PER_CPU(unsigned int, cpu_pvr);
202 static void show_cpuinfo_summary(struct seq_file *m)
204 struct device_node *root;
205 const char *model = NULL;
206 unsigned long bogosum = 0;
209 if (IS_ENABLED(CONFIG_SMP) && IS_ENABLED(CONFIG_PPC32)) {
210 for_each_online_cpu(i)
211 bogosum += loops_per_jiffy;
212 seq_printf(m, "total bogomips\t: %lu.%02lu\n",
213 bogosum / (500000 / HZ), bogosum / (5000 / HZ) % 100);
215 seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
217 seq_printf(m, "platform\t: %s\n", ppc_md.name);
218 root = of_find_node_by_path("/");
220 model = of_get_property(root, "model", NULL);
222 seq_printf(m, "model\t\t: %s\n", model);
225 if (ppc_md.show_cpuinfo != NULL)
226 ppc_md.show_cpuinfo(m);
228 /* Display the amount of memory */
229 if (IS_ENABLED(CONFIG_PPC32))
230 seq_printf(m, "Memory\t\t: %d MB\n",
231 (unsigned int)(total_memory / (1024 * 1024)));
234 static int show_cpuinfo(struct seq_file *m, void *v)
236 unsigned long cpu_id = (unsigned long)v - 1;
238 unsigned long proc_freq;
243 pvr = per_cpu(cpu_pvr, cpu_id);
245 pvr = mfspr(SPRN_PVR);
247 maj = (pvr >> 8) & 0xFF;
250 seq_printf(m, "processor\t: %lu\ncpu\t\t: ", cpu_id);
252 if (cur_cpu_spec->pvr_mask && cur_cpu_spec->cpu_name)
253 seq_puts(m, cur_cpu_spec->cpu_name);
255 seq_printf(m, "unknown (%08x)", pvr);
257 if (cpu_has_feature(CPU_FTR_ALTIVEC))
258 seq_puts(m, ", altivec supported");
263 if (cpu_has_feature(CPU_FTR_TAU)) {
264 if (IS_ENABLED(CONFIG_TAU_AVERAGE)) {
265 /* more straightforward, but potentially misleading */
266 seq_printf(m, "temperature \t: %u C (uncalibrated)\n",
269 /* show the actual temp sensor range */
271 temp = cpu_temp_both(cpu_id);
272 seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n",
273 temp & 0xff, temp >> 16);
276 #endif /* CONFIG_TAU */
279 * Platforms that have variable clock rates, should implement
280 * the method ppc_md.get_proc_freq() that reports the clock
281 * rate of a given cpu. The rest can use ppc_proc_freq to
282 * report the clock rate that is same across all cpus.
284 if (ppc_md.get_proc_freq)
285 proc_freq = ppc_md.get_proc_freq(cpu_id);
287 proc_freq = ppc_proc_freq;
290 seq_printf(m, "clock\t\t: %lu.%06luMHz\n",
291 proc_freq / 1000000, proc_freq % 1000000);
293 /* If we are a Freescale core do a simple check so
294 * we don't have to keep adding cases in the future */
295 if (PVR_VER(pvr) & 0x8000) {
296 switch (PVR_VER(pvr)) {
297 case 0x8000: /* 7441/7450/7451, Voyager */
298 case 0x8001: /* 7445/7455, Apollo 6 */
299 case 0x8002: /* 7447/7457, Apollo 7 */
300 case 0x8003: /* 7447A, Apollo 7 PM */
301 case 0x8004: /* 7448, Apollo 8 */
302 case 0x800c: /* 7410, Nitro */
303 maj = ((pvr >> 8) & 0xF);
306 default: /* e500/book-e */
312 switch (PVR_VER(pvr)) {
313 case 0x1008: /* 740P/750P ?? */
314 maj = ((pvr >> 8) & 0xFF) - 1;
317 case 0x004e: /* POWER9 bits 12-15 give chip type */
318 case 0x0080: /* POWER10 bit 12 gives SMT8/4 */
319 maj = (pvr >> 8) & 0x0F;
323 maj = (pvr >> 8) & 0xFF;
329 seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
330 maj, min, PVR_VER(pvr), PVR_REV(pvr));
332 if (IS_ENABLED(CONFIG_PPC32))
333 seq_printf(m, "bogomips\t: %lu.%02lu\n", loops_per_jiffy / (500000 / HZ),
334 (loops_per_jiffy / (5000 / HZ)) % 100);
338 /* If this is the last cpu, print the summary */
339 if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)
340 show_cpuinfo_summary(m);
345 static void *c_start(struct seq_file *m, loff_t *pos)
347 if (*pos == 0) /* just in case, cpu 0 is not the first */
348 *pos = cpumask_first(cpu_online_mask);
350 *pos = cpumask_next(*pos - 1, cpu_online_mask);
351 if ((*pos) < nr_cpu_ids)
352 return (void *)(unsigned long)(*pos + 1);
356 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
359 return c_start(m, pos);
362 static void c_stop(struct seq_file *m, void *v)
366 const struct seq_operations cpuinfo_op = {
370 .show = show_cpuinfo,
373 void __init check_for_initrd(void)
375 #ifdef CONFIG_BLK_DEV_INITRD
376 DBG(" -> check_for_initrd() initrd_start=0x%lx initrd_end=0x%lx\n",
377 initrd_start, initrd_end);
379 /* If we were passed an initrd, set the ROOT_DEV properly if the values
380 * look sensible. If not, clear initrd reference.
382 if (is_kernel_addr(initrd_start) && is_kernel_addr(initrd_end) &&
383 initrd_end > initrd_start)
384 ROOT_DEV = Root_RAM0;
386 initrd_start = initrd_end = 0;
389 pr_info("Found initrd at 0x%lx:0x%lx\n", initrd_start, initrd_end);
391 DBG(" <- check_for_initrd()\n");
392 #endif /* CONFIG_BLK_DEV_INITRD */
397 int threads_per_core, threads_per_subcore, threads_shift __read_mostly;
398 cpumask_t threads_core_mask __read_mostly;
399 EXPORT_SYMBOL_GPL(threads_per_core);
400 EXPORT_SYMBOL_GPL(threads_per_subcore);
401 EXPORT_SYMBOL_GPL(threads_shift);
402 EXPORT_SYMBOL_GPL(threads_core_mask);
404 static void __init cpu_init_thread_core_maps(int tpc)
408 threads_per_core = tpc;
409 threads_per_subcore = tpc;
410 cpumask_clear(&threads_core_mask);
412 /* This implementation only supports power of 2 number of threads
413 * for simplicity and performance
415 threads_shift = ilog2(tpc);
416 BUG_ON(tpc != (1 << threads_shift));
418 for (i = 0; i < tpc; i++)
419 cpumask_set_cpu(i, &threads_core_mask);
421 printk(KERN_INFO "CPU maps initialized for %d thread%s per core\n",
422 tpc, tpc > 1 ? "s" : "");
423 printk(KERN_DEBUG " (thread shift is %d)\n", threads_shift);
427 u32 *cpu_to_phys_id = NULL;
430 * setup_cpu_maps - initialize the following cpu maps:
434 * Having the possible map set up early allows us to restrict allocations
435 * of things like irqstacks to nr_cpu_ids rather than NR_CPUS.
437 * We do not initialize the online map here; cpus set their own bits in
438 * cpu_online_mask as they come up.
440 * This function is valid only for Open Firmware systems. finish_device_tree
441 * must be called before using this.
443 * While we're here, we may as well set the "physical" cpu ids in the paca.
445 * NOTE: This must match the parsing done in early_init_dt_scan_cpus.
447 void __init smp_setup_cpu_maps(void)
449 struct device_node *dn;
453 DBG("smp_setup_cpu_maps()\n");
455 cpu_to_phys_id = memblock_alloc(nr_cpu_ids * sizeof(u32),
458 panic("%s: Failed to allocate %zu bytes align=0x%zx\n",
459 __func__, nr_cpu_ids * sizeof(u32), __alignof__(u32));
461 for_each_node_by_type(dn, "cpu") {
462 const __be32 *intserv;
466 DBG(" * %pOF...\n", dn);
468 intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s",
471 DBG(" ibm,ppc-interrupt-server#s -> %lu threads\n",
472 (len / sizeof(int)));
474 DBG(" no ibm,ppc-interrupt-server#s -> 1 thread\n");
475 intserv = of_get_property(dn, "reg", &len);
477 cpu_be = cpu_to_be32(cpu);
478 /* XXX: what is this? uninitialized?? */
479 intserv = &cpu_be; /* assume logical == phys */
484 nthreads = len / sizeof(int);
486 for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
489 DBG(" thread %d -> cpu %d (hard id %d)\n",
490 j, cpu, be32_to_cpu(intserv[j]));
492 avail = of_device_is_available(dn);
494 avail = !of_property_match_string(dn,
495 "enable-method", "spin-table");
497 set_cpu_present(cpu, avail);
498 set_cpu_possible(cpu, true);
499 cpu_to_phys_id[cpu] = be32_to_cpu(intserv[j]);
503 if (cpu >= nr_cpu_ids) {
509 /* If no SMT supported, nthreads is forced to 1 */
510 if (!cpu_has_feature(CPU_FTR_SMT)) {
511 DBG(" SMT disabled ! nthreads forced to 1\n");
517 * On pSeries LPAR, we need to know how many cpus
518 * could possibly be added to this partition.
520 if (firmware_has_feature(FW_FEATURE_LPAR) &&
521 (dn = of_find_node_by_path("/rtas"))) {
522 int num_addr_cell, num_size_cell, maxcpus;
525 num_addr_cell = of_n_addr_cells(dn);
526 num_size_cell = of_n_size_cells(dn);
528 ireg = of_get_property(dn, "ibm,lrdr-capacity", NULL);
533 maxcpus = be32_to_cpup(ireg + num_addr_cell + num_size_cell);
535 /* Double maxcpus for processors which have SMT capability */
536 if (cpu_has_feature(CPU_FTR_SMT))
539 if (maxcpus > nr_cpu_ids) {
541 "Partition configured for %d cpus, "
542 "operating system maximum is %u.\n",
543 maxcpus, nr_cpu_ids);
544 maxcpus = nr_cpu_ids;
546 printk(KERN_INFO "Partition configured for %d cpus.\n",
549 for (cpu = 0; cpu < maxcpus; cpu++)
550 set_cpu_possible(cpu, true);
554 vdso_data->processorCount = num_present_cpus();
555 #endif /* CONFIG_PPC64 */
557 /* Initialize CPU <=> thread mapping/
559 * WARNING: We assume that the number of threads is the same for
560 * every CPU in the system. If that is not the case, then some code
561 * here will have to be reworked
563 cpu_init_thread_core_maps(nthreads);
565 /* Now that possible cpus are set, set nr_cpu_ids for later use */
570 #endif /* CONFIG_SMP */
572 #ifdef CONFIG_PCSPKR_PLATFORM
573 static __init int add_pcspkr(void)
575 struct device_node *np;
576 struct platform_device *pd;
579 np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
584 pd = platform_device_alloc("pcspkr", -1);
588 ret = platform_device_add(pd);
590 platform_device_put(pd);
594 device_initcall(add_pcspkr);
595 #endif /* CONFIG_PCSPKR_PLATFORM */
597 static char ppc_hw_desc_buf[128] __initdata;
599 struct seq_buf ppc_hw_desc __initdata = {
600 .buffer = ppc_hw_desc_buf,
601 .size = sizeof(ppc_hw_desc_buf),
606 static __init void probe_machine(void)
608 extern struct machdep_calls __machine_desc_start;
609 extern struct machdep_calls __machine_desc_end;
613 * Iterate all ppc_md structures until we find the proper
614 * one for the current machine type
616 DBG("Probing machine type ...\n");
619 * Check ppc_md is empty, if not we have a bug, ie, we setup an
620 * entry before probe_machine() which will be overwritten
622 for (i = 0; i < (sizeof(ppc_md) / sizeof(void *)); i++) {
623 if (((void **)&ppc_md)[i]) {
624 printk(KERN_ERR "Entry %d in ppc_md non empty before"
625 " machine probe !\n", i);
629 for (machine_id = &__machine_desc_start;
630 machine_id < &__machine_desc_end;
632 DBG(" %s ...", machine_id->name);
633 memcpy(&ppc_md, machine_id, sizeof(struct machdep_calls));
634 if (ppc_md.probe()) {
640 /* What can we do if we didn't find ? */
641 if (machine_id >= &__machine_desc_end) {
642 pr_err("No suitable machine description found !\n");
646 // Append the machine name to other info we've gathered
647 seq_buf_puts(&ppc_hw_desc, ppc_md.name);
649 // Set the generic hardware description shown in oopses
650 dump_stack_set_arch_desc(ppc_hw_desc.buffer);
652 pr_info("Hardware name: %s\n", ppc_hw_desc.buffer);
655 /* Match a class of boards, not a specific device configuration. */
656 int check_legacy_ioport(unsigned long base_port)
658 struct device_node *parent, *np = NULL;
663 if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
664 np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
666 parent = of_get_parent(np);
668 of_i8042_kbd_irq = irq_of_parse_and_map(parent, 0);
669 if (!of_i8042_kbd_irq)
670 of_i8042_kbd_irq = 1;
672 of_i8042_aux_irq = irq_of_parse_and_map(parent, 1);
673 if (!of_i8042_aux_irq)
674 of_i8042_aux_irq = 12;
680 np = of_find_node_by_type(NULL, "8042");
681 /* Pegasos has no device_type on its 8042 node, look for the
684 np = of_find_node_by_name(NULL, "8042");
686 of_i8042_kbd_irq = 1;
687 of_i8042_aux_irq = 12;
690 case FDC_BASE: /* FDC1 */
691 np = of_find_node_by_type(NULL, "fdc");
694 /* ipmi is supposed to fail here */
699 parent = of_get_parent(np);
701 if (of_node_is_type(parent, "isa"))
708 EXPORT_SYMBOL(check_legacy_ioport);
711 * Panic notifiers setup
713 * We have 3 notifiers for powerpc, each one from a different "nature":
715 * - ppc_panic_fadump_handler() is a hypervisor notifier, which hard-disables
716 * IRQs and deal with the Firmware-Assisted dump, when it is configured;
717 * should run early in the panic path.
719 * - dump_kernel_offset() is an informative notifier, just showing the KASLR
720 * offset if we have RANDOMIZE_BASE set.
722 * - ppc_panic_platform_handler() is a low-level handler that's registered
723 * only if the platform wishes to perform final actions in the panic path,
724 * hence it should run late and might not even return. Currently, only
725 * pseries and ps3 platforms register callbacks.
727 static int ppc_panic_fadump_handler(struct notifier_block *this,
728 unsigned long event, void *ptr)
731 * panic does a local_irq_disable, but we really
732 * want interrupts to be hard disabled.
737 * If firmware-assisted dump has been registered then trigger
738 * its callback and let the firmware handles everything else.
740 crash_fadump(NULL, ptr);
745 static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
748 pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n",
749 kaslr_offset(), KERNELBASE);
754 static int ppc_panic_platform_handler(struct notifier_block *this,
755 unsigned long event, void *ptr)
758 * This handler is only registered if we have a panic callback
759 * on ppc_md, hence NULL check is not needed.
760 * Also, it may not return, so it runs really late on panic path.
767 static struct notifier_block ppc_fadump_block = {
768 .notifier_call = ppc_panic_fadump_handler,
769 .priority = INT_MAX, /* run early, to notify the firmware ASAP */
772 static struct notifier_block kernel_offset_notifier = {
773 .notifier_call = dump_kernel_offset,
776 static struct notifier_block ppc_panic_block = {
777 .notifier_call = ppc_panic_platform_handler,
778 .priority = INT_MIN, /* may not return; must be done last */
781 void __init setup_panic(void)
783 /* Hard-disables IRQs + deal with FW-assisted dump (fadump) */
784 atomic_notifier_chain_register(&panic_notifier_list,
787 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0)
788 atomic_notifier_chain_register(&panic_notifier_list,
789 &kernel_offset_notifier);
791 /* Low-level platform-specific routines that should run on panic */
793 atomic_notifier_chain_register(&panic_notifier_list,
797 #ifdef CONFIG_CHECK_CACHE_COHERENCY
799 * For platforms that have configurable cache-coherency. This function
800 * checks that the cache coherency setting of the kernel matches the setting
801 * left by the firmware, as indicated in the device tree. Since a mismatch
802 * will eventually result in DMA failures, we print * and error and call
803 * BUG() in that case.
806 #define KERNEL_COHERENCY (!IS_ENABLED(CONFIG_NOT_COHERENT_CACHE))
808 static int __init check_cache_coherency(void)
810 struct device_node *np;
812 bool devtree_coherency;
814 np = of_find_node_by_path("/");
815 prop = of_get_property(np, "coherency-off", NULL);
818 devtree_coherency = prop ? false : true;
820 if (devtree_coherency != KERNEL_COHERENCY) {
822 "kernel coherency:%s != device tree_coherency:%s\n",
823 KERNEL_COHERENCY ? "on" : "off",
824 devtree_coherency ? "on" : "off");
831 late_initcall(check_cache_coherency);
832 #endif /* CONFIG_CHECK_CACHE_COHERENCY */
834 void ppc_printk_progress(char *s, unsigned short hex)
839 static __init void print_system_info(void)
841 pr_info("-----------------------------------------------------\n");
842 pr_info("phys_mem_size = 0x%llx\n",
843 (unsigned long long)memblock_phys_mem_size());
845 pr_info("dcache_bsize = 0x%x\n", dcache_bsize);
846 pr_info("icache_bsize = 0x%x\n", icache_bsize);
848 pr_info("cpu_features = 0x%016lx\n", cur_cpu_spec->cpu_features);
849 pr_info(" possible = 0x%016lx\n",
850 (unsigned long)CPU_FTRS_POSSIBLE);
851 pr_info(" always = 0x%016lx\n",
852 (unsigned long)CPU_FTRS_ALWAYS);
853 pr_info("cpu_user_features = 0x%08x 0x%08x\n",
854 cur_cpu_spec->cpu_user_features,
855 cur_cpu_spec->cpu_user_features2);
856 pr_info("mmu_features = 0x%08x\n", cur_cpu_spec->mmu_features);
858 pr_info("firmware_features = 0x%016lx\n", powerpc_firmware_features);
859 #ifdef CONFIG_PPC_BOOK3S
860 pr_info("vmalloc start = 0x%lx\n", KERN_VIRT_START);
861 pr_info("IO start = 0x%lx\n", KERN_IO_START);
862 pr_info("vmemmap start = 0x%lx\n", (unsigned long)vmemmap);
866 if (!early_radix_enabled())
867 print_system_hash_info();
869 if (PHYSICAL_START > 0)
870 pr_info("physical_start = 0x%llx\n",
871 (unsigned long long)PHYSICAL_START);
872 pr_info("-----------------------------------------------------\n");
876 static void __init smp_setup_pacas(void)
880 for_each_possible_cpu(cpu) {
881 if (cpu == smp_processor_id())
884 set_hard_smp_processor_id(cpu, cpu_to_phys_id[cpu]);
887 memblock_free(cpu_to_phys_id, nr_cpu_ids * sizeof(u32));
888 cpu_to_phys_id = NULL;
893 * Called into from start_kernel this initializes memblock, which is used
894 * to manage page allocation until mem_init is called.
896 void __init setup_arch(char **cmdline_p)
900 *cmdline_p = boot_command_line;
902 /* Set a half-reasonable default so udelay does something sensible */
903 loops_per_jiffy = 500000000 / HZ;
905 /* Unflatten the device-tree passed by prom_init or kexec */
906 unflatten_device_tree();
909 * Initialize cache line/block info from device-tree (on ppc64) or
910 * just cputable (on ppc32).
912 initialize_cache_info();
914 /* Initialize RTAS if available. */
917 /* Check if we have an initrd provided via the device-tree. */
920 /* Probe the machine type, establish ppc_md. */
923 /* Setup panic notifier if requested by the platform. */
927 * Configure ppc_md.power_save (ppc32 only, 64-bit machines do
928 * it from their respective probe() function.
932 /* Discover standard serial ports. */
933 find_legacy_serial_ports();
935 /* Register early console with the printk subsystem. */
936 register_early_udbg_console();
938 /* Setup the various CPU maps based on the device-tree. */
939 smp_setup_cpu_maps();
941 /* Initialize xmon. */
944 /* Check the SMT related command line arguments (ppc64). */
947 /* Parse memory topology */
948 mem_topology_setup();
951 * Release secondary cpus out of their spinloops at 0x60 now that
952 * we can map physical -> logical CPU ids.
954 * Freescale Book3e parts spin in a loop provided by firmware,
955 * so smp_release_cpus() does nothing for them.
960 /* On BookE, setup per-core TLB data structures. */
961 setup_tlb_core_data();
964 /* Print various info about the machine that has been gathered so far. */
967 klp_init_thread_info(&init_task);
969 setup_initial_init_mm(_stext, _etext, _edata, _end);
971 mm_iommu_init(&init_mm);
972 irqstack_early_init();
973 exc_lvl_early_init();
974 emergency_stack_init();
982 * Reserve large chunks of memory for use by CMA for KVM and hugetlb. These must
983 * be called after initmem_init(), so that pageblock_order is initialised.
986 gigantic_hugetlb_cma_reserve();
988 early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
990 if (ppc_md.setup_arch)
993 setup_barrier_nospec();
998 /* Initialize the MMU context management stuff. */
1001 /* Interrupt code needs to be 64K-aligned. */
1002 if (IS_ENABLED(CONFIG_PPC64) && (unsigned long)_stext & 0xffff)
1003 panic("Kernelbase not 64K-aligned (0x%lx)!\n",
1004 (unsigned long)_stext);