sfi.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * sfi.c - x86 architecture SFI support.
  3. *
  4. * Copyright (c) 2009, Intel Corporation.
  5. *
  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.
  9. *
  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
  13. * more details.
  14. *
  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.
  18. *
  19. */
  20. #define KMSG_COMPONENT "SFI"
  21. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  22. #include <linux/acpi.h>
  23. #include <linux/init.h>
  24. #include <linux/sfi.h>
  25. #include <linux/io.h>
  26. #include <asm/irqdomain.h>
  27. #include <asm/io_apic.h>
  28. #include <asm/mpspec.h>
  29. #include <asm/setup.h>
  30. #include <asm/apic.h>
  31. #ifdef CONFIG_X86_LOCAL_APIC
  32. static unsigned long sfi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  33. /* All CPUs enumerated by SFI must be present and enabled */
  34. static void __init mp_sfi_register_lapic(u8 id)
  35. {
  36. if (MAX_LOCAL_APIC - id <= 0) {
  37. pr_warning("Processor #%d invalid (max %d)\n",
  38. id, MAX_LOCAL_APIC);
  39. return;
  40. }
  41. pr_info("registering lapic[%d]\n", id);
  42. generic_processor_info(id, GET_APIC_VERSION(apic_read(APIC_LVR)));
  43. }
  44. static int __init sfi_parse_cpus(struct sfi_table_header *table)
  45. {
  46. struct sfi_table_simple *sb;
  47. struct sfi_cpu_table_entry *pentry;
  48. int i;
  49. int cpu_num;
  50. sb = (struct sfi_table_simple *)table;
  51. cpu_num = SFI_GET_NUM_ENTRIES(sb, struct sfi_cpu_table_entry);
  52. pentry = (struct sfi_cpu_table_entry *)sb->pentry;
  53. for (i = 0; i < cpu_num; i++) {
  54. mp_sfi_register_lapic(pentry->apic_id);
  55. pentry++;
  56. }
  57. smp_found_config = 1;
  58. return 0;
  59. }
  60. #endif /* CONFIG_X86_LOCAL_APIC */
  61. #ifdef CONFIG_X86_IO_APIC
  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;
  67. struct ioapic_domain_cfg cfg = {
  68. .type = IOAPIC_DOMAIN_STRICT,
  69. .ops = &mp_ioapic_irqdomain_ops,
  70. };
  71. sb = (struct sfi_table_simple *)table;
  72. num = SFI_GET_NUM_ENTRIES(sb, struct sfi_apic_table_entry);
  73. pentry = (struct sfi_apic_table_entry *)sb->pentry;
  74. for (i = 0; i < num; i++) {
  75. mp_register_ioapic(i, pentry->phys_addr, gsi_top, &cfg);
  76. pentry++;
  77. }
  78. WARN(pic_mode, KERN_WARNING
  79. "SFI: pic_mod shouldn't be 1 when IOAPIC table is present\n");
  80. pic_mode = 0;
  81. return 0;
  82. }
  83. #endif /* CONFIG_X86_IO_APIC */
  84. /*
  85. * sfi_platform_init(): register lapics & io-apics
  86. */
  87. int __init sfi_platform_init(void)
  88. {
  89. #ifdef CONFIG_X86_LOCAL_APIC
  90. register_lapic_address(sfi_lapic_addr);
  91. sfi_table_parse(SFI_SIG_CPUS, NULL, NULL, sfi_parse_cpus);
  92. #endif
  93. #ifdef CONFIG_X86_IO_APIC
  94. sfi_table_parse(SFI_SIG_APIC, NULL, NULL, sfi_parse_ioapic);
  95. #endif
  96. return 0;
  97. }