Thomas Gleixner | a61127c | 2019-05-29 16:57:49 -0700 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 2 | /* |
| 3 | * sfi.c - x86 architecture SFI support. |
| 4 | * |
| 5 | * Copyright (c) 2009, Intel Corporation. |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #define KMSG_COMPONENT "SFI" |
| 9 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 10 | |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 11 | #include <linux/acpi.h> |
| 12 | #include <linux/init.h> |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 13 | #include <linux/sfi.h> |
| 14 | #include <linux/io.h> |
| 15 | |
Thomas Gleixner | f7a0c78 | 2015-04-14 10:30:08 +0800 | [diff] [blame] | 16 | #include <asm/irqdomain.h> |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 17 | #include <asm/io_apic.h> |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 18 | #include <asm/mpspec.h> |
| 19 | #include <asm/setup.h> |
| 20 | #include <asm/apic.h> |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 21 | |
| 22 | #ifdef CONFIG_X86_LOCAL_APIC |
| 23 | static unsigned long sfi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; |
| 24 | |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 25 | /* All CPUs enumerated by SFI must be present and enabled */ |
Jan Beulich | 9611dc7 | 2012-11-23 16:33:05 +0000 | [diff] [blame] | 26 | static void __init mp_sfi_register_lapic(u8 id) |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 27 | { |
Yinghai Lu | cb2ded3 | 2011-01-04 16:38:52 -0800 | [diff] [blame] | 28 | if (MAX_LOCAL_APIC - id <= 0) { |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 29 | pr_warning("Processor #%d invalid (max %d)\n", |
Yinghai Lu | cb2ded3 | 2011-01-04 16:38:52 -0800 | [diff] [blame] | 30 | id, MAX_LOCAL_APIC); |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 31 | return; |
| 32 | } |
| 33 | |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 34 | pr_info("registering lapic[%d]\n", id); |
| 35 | |
| 36 | generic_processor_info(id, GET_APIC_VERSION(apic_read(APIC_LVR))); |
| 37 | } |
| 38 | |
| 39 | static int __init sfi_parse_cpus(struct sfi_table_header *table) |
| 40 | { |
| 41 | struct sfi_table_simple *sb; |
| 42 | struct sfi_cpu_table_entry *pentry; |
| 43 | int i; |
| 44 | int cpu_num; |
| 45 | |
| 46 | sb = (struct sfi_table_simple *)table; |
| 47 | cpu_num = SFI_GET_NUM_ENTRIES(sb, struct sfi_cpu_table_entry); |
| 48 | pentry = (struct sfi_cpu_table_entry *)sb->pentry; |
| 49 | |
| 50 | for (i = 0; i < cpu_num; i++) { |
| 51 | mp_sfi_register_lapic(pentry->apic_id); |
| 52 | pentry++; |
| 53 | } |
| 54 | |
| 55 | smp_found_config = 1; |
| 56 | return 0; |
| 57 | } |
| 58 | #endif /* CONFIG_X86_LOCAL_APIC */ |
| 59 | |
| 60 | #ifdef CONFIG_X86_IO_APIC |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 61 | |
| 62 | static int __init sfi_parse_ioapic(struct sfi_table_header *table) |
| 63 | { |
| 64 | struct sfi_table_simple *sb; |
| 65 | struct sfi_apic_table_entry *pentry; |
| 66 | int i, num; |
Jiang Liu | 1b5d3e0 | 2014-06-09 16:19:56 +0800 | [diff] [blame] | 67 | struct ioapic_domain_cfg cfg = { |
| 68 | .type = IOAPIC_DOMAIN_STRICT, |
Thomas Gleixner | f7a0c78 | 2015-04-14 10:30:08 +0800 | [diff] [blame] | 69 | .ops = &mp_ioapic_irqdomain_ops, |
Jiang Liu | 1b5d3e0 | 2014-06-09 16:19:56 +0800 | [diff] [blame] | 70 | }; |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 71 | |
| 72 | sb = (struct sfi_table_simple *)table; |
| 73 | num = SFI_GET_NUM_ENTRIES(sb, struct sfi_apic_table_entry); |
| 74 | pentry = (struct sfi_apic_table_entry *)sb->pentry; |
| 75 | |
| 76 | for (i = 0; i < num; i++) { |
Jiang Liu | 1b5d3e0 | 2014-06-09 16:19:56 +0800 | [diff] [blame] | 77 | mp_register_ioapic(i, pentry->phys_addr, gsi_top, &cfg); |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 78 | pentry++; |
| 79 | } |
| 80 | |
| 81 | WARN(pic_mode, KERN_WARNING |
| 82 | "SFI: pic_mod shouldn't be 1 when IOAPIC table is present\n"); |
| 83 | pic_mode = 0; |
| 84 | return 0; |
| 85 | } |
| 86 | #endif /* CONFIG_X86_IO_APIC */ |
| 87 | |
| 88 | /* |
| 89 | * sfi_platform_init(): register lapics & io-apics |
| 90 | */ |
| 91 | int __init sfi_platform_init(void) |
| 92 | { |
| 93 | #ifdef CONFIG_X86_LOCAL_APIC |
Yinghai Lu | 53301f3 | 2010-12-07 00:55:47 -0800 | [diff] [blame] | 94 | register_lapic_address(sfi_lapic_addr); |
Feng Tang | efafc8b | 2009-08-14 15:23:29 -0400 | [diff] [blame] | 95 | sfi_table_parse(SFI_SIG_CPUS, NULL, NULL, sfi_parse_cpus); |
| 96 | #endif |
| 97 | #ifdef CONFIG_X86_IO_APIC |
| 98 | sfi_table_parse(SFI_SIG_APIC, NULL, NULL, sfi_parse_ioapic); |
| 99 | #endif |
| 100 | return 0; |
| 101 | } |