History

Merge branches 'acpi-x86', 'acpi-soc', 'acpi-pmic' and 'acpi-apple'

* acpi-x86: ACPI / boot: Add number of legacy IRQs to debug output ACPI / boot: Correct address space of __acpi_map_table() ACPI / boot: Don't define unused variables * acpi-soc: ACPI / LPSS: Don't abort ACPI scan on missing mem resource * acpi-pmic: ACPI / PMIC: xpower: Do pinswitch magic when reading GPADC * acpi-apple: spi: Use Apple device properties in absence of ACPI resources ACPI / scan: Recognize Apple SPI and I2C slaves ACPI / property: Support Apple _DSM properties ACPI / property: Don't evaluate objects for devices w/o handle treewide: Consolidate Apple DMI checks

Rafael J. Wysocki committed 9 years ago

Commit 01d2f105 parents f928a49 42d516c a4bb2b4 58eefe2 8a2e48724 files · +278 −87Browse files

Unified · Split

24 files
  1. arch/arm64/kernel/acpi.c +2 −2
  2. arch/ia64/kernel/acpi.c +3 −3
  3. arch/x86/include/asm/setup.h +1 −0
  4. arch/x86/kernel/acpi/boot.c +7 −4
  5. arch/x86/kernel/early-quirks.c +2 −2
  6. arch/x86/kernel/quirks.c +10 −0
  7. arch/x86/kernel/setup.c +2 −0
  8. drivers/acpi/Makefile +1 −0
  9. drivers/acpi/acpi_lpss.c +2 −1
  10. drivers/acpi/internal.h +6 −0
  11. drivers/acpi/osi.c +8 −29
  12. drivers/acpi/pci_root.c +2 −2
  13. drivers/acpi/pmic/intel_pmic_xpower.c +18 −3
  14. drivers/acpi/property.c +6 −0
  15. drivers/acpi/sbs.c +2 −23
  16. drivers/acpi/scan.c +7 −0
  17. drivers/acpi/x86/apple.c +141 −0
  18. drivers/firmware/efi/apple-properties.c +2 −3
  19. drivers/pci/quirks.c +3 −2
  20. drivers/spi/spi.c +32 −0
  21. drivers/thunderbolt/icm.c +4 −9
  22. drivers/thunderbolt/tb.c +2 −2
  23. include/linux/acpi.h +2 −2
  24. include/linux/platform_data/x86/apple.h +13 −0
arch/arm64/kernel/acpi.c+2−2
@@ -95,7 +95,7 @@ static int __init dt_scan_depth1_nodes(unsigned long node, · 94 unmodified lines
9595 * __acpi_map_table() will be called before page_init(), so early_ioremap()
9696 * or early_memremap() should be called here to for ACPI table mapping.
9797 */
98−char *__init __acpi_map_table(unsigned long phys, unsigned long size)
98+void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
9999 {
100100 if (!size)
101101 return NULL;
@@ -103,7 +103,7 @@ char *__init __acpi_map_table(unsigned long phys, unsigned long size) · 1 unmodified line
103103 return early_memremap(phys, size);
104104 }
105105
106−void __init __acpi_unmap_table(char *map, unsigned long size)
106+void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
107107 {
108108 if (!map || !size)
109109 return;
arch/ia64/kernel/acpi.c+3−3
@@ -159,12 +159,12 @@ int acpi_request_vector(u32 int_type) · 158 unmodified lines
159159 return vector;
160160 }
161161
162−char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
162+void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
163163 {
164− return __va(phys_addr);
164+ return __va(phys);
165165 }
166166
167−void __init __acpi_unmap_table(char *map, unsigned long size)
167+void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
168168 {
169169 }
170170
arch/x86/include/asm/setup.h+1−0
@@ -39,6 +39,7 @@ static inline void vsmp_init(void) { } · 38 unmodified lines
3939 #endif
4040
4141 void setup_bios_corruption_check(void);
42+void early_platform_quirks(void);
4243
4344 extern unsigned long saved_video_mode;
4445
arch/x86/kernel/acpi/boot.c+7−4
@@ -118,7 +118,7 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = { · 117 unmodified lines
118118 * This is just a simple wrapper around early_ioremap(),
119119 * with sanity checks for phys == 0 and size == 0.
120120 */
121−char *__init __acpi_map_table(unsigned long phys, unsigned long size)
121+void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
122122 {
123123
124124 if (!phys || !size)
@@ -127,7 +127,7 @@ char *__init __acpi_map_table(unsigned long phys, unsigned long size) · 2 unmodified lines
127127 return early_ioremap(phys, size);
128128 }
129129
130−void __init __acpi_unmap_table(char *map, unsigned long size)
130+void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
131131 {
132132 if (!map || !size)
133133 return;
@@ -199,8 +199,10 @@ static int __init · 65 unmodified lines
199199 acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
200200 {
201201 struct acpi_madt_local_x2apic *processor = NULL;
202+#ifdef CONFIG_X86_X2APIC
202203 int apic_id;
203204 u8 enabled;
205+#endif
204206
205207 processor = (struct acpi_madt_local_x2apic *)header;
206208
@@ -209,9 +211,10 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) · 2 unmodified lines
209211
210212 acpi_table_print_madt_entry(header);
211213
214+#ifdef CONFIG_X86_X2APIC
212215 apic_id = processor->local_apic_id;
213216 enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
214−#ifdef CONFIG_X86_X2APIC
217+
215218 /*
216219 * We need to register disabled CPU as well to permit
217220 * counting disabled CPUs. This allows us to size
@@ -1083,7 +1086,7 @@ static void __init mp_config_acpi_legacy_irqs(void) · 865 unmodified lines
10831086 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
10841087 #endif
10851088 set_bit(MP_ISA_BUS, mp_bus_not_pci);
1086− pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
1089+ pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs());
10871090
10881091 /*
10891092 * Use the default configuration for the IRQs 0-15. Unless
arch/x86/kernel/early-quirks.c+2−2
@@ -12,10 +12,10 @@ · 11 unmodified lines
1212 #include <linux/pci.h>
1313 #include <linux/acpi.h>
1414 #include <linux/delay.h>
15−#include <linux/dmi.h>
1615 #include <linux/pci_ids.h>
1716 #include <linux/bcma/bcma.h>
1817 #include <linux/bcma/bcma_regs.h>
18+#include <linux/platform_data/x86/apple.h>
1919 #include <drm/i915_drm.h>
2020 #include <asm/pci-direct.h>
2121 #include <asm/dma.h>
@@ -593,7 +593,7 @@ static void __init apple_airport_reset(int bus, int slot, int func) · 571 unmodified lines
593593 u64 addr;
594594 int i;
595595
596− if (!dmi_match(DMI_SYS_VENDOR, "Apple Inc."))
596+ if (!x86_apple_machine)
597597 return;
598598
599599 /* Card may have been put into PCI_D3hot by grub quirk */
arch/x86/kernel/quirks.c+10−0
@@ -1,6 +1,7 @@
11 /*
22 * This file contains work-arounds for x86 and x86_64 platform bugs.
33 */
4+#include <linux/dmi.h>
45 #include <linux/pci.h>
56 #include <linux/irq.h>
67
@@ -656,3 +657,12 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, quirk_intel_brickland_xeon_ · 649 unmodified lines
656657 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras_cap);
657658 #endif
658659 #endif
660+
661+bool x86_apple_machine;
662+EXPORT_SYMBOL(x86_apple_machine);
663+
664+void __init early_platform_quirks(void)
665+{
666+ x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
667+ dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
668+}
arch/x86/kernel/setup.c+2−0
@@ -1206,6 +1206,8 @@ void __init setup_arch(char **cmdline_p) · 1205 unmodified lines
12061206
12071207 io_delay_init();
12081208
1209+ early_platform_quirks();
1210+
12091211 /*
12101212 * Parse the ACPI tables for possible boot-time SMP configuration.
12111213 */
drivers/acpi/Makefile+1−0
@@ -50,6 +50,7 @@ acpi-$(CONFIG_ACPI_REDUCED_HARDWARE_ONLY) += evged.o · 49 unmodified lines
5050 acpi-y += sysfs.o
5151 acpi-y += property.o
5252 acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
53+acpi-$(CONFIG_X86) += x86/apple.o
5354 acpi-$(CONFIG_X86) += x86/utils.o
5455 acpi-$(CONFIG_DEBUG_FS) += debugfs.o
5556 acpi-$(CONFIG_ACPI_NUMA) += numa.o
drivers/acpi/acpi_lpss.c+2−1
@@ -465,7 +465,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev, · 464 unmodified lines
465465 acpi_dev_free_resource_list(&resource_list);
466466
467467 if (!pdata->mmio_base) {
468− ret = -ENOMEM;
468+ /* Skip the device, but continue the namespace scan. */
469+ ret = 0;
469470 goto err_out;
470471 }
471472
drivers/acpi/internal.h+6−0
@@ -232,6 +232,12 @@ static inline void suspend_nvs_restore(void) {} · 231 unmodified lines
232232 void acpi_init_properties(struct acpi_device *adev);
233233 void acpi_free_properties(struct acpi_device *adev);
234234
235+#ifdef CONFIG_X86
236+void acpi_extract_apple_properties(struct acpi_device *adev);
237+#else
238+static inline void acpi_extract_apple_properties(struct acpi_device *adev) {}
239+#endif
240+
235241 /*--------------------------------------------------------------------------
236242 Watchdog
237243 -------------------------------------------------------------------------- */
drivers/acpi/osi.c+8−29
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include <linux/kernel.h>
2828 #include <linux/acpi.h>
2929 #include <linux/dmi.h>
30+#include <linux/platform_data/x86/apple.h>
3031
3132 #include "internal.h"
3233
@@ -257,12 +258,11 @@ bool acpi_osi_is_win8(void) · 224 unmodified lines
257258 }
258259 EXPORT_SYMBOL(acpi_osi_is_win8);
259260
260−static void __init acpi_osi_dmi_darwin(bool enable,
261− const struct dmi_system_id *d)
261+static void __init acpi_osi_dmi_darwin(void)
262262 {
263− pr_notice("DMI detected to setup _OSI(\"Darwin\"): %s\n", d->ident);
263+ pr_notice("DMI detected to setup _OSI(\"Darwin\"): Apple hardware\n");
264264 osi_config.darwin_dmi = 1;
265− __acpi_osi_setup_darwin(enable);
265+ __acpi_osi_setup_darwin(true);
266266 }
267267
268268 static void __init acpi_osi_dmi_linux(bool enable,
@@ -273,13 +273,6 @@ static void __init acpi_osi_dmi_linux(bool enable, · 4 unmodified lines
273273 __acpi_osi_setup_linux(enable);
274274 }
275275
276−static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d)
277−{
278− acpi_osi_dmi_darwin(true, d);
279−
280− return 0;
281−}
282−
283276 static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
284277 {
285278 acpi_osi_dmi_linux(true, d);
@@ -481,30 +474,16 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { · 195 unmodified lines
481474 DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"),
482475 },
483476 },
484−
485− /*
486− * Enable _OSI("Darwin") for all apple platforms.
487− */
488− {
489− .callback = dmi_enable_osi_darwin,
490− .ident = "Apple hardware",
491− .matches = {
492− DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
493− },
494− },
495− {
496− .callback = dmi_enable_osi_darwin,
497− .ident = "Apple hardware",
498− .matches = {
499− DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
500− },
501− },
502477 {}
503478 };
504479
505480 static __init void acpi_osi_dmi_blacklisted(void)
506481 {
507482 dmi_check_system(acpi_osi_dmi_table);
483+
484+ /* Enable _OSI("Darwin") for Apple platforms. */
485+ if (x86_apple_machine)
486+ acpi_osi_dmi_darwin();
508487 }
509488
510489 int __init early_acpi_osi_init(void)
drivers/acpi/pci_root.c+2−2
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 #include <linux/acpi.h>
3434 #include <linux/slab.h>
3535 #include <linux/dmi.h>
36+#include <linux/platform_data/x86/apple.h>
3637 #include <acpi/apei.h> /* for acpi_hest_init() */
3738
3839 #include "internal.h"
@@ -431,8 +432,7 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm) · 392 unmodified lines
431432 * been called successfully. We know the feature set supported by the
432433 * platform, so avoid calling _OSC at all
433434 */
434−
435− if (dmi_match(DMI_SYS_VENDOR, "Apple Inc.")) {
435+ if (x86_apple_machine) {
436436 root->osc_control_set = ~OSC_PCI_EXPRESS_PME_CONTROL;
437437 decode_osc_control(root, "OS assumes control of",
438438 root->osc_control_set);
drivers/acpi/pmic/intel_pmic_xpower.c+18−3
@@ -27,6 +27,9 @@ · 26 unmodified lines
2727 #define GPI1_LDO_ON (3 << 0)
2828 #define GPI1_LDO_OFF (4 << 0)
2929
30+#define AXP288_ADC_TS_PIN_GPADC 0xf2
31+#define AXP288_ADC_TS_PIN_ON 0xf3
32+
3033 static struct pmic_table power_table[] = {
3134 {
3235 .address = 0x00,
@@ -209,11 +212,23 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg, · 176 unmodified lines
209212 static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
210213 {
211214 u8 buf[2];
215+ int ret;
212216
213− if (regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2))
214− return -EIO;
217+ ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL,
218+ AXP288_ADC_TS_PIN_GPADC);
219+ if (ret)
220+ return ret;
221+
222+ /* After switching to the GPADC pin give things some time to settle */
223+ usleep_range(6000, 10000);
224+
225+ ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2);
226+ if (ret == 0)
227+ ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);
228+
229+ regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON);
215230
216− return (buf[0] << 4) + ((buf[1] >> 4) & 0x0F);
231+ return ret;
217232 }
218233
219234 static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
drivers/acpi/property.c+6−0
@@ -339,6 +339,9 @@ void acpi_init_properties(struct acpi_device *adev) · 338 unmodified lines
339339
340340 INIT_LIST_HEAD(&adev->data.subnodes);
341341
342+ if (!adev->handle)
343+ return;
344+
342345 /*
343346 * Check if ACPI_DT_NAMESPACE_HID is present and inthat case we fill in
344347 * Device Tree compatible properties for this device.
@@ -373,6 +376,9 @@ void acpi_init_properties(struct acpi_device *adev) · 28 unmodified lines
373376 if (acpi_of && !adev->flags.of_compatible_ok)
374377 acpi_handle_info(adev->handle,
375378 ACPI_DT_NAMESPACE_HID " requires 'compatible' property\n");
379+
380+ if (!adev->data.pointer)
381+ acpi_extract_apple_properties(adev);
376382 }
377383
378384 static void acpi_destroy_nondev_subnodes(struct list_head *list)
drivers/acpi/sbs.c+2−23
@@ -31,7 +31,7 @@ · 30 unmodified lines
3131 #include <linux/jiffies.h>
3232 #include <linux/delay.h>
3333 #include <linux/power_supply.h>
34−#include <linux/dmi.h>
34+#include <linux/platform_data/x86/apple.h>
3535
3636 #include "sbshc.h"
3737 #include "battery.h"
@@ -58,8 +58,6 @@ static unsigned int cache_time = 1000; · 20 unmodified lines
5858 module_param(cache_time, uint, 0644);
5959 MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
6060
61−static bool sbs_manager_broken;
62−
6361 #define MAX_SBS_BAT 4
6462 #define ACPI_SBS_BLOCK_MAX 32
6563
@@ -632,31 +630,12 @@ static void acpi_sbs_callback(void *context) · 566 unmodified lines
632630 }
633631 }
634632
635−static int disable_sbs_manager(const struct dmi_system_id *d)
636−{
637− sbs_manager_broken = true;
638− return 0;
639−}
640−
641−static struct dmi_system_id acpi_sbs_dmi_table[] = {
642− {
643− .callback = disable_sbs_manager,
644− .ident = "Apple",
645− .matches = {
646− DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc.")
647− },
648− },
649− { },
650−};
651−
652633 static int acpi_sbs_add(struct acpi_device *device)
653634 {
654635 struct acpi_sbs *sbs;
655636 int result = 0;
656637 int id;
657638
658− dmi_check_system(acpi_sbs_dmi_table);
659−
660639 sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL);
661640 if (!sbs) {
662641 result = -ENOMEM;
@@ -677,7 +656,7 @@ static int acpi_sbs_add(struct acpi_device *device) · 14 unmodified lines
677656
678657 result = 0;
679658
680− if (!sbs_manager_broken) {
659+ if (!x86_apple_machine) {
681660 result = acpi_manager_get_info(sbs);
682661 if (!result) {
683662 sbs->manager_present = 1;
drivers/acpi/scan.c+7−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/dmi.h>
1414 #include <linux/nls.h>
1515 #include <linux/dma-mapping.h>
16+#include <linux/platform_data/x86/apple.h>
1617
1718 #include <asm/pgtable.h>
1819
@@ -1527,6 +1528,12 @@ static bool acpi_is_spi_i2c_slave(struct acpi_device *device) · 1508 unmodified lines
15271528 struct list_head resource_list;
15281529 bool is_spi_i2c_slave = false;
15291530
1531+ /* Macs use device properties in lieu of _CRS resources */
1532+ if (x86_apple_machine &&
1533+ (fwnode_property_present(&device->fwnode, "spiSclkPeriod") ||
1534+ fwnode_property_present(&device->fwnode, "i2cAddress")))
1535+ return true;
1536+
15301537 INIT_LIST_HEAD(&resource_list);
15311538 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
15321539 &is_spi_i2c_slave);
drivers/acpi/x86/apple.c+141−0
@@ -0,0 +1,141 @@
1+/*
2+ * apple.c - Apple ACPI quirks
3+ * Copyright (C) 2017 Lukas Wunner <lukas@wunner.de>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License (version 2) as
7+ * published by the Free Software Foundation.
8+ */
9+
10+#include <linux/acpi.h>
11+#include <linux/bitmap.h>
12+#include <linux/platform_data/x86/apple.h>
13+#include <linux/uuid.h>
14+
15+/* Apple _DSM device properties GUID */
16+static const guid_t apple_prp_guid =
17+ GUID_INIT(0xa0b5b7c6, 0x1318, 0x441c,
18+ 0xb0, 0xc9, 0xfe, 0x69, 0x5e, 0xaf, 0x94, 0x9b);
19+
20+/**
21+ * acpi_extract_apple_properties - retrieve and convert Apple _DSM properties
22+ * @adev: ACPI device for which to retrieve the properties
23+ *
24+ * Invoke Apple's custom _DSM once to check the protocol version and once more
25+ * to retrieve the properties. They are marshalled up in a single package as
26+ * alternating key/value elements, unlike _DSD which stores them as a package
27+ * of 2-element packages. Convert to _DSD format and make them available under
28+ * the primary fwnode.
29+ */
30+void acpi_extract_apple_properties(struct acpi_device *adev)
31+{
32+ unsigned int i, j = 0, newsize = 0, numprops, numvalid;
33+ union acpi_object *props, *newprops;
34+ unsigned long *valid = NULL;
35+ void *free_space;
36+
37+ if (!x86_apple_machine)
38+ return;
39+
40+ props = acpi_evaluate_dsm_typed(adev->handle, &apple_prp_guid, 1, 0,
41+ NULL, ACPI_TYPE_BUFFER);
42+ if (!props)
43+ return;
44+
45+ if (!props->buffer.length)
46+ goto out_free;
47+
48+ if (props->buffer.pointer[0] != 3) {
49+ acpi_handle_info(adev->handle, FW_INFO
50+ "unsupported properties version %*ph\n",
51+ props->buffer.length, props->buffer.pointer);
52+ goto out_free;
53+ }
54+
55+ ACPI_FREE(props);
56+ props = acpi_evaluate_dsm_typed(adev->handle, &apple_prp_guid, 1, 1,
57+ NULL, ACPI_TYPE_PACKAGE);
58+ if (!props)
59+ return;
60+
61+ numprops = props->package.count / 2;
62+ if (!numprops)
63+ goto out_free;
64+
65+ valid = kcalloc(BITS_TO_LONGS(numprops), sizeof(long), GFP_KERNEL);
66+ if (!valid)
67+ goto out_free;
68+
69+ /* newsize = key length + value length of each tuple */
70+ for (i = 0; i < numprops; i++) {
71+ union acpi_object *key = &props->package.elements[i * 2];
72+ union acpi_object *val = &props->package.elements[i * 2 + 1];
73+
74+ if ( key->type != ACPI_TYPE_STRING ||
75+ (val->type != ACPI_TYPE_INTEGER &&
76+ val->type != ACPI_TYPE_BUFFER))
77+ continue; /* skip invalid properties */
78+
79+ __set_bit(i, valid);
80+ newsize += key->string.length + 1;
81+ if ( val->type == ACPI_TYPE_BUFFER)
82+ newsize += val->buffer.length;
83+ }
84+
85+ numvalid = bitmap_weight(valid, numprops);
86+ if (numprops > numvalid)
87+ acpi_handle_info(adev->handle, FW_INFO
88+ "skipped %u properties: wrong type\n",
89+ numprops - numvalid);
90+ if (numvalid == 0)
91+ goto out_free;
92+
93+ /* newsize += top-level package + 3 objects for each key/value tuple */
94+ newsize += (1 + 3 * numvalid) * sizeof(union acpi_object);
95+ newprops = ACPI_ALLOCATE_ZEROED(newsize);
96+ if (!newprops)
97+ goto out_free;
98+
99+ /* layout: top-level package | packages | key/value tuples | strings */
100+ newprops->type = ACPI_TYPE_PACKAGE;
101+ newprops->package.count = numvalid;
102+ newprops->package.elements = &newprops[1];
103+ free_space = &newprops[1 + 3 * numvalid];
104+
105+ for_each_set_bit(i, valid, numprops) {
106+ union acpi_object *key = &props->package.elements[i * 2];
107+ union acpi_object *val = &props->package.elements[i * 2 + 1];
108+ unsigned int k = 1 + numvalid + j * 2; /* index into newprops */
109+ unsigned int v = k + 1;
110+
111+ newprops[1 + j].type = ACPI_TYPE_PACKAGE;
112+ newprops[1 + j].package.count = 2;
113+ newprops[1 + j].package.elements = &newprops[k];
114+
115+ newprops[k].type = ACPI_TYPE_STRING;
116+ newprops[k].string.length = key->string.length;
117+ newprops[k].string.pointer = free_space;
118+ memcpy(free_space, key->string.pointer, key->string.length);
119+ free_space += key->string.length + 1;
120+
121+ newprops[v].type = val->type;
122+ if (val->type == ACPI_TYPE_INTEGER) {
123+ newprops[v].integer.value = val->integer.value;
124+ } else {
125+ newprops[v].buffer.length = val->buffer.length;
126+ newprops[v].buffer.pointer = free_space;
127+ memcpy(free_space, val->buffer.pointer,
128+ val->buffer.length);
129+ free_space += val->buffer.length;
130+ }
131+ j++; /* count valid properties */
132+ }
133+ WARN_ON(free_space != (void *)newprops + newsize);
134+
135+ adev->data.properties = newprops;
136+ adev->data.pointer = newprops;
137+
138+out_free:
139+ ACPI_FREE(props);
140+ kfree(valid);
141+}
drivers/firmware/efi/apple-properties.c+2−3
@@ -18,8 +18,8 @@ · 17 unmodified lines
1818 #define pr_fmt(fmt) "apple-properties: " fmt
1919
2020 #include <linux/bootmem.h>
21−#include <linux/dmi.h>
2221 #include <linux/efi.h>
22+#include <linux/platform_data/x86/apple.h>
2323 #include <linux/property.h>
2424 #include <linux/slab.h>
2525 #include <linux/ucs2_string.h>
@@ -191,8 +191,7 @@ static int __init map_properties(void) · 165 unmodified lines
191191 u64 pa_data;
192192 int ret;
193193
194− if (!dmi_match(DMI_SYS_VENDOR, "Apple Inc.") &&
195− !dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc."))
194+ if (!x86_apple_machine)
196195 return 0;
197196
198197 pa_data = boot_params.hdr.setup_data;
drivers/pci/quirks.c+3−2
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/sched.h>
2626 #include <linux/ktime.h>
2727 #include <linux/mm.h>
28+#include <linux/platform_data/x86/apple.h>
2829 #include <asm/dma.h> /* isa_dma_bridge_buggy */
2930 #include "pci.h"
3031
@@ -3447,7 +3448,7 @@ static void quirk_apple_poweroff_thunderbolt(struct pci_dev *dev) · 3416 unmodified lines
34473448 {
34483449 acpi_handle bridge, SXIO, SXFP, SXLV;
34493450
3450− if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc."))
3451+ if (!x86_apple_machine)
34513452 return;
34523453 if (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM)
34533454 return;
@@ -3492,7 +3493,7 @@ static void quirk_apple_wait_for_thunderbolt(struct pci_dev *dev) · 38 unmodified lines
34923493 struct pci_dev *sibling = NULL;
34933494 struct pci_dev *nhi = NULL;
34943495
3495− if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc."))
3496+ if (!x86_apple_machine)
34963497 return;
34973498 if (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)
34983499 return;
drivers/spi/spi.c+32−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 #include <linux/ioport.h>
4141 #include <linux/acpi.h>
4242 #include <linux/highmem.h>
43+#include <linux/platform_data/x86/apple.h>
4344
4445 #define CREATE_TRACE_POINTS
4546 #include <trace/events/spi.h>
@@ -1693,6 +1694,35 @@ static void of_register_spi_devices(struct spi_controller *ctlr) { } · 1647 unmodified lines
16931694 #endif
16941695
16951696 #ifdef CONFIG_ACPI
1697+static void acpi_spi_parse_apple_properties(struct spi_device *spi)
1698+{
1699+ struct acpi_device *dev = ACPI_COMPANION(&spi->dev);
1700+ const union acpi_object *obj;
1701+
1702+ if (!x86_apple_machine)
1703+ return;
1704+
1705+ if (!acpi_dev_get_property(dev, "spiSclkPeriod", ACPI_TYPE_BUFFER, &obj)
1706+ && obj->buffer.length >= 4)
1707+ spi->max_speed_hz = NSEC_PER_SEC / *(u32 *)obj->buffer.pointer;
1708+
1709+ if (!acpi_dev_get_property(dev, "spiWordSize", ACPI_TYPE_BUFFER, &obj)
1710+ && obj->buffer.length == 8)
1711+ spi->bits_per_word = *(u64 *)obj->buffer.pointer;
1712+
1713+ if (!acpi_dev_get_property(dev, "spiBitOrder", ACPI_TYPE_BUFFER, &obj)
1714+ && obj->buffer.length == 8 && !*(u64 *)obj->buffer.pointer)
1715+ spi->mode |= SPI_LSB_FIRST;
1716+
1717+ if (!acpi_dev_get_property(dev, "spiSPO", ACPI_TYPE_BUFFER, &obj)
1718+ && obj->buffer.length == 8 && *(u64 *)obj->buffer.pointer)
1719+ spi->mode |= SPI_CPOL;
1720+
1721+ if (!acpi_dev_get_property(dev, "spiSPH", ACPI_TYPE_BUFFER, &obj)
1722+ && obj->buffer.length == 8 && *(u64 *)obj->buffer.pointer)
1723+ spi->mode |= SPI_CPHA;
1724+}
1725+
16961726 static int acpi_spi_add_resource(struct acpi_resource *ares, void *data)
16971727 {
16981728 struct spi_device *spi = data;
@@ -1766,6 +1796,8 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, · 67 unmodified lines
17661796 acpi_spi_add_resource, spi);
17671797 acpi_dev_free_resource_list(&resource_list);
17681798
1799+ acpi_spi_parse_apple_properties(spi);
1800+
17691801 if (ret < 0 || !spi->max_speed_hz) {
17701802 spi_dev_put(spi);
17711803 return AE_OK;
drivers/thunderbolt/icm.c+4−9
@@ -13,9 +13,9 @@ · 12 unmodified lines
1313 */
1414
1515 #include <linux/delay.h>
16−#include <linux/dmi.h>
1716 #include <linux/mutex.h>
1817 #include <linux/pci.h>
18+#include <linux/platform_data/x86/apple.h>
1919 #include <linux/sizes.h>
2020 #include <linux/slab.h>
2121 #include <linux/workqueue.h>
@@ -102,11 +102,6 @@ static inline u64 get_route(u32 route_hi, u32 route_lo) · 80 unmodified lines
102102 return (u64)route_hi << 32 | route_lo;
103103 }
104104
105−static inline bool is_apple(void)
106−{
107− return dmi_match(DMI_BOARD_VENDOR, "Apple Inc.");
108−}
109−
110105 static bool icm_match(const struct tb_cfg_request *req,
111106 const struct ctl_pkg *pkg)
112107 {
@@ -176,7 +171,7 @@ static int icm_request(struct tb *tb, const void *request, size_t request_size, · 63 unmodified lines
176171
177172 static bool icm_fr_is_supported(struct tb *tb)
178173 {
179− return !is_apple();
174+ return !x86_apple_machine;
180175 }
181176
182177 static inline int icm_fr_get_switch_index(u32 port)
@@ -517,7 +512,7 @@ static bool icm_ar_is_supported(struct tb *tb) · 334 unmodified lines
517512 * Starting from Alpine Ridge we can use ICM on Apple machines
518513 * as well. We just need to reset and re-enable it first.
519514 */
520− if (!is_apple())
515+ if (!x86_apple_machine)
521516 return true;
522517
523518 /*
@@ -1011,7 +1006,7 @@ static int icm_start(struct tb *tb) · 487 unmodified lines
10111006 * don't provide images publicly either. To be on the safe side
10121007 * prevent root switch NVM upgrade on Macs for now.
10131008 */
1014− tb->root_switch->no_nvm_upgrade = is_apple();
1009+ tb->root_switch->no_nvm_upgrade = x86_apple_machine;
10151010
10161011 ret = tb_switch_add(tb->root_switch);
10171012 if (ret)
drivers/thunderbolt/tb.c+2−2
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 #include <linux/slab.h>
88 #include <linux/errno.h>
99 #include <linux/delay.h>
10−#include <linux/dmi.h>
10+#include <linux/platform_data/x86/apple.h>
1111
1212 #include "tb.h"
1313 #include "tb_regs.h"
@@ -453,7 +453,7 @@ struct tb *tb_probe(struct tb_nhi *nhi) · 439 unmodified lines
453453 struct tb_cm *tcm;
454454 struct tb *tb;
455455
456− if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc."))
456+ if (!x86_apple_machine)
457457 return NULL;
458458
459459 tb = tb_domain_alloc(nhi, sizeof(*tcm));
include/linux/acpi.h+2−2
@@ -228,8 +228,8 @@ struct acpi_subtable_proc { · 227 unmodified lines
228228 int count;
229229 };
230230
231−char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
232−void __acpi_unmap_table(char *map, unsigned long size);
231+void __iomem *__acpi_map_table(unsigned long phys, unsigned long size);
232+void __acpi_unmap_table(void __iomem *map, unsigned long size);
233233 int early_acpi_boot_init(void);
234234 int acpi_boot_init (void);
235235 void acpi_boot_table_init (void);
include/linux/platform_data/x86/apple.h+13−0
@@ -0,0 +1,13 @@
1+#ifndef PLATFORM_DATA_X86_APPLE_H
2+#define PLATFORM_DATA_X86_APPLE_H
3+
4+#ifdef CONFIG_X86
5+/**
6+ * x86_apple_machine - whether the machine is an x86 Apple Macintosh
7+ */
8+extern bool x86_apple_machine;
9+#else
10+#define x86_apple_machine false
11+#endif
12+
13+#endif