blob: 50a2b492fdd663ae727130b53454123ab2a30662 [file] [log] [blame]
Thomas Gleixner57844a82009-08-19 14:48:38 +02001/*
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 Gleixner9325a282009-08-29 17:51:26 +02007#include <linux/ioport.h>
Paul Gortmaker186f4362016-07-13 20:18:56 -04008#include <linux/export.h>
Stefano Stabellini294ee6f2010-10-06 16:12:28 -04009#include <linux/pci.h>
Thomas Gleixner57844a82009-08-19 14:48:38 +020010
Andy Shevchenko81b53e52018-02-20 20:05:05 +020011#include <asm/acpi.h>
Thomas Gleixner816c25e2009-08-19 14:36:27 +020012#include <asm/bios_ebda.h>
Thomas Gleixner6f30c1a2009-08-20 13:19:57 +020013#include <asm/paravirt.h>
Thomas Gleixnerb72d0db2009-08-29 16:24:51 +020014#include <asm/pci_x86.h>
Thomas Gleixnerfd6c6662009-08-20 10:41:58 +020015#include <asm/mpspec.h>
Thomas Gleixner8fee6972009-08-19 14:55:50 +020016#include <asm/setup.h>
Thomas Gleixner736deca2009-08-19 12:35:53 +020017#include <asm/apic.h>
Ingo Molnar66441bd2017-01-27 10:27:10 +010018#include <asm/e820/api.h>
Thomas Gleixner845b3942009-08-19 15:37:03 +020019#include <asm/time.h>
Thomas Gleixnerd9112f42009-08-20 09:41:38 +020020#include <asm/irq.h>
Konrad Rzeszutek Wilk4a8e2a32012-03-28 12:37:36 -040021#include <asm/io_apic.h>
Joerg Roedel71054d82012-09-26 12:44:37 +020022#include <asm/hpet.h>
Jack Steinerfd12a0d2009-11-19 14:23:41 -060023#include <asm/pat.h>
Thomas Gleixner2d826402009-08-20 17:06:25 +020024#include <asm/tsc.h>
FUJITA Tomonori338bac52009-10-27 16:34:44 +090025#include <asm/iommu.h>
Jacob Pan064a59b2011-11-10 13:43:05 +000026#include <asm/mach_traps.h>
Thomas Gleixner57844a82009-08-19 14:48:38 +020027
Paul Gortmaker148f9bb2013-06-18 18:23:59 -040028void x86_init_noop(void) { }
Thomas Gleixnerf4848472009-08-20 12:05:01 +020029void __init x86_init_uint_noop(unsigned int unused) { }
Juergen Grossc46dacb2018-02-21 10:42:32 +010030static int __init iommu_init_noop(void) { return 0; }
31static void iommu_shutdown_noop(void) { }
32static bool __init bool_x86_init_noop(void) { return false; }
33static void x86_op_int_noop(int cpu) { }
Thomas Gleixner57844a82009-08-19 14:48:38 +020034
35/*
36 * The platform setup functions are preset with the default functions
37 * for standard PC hardware.
38 */
Thomas Gleixner54e26032009-09-16 08:42:26 +020039struct x86_init_ops x86_init __initdata = {
Thomas Gleixnerf7cf5a52009-08-19 14:43:56 +020040
41 .resources = {
Dan Williams5d94e812011-03-08 10:36:19 -080042 .probe_roms = probe_roms,
Thomas Gleixner8fee6972009-08-19 14:55:50 +020043 .reserve_resources = reserve_standard_io_resources,
Ingo Molnar103e2062017-01-28 09:58:49 +010044 .memory_setup = e820__memory_setup_default,
Thomas Gleixnerf7cf5a52009-08-19 14:43:56 +020045 },
Thomas Gleixnerf4848472009-08-20 12:05:01 +020046
47 .mpparse = {
48 .mpc_record = x86_init_uint_noop,
Thomas Gleixnerde934102009-08-20 09:27:29 +020049 .setup_ioapic_ids = x86_init_noop,
Thomas Gleixnerfd6c6662009-08-20 10:41:58 +020050 .mpc_apic_id = default_mpc_apic_id,
Thomas Gleixner72302142009-08-20 12:18:32 +020051 .smp_read_mpc_oem = default_smp_read_mpc_oem,
Thomas Gleixner90e1c692009-08-20 12:34:47 +020052 .mpc_oem_bus_info = default_mpc_oem_bus_info,
Thomas Gleixnerb3f1b612009-08-20 11:11:52 +020053 .find_smp_config = default_find_smp_config,
54 .get_smp_config = default_get_smp_config,
Thomas Gleixnerf4848472009-08-20 12:05:01 +020055 },
Thomas Gleixnerd9112f42009-08-20 09:41:38 +020056
57 .irqs = {
58 .pre_vector_init = init_ISA_irqs,
Thomas Gleixner66bcaf02009-08-20 09:59:09 +020059 .intr_init = native_init_IRQ,
Thomas Gleixner428cf902009-08-20 10:35:46 +020060 .trap_init = x86_init_noop,
Dou Liyang34fba3e2017-09-13 17:12:52 +080061 .intr_mode_init = apic_intr_mode_init
Thomas Gleixnerd9112f42009-08-20 09:41:38 +020062 },
Thomas Gleixner42bbdb42009-08-20 13:04:10 +020063
64 .oem = {
65 .arch_setup = x86_init_noop,
Thomas Gleixner6f30c1a2009-08-20 13:19:57 +020066 .banner = default_banner,
Thomas Gleixner42bbdb42009-08-20 13:04:10 +020067 },
Thomas Gleixner030cb6c2009-08-20 14:30:02 +020068
69 .paging = {
Attilio Rao7737b212012-08-21 21:22:38 +010070 .pagetable_init = native_pagetable_init,
Thomas Gleixner030cb6c2009-08-20 14:30:02 +020071 },
Thomas Gleixner736deca2009-08-19 12:35:53 +020072
73 .timers = {
74 .setup_percpu_clockev = setup_boot_APIC_clock,
Thomas Gleixner845b3942009-08-19 15:37:03 +020075 .timer_init = hpet_time_init,
Feng Tang6b617e22011-02-15 00:13:31 +080076 .wallclock_init = x86_init_noop,
Thomas Gleixner736deca2009-08-19 12:35:53 +020077 },
FUJITA Tomonorid07c1be2009-11-10 19:46:12 +090078
79 .iommu = {
80 .iommu_init = iommu_init_noop,
81 },
Thomas Gleixnerb72d0db2009-08-29 16:24:51 +020082
83 .pci = {
84 .init = x86_default_pci_init,
Thomas Gleixnerab3b3792009-08-29 17:47:33 +020085 .init_irq = x86_default_pci_init_irq,
Thomas Gleixner9325a282009-08-29 17:51:26 +020086 .fixup_irqs = x86_default_pci_fixup_irqs,
Thomas Gleixnerb72d0db2009-08-29 16:24:51 +020087 },
Juergen Grossf72e38e2017-11-09 14:27:35 +010088
89 .hyper = {
90 .init_platform = x86_init_noop,
Juergen Grossf3614642017-11-09 14:27:38 +010091 .guest_late_init = x86_init_noop,
Juergen Grossf72e38e2017-11-09 14:27:35 +010092 .x2apic_available = bool_x86_init_noop,
93 .init_mem_mapping = x86_init_noop,
Pavel Tatashin6f84f8d2018-04-10 16:36:10 -070094 .init_after_bootmem = x86_init_noop,
Juergen Grossf72e38e2017-11-09 14:27:35 +010095 },
Juergen Gross038bac22018-02-19 11:09:05 +010096
97 .acpi = {
Juergen Grosse7b66d12018-10-10 08:14:56 +020098 .get_root_pointer = x86_default_get_root_pointer,
Andy Shevchenko81b53e52018-02-20 20:05:05 +020099 .reduced_hw_early_init = acpi_generic_reduced_hw_init,
Juergen Gross038bac22018-02-19 11:09:05 +0100100 },
Thomas Gleixner736deca2009-08-19 12:35:53 +0200101};
102
Paul Gortmaker148f9bb2013-06-18 18:23:59 -0400103struct x86_cpuinit_ops x86_cpuinit = {
Igor Mammedovdf156f92012-02-07 15:52:44 +0100104 .early_percpu_clock_init = x86_init_noop,
Thomas Gleixner736deca2009-08-19 12:35:53 +0200105 .setup_percpu_clockev = setup_secondary_APIC_clock,
Thomas Gleixner57844a82009-08-19 14:48:38 +0200106};
Thomas Gleixner2d826402009-08-20 17:06:25 +0200107
Russ Anderson78c06172010-02-26 10:49:12 -0600108static void default_nmi_init(void) { };
109
Kees Cook404f6aa2016-08-08 16:29:06 -0700110struct x86_platform_ops x86_platform __ro_after_init = {
Pavel Tatashin8dbe4382018-07-19 16:55:45 -0400111 .calibrate_cpu = native_calibrate_cpu_early,
Thomas Gleixner2d826402009-08-20 17:06:25 +0200112 .calibrate_tsc = native_calibrate_tsc,
Feng Tang7bd867d2009-09-10 10:48:56 +0800113 .get_wallclock = mach_get_cmos_time,
114 .set_wallclock = mach_set_rtc_mmss,
FUJITA Tomonori338bac52009-10-27 16:34:44 +0900115 .iommu_shutdown = iommu_shutdown_noop,
H. Peter Anvineb41c8b2009-11-23 14:46:07 -0800116 .is_untracked_pat_range = is_ISA_range,
Feng Tangc516ac52010-07-05 23:03:18 +0800117 .nmi_init = default_nmi_init,
Jacob Pan064a59b2011-11-10 13:43:05 +0000118 .get_nmi_reason = default_get_nmi_reason,
Marcelo Tosattib74f05d62012-02-13 11:07:27 -0200119 .save_sched_clock_state = tsc_save_sched_clock_state,
120 .restore_sched_clock_state = tsc_restore_sched_clock_state,
Juergen Grossf72e38e2017-11-09 14:27:35 +0100121 .hyper.pin_vcpu = x86_op_int_noop,
Thomas Gleixner2d826402009-08-20 17:06:25 +0200122};
H. Peter Anvin72550b32010-07-07 16:57:46 -0700123
124EXPORT_SYMBOL_GPL(x86_platform);
Thomas Petazzoni4287d822013-08-09 22:27:06 +0200125
126#if defined(CONFIG_PCI_MSI)
Kees Cook404f6aa2016-08-08 16:29:06 -0700127struct x86_msi_ops x86_msi __ro_after_init = {
Joerg Roedel71054d82012-09-26 12:44:37 +0200128 .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 Stabellini294ee6f2010-10-06 16:12:28 -0400132};
Konrad Rzeszutek Wilk4a8e2a32012-03-28 12:37:36 -0400133
Thomas Petazzoni4287d822013-08-09 22:27:06 +0200134/* MSI arch specific hooks */
135int 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
140void arch_teardown_msi_irqs(struct pci_dev *dev)
141{
142 x86_msi.teardown_msi_irqs(dev);
143}
144
145void arch_teardown_msi_irq(unsigned int irq)
146{
147 x86_msi.teardown_msi_irq(irq);
148}
149
DuanZhenzhongac8344c2013-12-04 13:09:16 +0800150void arch_restore_msi_irqs(struct pci_dev *dev)
Thomas Petazzoni4287d822013-08-09 22:27:06 +0200151{
DuanZhenzhongac8344c2013-12-04 13:09:16 +0800152 x86_msi.restore_msi_irqs(dev);
Thomas Petazzoni4287d822013-08-09 22:27:06 +0200153}
154#endif
155
Baoquan He51b146c2018-02-14 13:46:55 +0800156struct 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 Wilk4a8e2a32012-03-28 12:37:36 -0400159};