Skip to content

Commit

Permalink
Merge branches 'acpi-x86', 'acpi-pmic' and 'acpi-dptf'
Browse files Browse the repository at this point in the history
Merge x86-specific ACPI updates, PMIC driver ACPI updates and a DPTF
driver update for 5.17-rc1:

 - Rework the handling of device enumeration quirks in the x86-specific
   code and add new quirks for known-broken platforms (Hans de Goede).

 - Fix the handling of defective LPAT in the ACPI xpower PMIC driver
   and clean up some definitions of PMIC data structures (Hans de
   Goede).

 - Fix outdated comment in the ACPI DPTF driver (Sumeet Pawnikar).

* acpi-x86:
  ACPI / x86: Skip AC and battery devices on x86 Android tablets with broken DSDTs
  ACPI / x86: Introduce an acpi_quirk_skip_acpi_ac_and_battery() helper
  mmc: sdhci-acpi: Use the new soc_intel_is_byt() helper
  mmc: sdhci-acpi: Remove special handling for GPD win/pocket devices
  ACPI / x86: Add PWM2 on the Xiaomi Mi Pad 2 to the always_present list
  ACPI / x86: Add not-present quirk for the PCI0.SDHB.BRC1 device on the GPD win
  ACPI / x86: Allow specifying acpi_device_override_status() quirks by path
  ACPI: Change acpi_device_always_present() into acpi_device_override_status()
  ACPI / x86: Drop PWM2 device on Lenovo Yoga Book from always present table

* acpi-pmic:
  ACPI: PMIC: xpower: Fix _TMP ACPI errors
  ACPI: PMIC: allow drivers to provide a custom lpat_raw_to_temp() function
  ACPI: PMIC: constify all struct intel_pmic_opregion_data declarations

* acpi-dptf:
  ACPI: DPTF: Update device ID in a comment
  • Loading branch information
Rafael J. Wysocki committed Jan 10, 2022
4 parents 5847d2d + 1b15b69 + 5f96ba5 + 75f32fa commit af8fefd
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 214 deletions.
43 changes: 3 additions & 40 deletions drivers/acpi/ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,12 @@ static const struct acpi_device_id ac_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, ac_device_ids);

/* Lists of PMIC ACPI HIDs with an (often better) native charger driver */
static const struct acpi_ac_bl acpi_ac_blacklist[] = {
{ "INT33F4", -1 }, /* X-Powers AXP288 PMIC */
{ "INT34D3", 3 }, /* Intel Cherrytrail Whiskey Cove PMIC */
};

#ifdef CONFIG_PM_SLEEP
static int acpi_ac_resume(struct device *dev);
#endif
static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);

static int ac_sleep_before_get_state_ms;
static int ac_check_pmic = 1;
static int ac_only;

static struct acpi_driver acpi_ac_driver = {
Expand Down Expand Up @@ -200,12 +193,6 @@ static int __init thinkpad_e530_quirk(const struct dmi_system_id *d)
return 0;
}

static int __init ac_do_not_check_pmic_quirk(const struct dmi_system_id *d)
{
ac_check_pmic = 0;
return 0;
}

static int __init ac_only_quirk(const struct dmi_system_id *d)
{
ac_only = 1;
Expand All @@ -214,29 +201,13 @@ static int __init ac_only_quirk(const struct dmi_system_id *d)

/* Please keep this list alphabetically sorted */
static const struct dmi_system_id ac_dmi_table[] __initconst = {
{
/* ECS EF20EA, AXP288 PMIC but uses separate fuel-gauge */
.callback = ac_do_not_check_pmic_quirk,
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
},
},
{
/* Kodlix GK45 returning incorrect state */
.callback = ac_only_quirk,
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "GK45"),
},
},
{
/* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */
.callback = ac_do_not_check_pmic_quirk,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "80XF"),
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
},
},
{
/* Lenovo Thinkpad e530, see comment in acpi_ac_notify() */
.callback = thinkpad_e530_quirk,
Expand Down Expand Up @@ -341,23 +312,15 @@ static int acpi_ac_remove(struct acpi_device *device)

static int __init acpi_ac_init(void)
{
unsigned int i;
int result;

if (acpi_disabled)
return -ENODEV;

dmi_check_system(ac_dmi_table);
if (acpi_quirk_skip_acpi_ac_and_battery())
return -ENODEV;

if (ac_check_pmic) {
for (i = 0; i < ARRAY_SIZE(acpi_ac_blacklist); i++)
if (acpi_dev_present(acpi_ac_blacklist[i].hid, "1",
acpi_ac_blacklist[i].hrv)) {
pr_info("found native %s PMIC, not loading\n",
acpi_ac_blacklist[i].hid);
return -ENODEV;
}
}
dmi_check_system(ac_dmi_table);

result = acpi_bus_register_driver(&acpi_ac_driver);
if (result < 0)
Expand Down
42 changes: 3 additions & 39 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ static bool battery_driver_registered;
static int battery_bix_broken_package;
static int battery_notification_delay_ms;
static int battery_ac_is_broken;
static int battery_check_pmic = 1;
static unsigned int cache_time = 1000;
module_param(cache_time, uint, 0644);
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
Expand All @@ -64,11 +63,6 @@ static const struct acpi_device_id battery_device_ids[] = {

MODULE_DEVICE_TABLE(acpi, battery_device_ids);

/* Lists of PMIC ACPI HIDs with an (often better) native battery driver */
static const char * const acpi_battery_blacklist[] = {
"INT33F4", /* X-Powers AXP288 PMIC */
};

enum {
ACPI_BATTERY_ALARM_PRESENT,
ACPI_BATTERY_XINFO_PRESENT,
Expand Down Expand Up @@ -1104,13 +1098,6 @@ battery_ac_is_broken_quirk(const struct dmi_system_id *d)
return 0;
}

static int __init
battery_do_not_check_pmic_quirk(const struct dmi_system_id *d)
{
battery_check_pmic = 0;
return 0;
}

static const struct dmi_system_id bat_dmi_table[] __initconst = {
{
/* NEC LZ750/LS */
Expand Down Expand Up @@ -1139,22 +1126,6 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
},
},
{
/* ECS EF20EA, AXP288 PMIC but uses separate fuel-gauge */
.callback = battery_do_not_check_pmic_quirk,
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
},
},
{
/* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */
.callback = battery_do_not_check_pmic_quirk,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "80XF"),
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
},
},
{},
};

Expand Down Expand Up @@ -1279,19 +1250,12 @@ static struct acpi_driver acpi_battery_driver = {

static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
{
unsigned int i;
int result;

dmi_check_system(bat_dmi_table);
if (acpi_quirk_skip_acpi_ac_and_battery())
return;

if (battery_check_pmic) {
for (i = 0; i < ARRAY_SIZE(acpi_battery_blacklist); i++)
if (acpi_dev_present(acpi_battery_blacklist[i], "1", -1)) {
pr_info("found native %s PMIC, not loading\n",
acpi_battery_blacklist[i]);
return;
}
}
dmi_check_system(bat_dmi_table);

result = acpi_bus_register_driver(&acpi_battery_driver);
battery_driver_registered = (result == 0);
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ int acpi_bus_get_status(struct acpi_device *device)
acpi_status status;
unsigned long long sta;

if (acpi_device_always_present(device)) {
acpi_set_device_status(device, ACPI_STA_DEFAULT);
if (acpi_device_override_status(device, &sta)) {
acpi_set_device_status(device, sta);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/dptf/dptf_pch_fivr.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int pch_fivr_read(acpi_handle handle, char *method, struct pch_fivr_resp
}

/*
* Presentation of attributes which are defined for INT1045
* Presentation of attributes which are defined for INTC10xx
* They are:
* freq_mhz_low_clock : Set PCH FIVR switching freq for
* FIVR clock 19.2MHz and 24MHz
Expand Down
14 changes: 7 additions & 7 deletions drivers/acpi/pmic/intel_pmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct intel_pmic_opregion {
struct mutex lock;
struct acpi_lpat_conversion_table *lpat_table;
struct regmap *regmap;
struct intel_pmic_opregion_data *data;
const struct intel_pmic_opregion_data *data;
struct intel_pmic_regs_handler_ctx ctx;
};

Expand Down Expand Up @@ -53,7 +53,7 @@ static acpi_status intel_pmic_power_handler(u32 function,
{
struct intel_pmic_opregion *opregion = region_context;
struct regmap *regmap = opregion->regmap;
struct intel_pmic_opregion_data *d = opregion->data;
const struct intel_pmic_opregion_data *d = opregion->data;
int reg, bit, result;

if (bits != 32 || !value64)
Expand Down Expand Up @@ -95,7 +95,7 @@ static int pmic_read_temp(struct intel_pmic_opregion *opregion,
return 0;
}

temp = acpi_lpat_raw_to_temp(opregion->lpat_table, raw_temp);
temp = opregion->data->lpat_raw_to_temp(opregion->lpat_table, raw_temp);
if (temp < 0)
return temp;

Expand Down Expand Up @@ -135,7 +135,7 @@ static int pmic_thermal_aux(struct intel_pmic_opregion *opregion, int reg,
static int pmic_thermal_pen(struct intel_pmic_opregion *opregion, int reg,
int bit, u32 function, u64 *value)
{
struct intel_pmic_opregion_data *d = opregion->data;
const struct intel_pmic_opregion_data *d = opregion->data;
struct regmap *regmap = opregion->regmap;

if (!d->get_policy || !d->update_policy)
Expand Down Expand Up @@ -171,7 +171,7 @@ static acpi_status intel_pmic_thermal_handler(u32 function,
void *handler_context, void *region_context)
{
struct intel_pmic_opregion *opregion = region_context;
struct intel_pmic_opregion_data *d = opregion->data;
const struct intel_pmic_opregion_data *d = opregion->data;
int reg, bit, result;

if (bits != 32 || !value64)
Expand Down Expand Up @@ -255,7 +255,7 @@ static acpi_status intel_pmic_regs_handler(u32 function,

int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
struct regmap *regmap,
struct intel_pmic_opregion_data *d)
const struct intel_pmic_opregion_data *d)
{
acpi_status status = AE_OK;
struct intel_pmic_opregion *opregion;
Expand Down Expand Up @@ -344,7 +344,7 @@ EXPORT_SYMBOL_GPL(intel_pmic_install_opregion_handler);
int intel_soc_pmic_exec_mipi_pmic_seq_element(u16 i2c_address, u32 reg_address,
u32 value, u32 mask)
{
struct intel_pmic_opregion_data *d;
const struct intel_pmic_opregion_data *d;
int ret;

if (!intel_pmic_opregion) {
Expand Down
8 changes: 7 additions & 1 deletion drivers/acpi/pmic/intel_pmic.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#ifndef __INTEL_PMIC_H
#define __INTEL_PMIC_H

#include <acpi/acpi_lpat.h>

struct pmic_table {
int address; /* operation region address */
int reg; /* corresponding thermal register */
Expand All @@ -17,6 +19,8 @@ struct intel_pmic_opregion_data {
int (*update_policy)(struct regmap *r, int reg, int bit, int enable);
int (*exec_mipi_pmic_seq_element)(struct regmap *r, u16 i2c_address,
u32 reg_address, u32 value, u32 mask);
int (*lpat_raw_to_temp)(struct acpi_lpat_conversion_table *lpat_table,
int raw);
struct pmic_table *power_table;
int power_table_count;
struct pmic_table *thermal_table;
Expand All @@ -25,6 +29,8 @@ struct intel_pmic_opregion_data {
int pmic_i2c_address;
};

int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle, struct regmap *regmap, struct intel_pmic_opregion_data *d);
int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
struct regmap *regmap,
const struct intel_pmic_opregion_data *d);

#endif
3 changes: 2 additions & 1 deletion drivers/acpi/pmic/intel_pmic_bxtwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,14 @@ intel_bxtwc_pmic_update_policy(struct regmap *regmap,
return regmap_update_bits(regmap, reg, mask, val);
}

static struct intel_pmic_opregion_data intel_bxtwc_pmic_opregion_data = {
static const struct intel_pmic_opregion_data intel_bxtwc_pmic_opregion_data = {
.get_power = intel_bxtwc_pmic_get_power,
.update_power = intel_bxtwc_pmic_update_power,
.get_raw_temp = intel_bxtwc_pmic_get_raw_temp,
.update_aux = intel_bxtwc_pmic_update_aux,
.get_policy = intel_bxtwc_pmic_get_policy,
.update_policy = intel_bxtwc_pmic_update_policy,
.lpat_raw_to_temp = acpi_lpat_raw_to_temp,
.power_table = power_table,
.power_table_count = ARRAY_SIZE(power_table),
.thermal_table = thermal_table,
Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/pmic/intel_pmic_bytcrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,14 @@ static int intel_crc_pmic_update_policy(struct regmap *regmap,
return 0;
}

static struct intel_pmic_opregion_data intel_crc_pmic_opregion_data = {
static const struct intel_pmic_opregion_data intel_crc_pmic_opregion_data = {
.get_power = intel_crc_pmic_get_power,
.update_power = intel_crc_pmic_update_power,
.get_raw_temp = intel_crc_pmic_get_raw_temp,
.update_aux = intel_crc_pmic_update_aux,
.get_policy = intel_crc_pmic_get_policy,
.update_policy = intel_crc_pmic_update_policy,
.lpat_raw_to_temp = acpi_lpat_raw_to_temp,
.power_table = power_table,
.power_table_count= ARRAY_SIZE(power_table),
.thermal_table = thermal_table,
Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/pmic/intel_pmic_chtcrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
* intel_soc_pmic_exec_mipi_pmic_seq_element work on devices with a
* CHT Crystal Cove PMIC.
*/
static struct intel_pmic_opregion_data intel_chtcrc_pmic_opregion_data = {
static const struct intel_pmic_opregion_data intel_chtcrc_pmic_opregion_data = {
.lpat_raw_to_temp = acpi_lpat_raw_to_temp,
.pmic_i2c_address = 0x6e,
};

Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/pmic/intel_pmic_chtdc_ti.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
return ((buf[0] & 0x03) << 8) | buf[1];
}

static struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = {
static const struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = {
.get_power = chtdc_ti_pmic_get_power,
.update_power = chtdc_ti_pmic_update_power,
.get_raw_temp = chtdc_ti_pmic_get_raw_temp,
.lpat_raw_to_temp = acpi_lpat_raw_to_temp,
.power_table = chtdc_ti_power_table,
.power_table_count = ARRAY_SIZE(chtdc_ti_power_table),
.thermal_table = chtdc_ti_thermal_table,
Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/pmic/intel_pmic_chtwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,11 @@ static int intel_cht_wc_exec_mipi_pmic_seq_element(struct regmap *regmap,
* The thermal table and ops are empty, we do not support the Thermal opregion
* (DPTF) due to lacking documentation.
*/
static struct intel_pmic_opregion_data intel_cht_wc_pmic_opregion_data = {
static const struct intel_pmic_opregion_data intel_cht_wc_pmic_opregion_data = {
.get_power = intel_cht_wc_pmic_get_power,
.update_power = intel_cht_wc_pmic_update_power,
.exec_mipi_pmic_seq_element = intel_cht_wc_exec_mipi_pmic_seq_element,
.lpat_raw_to_temp = acpi_lpat_raw_to_temp,
.power_table = power_table,
.power_table_count = ARRAY_SIZE(power_table),
};
Expand Down
24 changes: 23 additions & 1 deletion drivers/acpi/pmic/intel_pmic_xpower.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,33 @@ static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap,
return ret;
}

static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
static int intel_xpower_lpat_raw_to_temp(struct acpi_lpat_conversion_table *lpat_table,
int raw)
{
struct acpi_lpat first = lpat_table->lpat[0];
struct acpi_lpat last = lpat_table->lpat[lpat_table->lpat_count - 1];

/*
* Some LPAT tables in the ACPI Device for the AXP288 PMIC for some
* reason only describe a small temperature range, e.g. 27° - 37°
* Celcius. Resulting in errors when the tablet is idle in a cool room.
*
* To avoid these errors clamp the raw value to be inside the LPAT.
*/
if (first.raw < last.raw)
raw = clamp(raw, first.raw, last.raw);
else
raw = clamp(raw, last.raw, first.raw);

return acpi_lpat_raw_to_temp(lpat_table, raw);
}

static const struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
.get_power = intel_xpower_pmic_get_power,
.update_power = intel_xpower_pmic_update_power,
.get_raw_temp = intel_xpower_pmic_get_raw_temp,
.exec_mipi_pmic_seq_element = intel_xpower_exec_mipi_pmic_seq_element,
.lpat_raw_to_temp = intel_xpower_lpat_raw_to_temp,
.power_table = power_table,
.power_table_count = ARRAY_SIZE(power_table),
.thermal_table = thermal_table,
Expand Down
Loading

0 comments on commit af8fefd

Please sign in to comment.