xref: /openbmc/linux/arch/x86/kernel/apic/probe_64.c (revision b5a5ce58)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright 2004 James Cleverdon, IBM.
4  *
5  * Generic APIC sub-arch probe layer.
6  *
7  * Hacked for x86-64 by James Cleverdon from i386 architecture code by
8  * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
9  * James Cleverdon.
10  */
11 #include <linux/thread_info.h>
12 #include <asm/apic.h>
13 
14 #include "local.h"
15 
16 static __init void apic_install_driver(struct apic *driver)
17 {
18 	if (apic == driver)
19 		return;
20 
21 	apic = driver;
22 
23 	if (IS_ENABLED(CONFIG_X86_X2APIC) && apic->x2apic_set_max_apicid)
24 		apic->max_apic_id = x2apic_max_apicid;
25 
26 	pr_info("Switched APIC routing to %s:\n", apic->name);
27 }
28 
29 /* Select the appropriate APIC driver */
30 void __init x86_64_probe_apic(void)
31 {
32 	struct apic **drv;
33 
34 	enable_IR_x2apic();
35 
36 	for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
37 		if ((*drv)->probe && (*drv)->probe()) {
38 			apic_install_driver(*drv);
39 			break;
40 		}
41 	}
42 }
43 
44 int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
45 {
46 	struct apic **drv;
47 
48 	for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
49 		if ((*drv)->acpi_madt_oem_check(oem_id, oem_table_id)) {
50 			apic_install_driver(*drv);
51 			return 1;
52 		}
53 	}
54 	return 0;
55 }
56