blob: 5a7e4619e1c47589fc6745d5843c7ef743170318 [file] [log] [blame]
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +01001/*
2 * Copyright 2003 Andi Kleen, SuSE Labs.
3 * Subject to the GNU Public License, v.2
4 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Generic x86 APIC driver probe layer.
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +01006 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/threads.h>
8#include <linux/cpumask.h>
9#include <linux/string.h>
10#include <linux/kernel.h>
11#include <linux/ctype.h>
12#include <linux/init.h>
Rusty Russell1a3f2392006-09-26 10:52:32 +020013#include <linux/errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/fixmap.h>
15#include <asm/mpspec.h>
16#include <asm/apicdef.h>
17#include <asm/genapic.h>
18
Yinghai Lud49c4282008-06-08 18:31:54 -070019extern struct genapic apic_numaq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020extern struct genapic apic_summit;
21extern struct genapic apic_bigsmp;
22extern struct genapic apic_es7000;
23extern struct genapic apic_default;
24
25struct genapic *genapic = &apic_default;
26
Adrian Bunk96d553582007-10-17 18:04:36 +020027static struct genapic *apic_probe[] __initdata = {
Yinghai Lud49c4282008-06-08 18:31:54 -070028#ifdef CONFIG_X86_NUMAQ
29 &apic_numaq,
30#endif
31#ifdef CONFIG_X86_SUMMIT
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 &apic_summit,
Yinghai Lud49c4282008-06-08 18:31:54 -070033#endif
34#ifdef CONFIG_X86_BIGSMP
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +010035 &apic_bigsmp,
Yinghai Lud49c4282008-06-08 18:31:54 -070036#endif
37#ifdef CONFIG_X86_ES7000
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 &apic_es7000,
Yinghai Lud49c4282008-06-08 18:31:54 -070039#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 &apic_default, /* must be last */
41 NULL,
42};
43
Rusty Russell1a3f2392006-09-26 10:52:32 +020044static int cmdline_apic __initdata;
45static int __init parse_apic(char *arg)
46{
47 int i;
48
49 if (!arg)
50 return -EINVAL;
51
52 for (i = 0; apic_probe[i]; i++) {
53 if (!strcmp(apic_probe[i]->name, arg)) {
54 genapic = apic_probe[i];
55 cmdline_apic = 1;
56 return 0;
57 }
58 }
Andi Kleen9a8cb622006-12-07 02:14:11 +010059
60 /* Parsed again by __setup for debug/verbose */
61 return 0;
Rusty Russell1a3f2392006-09-26 10:52:32 +020062}
63early_param("apic", parse_apic);
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070064
65void __init generic_bigsmp_probe(void)
66{
Yinghai Lub20d70b2008-06-09 17:00:15 -070067#ifdef CONFIG_X86_BIGSMP
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070068 /*
69 * This routine is used to switch to bigsmp mode when
70 * - There is no apic= option specified by the user
Simon Arlott27b46d72007-10-20 01:13:56 +020071 * - generic_apic_probe() has chosen apic_default as the sub_arch
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070072 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
73 */
74
75 if (!cmdline_apic && genapic == &apic_default)
76 if (apic_bigsmp.probe()) {
77 genapic = &apic_bigsmp;
78 printk(KERN_INFO "Overriding APIC driver with %s\n",
79 genapic->name);
80 }
Yinghai Lud49c4282008-06-08 18:31:54 -070081#endif
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070082}
83
Rusty Russell1a3f2392006-09-26 10:52:32 +020084void __init generic_apic_probe(void)
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +010085{
Rusty Russell1a3f2392006-09-26 10:52:32 +020086 if (!cmdline_apic) {
87 int i;
88 for (i = 0; apic_probe[i]; i++) {
89 if (apic_probe[i]->probe()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 genapic = apic_probe[i];
Rusty Russell1a3f2392006-09-26 10:52:32 +020091 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 }
93 }
Rusty Russell1a3f2392006-09-26 10:52:32 +020094 /* Not visible without early console */
95 if (!apic_probe[i])
96 panic("Didn't find an APIC driver");
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +010099}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101/* These functions can switch the APIC even after the initial ->probe() */
102
Yinghai Lud49c4282008-06-08 18:31:54 -0700103int __init mps_oem_check(struct mp_config_table *mpc, char *oem,
104 char *productid)
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +0100105{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 int i;
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +0100107 for (i = 0; apic_probe[i]; ++i) {
108 if (apic_probe[i]->mps_oem_check(mpc, oem, productid)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +0200109 if (!cmdline_apic) {
110 genapic = apic_probe[i];
111 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
112 genapic->name);
113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 return 1;
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +0100115 }
116 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 return 0;
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +0100118}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
121{
122 int i;
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +0100123 for (i = 0; apic_probe[i]; ++i) {
124 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +0200125 if (!cmdline_apic) {
126 genapic = apic_probe[i];
127 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
128 genapic->name);
129 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 return 1;
Paolo Ciarrocchi9b0c5022008-02-19 23:57:17 +0100131 }
132 }
133 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134}
135
136int hard_smp_processor_id(void)
137{
138 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
139}