Commit 8e1b295b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'acpi-5.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI fixes from Rafael Wysocki:
 "Fix a build failure introduced recently, fix the xpower PMIC ACPI
  driver, clean up the handling of duplicate entries in _PRx power
  resource lists and fix addresses in NUMA-related messages on 32-bit
  with PAE.

  Specifics:

   - Fix build failures with both CONFIG_NLS and CONFIG_PCI unset that
     can occur since ACPI can be built without PCI now (Sinan Kaya).

   - Clean up the handling of duplicate entries in power resource lists
     returned by _PRx evaluation to avoid triggering WARN_ON() on
     attempts to add duplicate symlinks in sysfs (Hans de Goede).

   - Fix issues with the TS current-source switching on systems using
     the xpower PMIC by avoiding to update unrelated bits in the TS
     pin-ctrl register and avoiding to unconditionally enable TS
     current-source on systems where it is not used (Hans de Goede).

   - Fix addresses in NUMA-related messages on 32-bit with PAE which can
     be truncated due to integer type conversions (Chao Fan)"

* tag 'acpi-5.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPI / PMIC: xpower: Fix TS-pin current-source handling
  ACPI: NUMA: Use correct type for printing addresses on i386-PAE
  ACPI: power: Skip duplicate power resource references in _PRx
  ACPI: Fix build failure when CONFIG_NLS is set to 'n'
parents f4f31fff 65a4f3a1
......@@ -10,6 +10,7 @@ menuconfig ACPI
bool "ACPI (Advanced Configuration and Power Interface) Support"
depends on ARCH_SUPPORTS_ACPI
select PNP
select NLS
default y if X86
help
Advanced Configuration and Power Interface (ACPI) support for
......
......@@ -146,9 +146,9 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
{
struct acpi_srat_mem_affinity *p =
(struct acpi_srat_mem_affinity *)header;
pr_debug("SRAT Memory (0x%lx length 0x%lx) in proximity domain %d %s%s%s\n",
(unsigned long)p->base_address,
(unsigned long)p->length,
pr_debug("SRAT Memory (0x%llx length 0x%llx) in proximity domain %d %s%s%s\n",
(unsigned long long)p->base_address,
(unsigned long long)p->length,
p->proximity_domain,
(p->flags & ACPI_SRAT_MEM_ENABLED) ?
"enabled" : "disabled",
......
......@@ -20,8 +20,11 @@
#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
#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0)
#define AXP288_ADC_TS_CURRENT_OFF (0 << 0)
#define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0)
#define AXP288_ADC_TS_CURRENT_ON_ONDEMAND (2 << 0)
#define AXP288_ADC_TS_CURRENT_ON (3 << 0)
static struct pmic_table power_table[] = {
{
......@@ -212,22 +215,44 @@ 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)
{
int ret, adc_ts_pin_ctrl;
u8 buf[2];
int ret;
ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL,
AXP288_ADC_TS_PIN_GPADC);
/*
* The current-source used for the battery temp-sensor (TS) is shared
* with the GPADC. For proper fuel-gauge and charger operation the TS
* current-source needs to be permanently on. But to read the GPADC we
* need to temporary switch the TS current-source to ondemand, so that
* the GPADC can use it, otherwise we will always read an all 0 value.
*
* Note that the switching from on to on-ondemand is not necessary
* when the TS current-source is off (this happens on devices which
* do not use the TS-pin).
*/
ret = regmap_read(regmap, AXP288_ADC_TS_PIN_CTRL, &adc_ts_pin_ctrl);
if (ret)
return ret;
/* After switching to the GPADC pin give things some time to settle */
usleep_range(6000, 10000);
if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
ret = regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
AXP288_ADC_TS_CURRENT_ON_ONDEMAND);
if (ret)
return ret;
/* Wait a bit after switching the current-source */
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);
if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
AXP288_ADC_TS_CURRENT_ON);
}
return ret;
}
......
......@@ -131,6 +131,23 @@ void acpi_power_resources_list_free(struct list_head *list)
}
}
static bool acpi_power_resource_is_dup(union acpi_object *package,
unsigned int start, unsigned int i)
{
acpi_handle rhandle, dup;
unsigned int j;
/* The caller is expected to check the package element types */
rhandle = package->package.elements[i].reference.handle;
for (j = start; j < i; j++) {
dup = package->package.elements[j].reference.handle;
if (dup == rhandle)
return true;
}
return false;
}
int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
struct list_head *list)
{
......@@ -150,6 +167,11 @@ int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
err = -ENODEV;
break;
}
/* Some ACPI tables contain duplicate power resource references */
if (acpi_power_resource_is_dup(package, start, i))
continue;
err = acpi_add_power_resource(rhandle);
if (err)
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment