2 * sfi.c - x86 architecture SFI support.
4 * Copyright (c) 2009, Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 #define KMSG_COMPONENT "SFI"
22 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
24 #include <linux/acpi.h>
25 #include <linux/init.h>
26 #include <linux/sfi.h>
28 #include <linux/irqdomain.h>
30 #include <asm/io_apic.h>
31 #include <asm/mpspec.h>
32 #include <asm/setup.h>
35 #ifdef CONFIG_X86_LOCAL_APIC
36 static unsigned long sfi_lapic_addr __initdata
= APIC_DEFAULT_PHYS_BASE
;
38 /* All CPUs enumerated by SFI must be present and enabled */
39 static void __init
mp_sfi_register_lapic(u8 id
)
41 if (MAX_LOCAL_APIC
- id
<= 0) {
42 pr_warning("Processor #%d invalid (max %d)\n",
47 pr_info("registering lapic[%d]\n", id
);
49 generic_processor_info(id
, GET_APIC_VERSION(apic_read(APIC_LVR
)));
52 static int __init
sfi_parse_cpus(struct sfi_table_header
*table
)
54 struct sfi_table_simple
*sb
;
55 struct sfi_cpu_table_entry
*pentry
;
59 sb
= (struct sfi_table_simple
*)table
;
60 cpu_num
= SFI_GET_NUM_ENTRIES(sb
, struct sfi_cpu_table_entry
);
61 pentry
= (struct sfi_cpu_table_entry
*)sb
->pentry
;
63 for (i
= 0; i
< cpu_num
; i
++) {
64 mp_sfi_register_lapic(pentry
->apic_id
);
71 #endif /* CONFIG_X86_LOCAL_APIC */
73 #ifdef CONFIG_X86_IO_APIC
74 static struct irq_domain_ops sfi_ioapic_irqdomain_ops
= {
75 .map
= mp_irqdomain_map
,
78 static int __init
sfi_parse_ioapic(struct sfi_table_header
*table
)
80 struct sfi_table_simple
*sb
;
81 struct sfi_apic_table_entry
*pentry
;
83 struct ioapic_domain_cfg cfg
= {
84 .type
= IOAPIC_DOMAIN_STRICT
,
85 .ops
= &sfi_ioapic_irqdomain_ops
,
88 sb
= (struct sfi_table_simple
*)table
;
89 num
= SFI_GET_NUM_ENTRIES(sb
, struct sfi_apic_table_entry
);
90 pentry
= (struct sfi_apic_table_entry
*)sb
->pentry
;
92 for (i
= 0; i
< num
; i
++) {
93 mp_register_ioapic(i
, pentry
->phys_addr
, gsi_top
, &cfg
);
97 WARN(pic_mode
, KERN_WARNING
98 "SFI: pic_mod shouldn't be 1 when IOAPIC table is present\n");
102 #endif /* CONFIG_X86_IO_APIC */
105 * sfi_platform_init(): register lapics & io-apics
107 int __init
sfi_platform_init(void)
109 #ifdef CONFIG_X86_LOCAL_APIC
110 register_lapic_address(sfi_lapic_addr
);
111 sfi_table_parse(SFI_SIG_CPUS
, NULL
, NULL
, sfi_parse_cpus
);
113 #ifdef CONFIG_X86_IO_APIC
114 sfi_table_parse(SFI_SIG_APIC
, NULL
, NULL
, sfi_parse_ioapic
);