1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#define KMSG_COMPONENT "SFI"
22#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
23
24#include <linux/acpi.h>
25#include <linux/init.h>
26#include <linux/sfi.h>
27#include <linux/io.h>
28#include <linux/irqdomain.h>
29
30#include <asm/io_apic.h>
31#include <asm/mpspec.h>
32#include <asm/setup.h>
33#include <asm/apic.h>
34
35#ifdef CONFIG_X86_LOCAL_APIC
36static unsigned long sfi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
37
38
39static void __init mp_sfi_register_lapic(u8 id)
40{
41 if (MAX_LOCAL_APIC - id <= 0) {
42 pr_warning("Processor #%d invalid (max %d)\n",
43 id, MAX_LOCAL_APIC);
44 return;
45 }
46
47 pr_info("registering lapic[%d]\n", id);
48
49 generic_processor_info(id, GET_APIC_VERSION(apic_read(APIC_LVR)));
50}
51
52static int __init sfi_parse_cpus(struct sfi_table_header *table)
53{
54 struct sfi_table_simple *sb;
55 struct sfi_cpu_table_entry *pentry;
56 int i;
57 int cpu_num;
58
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;
62
63 for (i = 0; i < cpu_num; i++) {
64 mp_sfi_register_lapic(pentry->apic_id);
65 pentry++;
66 }
67
68 smp_found_config = 1;
69 return 0;
70}
71#endif
72
73#ifdef CONFIG_X86_IO_APIC
74static struct irq_domain_ops sfi_ioapic_irqdomain_ops = {
75 .map = mp_irqdomain_map,
76};
77
78static int __init sfi_parse_ioapic(struct sfi_table_header *table)
79{
80 struct sfi_table_simple *sb;
81 struct sfi_apic_table_entry *pentry;
82 int i, num;
83 struct ioapic_domain_cfg cfg = {
84 .type = IOAPIC_DOMAIN_STRICT,
85 .ops = &sfi_ioapic_irqdomain_ops,
86 };
87
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;
91
92 for (i = 0; i < num; i++) {
93 mp_register_ioapic(i, pentry->phys_addr, gsi_top, &cfg);
94 pentry++;
95 }
96
97 WARN(pic_mode, KERN_WARNING
98 "SFI: pic_mod shouldn't be 1 when IOAPIC table is present\n");
99 pic_mode = 0;
100 return 0;
101}
102#endif
103
104
105
106
107int __init sfi_platform_init(void)
108{
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);
112#endif
113#ifdef CONFIG_X86_IO_APIC
114 sfi_table_parse(SFI_SIG_APIC, NULL, NULL, sfi_parse_ioapic);
115#endif
116 return 0;
117}
118