^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Common boot and setup code for both 32-bit and 64-bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Extracted from arch/powerpc/kernel/setup_64.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2001 PPC64 Team, IBM Corp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #undef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/initrd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/console.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/screen_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/root_dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/serial.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/serial_8250.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/of_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/hugetlb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/pgtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <asm/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <asm/paca.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <asm/prom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <asm/vdso_datapage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <asm/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <asm/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <asm/machdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <asm/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <asm/cputable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <asm/sections.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <asm/firmware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <asm/btext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <asm/nvram.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include <asm/rtas.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include <asm/iommu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include <asm/serial.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include <asm/cache.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include <asm/mmu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #include <asm/xmon.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include <asm/cputhreads.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include <mm/mmu_decl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #include <asm/fadump.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include <asm/udbg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #include <asm/hugetlb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #include <asm/livepatch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #include <asm/mmu_context.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #include <asm/cpu_has_feature.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #include <asm/kasan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #include "setup.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #include <asm/udbg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define DBG(fmt...) udbg_printf(fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define DBG(fmt...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* The main machine-dep calls structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct machdep_calls ppc_md;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) EXPORT_SYMBOL(ppc_md);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct machdep_calls *machine_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) EXPORT_SYMBOL(machine_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int boot_cpuid = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) EXPORT_SYMBOL_GPL(boot_cpuid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * These are used in binfmt_elf.c to put aux entries on the stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * for each elf executable being started.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int dcache_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int icache_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int ucache_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) unsigned long klimit = (unsigned long) _end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * This still seems to be needed... -- paulus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct screen_info screen_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .orig_x = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .orig_y = 25,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .orig_video_cols = 80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .orig_video_lines = 25,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .orig_video_isVGA = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .orig_video_points = 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #if defined(CONFIG_FB_VGA16_MODULE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) EXPORT_SYMBOL(screen_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* Variables required to store legacy IO irq routing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int of_i8042_kbd_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) EXPORT_SYMBOL_GPL(of_i8042_kbd_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int of_i8042_aux_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) EXPORT_SYMBOL_GPL(of_i8042_aux_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #ifdef __DO_IRQ_CANON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* XXX should go elsewhere eventually */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int ppc_do_canonicalize_irqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #ifdef CONFIG_CRASH_CORE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /* This keeps a track of which one is the crashing cpu. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int crashing_cpu = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* also used by kexec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) void machine_shutdown(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * if fadump is active, cleanup the fadump registration before we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * shutdown.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) fadump_cleanup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if (ppc_md.machine_shutdown)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ppc_md.machine_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static void machine_hang(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) pr_emerg("System Halted, OK to turn off power\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) while (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void machine_restart(char *cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) machine_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (ppc_md.restart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) ppc_md.restart(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) smp_send_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) do_kernel_restart(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) mdelay(1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) machine_hang();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void machine_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) machine_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (pm_power_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) pm_power_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) smp_send_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) machine_hang();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* Used by the G5 thermal driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) EXPORT_SYMBOL_GPL(machine_power_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) void (*pm_power_off)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) EXPORT_SYMBOL_GPL(pm_power_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) void machine_halt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) machine_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if (ppc_md.halt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ppc_md.halt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) smp_send_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) machine_hang();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) DEFINE_PER_CPU(unsigned int, cpu_pvr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static void show_cpuinfo_summary(struct seq_file *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct device_node *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) const char *model = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) unsigned long bogosum = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (IS_ENABLED(CONFIG_SMP) && IS_ENABLED(CONFIG_PPC32)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) for_each_online_cpu(i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) bogosum += loops_per_jiffy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) seq_printf(m, "total bogomips\t: %lu.%02lu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) bogosum / (500000 / HZ), bogosum / (5000 / HZ) % 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (ppc_md.name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) seq_printf(m, "platform\t: %s\n", ppc_md.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) root = of_find_node_by_path("/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) if (root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) model = of_get_property(root, "model", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (model)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) seq_printf(m, "model\t\t: %s\n", model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) of_node_put(root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (ppc_md.show_cpuinfo != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ppc_md.show_cpuinfo(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* Display the amount of memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (IS_ENABLED(CONFIG_PPC32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) seq_printf(m, "Memory\t\t: %d MB\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) (unsigned int)(total_memory / (1024 * 1024)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static int show_cpuinfo(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) unsigned long cpu_id = (unsigned long)v - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) unsigned int pvr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) unsigned long proc_freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) unsigned short maj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) unsigned short min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) pvr = per_cpu(cpu_pvr, cpu_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) pvr = mfspr(SPRN_PVR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) maj = (pvr >> 8) & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) min = pvr & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) seq_printf(m, "processor\t: %lu\n", cpu_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) seq_printf(m, "cpu\t\t: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if (cur_cpu_spec->pvr_mask && cur_cpu_spec->cpu_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) seq_printf(m, "%s", cur_cpu_spec->cpu_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) seq_printf(m, "unknown (%08x)", pvr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) if (cpu_has_feature(CPU_FTR_ALTIVEC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) seq_printf(m, ", altivec supported");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) seq_printf(m, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) #ifdef CONFIG_TAU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if (cpu_has_feature(CPU_FTR_TAU)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) if (IS_ENABLED(CONFIG_TAU_AVERAGE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* more straightforward, but potentially misleading */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) seq_printf(m, "temperature \t: %u C (uncalibrated)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) cpu_temp(cpu_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) /* show the actual temp sensor range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) u32 temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) temp = cpu_temp_both(cpu_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) temp & 0xff, temp >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) #endif /* CONFIG_TAU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * Platforms that have variable clock rates, should implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * the method ppc_md.get_proc_freq() that reports the clock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * rate of a given cpu. The rest can use ppc_proc_freq to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * report the clock rate that is same across all cpus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (ppc_md.get_proc_freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) proc_freq = ppc_md.get_proc_freq(cpu_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) proc_freq = ppc_proc_freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (proc_freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) seq_printf(m, "clock\t\t: %lu.%06luMHz\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) proc_freq / 1000000, proc_freq % 1000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) if (ppc_md.show_percpuinfo != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) ppc_md.show_percpuinfo(m, cpu_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /* If we are a Freescale core do a simple check so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * we dont have to keep adding cases in the future */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) if (PVR_VER(pvr) & 0x8000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) switch (PVR_VER(pvr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) case 0x8000: /* 7441/7450/7451, Voyager */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) case 0x8001: /* 7445/7455, Apollo 6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) case 0x8002: /* 7447/7457, Apollo 7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) case 0x8003: /* 7447A, Apollo 7 PM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) case 0x8004: /* 7448, Apollo 8 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) case 0x800c: /* 7410, Nitro */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) maj = ((pvr >> 8) & 0xF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) min = PVR_MIN(pvr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) default: /* e500/book-e */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) maj = PVR_MAJ(pvr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) min = PVR_MIN(pvr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) switch (PVR_VER(pvr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) case 0x1008: /* 740P/750P ?? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) maj = ((pvr >> 8) & 0xFF) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) min = pvr & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) case 0x004e: /* POWER9 bits 12-15 give chip type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) case 0x0080: /* POWER10 bit 12 gives SMT8/4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) maj = (pvr >> 8) & 0x0F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) min = pvr & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) maj = (pvr >> 8) & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) min = pvr & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) maj, min, PVR_VER(pvr), PVR_REV(pvr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if (IS_ENABLED(CONFIG_PPC32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) seq_printf(m, "bogomips\t: %lu.%02lu\n", loops_per_jiffy / (500000 / HZ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) (loops_per_jiffy / (5000 / HZ)) % 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) seq_printf(m, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) /* If this is the last cpu, print the summary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) show_cpuinfo_summary(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) static void *c_start(struct seq_file *m, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) if (*pos == 0) /* just in case, cpu 0 is not the first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) *pos = cpumask_first(cpu_online_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) *pos = cpumask_next(*pos - 1, cpu_online_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) if ((*pos) < nr_cpu_ids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return (void *)(unsigned long)(*pos + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) static void *c_next(struct seq_file *m, void *v, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) (*pos)++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) return c_start(m, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) static void c_stop(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) const struct seq_operations cpuinfo_op = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) .start = c_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) .next = c_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) .stop = c_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) .show = show_cpuinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) void __init check_for_initrd(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) #ifdef CONFIG_BLK_DEV_INITRD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) DBG(" -> check_for_initrd() initrd_start=0x%lx initrd_end=0x%lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) initrd_start, initrd_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) /* If we were passed an initrd, set the ROOT_DEV properly if the values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * look sensible. If not, clear initrd reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) if (is_kernel_addr(initrd_start) && is_kernel_addr(initrd_end) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) initrd_end > initrd_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) ROOT_DEV = Root_RAM0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) initrd_start = initrd_end = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (initrd_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) pr_info("Found initrd at 0x%lx:0x%lx\n", initrd_start, initrd_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) DBG(" <- check_for_initrd()\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) #endif /* CONFIG_BLK_DEV_INITRD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) int threads_per_core, threads_per_subcore, threads_shift __read_mostly;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) cpumask_t threads_core_mask __read_mostly;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) EXPORT_SYMBOL_GPL(threads_per_core);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) EXPORT_SYMBOL_GPL(threads_per_subcore);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) EXPORT_SYMBOL_GPL(threads_shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) EXPORT_SYMBOL_GPL(threads_core_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) static void __init cpu_init_thread_core_maps(int tpc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) threads_per_core = tpc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) threads_per_subcore = tpc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) cpumask_clear(&threads_core_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) /* This implementation only supports power of 2 number of threads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * for simplicity and performance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) threads_shift = ilog2(tpc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) BUG_ON(tpc != (1 << threads_shift));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) for (i = 0; i < tpc; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) cpumask_set_cpu(i, &threads_core_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) printk(KERN_INFO "CPU maps initialized for %d thread%s per core\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) tpc, tpc > 1 ? "s" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) printk(KERN_DEBUG " (thread shift is %d)\n", threads_shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) u32 *cpu_to_phys_id = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * setup_cpu_maps - initialize the following cpu maps:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * cpu_possible_mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * cpu_present_mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * Having the possible map set up early allows us to restrict allocations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * of things like irqstacks to nr_cpu_ids rather than NR_CPUS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * We do not initialize the online map here; cpus set their own bits in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) * cpu_online_mask as they come up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) * This function is valid only for Open Firmware systems. finish_device_tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) * must be called before using this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) * While we're here, we may as well set the "physical" cpu ids in the paca.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) * NOTE: This must match the parsing done in early_init_dt_scan_cpus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) void __init smp_setup_cpu_maps(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) struct device_node *dn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) int cpu = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) int nthreads = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) DBG("smp_setup_cpu_maps()\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) cpu_to_phys_id = memblock_alloc(nr_cpu_ids * sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) __alignof__(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) if (!cpu_to_phys_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) panic("%s: Failed to allocate %zu bytes align=0x%zx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) __func__, nr_cpu_ids * sizeof(u32), __alignof__(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) for_each_node_by_type(dn, "cpu") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) const __be32 *intserv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) __be32 cpu_be;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) int j, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) DBG(" * %pOF...\n", dn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) &len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) if (intserv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) DBG(" ibm,ppc-interrupt-server#s -> %d threads\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) nthreads);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) DBG(" no ibm,ppc-interrupt-server#s -> 1 thread\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) intserv = of_get_property(dn, "reg", &len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) if (!intserv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) cpu_be = cpu_to_be32(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) /* XXX: what is this? uninitialized?? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) intserv = &cpu_be; /* assume logical == phys */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) len = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) nthreads = len / sizeof(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) bool avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) DBG(" thread %d -> cpu %d (hard id %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) j, cpu, be32_to_cpu(intserv[j]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) avail = of_device_is_available(dn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) if (!avail)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) avail = !of_property_match_string(dn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) "enable-method", "spin-table");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) set_cpu_present(cpu, avail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) set_cpu_possible(cpu, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) cpu_to_phys_id[cpu] = be32_to_cpu(intserv[j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) cpu++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (cpu >= nr_cpu_ids) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) of_node_put(dn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /* If no SMT supported, nthreads is forced to 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) if (!cpu_has_feature(CPU_FTR_SMT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) DBG(" SMT disabled ! nthreads forced to 1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) nthreads = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * On pSeries LPAR, we need to know how many cpus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * could possibly be added to this partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (firmware_has_feature(FW_FEATURE_LPAR) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) (dn = of_find_node_by_path("/rtas"))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) int num_addr_cell, num_size_cell, maxcpus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) const __be32 *ireg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) num_addr_cell = of_n_addr_cells(dn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) num_size_cell = of_n_size_cells(dn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) ireg = of_get_property(dn, "ibm,lrdr-capacity", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) if (!ireg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) maxcpus = be32_to_cpup(ireg + num_addr_cell + num_size_cell);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) /* Double maxcpus for processors which have SMT capability */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) if (cpu_has_feature(CPU_FTR_SMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) maxcpus *= nthreads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) if (maxcpus > nr_cpu_ids) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) printk(KERN_WARNING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) "Partition configured for %d cpus, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) "operating system maximum is %u.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) maxcpus, nr_cpu_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) maxcpus = nr_cpu_ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) printk(KERN_INFO "Partition configured for %d cpus.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) maxcpus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) for (cpu = 0; cpu < maxcpus; cpu++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) set_cpu_possible(cpu, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) of_node_put(dn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) vdso_data->processorCount = num_present_cpus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) #endif /* CONFIG_PPC64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) /* Initialize CPU <=> thread mapping/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * WARNING: We assume that the number of threads is the same for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) * every CPU in the system. If that is not the case, then some code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) * here will have to be reworked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) cpu_init_thread_core_maps(nthreads);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) /* Now that possible cpus are set, set nr_cpu_ids for later use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) setup_nr_cpu_ids();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) free_unused_pacas();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) #endif /* CONFIG_SMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) #ifdef CONFIG_PCSPKR_PLATFORM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) static __init int add_pcspkr(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) struct device_node *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) struct platform_device *pd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) pd = platform_device_alloc("pcspkr", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) if (!pd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) ret = platform_device_add(pd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) platform_device_put(pd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) device_initcall(add_pcspkr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) #endif /* CONFIG_PCSPKR_PLATFORM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) void probe_machine(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) extern struct machdep_calls __machine_desc_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) extern struct machdep_calls __machine_desc_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * Iterate all ppc_md structures until we find the proper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * one for the current machine type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) DBG("Probing machine type ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * Check ppc_md is empty, if not we have a bug, ie, we setup an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) * entry before probe_machine() which will be overwritten
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) for (i = 0; i < (sizeof(ppc_md) / sizeof(void *)); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) if (((void **)&ppc_md)[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) printk(KERN_ERR "Entry %d in ppc_md non empty before"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) " machine probe !\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) for (machine_id = &__machine_desc_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) machine_id < &__machine_desc_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) machine_id++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) DBG(" %s ...", machine_id->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) memcpy(&ppc_md, machine_id, sizeof(struct machdep_calls));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) if (ppc_md.probe()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) DBG(" match !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) DBG("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) /* What can we do if we didn't find ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) if (machine_id >= &__machine_desc_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) pr_err("No suitable machine description found !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) for (;;);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) /* Match a class of boards, not a specific device configuration. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) int check_legacy_ioport(unsigned long base_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) struct device_node *parent, *np = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) int ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) switch(base_port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) case I8042_DATA_REG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) if (np) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) parent = of_get_parent(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) of_i8042_kbd_irq = irq_of_parse_and_map(parent, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) if (!of_i8042_kbd_irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) of_i8042_kbd_irq = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) of_i8042_aux_irq = irq_of_parse_and_map(parent, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) if (!of_i8042_aux_irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) of_i8042_aux_irq = 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) np = parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) np = of_find_node_by_type(NULL, "8042");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) /* Pegasos has no device_type on its 8042 node, look for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) * name instead */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) np = of_find_node_by_name(NULL, "8042");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) if (np) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) of_i8042_kbd_irq = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) of_i8042_aux_irq = 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) case FDC_BASE: /* FDC1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) np = of_find_node_by_type(NULL, "fdc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) /* ipmi is supposed to fail here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) parent = of_get_parent(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) if (parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) if (of_node_is_type(parent, "isa"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) of_node_put(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) EXPORT_SYMBOL(check_legacy_ioport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) static int ppc_panic_event(struct notifier_block *this,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) * panic does a local_irq_disable, but we really
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) * want interrupts to be hard disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) hard_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) * If firmware-assisted dump has been registered then trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) * firmware-assisted dump and let firmware handle everything else.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) crash_fadump(NULL, ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) if (ppc_md.panic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) ppc_md.panic(ptr); /* May not return */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) static struct notifier_block ppc_panic_block = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) .notifier_call = ppc_panic_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) .priority = INT_MIN /* may not return; must be done last */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) * Dump out kernel offset information on panic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) kaslr_offset(), KERNELBASE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) static struct notifier_block kernel_offset_notifier = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) .notifier_call = dump_kernel_offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) void __init setup_panic(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) atomic_notifier_chain_register(&panic_notifier_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) &kernel_offset_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) /* PPC64 always does a hard irq disable in its panic handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) if (!IS_ENABLED(CONFIG_PPC64) && !ppc_md.panic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) #ifdef CONFIG_CHECK_CACHE_COHERENCY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) * For platforms that have configurable cache-coherency. This function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) * checks that the cache coherency setting of the kernel matches the setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) * left by the firmware, as indicated in the device tree. Since a mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) * will eventually result in DMA failures, we print * and error and call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) * BUG() in that case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) #define KERNEL_COHERENCY (!IS_ENABLED(CONFIG_NOT_COHERENT_CACHE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) static int __init check_cache_coherency(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) struct device_node *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) const void *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) bool devtree_coherency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) np = of_find_node_by_path("/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) prop = of_get_property(np, "coherency-off", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) devtree_coherency = prop ? false : true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) if (devtree_coherency != KERNEL_COHERENCY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) "kernel coherency:%s != device tree_coherency:%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) KERNEL_COHERENCY ? "on" : "off",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) devtree_coherency ? "on" : "off");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) late_initcall(check_cache_coherency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) #endif /* CONFIG_CHECK_CACHE_COHERENCY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) struct dentry *powerpc_debugfs_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) EXPORT_SYMBOL(powerpc_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) static int powerpc_debugfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) powerpc_debugfs_root = debugfs_create_dir("powerpc", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) arch_initcall(powerpc_debugfs_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) void ppc_printk_progress(char *s, unsigned short hex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) pr_info("%s\n", s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) static __init void print_system_info(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) pr_info("-----------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) pr_info("phys_mem_size = 0x%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) (unsigned long long)memblock_phys_mem_size());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) pr_info("dcache_bsize = 0x%x\n", dcache_bsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) pr_info("icache_bsize = 0x%x\n", icache_bsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) if (ucache_bsize != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) pr_info("ucache_bsize = 0x%x\n", ucache_bsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) pr_info("cpu_features = 0x%016lx\n", cur_cpu_spec->cpu_features);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) pr_info(" possible = 0x%016lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) (unsigned long)CPU_FTRS_POSSIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) pr_info(" always = 0x%016lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) (unsigned long)CPU_FTRS_ALWAYS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) pr_info("cpu_user_features = 0x%08x 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) cur_cpu_spec->cpu_user_features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) cur_cpu_spec->cpu_user_features2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) pr_info("mmu_features = 0x%08x\n", cur_cpu_spec->mmu_features);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) pr_info("firmware_features = 0x%016lx\n", powerpc_firmware_features);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) #ifdef CONFIG_PPC_BOOK3S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) pr_info("vmalloc start = 0x%lx\n", KERN_VIRT_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) pr_info("IO start = 0x%lx\n", KERN_IO_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) pr_info("vmemmap start = 0x%lx\n", (unsigned long)vmemmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) if (!early_radix_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) print_system_hash_info();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) if (PHYSICAL_START > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) pr_info("physical_start = 0x%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) (unsigned long long)PHYSICAL_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) pr_info("-----------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) static void smp_setup_pacas(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) for_each_possible_cpu(cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) if (cpu == smp_processor_id())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) allocate_paca(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) set_hard_smp_processor_id(cpu, cpu_to_phys_id[cpu]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) memblock_free(__pa(cpu_to_phys_id), nr_cpu_ids * sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) cpu_to_phys_id = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) * Called into from start_kernel this initializes memblock, which is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) * to manage page allocation until mem_init is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) void __init setup_arch(char **cmdline_p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) kasan_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) *cmdline_p = boot_command_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) /* Set a half-reasonable default so udelay does something sensible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) loops_per_jiffy = 500000000 / HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) /* Unflatten the device-tree passed by prom_init or kexec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) unflatten_device_tree();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) * Initialize cache line/block info from device-tree (on ppc64) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) * just cputable (on ppc32).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) initialize_cache_info();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) /* Initialize RTAS if available. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) rtas_initialize();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) /* Check if we have an initrd provided via the device-tree. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) check_for_initrd();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) /* Probe the machine type, establish ppc_md. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) probe_machine();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) /* Setup panic notifier if requested by the platform. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) setup_panic();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) * Configure ppc_md.power_save (ppc32 only, 64-bit machines do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) * it from their respective probe() function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) setup_power_save();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) /* Discover standard serial ports. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) find_legacy_serial_ports();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) /* Register early console with the printk subsystem. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) register_early_udbg_console();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) /* Setup the various CPU maps based on the device-tree. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) smp_setup_cpu_maps();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) /* Initialize xmon. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) xmon_setup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) /* Check the SMT related command line arguments (ppc64). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) check_smt_enabled();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) /* Parse memory topology */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) mem_topology_setup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) * Release secondary cpus out of their spinloops at 0x60 now that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) * we can map physical -> logical CPU ids.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) * Freescale Book3e parts spin in a loop provided by firmware,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) * so smp_release_cpus() does nothing for them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) smp_setup_pacas();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) /* On BookE, setup per-core TLB data structures. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) setup_tlb_core_data();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) /* Print various info about the machine that has been gathered so far. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) print_system_info();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) /* Reserve large chunks of memory for use by CMA for KVM. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) kvm_cma_reserve();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) /* Reserve large chunks of memory for us by CMA for hugetlb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) gigantic_hugetlb_cma_reserve();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) klp_init_thread_info(&init_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) init_mm.start_code = (unsigned long)_stext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) init_mm.end_code = (unsigned long) _etext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) init_mm.end_data = (unsigned long) _edata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) init_mm.brk = klimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) mm_iommu_init(&init_mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) irqstack_early_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) exc_lvl_early_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) emergency_stack_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) smp_release_cpus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) initmem_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) if (ppc_md.setup_arch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) ppc_md.setup_arch();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) setup_barrier_nospec();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) setup_spectre_v2();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) paging_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) /* Initialize the MMU context management stuff. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) mmu_context_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) /* Interrupt code needs to be 64K-aligned. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) if (IS_ENABLED(CONFIG_PPC64) && (unsigned long)_stext & 0xffff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) panic("Kernelbase not 64K-aligned (0x%lx)!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) (unsigned long)_stext);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) }