Skip to content

Commit

Permalink
Merge branches 'acpi-x86', 'acpi-soc', 'acpi-pmic' and 'acpi-apple'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Rafael J. Wysocki committed Sep 3, 2017
5 parents f928a49 + 42d516c + a4bb2b4 + 58eefe2 + 8a2e487 commit 01d2f10
Show file tree
Hide file tree
Showing 24 changed files with 278 additions and 87 deletions.
4 changes: 2 additions & 2 deletions arch/arm64/kernel/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
* __acpi_map_table() will be called before page_init(), so early_ioremap()
* or early_memremap() should be called here to for ACPI table mapping.
*/
char *__init __acpi_map_table(unsigned long phys, unsigned long size)
void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
{
if (!size)
return NULL;

return early_memremap(phys, size);
}

void __init __acpi_unmap_table(char *map, unsigned long size)
void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
{
if (!map || !size)
return;
Expand Down
6 changes: 3 additions & 3 deletions arch/ia64/kernel/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ int acpi_request_vector(u32 int_type)
return vector;
}

char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
{
return __va(phys_addr);
return __va(phys);
}

void __init __acpi_unmap_table(char *map, unsigned long size)
void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
{
}

Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static inline void vsmp_init(void) { }
#endif

void setup_bios_corruption_check(void);
void early_platform_quirks(void);

extern unsigned long saved_video_mode;

Expand Down
11 changes: 7 additions & 4 deletions arch/x86/kernel/acpi/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
* This is just a simple wrapper around early_ioremap(),
* with sanity checks for phys == 0 and size == 0.
*/
char *__init __acpi_map_table(unsigned long phys, unsigned long size)
void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
{

if (!phys || !size)
Expand All @@ -127,7 +127,7 @@ char *__init __acpi_map_table(unsigned long phys, unsigned long size)
return early_ioremap(phys, size);
}

void __init __acpi_unmap_table(char *map, unsigned long size)
void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
{
if (!map || !size)
return;
Expand Down Expand Up @@ -199,8 +199,10 @@ static int __init
acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
{
struct acpi_madt_local_x2apic *processor = NULL;
#ifdef CONFIG_X86_X2APIC
int apic_id;
u8 enabled;
#endif

processor = (struct acpi_madt_local_x2apic *)header;

Expand All @@ -209,9 +211,10 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)

acpi_table_print_madt_entry(header);

#ifdef CONFIG_X86_X2APIC
apic_id = processor->local_apic_id;
enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
#ifdef CONFIG_X86_X2APIC

/*
* We need to register disabled CPU as well to permit
* counting disabled CPUs. This allows us to size
Expand Down Expand Up @@ -1083,7 +1086,7 @@ static void __init mp_config_acpi_legacy_irqs(void)
mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
#endif
set_bit(MP_ISA_BUS, mp_bus_not_pci);
pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs());

/*
* Use the default configuration for the IRQs 0-15. Unless
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/kernel/early-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include <linux/pci.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/dmi.h>
#include <linux/pci_ids.h>
#include <linux/bcma/bcma.h>
#include <linux/bcma/bcma_regs.h>
#include <linux/platform_data/x86/apple.h>
#include <drm/i915_drm.h>
#include <asm/pci-direct.h>
#include <asm/dma.h>
Expand Down Expand Up @@ -593,7 +593,7 @@ static void __init apple_airport_reset(int bus, int slot, int func)
u64 addr;
int i;

if (!dmi_match(DMI_SYS_VENDOR, "Apple Inc."))
if (!x86_apple_machine)
return;

/* Card may have been put into PCI_D3hot by grub quirk */
Expand Down
10 changes: 10 additions & 0 deletions arch/x86/kernel/quirks.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* This file contains work-arounds for x86 and x86_64 platform bugs.
*/
#include <linux/dmi.h>
#include <linux/pci.h>
#include <linux/irq.h>

Expand Down Expand Up @@ -656,3 +657,12 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, quirk_intel_brickland_xeon_
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras_cap);
#endif
#endif

bool x86_apple_machine;
EXPORT_SYMBOL(x86_apple_machine);

void __init early_platform_quirks(void)
{
x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
}
2 changes: 2 additions & 0 deletions arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,8 @@ void __init setup_arch(char **cmdline_p)

io_delay_init();

early_platform_quirks();

/*
* Parse the ACPI tables for possible boot-time SMP configuration.
*/
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ acpi-$(CONFIG_ACPI_REDUCED_HARDWARE_ONLY) += evged.o
acpi-y += sysfs.o
acpi-y += property.o
acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
acpi-$(CONFIG_X86) += x86/apple.o
acpi-$(CONFIG_X86) += x86/utils.o
acpi-$(CONFIG_DEBUG_FS) += debugfs.o
acpi-$(CONFIG_ACPI_NUMA) += numa.o
Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/acpi_lpss.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
acpi_dev_free_resource_list(&resource_list);

if (!pdata->mmio_base) {
ret = -ENOMEM;
/* Skip the device, but continue the namespace scan. */
ret = 0;
goto err_out;
}

Expand Down
6 changes: 6 additions & 0 deletions drivers/acpi/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ static inline void suspend_nvs_restore(void) {}
void acpi_init_properties(struct acpi_device *adev);
void acpi_free_properties(struct acpi_device *adev);

#ifdef CONFIG_X86
void acpi_extract_apple_properties(struct acpi_device *adev);
#else
static inline void acpi_extract_apple_properties(struct acpi_device *adev) {}
#endif

/*--------------------------------------------------------------------------
Watchdog
-------------------------------------------------------------------------- */
Expand Down
37 changes: 8 additions & 29 deletions drivers/acpi/osi.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/platform_data/x86/apple.h>

#include "internal.h"

Expand Down Expand Up @@ -257,12 +258,11 @@ bool acpi_osi_is_win8(void)
}
EXPORT_SYMBOL(acpi_osi_is_win8);

static void __init acpi_osi_dmi_darwin(bool enable,
const struct dmi_system_id *d)
static void __init acpi_osi_dmi_darwin(void)
{
pr_notice("DMI detected to setup _OSI(\"Darwin\"): %s\n", d->ident);
pr_notice("DMI detected to setup _OSI(\"Darwin\"): Apple hardware\n");
osi_config.darwin_dmi = 1;
__acpi_osi_setup_darwin(enable);
__acpi_osi_setup_darwin(true);
}

static void __init acpi_osi_dmi_linux(bool enable,
Expand All @@ -273,13 +273,6 @@ static void __init acpi_osi_dmi_linux(bool enable,
__acpi_osi_setup_linux(enable);
}

static int __init dmi_enable_osi_darwin(const struct dmi_system_id *d)
{
acpi_osi_dmi_darwin(true, d);

return 0;
}

static int __init dmi_enable_osi_linux(const struct dmi_system_id *d)
{
acpi_osi_dmi_linux(true, d);
Expand Down Expand Up @@ -481,30 +474,16 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"),
},
},

/*
* Enable _OSI("Darwin") for all apple platforms.
*/
{
.callback = dmi_enable_osi_darwin,
.ident = "Apple hardware",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
},
},
{
.callback = dmi_enable_osi_darwin,
.ident = "Apple hardware",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
},
},
{}
};

static __init void acpi_osi_dmi_blacklisted(void)
{
dmi_check_system(acpi_osi_dmi_table);

/* Enable _OSI("Darwin") for Apple platforms. */
if (x86_apple_machine)
acpi_osi_dmi_darwin();
}

int __init early_acpi_osi_init(void)
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/pci_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/acpi.h>
#include <linux/slab.h>
#include <linux/dmi.h>
#include <linux/platform_data/x86/apple.h>
#include <acpi/apei.h> /* for acpi_hest_init() */

#include "internal.h"
Expand Down Expand Up @@ -431,8 +432,7 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)
* been called successfully. We know the feature set supported by the
* platform, so avoid calling _OSC at all
*/

if (dmi_match(DMI_SYS_VENDOR, "Apple Inc.")) {
if (x86_apple_machine) {
root->osc_control_set = ~OSC_PCI_EXPRESS_PME_CONTROL;
decode_osc_control(root, "OS assumes control of",
root->osc_control_set);
Expand Down
21 changes: 18 additions & 3 deletions drivers/acpi/pmic/intel_pmic_xpower.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#define GPI1_LDO_ON (3 << 0)
#define GPI1_LDO_OFF (4 << 0)

#define AXP288_ADC_TS_PIN_GPADC 0xf2
#define AXP288_ADC_TS_PIN_ON 0xf3

static struct pmic_table power_table[] = {
{
.address = 0x00,
Expand Down Expand Up @@ -209,11 +212,23 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
{
u8 buf[2];
int ret;

if (regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2))
return -EIO;
ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL,
AXP288_ADC_TS_PIN_GPADC);
if (ret)
return ret;

/* After switching to the GPADC pin give things some time to settle */
usleep_range(6000, 10000);

ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2);
if (ret == 0)
ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);

regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON);

return (buf[0] << 4) + ((buf[1] >> 4) & 0x0F);
return ret;
}

static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
Expand Down
6 changes: 6 additions & 0 deletions drivers/acpi/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ void acpi_init_properties(struct acpi_device *adev)

INIT_LIST_HEAD(&adev->data.subnodes);

if (!adev->handle)
return;

/*
* Check if ACPI_DT_NAMESPACE_HID is present and inthat case we fill in
* Device Tree compatible properties for this device.
Expand Down Expand Up @@ -373,6 +376,9 @@ void acpi_init_properties(struct acpi_device *adev)
if (acpi_of && !adev->flags.of_compatible_ok)
acpi_handle_info(adev->handle,
ACPI_DT_NAMESPACE_HID " requires 'compatible' property\n");

if (!adev->data.pointer)
acpi_extract_apple_properties(adev);
}

static void acpi_destroy_nondev_subnodes(struct list_head *list)
Expand Down
25 changes: 2 additions & 23 deletions drivers/acpi/sbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <linux/jiffies.h>
#include <linux/delay.h>
#include <linux/power_supply.h>
#include <linux/dmi.h>
#include <linux/platform_data/x86/apple.h>

#include "sbshc.h"
#include "battery.h"
Expand All @@ -58,8 +58,6 @@ static unsigned int cache_time = 1000;
module_param(cache_time, uint, 0644);
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");

static bool sbs_manager_broken;

#define MAX_SBS_BAT 4
#define ACPI_SBS_BLOCK_MAX 32

Expand Down Expand Up @@ -632,31 +630,12 @@ static void acpi_sbs_callback(void *context)
}
}

static int disable_sbs_manager(const struct dmi_system_id *d)
{
sbs_manager_broken = true;
return 0;
}

static struct dmi_system_id acpi_sbs_dmi_table[] = {
{
.callback = disable_sbs_manager,
.ident = "Apple",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc.")
},
},
{ },
};

static int acpi_sbs_add(struct acpi_device *device)
{
struct acpi_sbs *sbs;
int result = 0;
int id;

dmi_check_system(acpi_sbs_dmi_table);

sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL);
if (!sbs) {
result = -ENOMEM;
Expand All @@ -677,7 +656,7 @@ static int acpi_sbs_add(struct acpi_device *device)

result = 0;

if (!sbs_manager_broken) {
if (!x86_apple_machine) {
result = acpi_manager_get_info(sbs);
if (!result) {
sbs->manager_present = 1;
Expand Down
Loading

0 comments on commit 01d2f10

Please sign in to comment.