Thomas Gleixner | 57844a8 | 2009-08-19 14:48:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 Thomas Gleixner <tglx@linutronix.de> |
| 3 | * |
| 4 | * For licencing details see kernel-base/COPYING |
| 5 | */ |
| 6 | #include <linux/init.h> |
Thomas Gleixner | 9325a28 | 2009-08-29 17:51:26 +0200 | [diff] [blame] | 7 | #include <linux/ioport.h> |
Paul Gortmaker | 186f436 | 2016-07-13 20:18:56 -0400 | [diff] [blame] | 8 | #include <linux/export.h> |
Stefano Stabellini | 294ee6f | 2010-10-06 16:12:28 -0400 | [diff] [blame] | 9 | #include <linux/pci.h> |
Thomas Gleixner | 57844a8 | 2009-08-19 14:48:38 +0200 | [diff] [blame] | 10 | |
Andy Shevchenko | 81b53e5 | 2018-02-20 20:05:05 +0200 | [diff] [blame] | 11 | #include <asm/acpi.h> |
Thomas Gleixner | 816c25e | 2009-08-19 14:36:27 +0200 | [diff] [blame] | 12 | #include <asm/bios_ebda.h> |
Thomas Gleixner | 6f30c1a | 2009-08-20 13:19:57 +0200 | [diff] [blame] | 13 | #include <asm/paravirt.h> |
Thomas Gleixner | b72d0db | 2009-08-29 16:24:51 +0200 | [diff] [blame] | 14 | #include <asm/pci_x86.h> |
Thomas Gleixner | fd6c666 | 2009-08-20 10:41:58 +0200 | [diff] [blame] | 15 | #include <asm/mpspec.h> |
Thomas Gleixner | 8fee697 | 2009-08-19 14:55:50 +0200 | [diff] [blame] | 16 | #include <asm/setup.h> |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 17 | #include <asm/apic.h> |
Ingo Molnar | 66441bd | 2017-01-27 10:27:10 +0100 | [diff] [blame] | 18 | #include <asm/e820/api.h> |
Thomas Gleixner | 845b394 | 2009-08-19 15:37:03 +0200 | [diff] [blame] | 19 | #include <asm/time.h> |
Thomas Gleixner | d9112f4 | 2009-08-20 09:41:38 +0200 | [diff] [blame] | 20 | #include <asm/irq.h> |
Konrad Rzeszutek Wilk | 4a8e2a3 | 2012-03-28 12:37:36 -0400 | [diff] [blame] | 21 | #include <asm/io_apic.h> |
Joerg Roedel | 71054d8 | 2012-09-26 12:44:37 +0200 | [diff] [blame] | 22 | #include <asm/hpet.h> |
Ingo Molnar | eb243d1 | 2019-11-20 15:33:57 +0100 | [diff] [blame] | 23 | #include <asm/memtype.h> |
Thomas Gleixner | 2d82640 | 2009-08-20 17:06:25 +0200 | [diff] [blame] | 24 | #include <asm/tsc.h> |
FUJITA Tomonori | 338bac5 | 2009-10-27 16:34:44 +0900 | [diff] [blame] | 25 | #include <asm/iommu.h> |
Jacob Pan | 064a59b | 2011-11-10 13:43:05 +0000 | [diff] [blame] | 26 | #include <asm/mach_traps.h> |
Thomas Gleixner | 57844a8 | 2009-08-19 14:48:38 +0200 | [diff] [blame] | 27 | |
Paul Gortmaker | 148f9bb | 2013-06-18 18:23:59 -0400 | [diff] [blame] | 28 | void x86_init_noop(void) { } |
Thomas Gleixner | f484847 | 2009-08-20 12:05:01 +0200 | [diff] [blame] | 29 | void __init x86_init_uint_noop(unsigned int unused) { } |
Juergen Gross | c46dacb | 2018-02-21 10:42:32 +0100 | [diff] [blame] | 30 | static int __init iommu_init_noop(void) { return 0; } |
| 31 | static void iommu_shutdown_noop(void) { } |
Zhenzhong Duan | bef6e0a | 2019-07-16 12:26:09 +0800 | [diff] [blame] | 32 | bool __init bool_x86_init_noop(void) { return false; } |
| 33 | void x86_op_int_noop(int cpu) { } |
Rahul Tanwar | c311ed6 | 2019-10-10 17:28:56 +0800 | [diff] [blame] | 34 | static __init int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; } |
| 35 | static __init void get_rtc_noop(struct timespec64 *now) { } |
| 36 | |
| 37 | static __initconst const struct of_device_id of_cmos_match[] = { |
| 38 | { .compatible = "motorola,mc146818" }, |
| 39 | {} |
| 40 | }; |
| 41 | |
| 42 | /* |
| 43 | * Allow devicetree configured systems to disable the RTC by setting the |
| 44 | * corresponding DT node's status property to disabled. Code is optimized |
| 45 | * out for CONFIG_OF=n builds. |
| 46 | */ |
| 47 | static __init void x86_wallclock_init(void) |
| 48 | { |
| 49 | struct device_node *node = of_find_matching_node(NULL, of_cmos_match); |
| 50 | |
| 51 | if (node && !of_device_is_available(node)) { |
| 52 | x86_platform.get_wallclock = get_rtc_noop; |
| 53 | x86_platform.set_wallclock = set_rtc_noop; |
| 54 | } |
| 55 | } |
Thomas Gleixner | 57844a8 | 2009-08-19 14:48:38 +0200 | [diff] [blame] | 56 | |
| 57 | /* |
| 58 | * The platform setup functions are preset with the default functions |
| 59 | * for standard PC hardware. |
| 60 | */ |
Thomas Gleixner | 54e2603 | 2009-09-16 08:42:26 +0200 | [diff] [blame] | 61 | struct x86_init_ops x86_init __initdata = { |
Thomas Gleixner | f7cf5a5 | 2009-08-19 14:43:56 +0200 | [diff] [blame] | 62 | |
| 63 | .resources = { |
Dan Williams | 5d94e81 | 2011-03-08 10:36:19 -0800 | [diff] [blame] | 64 | .probe_roms = probe_roms, |
Thomas Gleixner | 8fee697 | 2009-08-19 14:55:50 +0200 | [diff] [blame] | 65 | .reserve_resources = reserve_standard_io_resources, |
Ingo Molnar | 103e206 | 2017-01-28 09:58:49 +0100 | [diff] [blame] | 66 | .memory_setup = e820__memory_setup_default, |
Thomas Gleixner | f7cf5a5 | 2009-08-19 14:43:56 +0200 | [diff] [blame] | 67 | }, |
Thomas Gleixner | f484847 | 2009-08-20 12:05:01 +0200 | [diff] [blame] | 68 | |
| 69 | .mpparse = { |
| 70 | .mpc_record = x86_init_uint_noop, |
Thomas Gleixner | de93410 | 2009-08-20 09:27:29 +0200 | [diff] [blame] | 71 | .setup_ioapic_ids = x86_init_noop, |
Thomas Gleixner | fd6c666 | 2009-08-20 10:41:58 +0200 | [diff] [blame] | 72 | .mpc_apic_id = default_mpc_apic_id, |
Thomas Gleixner | 7230214 | 2009-08-20 12:18:32 +0200 | [diff] [blame] | 73 | .smp_read_mpc_oem = default_smp_read_mpc_oem, |
Thomas Gleixner | 90e1c69 | 2009-08-20 12:34:47 +0200 | [diff] [blame] | 74 | .mpc_oem_bus_info = default_mpc_oem_bus_info, |
Thomas Gleixner | b3f1b61 | 2009-08-20 11:11:52 +0200 | [diff] [blame] | 75 | .find_smp_config = default_find_smp_config, |
| 76 | .get_smp_config = default_get_smp_config, |
Thomas Gleixner | f484847 | 2009-08-20 12:05:01 +0200 | [diff] [blame] | 77 | }, |
Thomas Gleixner | d9112f4 | 2009-08-20 09:41:38 +0200 | [diff] [blame] | 78 | |
| 79 | .irqs = { |
| 80 | .pre_vector_init = init_ISA_irqs, |
Thomas Gleixner | 66bcaf0 | 2009-08-20 09:59:09 +0200 | [diff] [blame] | 81 | .intr_init = native_init_IRQ, |
Thomas Gleixner | 428cf90 | 2009-08-20 10:35:46 +0200 | [diff] [blame] | 82 | .trap_init = x86_init_noop, |
Thomas Gleixner | 9799238 | 2020-01-23 12:54:53 +0100 | [diff] [blame] | 83 | .intr_mode_select = apic_intr_mode_select, |
Dou Liyang | 34fba3e | 2017-09-13 17:12:52 +0800 | [diff] [blame] | 84 | .intr_mode_init = apic_intr_mode_init |
Thomas Gleixner | d9112f4 | 2009-08-20 09:41:38 +0200 | [diff] [blame] | 85 | }, |
Thomas Gleixner | 42bbdb4 | 2009-08-20 13:04:10 +0200 | [diff] [blame] | 86 | |
| 87 | .oem = { |
| 88 | .arch_setup = x86_init_noop, |
Thomas Gleixner | 6f30c1a | 2009-08-20 13:19:57 +0200 | [diff] [blame] | 89 | .banner = default_banner, |
Thomas Gleixner | 42bbdb4 | 2009-08-20 13:04:10 +0200 | [diff] [blame] | 90 | }, |
Thomas Gleixner | 030cb6c | 2009-08-20 14:30:02 +0200 | [diff] [blame] | 91 | |
| 92 | .paging = { |
Attilio Rao | 7737b21 | 2012-08-21 21:22:38 +0100 | [diff] [blame] | 93 | .pagetable_init = native_pagetable_init, |
Thomas Gleixner | 030cb6c | 2009-08-20 14:30:02 +0200 | [diff] [blame] | 94 | }, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 95 | |
| 96 | .timers = { |
| 97 | .setup_percpu_clockev = setup_boot_APIC_clock, |
Thomas Gleixner | 845b394 | 2009-08-19 15:37:03 +0200 | [diff] [blame] | 98 | .timer_init = hpet_time_init, |
Rahul Tanwar | c311ed6 | 2019-10-10 17:28:56 +0800 | [diff] [blame] | 99 | .wallclock_init = x86_wallclock_init, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 100 | }, |
FUJITA Tomonori | d07c1be | 2009-11-10 19:46:12 +0900 | [diff] [blame] | 101 | |
| 102 | .iommu = { |
| 103 | .iommu_init = iommu_init_noop, |
| 104 | }, |
Thomas Gleixner | b72d0db | 2009-08-29 16:24:51 +0200 | [diff] [blame] | 105 | |
| 106 | .pci = { |
| 107 | .init = x86_default_pci_init, |
Thomas Gleixner | ab3b379 | 2009-08-29 17:47:33 +0200 | [diff] [blame] | 108 | .init_irq = x86_default_pci_init_irq, |
Thomas Gleixner | 9325a28 | 2009-08-29 17:51:26 +0200 | [diff] [blame] | 109 | .fixup_irqs = x86_default_pci_fixup_irqs, |
Thomas Gleixner | b72d0db | 2009-08-29 16:24:51 +0200 | [diff] [blame] | 110 | }, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 111 | |
| 112 | .hyper = { |
| 113 | .init_platform = x86_init_noop, |
Juergen Gross | f361464 | 2017-11-09 14:27:38 +0100 | [diff] [blame] | 114 | .guest_late_init = x86_init_noop, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 115 | .x2apic_available = bool_x86_init_noop, |
| 116 | .init_mem_mapping = x86_init_noop, |
Pavel Tatashin | 6f84f8d | 2018-04-10 16:36:10 -0700 | [diff] [blame] | 117 | .init_after_bootmem = x86_init_noop, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 118 | }, |
Juergen Gross | 038bac2 | 2018-02-19 11:09:05 +0100 | [diff] [blame] | 119 | |
| 120 | .acpi = { |
Josh Boyer | 41fa1ee | 2019-08-19 17:17:51 -0700 | [diff] [blame] | 121 | .set_root_pointer = x86_default_set_root_pointer, |
Juergen Gross | e7b66d1 | 2018-10-10 08:14:56 +0200 | [diff] [blame] | 122 | .get_root_pointer = x86_default_get_root_pointer, |
Andy Shevchenko | 81b53e5 | 2018-02-20 20:05:05 +0200 | [diff] [blame] | 123 | .reduced_hw_early_init = acpi_generic_reduced_hw_init, |
Juergen Gross | 038bac2 | 2018-02-19 11:09:05 +0100 | [diff] [blame] | 124 | }, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 125 | }; |
| 126 | |
Paul Gortmaker | 148f9bb | 2013-06-18 18:23:59 -0400 | [diff] [blame] | 127 | struct x86_cpuinit_ops x86_cpuinit = { |
Igor Mammedov | df156f9 | 2012-02-07 15:52:44 +0100 | [diff] [blame] | 128 | .early_percpu_clock_init = x86_init_noop, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 129 | .setup_percpu_clockev = setup_secondary_APIC_clock, |
Thomas Gleixner | 57844a8 | 2009-08-19 14:48:38 +0200 | [diff] [blame] | 130 | }; |
Thomas Gleixner | 2d82640 | 2009-08-20 17:06:25 +0200 | [diff] [blame] | 131 | |
Russ Anderson | 78c0617 | 2010-02-26 10:49:12 -0600 | [diff] [blame] | 132 | static void default_nmi_init(void) { }; |
| 133 | |
Kees Cook | 404f6aa | 2016-08-08 16:29:06 -0700 | [diff] [blame] | 134 | struct x86_platform_ops x86_platform __ro_after_init = { |
Pavel Tatashin | 8dbe438 | 2018-07-19 16:55:45 -0400 | [diff] [blame] | 135 | .calibrate_cpu = native_calibrate_cpu_early, |
Thomas Gleixner | 2d82640 | 2009-08-20 17:06:25 +0200 | [diff] [blame] | 136 | .calibrate_tsc = native_calibrate_tsc, |
Feng Tang | 7bd867d | 2009-09-10 10:48:56 +0800 | [diff] [blame] | 137 | .get_wallclock = mach_get_cmos_time, |
| 138 | .set_wallclock = mach_set_rtc_mmss, |
FUJITA Tomonori | 338bac5 | 2009-10-27 16:34:44 +0900 | [diff] [blame] | 139 | .iommu_shutdown = iommu_shutdown_noop, |
H. Peter Anvin | eb41c8b | 2009-11-23 14:46:07 -0800 | [diff] [blame] | 140 | .is_untracked_pat_range = is_ISA_range, |
Feng Tang | c516ac5 | 2010-07-05 23:03:18 +0800 | [diff] [blame] | 141 | .nmi_init = default_nmi_init, |
Jacob Pan | 064a59b | 2011-11-10 13:43:05 +0000 | [diff] [blame] | 142 | .get_nmi_reason = default_get_nmi_reason, |
Marcelo Tosatti | b74f05d6 | 2012-02-13 11:07:27 -0200 | [diff] [blame] | 143 | .save_sched_clock_state = tsc_save_sched_clock_state, |
| 144 | .restore_sched_clock_state = tsc_restore_sched_clock_state, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 145 | .hyper.pin_vcpu = x86_op_int_noop, |
Thomas Gleixner | 2d82640 | 2009-08-20 17:06:25 +0200 | [diff] [blame] | 146 | }; |
H. Peter Anvin | 72550b3 | 2010-07-07 16:57:46 -0700 | [diff] [blame] | 147 | |
| 148 | EXPORT_SYMBOL_GPL(x86_platform); |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 149 | |
| 150 | #if defined(CONFIG_PCI_MSI) |
Kees Cook | 404f6aa | 2016-08-08 16:29:06 -0700 | [diff] [blame] | 151 | struct x86_msi_ops x86_msi __ro_after_init = { |
Joerg Roedel | 71054d8 | 2012-09-26 12:44:37 +0200 | [diff] [blame] | 152 | .setup_msi_irqs = native_setup_msi_irqs, |
| 153 | .teardown_msi_irq = native_teardown_msi_irq, |
| 154 | .teardown_msi_irqs = default_teardown_msi_irqs, |
| 155 | .restore_msi_irqs = default_restore_msi_irqs, |
Stefano Stabellini | 294ee6f | 2010-10-06 16:12:28 -0400 | [diff] [blame] | 156 | }; |
Konrad Rzeszutek Wilk | 4a8e2a3 | 2012-03-28 12:37:36 -0400 | [diff] [blame] | 157 | |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 158 | /* MSI arch specific hooks */ |
| 159 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) |
| 160 | { |
| 161 | return x86_msi.setup_msi_irqs(dev, nvec, type); |
| 162 | } |
| 163 | |
| 164 | void arch_teardown_msi_irqs(struct pci_dev *dev) |
| 165 | { |
| 166 | x86_msi.teardown_msi_irqs(dev); |
| 167 | } |
| 168 | |
| 169 | void arch_teardown_msi_irq(unsigned int irq) |
| 170 | { |
| 171 | x86_msi.teardown_msi_irq(irq); |
| 172 | } |
| 173 | |
DuanZhenzhong | ac8344c | 2013-12-04 13:09:16 +0800 | [diff] [blame] | 174 | void arch_restore_msi_irqs(struct pci_dev *dev) |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 175 | { |
DuanZhenzhong | ac8344c | 2013-12-04 13:09:16 +0800 | [diff] [blame] | 176 | x86_msi.restore_msi_irqs(dev); |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 177 | } |
| 178 | #endif |
| 179 | |
Baoquan He | 51b146c | 2018-02-14 13:46:55 +0800 | [diff] [blame] | 180 | struct x86_apic_ops x86_apic_ops __ro_after_init = { |
| 181 | .io_apic_read = native_io_apic_read, |
| 182 | .restore = native_restore_boot_irq_mode, |
Konrad Rzeszutek Wilk | 4a8e2a3 | 2012-03-28 12:37:36 -0400 | [diff] [blame] | 183 | }; |