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 */
64338e40dSKevin 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*adbb4453SJuergen 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,
714338e40dSKevin Loughlin .dmi_setup = dmi_setup,
72f7cf5a5bSThomas Gleixner },
73f4848472SThomas Gleixner
74f4848472SThomas Gleixner .mpparse = {
75de934103SThomas Gleixner .setup_ioapic_ids = x86_init_noop,
76b3f1b617SThomas Gleixner .find_smp_config = default_find_smp_config,
77b3f1b617SThomas Gleixner .get_smp_config = default_get_smp_config,
78f4848472SThomas Gleixner },
79d9112f43SThomas Gleixner
80d9112f43SThomas Gleixner .irqs = {
81d9112f43SThomas Gleixner .pre_vector_init = init_ISA_irqs,
8266bcaf0bSThomas Gleixner .intr_init = native_init_IRQ,
8397992387SThomas Gleixner .intr_mode_select = apic_intr_mode_select,
846b15ffa0SThomas Gleixner .intr_mode_init = apic_intr_mode_init,
856b15ffa0SThomas Gleixner .create_pci_msi_domain = native_create_pci_msi_domain,
86d9112f43SThomas Gleixner },
8742bbdb43SThomas Gleixner
8842bbdb43SThomas Gleixner .oem = {
8942bbdb43SThomas Gleixner .arch_setup = x86_init_noop,
906f30c1acSThomas Gleixner .banner = default_banner,
9142bbdb43SThomas Gleixner },
92030cb6c0SThomas Gleixner
93030cb6c0SThomas Gleixner .paging = {
947737b215SAttilio Rao .pagetable_init = native_pagetable_init,
95030cb6c0SThomas Gleixner },
96736decacSThomas Gleixner
97736decacSThomas Gleixner .timers = {
98736decacSThomas Gleixner .setup_percpu_clockev = setup_boot_APIC_clock,
99845b3944SThomas Gleixner .timer_init = hpet_time_init,
100c311ed61SRahul Tanwar .wallclock_init = x86_wallclock_init,
101736decacSThomas Gleixner },
102d07c1be0SFUJITA Tomonori
103d07c1be0SFUJITA Tomonori .iommu = {
104d07c1be0SFUJITA Tomonori .iommu_init = iommu_init_noop,
105d07c1be0SFUJITA Tomonori },
106b72d0db9SThomas Gleixner
107b72d0db9SThomas Gleixner .pci = {
108b72d0db9SThomas Gleixner .init = x86_default_pci_init,
109ab3b3793SThomas Gleixner .init_irq = x86_default_pci_init_irq,
1109325a28cSThomas Gleixner .fixup_irqs = x86_default_pci_fixup_irqs,
111b72d0db9SThomas Gleixner },
112f72e38e8SJuergen Gross
113f72e38e8SJuergen Gross .hyper = {
114f72e38e8SJuergen Gross .init_platform = x86_init_noop,
115f3614646SJuergen Gross .guest_late_init = x86_init_noop,
116f72e38e8SJuergen Gross .x2apic_available = bool_x86_init_noop,
117ab0f59c6SDavid Woodhouse .msi_ext_dest_id = bool_x86_init_noop,
118f72e38e8SJuergen Gross .init_mem_mapping = x86_init_noop,
1196f84f8d1SPavel Tatashin .init_after_bootmem = x86_init_noop,
120f72e38e8SJuergen Gross },
121038bac2bSJuergen Gross
122038bac2bSJuergen Gross .acpi = {
12341fa1ee9SJosh Boyer .set_root_pointer = x86_default_set_root_pointer,
124e7b66d16SJuergen Gross .get_root_pointer = x86_default_get_root_pointer,
12581b53e5fSAndy Shevchenko .reduced_hw_early_init = acpi_generic_reduced_hw_init,
126038bac2bSJuergen Gross },
127736decacSThomas Gleixner };
128736decacSThomas Gleixner
129148f9bb8SPaul Gortmaker struct x86_cpuinit_ops x86_cpuinit = {
130df156f90SIgor Mammedov .early_percpu_clock_init = x86_init_noop,
131736decacSThomas Gleixner .setup_percpu_clockev = setup_secondary_APIC_clock,
132ff3cfcb0SThomas Gleixner .parallel_bringup = true,
13357844a8fSThomas Gleixner };
1342d826404SThomas Gleixner
default_nmi_init(void)13578c06176SRuss Anderson static void default_nmi_init(void) { };
13678c06176SRuss Anderson
enc_status_change_prepare_noop(unsigned long vaddr,int npages,bool enc)1373f6819ddSKirill A. Shutemov static bool enc_status_change_prepare_noop(unsigned long vaddr, int npages, bool enc) { return true; }
enc_status_change_finish_noop(unsigned long vaddr,int npages,bool enc)13894142c9dSKirill A. Shutemov static bool enc_status_change_finish_noop(unsigned long vaddr, int npages, bool enc) { return true; }
enc_tlb_flush_required_noop(bool enc)1391e8c5971SBrijesh Singh static bool enc_tlb_flush_required_noop(bool enc) { return false; }
enc_cache_flush_required_noop(void)1401e8c5971SBrijesh Singh static bool enc_cache_flush_required_noop(void) { return false; }
is_private_mmio_noop(u64 addr)14188e378d4SMichael Kelley static bool is_private_mmio_noop(u64 addr) {return false; }
1421e8c5971SBrijesh Singh
143404f6aacSKees Cook struct x86_platform_ops x86_platform __ro_after_init = {
1448dbe4385SPavel Tatashin .calibrate_cpu = native_calibrate_cpu_early,
1452d826404SThomas Gleixner .calibrate_tsc = native_calibrate_tsc,
1467bd867dfSFeng Tang .get_wallclock = mach_get_cmos_time,
147e1a6bc7cSMateusz Jończyk .set_wallclock = mach_set_cmos_time,
148338bac52SFUJITA Tomonori .iommu_shutdown = iommu_shutdown_noop,
149eb41c8beSH. Peter Anvin .is_untracked_pat_range = is_ISA_range,
150c516ac58SFeng Tang .nmi_init = default_nmi_init,
151064a59b6SJacob Pan .get_nmi_reason = default_get_nmi_reason,
152b74f05d6SMarcelo Tosatti .save_sched_clock_state = tsc_save_sched_clock_state,
153b74f05d6SMarcelo Tosatti .restore_sched_clock_state = tsc_restore_sched_clock_state,
154f1e52500SJuergen Gross .realmode_reserve = reserve_real_mode,
155f1e52500SJuergen Gross .realmode_init = init_real_mode,
156f72e38e8SJuergen Gross .hyper.pin_vcpu = x86_op_int_noop,
15788e378d4SMichael Kelley .hyper.is_private_mmio = is_private_mmio_noop,
1581e8c5971SBrijesh Singh
1591e8c5971SBrijesh Singh .guest = {
1601e8c5971SBrijesh Singh .enc_status_change_prepare = enc_status_change_prepare_noop,
1611e8c5971SBrijesh Singh .enc_status_change_finish = enc_status_change_finish_noop,
1621e8c5971SBrijesh Singh .enc_tlb_flush_required = enc_tlb_flush_required_noop,
1631e8c5971SBrijesh Singh .enc_cache_flush_required = enc_cache_flush_required_noop,
1641e8c5971SBrijesh Singh },
1652d826404SThomas Gleixner };
16672550b3aSH. Peter Anvin
16772550b3aSH. Peter Anvin EXPORT_SYMBOL_GPL(x86_platform);
1684287d824SThomas Petazzoni
16951b146c5SBaoquan He struct x86_apic_ops x86_apic_ops __ro_after_init = {
17051b146c5SBaoquan He .io_apic_read = native_io_apic_read,
17151b146c5SBaoquan He .restore = native_restore_boot_irq_mode,
1724a8e2a31SKonrad Rzeszutek Wilk };
173