157844a8fSThomas Gleixner /*
257844a8fSThomas Gleixner * Copyright (C) 2009 Thomas Gleixner <tglx@linutronix.de>
357844a8fSThomas Gleixner *
457844a8fSThomas Gleixner * For licencing details see kernel-base/COPYING
557844a8fSThomas Gleixner */
60f4a1e80SKevin Loughlin #include <linux/dmi.h>
757844a8fSThomas Gleixner #include <linux/init.h>
89325a28cSThomas Gleixner #include <linux/ioport.h>
9186f4360SPaul Gortmaker #include <linux/export.h>
10294ee6f8SStefano Stabellini #include <linux/pci.h>
11*9221222cSJuergen Gross #include <linux/acpi.h>
1257844a8fSThomas Gleixner
1381b53e5fSAndy Shevchenko #include <asm/acpi.h>
14816c25e7SThomas Gleixner #include <asm/bios_ebda.h>
156f30c1acSThomas Gleixner #include <asm/paravirt.h>
16b72d0db9SThomas Gleixner #include <asm/pci_x86.h>
17fd6c6661SThomas Gleixner #include <asm/mpspec.h>
188fee697dSThomas Gleixner #include <asm/setup.h>
19736decacSThomas Gleixner #include <asm/apic.h>
2066441bd3SIngo Molnar #include <asm/e820/api.h>
21845b3944SThomas Gleixner #include <asm/time.h>
22d9112f43SThomas Gleixner #include <asm/irq.h>
234a8e2a31SKonrad Rzeszutek Wilk #include <asm/io_apic.h>
2471054d88SJoerg Roedel #include <asm/hpet.h>
25eb243d1dSIngo Molnar #include <asm/memtype.h>
262d826404SThomas Gleixner #include <asm/tsc.h>
27338bac52SFUJITA Tomonori #include <asm/iommu.h>
28064a59b6SJacob Pan #include <asm/mach_traps.h>
296b15ffa0SThomas Gleixner #include <asm/irqdomain.h>
30f1e52500SJuergen Gross #include <asm/realmode.h>
3157844a8fSThomas Gleixner
x86_init_noop(void)32148f9bb8SPaul Gortmaker void x86_init_noop(void) { }
x86_init_uint_noop(unsigned int unused)33f4848472SThomas Gleixner void __init x86_init_uint_noop(unsigned int unused) { }
iommu_init_noop(void)34c46dacb7SJuergen Gross static int __init iommu_init_noop(void) { return 0; }
iommu_shutdown_noop(void)35c46dacb7SJuergen Gross static void iommu_shutdown_noop(void) { }
bool_x86_init_noop(void)36bef6e0aeSZhenzhong Duan bool __init bool_x86_init_noop(void) { return false; }
x86_op_int_noop(int cpu)37bef6e0aeSZhenzhong Duan void x86_op_int_noop(int cpu) { }
set_rtc_noop(const struct timespec64 * now)38d21a19e1SSaurabh Sengar int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
get_rtc_noop(struct timespec64 * now)39d21a19e1SSaurabh Sengar void get_rtc_noop(struct timespec64 *now) { }
40c311ed61SRahul Tanwar
41c311ed61SRahul Tanwar static __initconst const struct of_device_id of_cmos_match[] = {
42c311ed61SRahul Tanwar { .compatible = "motorola,mc146818" },
43c311ed61SRahul Tanwar {}
44c311ed61SRahul Tanwar };
45c311ed61SRahul Tanwar
46c311ed61SRahul Tanwar /*
47c311ed61SRahul Tanwar * Allow devicetree configured systems to disable the RTC by setting the
48c311ed61SRahul Tanwar * corresponding DT node's status property to disabled. Code is optimized
49c311ed61SRahul Tanwar * out for CONFIG_OF=n builds.
50c311ed61SRahul Tanwar */
x86_wallclock_init(void)51c311ed61SRahul Tanwar static __init void x86_wallclock_init(void)
52c311ed61SRahul Tanwar {
53c311ed61SRahul Tanwar struct device_node *node = of_find_matching_node(NULL, of_cmos_match);
54c311ed61SRahul Tanwar
55c311ed61SRahul Tanwar if (node && !of_device_is_available(node)) {
56c311ed61SRahul Tanwar x86_platform.get_wallclock = get_rtc_noop;
57c311ed61SRahul Tanwar x86_platform.set_wallclock = set_rtc_noop;
58c311ed61SRahul Tanwar }
59c311ed61SRahul Tanwar }
6057844a8fSThomas Gleixner
6157844a8fSThomas Gleixner /*
6257844a8fSThomas Gleixner * The platform setup functions are preset with the default functions
6357844a8fSThomas Gleixner * for standard PC hardware.
6457844a8fSThomas Gleixner */
6554e2603fSThomas Gleixner struct x86_init_ops x86_init __initdata = {
66f7cf5a5bSThomas Gleixner
67f7cf5a5bSThomas Gleixner .resources = {
685d94e81fSDan Williams .probe_roms = probe_roms,
698fee697dSThomas Gleixner .reserve_resources = reserve_standard_io_resources,
70103e2063SIngo Molnar .memory_setup = e820__memory_setup_default,
710f4a1e80SKevin Loughlin .dmi_setup = dmi_setup,
72f7cf5a5bSThomas Gleixner },
73f4848472SThomas Gleixner
74f4848472SThomas Gleixner .mpparse = {
75de934103SThomas Gleixner .setup_ioapic_ids = x86_init_noop,
76e061c7aeSThomas Gleixner .find_mptable = mpparse_find_mptable,
77dcb76008SThomas Gleixner .early_parse_smp_cfg = mpparse_parse_early_smp_config,
78dcb76008SThomas Gleixner .parse_smp_cfg = mpparse_parse_smp_config,
79f4848472SThomas Gleixner },
80d9112f43SThomas Gleixner
81d9112f43SThomas Gleixner .irqs = {
82d9112f43SThomas Gleixner .pre_vector_init = init_ISA_irqs,
8366bcaf0bSThomas Gleixner .intr_init = native_init_IRQ,
8497992387SThomas Gleixner .intr_mode_select = apic_intr_mode_select,
856b15ffa0SThomas Gleixner .intr_mode_init = apic_intr_mode_init,
866b15ffa0SThomas Gleixner .create_pci_msi_domain = native_create_pci_msi_domain,
87d9112f43SThomas Gleixner },
8842bbdb43SThomas Gleixner
8942bbdb43SThomas Gleixner .oem = {
9042bbdb43SThomas Gleixner .arch_setup = x86_init_noop,
916f30c1acSThomas Gleixner .banner = default_banner,
9242bbdb43SThomas Gleixner },
93030cb6c0SThomas Gleixner
94030cb6c0SThomas Gleixner .paging = {
957737b215SAttilio Rao .pagetable_init = native_pagetable_init,
96030cb6c0SThomas Gleixner },
97736decacSThomas Gleixner
98736decacSThomas Gleixner .timers = {
99736decacSThomas Gleixner .setup_percpu_clockev = setup_boot_APIC_clock,
100845b3944SThomas Gleixner .timer_init = hpet_time_init,
101c311ed61SRahul Tanwar .wallclock_init = x86_wallclock_init,
102736decacSThomas Gleixner },
103d07c1be0SFUJITA Tomonori
104d07c1be0SFUJITA Tomonori .iommu = {
105d07c1be0SFUJITA Tomonori .iommu_init = iommu_init_noop,
106d07c1be0SFUJITA Tomonori },
107b72d0db9SThomas Gleixner
108b72d0db9SThomas Gleixner .pci = {
109b72d0db9SThomas Gleixner .init = x86_default_pci_init,
110ab3b3793SThomas Gleixner .init_irq = x86_default_pci_init_irq,
1119325a28cSThomas Gleixner .fixup_irqs = x86_default_pci_fixup_irqs,
112b72d0db9SThomas Gleixner },
113f72e38e8SJuergen Gross
114f72e38e8SJuergen Gross .hyper = {
115f72e38e8SJuergen Gross .init_platform = x86_init_noop,
116f3614646SJuergen Gross .guest_late_init = x86_init_noop,
117f72e38e8SJuergen Gross .x2apic_available = bool_x86_init_noop,
118ab0f59c6SDavid Woodhouse .msi_ext_dest_id = bool_x86_init_noop,
119f72e38e8SJuergen Gross .init_mem_mapping = x86_init_noop,
1206f84f8d1SPavel Tatashin .init_after_bootmem = x86_init_noop,
121f72e38e8SJuergen Gross },
122038bac2bSJuergen Gross
123038bac2bSJuergen Gross .acpi = {
12441fa1ee9SJosh Boyer .set_root_pointer = x86_default_set_root_pointer,
125e7b66d16SJuergen Gross .get_root_pointer = x86_default_get_root_pointer,
12681b53e5fSAndy Shevchenko .reduced_hw_early_init = acpi_generic_reduced_hw_init,
127038bac2bSJuergen Gross },
128736decacSThomas Gleixner };
129736decacSThomas Gleixner
130148f9bb8SPaul Gortmaker struct x86_cpuinit_ops x86_cpuinit = {
131df156f90SIgor Mammedov .early_percpu_clock_init = x86_init_noop,
132736decacSThomas Gleixner .setup_percpu_clockev = setup_secondary_APIC_clock,
133ff3cfcb0SThomas Gleixner .parallel_bringup = true,
13457844a8fSThomas Gleixner };
1352d826404SThomas Gleixner
default_nmi_init(void)13678c06176SRuss Anderson static void default_nmi_init(void) { };
13778c06176SRuss Anderson
enc_status_change_prepare_noop(unsigned long vaddr,int npages,bool enc)13899c5c4c6SKirill A. Shutemov static int enc_status_change_prepare_noop(unsigned long vaddr, int npages, bool enc) { return 0; }
enc_status_change_finish_noop(unsigned long vaddr,int npages,bool enc)13999c5c4c6SKirill A. Shutemov static int enc_status_change_finish_noop(unsigned long vaddr, int npages, bool enc) { return 0; }
enc_tlb_flush_required_noop(bool enc)1401e8c5971SBrijesh Singh static bool enc_tlb_flush_required_noop(bool enc) { return false; }
enc_cache_flush_required_noop(void)1411e8c5971SBrijesh Singh static bool enc_cache_flush_required_noop(void) { return false; }
enc_kexec_begin_noop(void)14222daa422SKirill A. Shutemov static void enc_kexec_begin_noop(void) {}
enc_kexec_finish_noop(void)14322daa422SKirill A. Shutemov static void enc_kexec_finish_noop(void) {}
is_private_mmio_noop(u64 addr)14488e378d4SMichael Kelley static bool is_private_mmio_noop(u64 addr) {return false; }
1451e8c5971SBrijesh Singh
146404f6aacSKees Cook struct x86_platform_ops x86_platform __ro_after_init = {
1478dbe4385SPavel Tatashin .calibrate_cpu = native_calibrate_cpu_early,
1482d826404SThomas Gleixner .calibrate_tsc = native_calibrate_tsc,
1497bd867dfSFeng Tang .get_wallclock = mach_get_cmos_time,
150e1a6bc7cSMateusz Jończyk .set_wallclock = mach_set_cmos_time,
151338bac52SFUJITA Tomonori .iommu_shutdown = iommu_shutdown_noop,
152eb41c8beSH. Peter Anvin .is_untracked_pat_range = is_ISA_range,
153c516ac58SFeng Tang .nmi_init = default_nmi_init,
154064a59b6SJacob Pan .get_nmi_reason = default_get_nmi_reason,
155b74f05d6SMarcelo Tosatti .save_sched_clock_state = tsc_save_sched_clock_state,
156b74f05d6SMarcelo Tosatti .restore_sched_clock_state = tsc_restore_sched_clock_state,
157f1e52500SJuergen Gross .realmode_reserve = reserve_real_mode,
158f1e52500SJuergen Gross .realmode_init = init_real_mode,
159f72e38e8SJuergen Gross .hyper.pin_vcpu = x86_op_int_noop,
16088e378d4SMichael Kelley .hyper.is_private_mmio = is_private_mmio_noop,
1611e8c5971SBrijesh Singh
1621e8c5971SBrijesh Singh .guest = {
1631e8c5971SBrijesh Singh .enc_status_change_prepare = enc_status_change_prepare_noop,
1641e8c5971SBrijesh Singh .enc_status_change_finish = enc_status_change_finish_noop,
1651e8c5971SBrijesh Singh .enc_tlb_flush_required = enc_tlb_flush_required_noop,
1661e8c5971SBrijesh Singh .enc_cache_flush_required = enc_cache_flush_required_noop,
16722daa422SKirill A. Shutemov .enc_kexec_begin = enc_kexec_begin_noop,
16822daa422SKirill A. Shutemov .enc_kexec_finish = enc_kexec_finish_noop,
1691e8c5971SBrijesh Singh },
1702d826404SThomas Gleixner };
17172550b3aSH. Peter Anvin
17272550b3aSH. Peter Anvin EXPORT_SYMBOL_GPL(x86_platform);
1734287d824SThomas Petazzoni
17451b146c5SBaoquan He struct x86_apic_ops x86_apic_ops __ro_after_init = {
17551b146c5SBaoquan He .io_apic_read = native_io_apic_read,
17651b146c5SBaoquan He .restore = native_restore_boot_irq_mode,
1774a8e2a31SKonrad Rzeszutek Wilk };
178