From: Carlo Caione <carlo@caione.org>
To: linux@endlessm.com, hdegoede@redhat.com, rjw@rjwysocki.net,
lenb@kernel.org, sre@kernel.org, wens@csie.org,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org
Cc: Carlo Caione <carlo@endlessm.com>
Subject: [PATCH v2 1/3] ACPI: AC/battery: Add quirk to avoid using PMIC
Date: Fri, 16 Feb 2018 08:26:14 +0000 [thread overview]
Message-ID: <20180216082616.25084-2-carlo@caione.org> (raw)
In-Reply-To: <20180216082616.25084-1-carlo@caione.org>
From: Carlo Caione <carlo@endlessm.com>
With commits af3ec837 and dccfae6d a blacklist was introduced to avoid
using the ACPI drivers for AC and battery when a native PMIC driver was
already present. While this is in general a good idea (because of broken
DSDT or proprietary and undocumented ACPI opregions for the ACPI
AC/battery devices) we have come across at least one CherryTrail laptop
(ECS EF20EA) shipping the AXP288 together with a separate FG controller
(a MAX17047) instead of the one embedded in the AXP288.
The net effect of blacklisting the ACPI drivers is that on this platform
the AC/battery reporting is broken since the information is coming from
the AXP288 FG driver, not actually used in hardware.
In this case we want to keep using the ACPI AC/battery driver that is
able to interface correctly with the real FG controller.
We introduce therefore a new quirk to avoid the blacklist.
Signed-off-by: Carlo Caione <carlo@endlessm.com>
---
drivers/acpi/ac.c | 26 ++++++++++++++++++--------
drivers/acpi/battery.c | 26 ++++++++++++++++++--------
2 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 47a7ed557bd6..b9a4ca720309 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -87,6 +87,7 @@ static int acpi_ac_open_fs(struct inode *inode, struct file *file);
static int ac_sleep_before_get_state_ms;
+static bool ac_not_use_pmic;
static struct acpi_driver acpi_ac_driver = {
.name = "ac",
@@ -316,6 +317,12 @@ static int thinkpad_e530_quirk(const struct dmi_system_id *d)
return 0;
}
+static int ac_not_use_pmic_quirk(const struct dmi_system_id *d)
+{
+ ac_not_use_pmic = true;
+ return 0;
+}
+
static const struct dmi_system_id ac_dmi_table[] = {
{
.callback = thinkpad_e530_quirk,
@@ -384,7 +391,6 @@ static int acpi_ac_add(struct acpi_device *device)
kfree(ac);
}
- dmi_check_system(ac_dmi_table);
return result;
}
@@ -442,13 +448,17 @@ static int __init acpi_ac_init(void)
if (acpi_disabled)
return -ENODEV;
- 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(PREFIX "AC: found native %s PMIC, not loading\n",
- acpi_ac_blacklist[i].hid);
- return -ENODEV;
- }
+ dmi_check_system(ac_dmi_table);
+
+ if (!ac_not_use_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(PREFIX "AC: found native %s PMIC, not loading\n",
+ acpi_ac_blacklist[i].hid);
+ return -ENODEV;
+ }
+ }
#ifdef CONFIG_ACPI_PROCFS_POWER
acpi_ac_dir = acpi_lock_ac_dir();
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 7128488a3a72..258d2e66f230 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -71,6 +71,7 @@ static bool battery_driver_registered;
static int battery_bix_broken_package;
static int battery_notification_delay_ms;
static int battery_full_discharging;
+static bool battery_not_use_pmic;
static unsigned int cache_time = 1000;
module_param(cache_time, uint, 0644);
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -1176,6 +1177,13 @@ static int __init battery_full_discharging_quirk(const struct dmi_system_id *d)
return 0;
}
+static int __init
+battery_not_use_pmic_quirk(const struct dmi_system_id *d)
+{
+ battery_not_use_pmic = true;
+ return 0;
+}
+
static const struct dmi_system_id bat_dmi_table[] __initconst = {
{
.callback = battery_bix_broken_package_quirk,
@@ -1364,16 +1372,18 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
unsigned int i;
int result;
- for (i = 0; i < ARRAY_SIZE(acpi_battery_blacklist); i++)
- if (acpi_dev_present(acpi_battery_blacklist[i], "1", -1)) {
- pr_info(PREFIX ACPI_BATTERY_DEVICE_NAME
- ": found native %s PMIC, not loading\n",
- acpi_battery_blacklist[i]);
- return;
- }
-
dmi_check_system(bat_dmi_table);
+ if (!battery_not_use_pmic) {
+ for (i = 0; i < ARRAY_SIZE(acpi_battery_blacklist); i++)
+ if (acpi_dev_present(acpi_battery_blacklist[i], "1", -1)) {
+ pr_info(PREFIX ACPI_BATTERY_DEVICE_NAME
+ ": found native %s PMIC, not loading\n",
+ acpi_battery_blacklist[i]);
+ return;
+ }
+ }
+
#ifdef CONFIG_ACPI_PROCFS_POWER
acpi_battery_dir = acpi_lock_battery_dir();
if (!acpi_battery_dir)
--
2.14.1
next prev parent reply other threads:[~2018-02-16 8:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 8:26 [PATCH v2 0/3] power: supply: Fix AXP288 fallback when not needed Carlo Caione
2018-02-16 8:26 ` Carlo Caione [this message]
2018-02-16 8:40 ` [PATCH v2 1/3] ACPI: AC/battery: Add quirk to avoid using PMIC Rafael J. Wysocki
2018-02-16 8:26 ` [PATCH v2 2/3] ACPI: AC/battery: Add quirks for ECS EF20EA Carlo Caione
2018-02-16 8:26 ` [PATCH v2 3/3] power: supply: axp288_fuel_gauge: Do not register FG on " Carlo Caione
2018-02-16 14:26 ` Sebastian Reichel
2018-02-16 8:41 ` [PATCH v2 0/3] power: supply: Fix AXP288 fallback when not needed Hans de Goede
2018-02-16 8:51 ` Rafael J. Wysocki
2018-02-16 8:52 ` Hans de Goede
2018-02-16 8:58 ` Carlo Caione
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180216082616.25084-2-carlo@caione.org \
--to=carlo@caione.org \
--cc=carlo@endlessm.com \
--cc=hdegoede@redhat.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@endlessm.com \
--cc=rjw@rjwysocki.net \
--cc=sre@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox