1 /* 2 * Copyright (C) 2009 Linutronix GmbH, Thomas Gleixner <tglx@kernel.org> 3 * 4 * For licencing details see kernel-base/COPYING 5 */ 6 #include <linux/dmi.h> 7 #include <linux/init.h> 8 #include <linux/ioport.h> 9 #include <linux/export.h> 10 #include <linux/pci.h> 11 #include <linux/acpi.h> 12 #include <linux/sizes.h> 13 14 #include <asm/acpi.h> 15 #include <asm/bios_ebda.h> 16 #include <asm/paravirt.h> 17 #include <asm/pci_x86.h> 18 #include <asm/mpspec.h> 19 #include <asm/setup.h> 20 #include <asm/apic.h> 21 #include <asm/e820/api.h> 22 #include <asm/time.h> 23 #include <asm/irq.h> 24 #include <asm/io_apic.h> 25 #include <asm/hpet.h> 26 #include <asm/memtype.h> 27 #include <asm/tsc.h> 28 #include <asm/iommu.h> 29 #include <asm/mach_traps.h> 30 #include <asm/irqdomain.h> 31 #include <asm/realmode.h> 32 33 void x86_init_noop(void) { } 34 void __init x86_init_uint_noop(unsigned int unused) { } 35 static int __init iommu_init_noop(void) { return 0; } 36 static void iommu_shutdown_noop(void) { } 37 bool __init bool_x86_init_noop(void) { return false; } 38 void x86_op_int_noop(int cpu) { } 39 int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; } 40 void get_rtc_noop(struct timespec64 *now) { } 41 42 static __initconst const struct of_device_id of_cmos_match[] = { 43 { .compatible = "motorola,mc146818" }, 44 {} 45 }; 46 47 /* 48 * Allow devicetree configured systems to disable the RTC by setting the 49 * corresponding DT node's status property to disabled. Code is optimized 50 * out for CONFIG_OF=n builds. 51 */ 52 static __init void x86_wallclock_init(void) 53 { 54 struct device_node *node = of_find_matching_node(NULL, of_cmos_match); 55 56 if (node && !of_device_is_available(node)) { 57 x86_platform.get_wallclock = get_rtc_noop; 58 x86_platform.set_wallclock = set_rtc_noop; 59 } 60 } 61 62 /* 63 * The platform setup functions are preset with the default functions 64 * for standard PC hardware. 65 */ 66 struct x86_init_ops x86_init __initdata = { 67 68 .resources = { 69 .probe_roms = probe_roms, 70 .reserve_resources = reserve_standard_io_resources, 71 .memory_setup = e820__memory_setup_default, 72 .dmi_setup = dmi_setup, 73 /* Has to be under 1M so we can execute real-mode AP code. */ 74 .realmode_limit = SZ_1M, 75 }, 76 77 .mpparse = { 78 .setup_ioapic_ids = x86_init_noop, 79 .find_mptable = mpparse_find_mptable, 80 .early_parse_smp_cfg = mpparse_parse_early_smp_config, 81 .parse_smp_cfg = mpparse_parse_smp_config, 82 }, 83 84 .irqs = { 85 .pre_vector_init = init_ISA_irqs, 86 .intr_init = native_init_IRQ, 87 .intr_mode_select = apic_intr_mode_select, 88 .intr_mode_init = apic_intr_mode_init, 89 .create_pci_msi_domain = native_create_pci_msi_domain, 90 }, 91 92 .oem = { 93 .arch_setup = x86_init_noop, 94 .banner = default_banner, 95 }, 96 97 .paging = { 98 .pagetable_init = native_pagetable_init, 99 }, 100 101 .timers = { 102 .setup_percpu_clockev = setup_boot_APIC_clock, 103 .timer_init = hpet_time_init, 104 .wallclock_init = x86_wallclock_init, 105 }, 106 107 .iommu = { 108 .iommu_init = iommu_init_noop, 109 }, 110 111 .pci = { 112 .init = x86_default_pci_init, 113 .init_irq = x86_default_pci_init_irq, 114 .fixup_irqs = x86_default_pci_fixup_irqs, 115 }, 116 117 .hyper = { 118 .init_platform = x86_init_noop, 119 .guest_late_init = x86_init_noop, 120 .x2apic_available = bool_x86_init_noop, 121 .msi_ext_dest_id = bool_x86_init_noop, 122 .init_mem_mapping = x86_init_noop, 123 .init_after_bootmem = x86_init_noop, 124 }, 125 126 .acpi = { 127 .set_root_pointer = x86_default_set_root_pointer, 128 .get_root_pointer = x86_default_get_root_pointer, 129 .reduced_hw_early_init = acpi_generic_reduced_hw_init, 130 }, 131 }; 132 133 struct x86_cpuinit_ops x86_cpuinit = { 134 .early_percpu_clock_init = x86_init_noop, 135 .setup_percpu_clockev = setup_secondary_APIC_clock, 136 .parallel_bringup = true, 137 }; 138 139 static void default_nmi_init(void) { }; 140 141 static int enc_status_change_prepare_noop(unsigned long vaddr, int npages, bool enc) { return 0; } 142 static int enc_status_change_finish_noop(unsigned long vaddr, int npages, bool enc) { return 0; } 143 static bool enc_tlb_flush_required_noop(bool enc) { return false; } 144 static bool enc_cache_flush_required_noop(void) { return false; } 145 static void enc_kexec_begin_noop(void) {} 146 static void enc_kexec_finish_noop(void) {} 147 static bool is_private_mmio_noop(u64 addr) {return false; } 148 149 struct x86_platform_ops x86_platform __ro_after_init = { 150 .calibrate_cpu = native_calibrate_cpu_early, 151 .calibrate_tsc = native_calibrate_tsc, 152 .get_wallclock = mach_get_cmos_time, 153 .set_wallclock = mach_set_cmos_time, 154 .iommu_shutdown = iommu_shutdown_noop, 155 .is_untracked_pat_range = is_ISA_range, 156 .nmi_init = default_nmi_init, 157 .get_nmi_reason = default_get_nmi_reason, 158 .save_sched_clock_state = tsc_save_sched_clock_state, 159 .restore_sched_clock_state = tsc_restore_sched_clock_state, 160 .realmode_reserve = reserve_real_mode, 161 .realmode_init = init_real_mode, 162 .hyper.pin_vcpu = x86_op_int_noop, 163 .hyper.is_private_mmio = is_private_mmio_noop, 164 165 .guest = { 166 .enc_status_change_prepare = enc_status_change_prepare_noop, 167 .enc_status_change_finish = enc_status_change_finish_noop, 168 .enc_tlb_flush_required = enc_tlb_flush_required_noop, 169 .enc_cache_flush_required = enc_cache_flush_required_noop, 170 .enc_kexec_begin = enc_kexec_begin_noop, 171 .enc_kexec_finish = enc_kexec_finish_noop, 172 }, 173 }; 174 175 EXPORT_SYMBOL_GPL(x86_platform); 176 177 struct x86_apic_ops x86_apic_ops __ro_after_init = { 178 .io_apic_read = native_io_apic_read, 179 .restore = native_restore_boot_irq_mode, 180 }; 181