From 72ebe5a0b3505019d4e7592c0dd9281e0b9e44c7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 May 2017 23:35:39 +0200 Subject: [PATCH 1/3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler Some Bay Trail devices use a GPI1 regulator field (address 0x4c) in their 0x8d power OpRegion, add support for this. This fixes AE_BAD_PARAMETER errors getting thrown on these devices and fixes these errors causing these devices to not suspend. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/pmic/intel_pmic_xpower.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c index 1a76c784cd4c..3b7d5be5b7ed 100644 --- a/drivers/acpi/pmic/intel_pmic_xpower.c +++ b/drivers/acpi/pmic/intel_pmic_xpower.c @@ -21,6 +21,11 @@ #include "intel_pmic.h" #define XPOWER_GPADC_LOW 0x5b +#define XPOWER_GPI1_CTRL 0x92 + +#define GPI1_LDO_MASK GENMASK(2, 0) +#define GPI1_LDO_ON (3 << 0) +#define GPI1_LDO_OFF (4 << 0) static struct pmic_table power_table[] = { { @@ -118,6 +123,10 @@ static struct pmic_table power_table[] = { .reg = 0x10, .bit = 0x00 }, /* BUC6 */ + { + .address = 0x4c, + .reg = 0x92, + }, /* GPI1 */ }; /* TMP0 - TMP5 are the same, all from GPADC */ @@ -156,7 +165,12 @@ static int intel_xpower_pmic_get_power(struct regmap *regmap, int reg, if (regmap_read(regmap, reg, &data)) return -EIO; - *value = (data & BIT(bit)) ? 1 : 0; + /* GPIO1 LDO regulator needs special handling */ + if (reg == XPOWER_GPI1_CTRL) + *value = ((data & GPI1_LDO_MASK) == GPI1_LDO_ON); + else + *value = (data & BIT(bit)) ? 1 : 0; + return 0; } @@ -165,6 +179,11 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg, { int data; + /* GPIO1 LDO regulator needs special handling */ + if (reg == XPOWER_GPI1_CTRL) + return regmap_update_bits(regmap, reg, GPI1_LDO_MASK, + on ? GPI1_LDO_ON : GPI1_LDO_OFF); + if (regmap_read(regmap, reg, &data)) return -EIO; From b6aeab44ed387e5264d2969bc7deee993b29a515 Mon Sep 17 00:00:00 2001 From: Vincent Legoll Date: Sat, 20 May 2017 20:38:13 +0200 Subject: [PATCH 2/3] ACPI: fix whitespace in pr_fmt() to align log entries See this dmesg extract before the patch: [ 0.679466] ACPI: Dynamic OEM Table Load: [ 0.679470] ACPI: SSDT 0xFFFF910F6B497E00 00018A (v02 PmRef ApCst 00003000 INTL 20160422) [ 0.679579] ACPI: Executed 1 blocks of module-level executable AML code [ 0.681477] ACPI : EC: EC started [ 0.681478] ACPI : EC: interrupt blocked [ 0.684798] ACPI: Interpreter enabled [ 0.684835] ACPI: (supports S0 S3 S4 S5) Signed-off-by: Vincent Legoll Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_dbg.c | 2 +- drivers/acpi/button.c | 2 +- drivers/acpi/ec.c | 2 +- drivers/acpi/ioapic.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c index dee86925a9a1..3ec05aa1a903 100644 --- a/drivers/acpi/acpi_dbg.c +++ b/drivers/acpi/acpi_dbg.c @@ -10,7 +10,7 @@ */ /* #define DEBUG */ -#define pr_fmt(fmt) "ACPI : AML: " fmt +#define pr_fmt(fmt) "ACPI: AML: " fmt #include #include diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index e19f530f1083..34e07d6f65ad 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -19,7 +19,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#define pr_fmt(fmt) "ACPI : button: " fmt +#define pr_fmt(fmt) "ACPI: button: " fmt #include #include diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index c24235d8fb52..01e6e392f2ad 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -27,7 +27,7 @@ /* Uncomment next line to get verbose printout */ /* #define DEBUG */ -#define pr_fmt(fmt) "ACPI : EC: " fmt +#define pr_fmt(fmt) "ACPI: EC: " fmt #include #include diff --git a/drivers/acpi/ioapic.c b/drivers/acpi/ioapic.c index 7e4fbf9a53a3..3595aa9c7c18 100644 --- a/drivers/acpi/ioapic.c +++ b/drivers/acpi/ioapic.c @@ -21,7 +21,7 @@ * registered when we parsed the ACPI MADT. */ -#define pr_fmt(fmt) "ACPI : IOAPIC: " fmt +#define pr_fmt(fmt) "ACPI: IOAPIC: " fmt #include #include From 772bf1e2878ecfca0d1f332071c83e021dd9cf01 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 9 Jun 2017 20:36:31 +0200 Subject: [PATCH 3/3] ACPI: configfs: Unload SSDT on configfs entry removal Call directly into acpica to load a table to obtain its index on return. We choose the direct call of acpica internal functions to avoid having to modify its API which is used outside of Linux as well. Use that index to unload the table again when the corresponding directory in configfs gets removed. This allows to change SSDTs without rebooting the system. It also allows to destroy devices again that a dynamically loaded SSDT created. This is widely similar to the DT overlay behavior. Signed-off-by: Jan Kiszka Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_configfs.c | 20 +++++++++++++++++++- drivers/acpi/acpica/tbdata.c | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c index 146a77fb762d..853bc7fc673f 100644 --- a/drivers/acpi/acpi_configfs.c +++ b/drivers/acpi/acpi_configfs.c @@ -15,11 +15,15 @@ #include #include +#include "acpica/accommon.h" +#include "acpica/actables.h" + static struct config_group *acpi_table_group; struct acpi_table { struct config_item cfg; struct acpi_table_header *header; + u32 index; }; static ssize_t acpi_table_aml_write(struct config_item *cfg, @@ -52,7 +56,11 @@ static ssize_t acpi_table_aml_write(struct config_item *cfg, if (!table->header) return -ENOMEM; - ret = acpi_load_table(table->header); + ACPI_INFO(("Host-directed Dynamic ACPI Table Load:")); + ret = acpi_tb_install_and_load_table( + ACPI_PTR_TO_PHYSADDR(table->header), + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE, + &table->index); if (ret) { kfree(table->header); table->header = NULL; @@ -215,8 +223,18 @@ static struct config_item *acpi_table_make_item(struct config_group *group, return &table->cfg; } +static void acpi_table_drop_item(struct config_group *group, + struct config_item *cfg) +{ + struct acpi_table *table = container_of(cfg, struct acpi_table, cfg); + + ACPI_INFO(("Host-directed Dynamic ACPI Table Unload")); + acpi_tb_unload_table(table->index); +} + struct configfs_group_operations acpi_table_group_ops = { .make_item = acpi_table_make_item, + .drop_item = acpi_table_drop_item, }; static struct config_item_type acpi_tables_type = { diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c index 27c5c27d4818..c9d6fa6d7cc6 100644 --- a/drivers/acpi/acpica/tbdata.c +++ b/drivers/acpi/acpica/tbdata.c @@ -867,6 +867,8 @@ exit: return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_tb_install_and_load_table) + /******************************************************************************* * * FUNCTION: acpi_tb_unload_table @@ -914,3 +916,5 @@ acpi_status acpi_tb_unload_table(u32 table_index) acpi_tb_set_table_loaded_flag(table_index, FALSE); return_ACPI_STATUS(status); } + +ACPI_EXPORT_SYMBOL(acpi_tb_unload_table)