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> |
Jack Steiner | fd12a0d | 2009-11-19 14:23:41 -0600 | [diff] [blame] | 23 | #include <asm/pat.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) { } |
| 32 | static bool __init bool_x86_init_noop(void) { return false; } |
| 33 | static void x86_op_int_noop(int cpu) { } |
Thomas Gleixner | 57844a8 | 2009-08-19 14:48:38 +0200 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * The platform setup functions are preset with the default functions |
| 37 | * for standard PC hardware. |
| 38 | */ |
Thomas Gleixner | 54e2603 | 2009-09-16 08:42:26 +0200 | [diff] [blame] | 39 | struct x86_init_ops x86_init __initdata = { |
Thomas Gleixner | f7cf5a5 | 2009-08-19 14:43:56 +0200 | [diff] [blame] | 40 | |
| 41 | .resources = { |
Dan Williams | 5d94e81 | 2011-03-08 10:36:19 -0800 | [diff] [blame] | 42 | .probe_roms = probe_roms, |
Thomas Gleixner | 8fee697 | 2009-08-19 14:55:50 +0200 | [diff] [blame] | 43 | .reserve_resources = reserve_standard_io_resources, |
Ingo Molnar | 103e206 | 2017-01-28 09:58:49 +0100 | [diff] [blame] | 44 | .memory_setup = e820__memory_setup_default, |
Thomas Gleixner | f7cf5a5 | 2009-08-19 14:43:56 +0200 | [diff] [blame] | 45 | }, |
Thomas Gleixner | f484847 | 2009-08-20 12:05:01 +0200 | [diff] [blame] | 46 | |
| 47 | .mpparse = { |
| 48 | .mpc_record = x86_init_uint_noop, |
Thomas Gleixner | de93410 | 2009-08-20 09:27:29 +0200 | [diff] [blame] | 49 | .setup_ioapic_ids = x86_init_noop, |
Thomas Gleixner | fd6c666 | 2009-08-20 10:41:58 +0200 | [diff] [blame] | 50 | .mpc_apic_id = default_mpc_apic_id, |
Thomas Gleixner | 7230214 | 2009-08-20 12:18:32 +0200 | [diff] [blame] | 51 | .smp_read_mpc_oem = default_smp_read_mpc_oem, |
Thomas Gleixner | 90e1c69 | 2009-08-20 12:34:47 +0200 | [diff] [blame] | 52 | .mpc_oem_bus_info = default_mpc_oem_bus_info, |
Thomas Gleixner | b3f1b61 | 2009-08-20 11:11:52 +0200 | [diff] [blame] | 53 | .find_smp_config = default_find_smp_config, |
| 54 | .get_smp_config = default_get_smp_config, |
Thomas Gleixner | f484847 | 2009-08-20 12:05:01 +0200 | [diff] [blame] | 55 | }, |
Thomas Gleixner | d9112f4 | 2009-08-20 09:41:38 +0200 | [diff] [blame] | 56 | |
| 57 | .irqs = { |
| 58 | .pre_vector_init = init_ISA_irqs, |
Thomas Gleixner | 66bcaf0 | 2009-08-20 09:59:09 +0200 | [diff] [blame] | 59 | .intr_init = native_init_IRQ, |
Thomas Gleixner | 428cf90 | 2009-08-20 10:35:46 +0200 | [diff] [blame] | 60 | .trap_init = x86_init_noop, |
Dou Liyang | 34fba3e | 2017-09-13 17:12:52 +0800 | [diff] [blame] | 61 | .intr_mode_init = apic_intr_mode_init |
Thomas Gleixner | d9112f4 | 2009-08-20 09:41:38 +0200 | [diff] [blame] | 62 | }, |
Thomas Gleixner | 42bbdb4 | 2009-08-20 13:04:10 +0200 | [diff] [blame] | 63 | |
| 64 | .oem = { |
| 65 | .arch_setup = x86_init_noop, |
Thomas Gleixner | 6f30c1a | 2009-08-20 13:19:57 +0200 | [diff] [blame] | 66 | .banner = default_banner, |
Thomas Gleixner | 42bbdb4 | 2009-08-20 13:04:10 +0200 | [diff] [blame] | 67 | }, |
Thomas Gleixner | 030cb6c | 2009-08-20 14:30:02 +0200 | [diff] [blame] | 68 | |
| 69 | .paging = { |
Attilio Rao | 7737b21 | 2012-08-21 21:22:38 +0100 | [diff] [blame] | 70 | .pagetable_init = native_pagetable_init, |
Thomas Gleixner | 030cb6c | 2009-08-20 14:30:02 +0200 | [diff] [blame] | 71 | }, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 72 | |
| 73 | .timers = { |
| 74 | .setup_percpu_clockev = setup_boot_APIC_clock, |
Thomas Gleixner | 845b394 | 2009-08-19 15:37:03 +0200 | [diff] [blame] | 75 | .timer_init = hpet_time_init, |
Feng Tang | 6b617e2 | 2011-02-15 00:13:31 +0800 | [diff] [blame] | 76 | .wallclock_init = x86_init_noop, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 77 | }, |
FUJITA Tomonori | d07c1be | 2009-11-10 19:46:12 +0900 | [diff] [blame] | 78 | |
| 79 | .iommu = { |
| 80 | .iommu_init = iommu_init_noop, |
| 81 | }, |
Thomas Gleixner | b72d0db | 2009-08-29 16:24:51 +0200 | [diff] [blame] | 82 | |
| 83 | .pci = { |
| 84 | .init = x86_default_pci_init, |
Thomas Gleixner | ab3b379 | 2009-08-29 17:47:33 +0200 | [diff] [blame] | 85 | .init_irq = x86_default_pci_init_irq, |
Thomas Gleixner | 9325a28 | 2009-08-29 17:51:26 +0200 | [diff] [blame] | 86 | .fixup_irqs = x86_default_pci_fixup_irqs, |
Thomas Gleixner | b72d0db | 2009-08-29 16:24:51 +0200 | [diff] [blame] | 87 | }, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 88 | |
| 89 | .hyper = { |
| 90 | .init_platform = x86_init_noop, |
Juergen Gross | f361464 | 2017-11-09 14:27:38 +0100 | [diff] [blame] | 91 | .guest_late_init = x86_init_noop, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 92 | .x2apic_available = bool_x86_init_noop, |
| 93 | .init_mem_mapping = x86_init_noop, |
Pavel Tatashin | 6f84f8d | 2018-04-10 16:36:10 -0700 | [diff] [blame] | 94 | .init_after_bootmem = x86_init_noop, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 95 | }, |
Juergen Gross | 038bac2 | 2018-02-19 11:09:05 +0100 | [diff] [blame] | 96 | |
| 97 | .acpi = { |
Juergen Gross | e7b66d1 | 2018-10-10 08:14:56 +0200 | [diff] [blame^] | 98 | .get_root_pointer = x86_default_get_root_pointer, |
Andy Shevchenko | 81b53e5 | 2018-02-20 20:05:05 +0200 | [diff] [blame] | 99 | .reduced_hw_early_init = acpi_generic_reduced_hw_init, |
Juergen Gross | 038bac2 | 2018-02-19 11:09:05 +0100 | [diff] [blame] | 100 | }, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 101 | }; |
| 102 | |
Paul Gortmaker | 148f9bb | 2013-06-18 18:23:59 -0400 | [diff] [blame] | 103 | struct x86_cpuinit_ops x86_cpuinit = { |
Igor Mammedov | df156f9 | 2012-02-07 15:52:44 +0100 | [diff] [blame] | 104 | .early_percpu_clock_init = x86_init_noop, |
Thomas Gleixner | 736deca | 2009-08-19 12:35:53 +0200 | [diff] [blame] | 105 | .setup_percpu_clockev = setup_secondary_APIC_clock, |
Thomas Gleixner | 57844a8 | 2009-08-19 14:48:38 +0200 | [diff] [blame] | 106 | }; |
Thomas Gleixner | 2d82640 | 2009-08-20 17:06:25 +0200 | [diff] [blame] | 107 | |
Russ Anderson | 78c0617 | 2010-02-26 10:49:12 -0600 | [diff] [blame] | 108 | static void default_nmi_init(void) { }; |
| 109 | |
Kees Cook | 404f6aa | 2016-08-08 16:29:06 -0700 | [diff] [blame] | 110 | struct x86_platform_ops x86_platform __ro_after_init = { |
Pavel Tatashin | 8dbe438 | 2018-07-19 16:55:45 -0400 | [diff] [blame] | 111 | .calibrate_cpu = native_calibrate_cpu_early, |
Thomas Gleixner | 2d82640 | 2009-08-20 17:06:25 +0200 | [diff] [blame] | 112 | .calibrate_tsc = native_calibrate_tsc, |
Feng Tang | 7bd867d | 2009-09-10 10:48:56 +0800 | [diff] [blame] | 113 | .get_wallclock = mach_get_cmos_time, |
| 114 | .set_wallclock = mach_set_rtc_mmss, |
FUJITA Tomonori | 338bac5 | 2009-10-27 16:34:44 +0900 | [diff] [blame] | 115 | .iommu_shutdown = iommu_shutdown_noop, |
H. Peter Anvin | eb41c8b | 2009-11-23 14:46:07 -0800 | [diff] [blame] | 116 | .is_untracked_pat_range = is_ISA_range, |
Feng Tang | c516ac5 | 2010-07-05 23:03:18 +0800 | [diff] [blame] | 117 | .nmi_init = default_nmi_init, |
Jacob Pan | 064a59b | 2011-11-10 13:43:05 +0000 | [diff] [blame] | 118 | .get_nmi_reason = default_get_nmi_reason, |
Marcelo Tosatti | b74f05d6 | 2012-02-13 11:07:27 -0200 | [diff] [blame] | 119 | .save_sched_clock_state = tsc_save_sched_clock_state, |
| 120 | .restore_sched_clock_state = tsc_restore_sched_clock_state, |
Juergen Gross | f72e38e | 2017-11-09 14:27:35 +0100 | [diff] [blame] | 121 | .hyper.pin_vcpu = x86_op_int_noop, |
Thomas Gleixner | 2d82640 | 2009-08-20 17:06:25 +0200 | [diff] [blame] | 122 | }; |
H. Peter Anvin | 72550b3 | 2010-07-07 16:57:46 -0700 | [diff] [blame] | 123 | |
| 124 | EXPORT_SYMBOL_GPL(x86_platform); |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 125 | |
| 126 | #if defined(CONFIG_PCI_MSI) |
Kees Cook | 404f6aa | 2016-08-08 16:29:06 -0700 | [diff] [blame] | 127 | struct x86_msi_ops x86_msi __ro_after_init = { |
Joerg Roedel | 71054d8 | 2012-09-26 12:44:37 +0200 | [diff] [blame] | 128 | .setup_msi_irqs = native_setup_msi_irqs, |
| 129 | .teardown_msi_irq = native_teardown_msi_irq, |
| 130 | .teardown_msi_irqs = default_teardown_msi_irqs, |
| 131 | .restore_msi_irqs = default_restore_msi_irqs, |
Stefano Stabellini | 294ee6f | 2010-10-06 16:12:28 -0400 | [diff] [blame] | 132 | }; |
Konrad Rzeszutek Wilk | 4a8e2a3 | 2012-03-28 12:37:36 -0400 | [diff] [blame] | 133 | |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 134 | /* MSI arch specific hooks */ |
| 135 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) |
| 136 | { |
| 137 | return x86_msi.setup_msi_irqs(dev, nvec, type); |
| 138 | } |
| 139 | |
| 140 | void arch_teardown_msi_irqs(struct pci_dev *dev) |
| 141 | { |
| 142 | x86_msi.teardown_msi_irqs(dev); |
| 143 | } |
| 144 | |
| 145 | void arch_teardown_msi_irq(unsigned int irq) |
| 146 | { |
| 147 | x86_msi.teardown_msi_irq(irq); |
| 148 | } |
| 149 | |
DuanZhenzhong | ac8344c | 2013-12-04 13:09:16 +0800 | [diff] [blame] | 150 | void arch_restore_msi_irqs(struct pci_dev *dev) |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 151 | { |
DuanZhenzhong | ac8344c | 2013-12-04 13:09:16 +0800 | [diff] [blame] | 152 | x86_msi.restore_msi_irqs(dev); |
Thomas Petazzoni | 4287d82 | 2013-08-09 22:27:06 +0200 | [diff] [blame] | 153 | } |
| 154 | #endif |
| 155 | |
Baoquan He | 51b146c | 2018-02-14 13:46:55 +0800 | [diff] [blame] | 156 | struct x86_apic_ops x86_apic_ops __ro_after_init = { |
| 157 | .io_apic_read = native_io_apic_read, |
| 158 | .restore = native_restore_boot_irq_mode, |
Konrad Rzeszutek Wilk | 4a8e2a3 | 2012-03-28 12:37:36 -0400 | [diff] [blame] | 159 | }; |