Received: by 10.223.185.116 with SMTP id b49csp1014816wrg; Fri, 16 Feb 2018 10:50:43 -0800 (PST) X-Google-Smtp-Source: AH8x224jZVQgmT77TC/kSoNPCd45vARFw9DqVZl779P39+WHk868LEj8CFw53yPP+gimOO9rp33n X-Received: by 10.167.128.81 with SMTP id y17mr6913945pfm.91.1518807043585; Fri, 16 Feb 2018 10:50:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807043; cv=none; d=google.com; s=arc-20160816; b=otNLG+uEv3xIOHo7udAS7E5CXRGTHg3vibgusbuWmNi9+hwGKiuGYxGe0Ilv19H5W8 rxNG/JEEMlKxFNjKJEs1dAUmV+KdtfJoNFNBHGLHgfsoaworihmNe1QQlWe+HCOru7qT Y/1xGpjVrZMZWnWrSAaHvImpR6bMZ2y/l0+iOmS+vGxpw0Rk/bVsyJPrG9GaX4dmVWC2 5VmE6iK/EsU+dUbA/geoU4CBDob82Fw+8ZilBrMzLOlX4jckH1O2dV1htkonh96B4LTi TCI7UBmzQiSISXxg4gZ3Gn11ZeCdCRmi7rzj8jQLgUebN1Y8O1+SOIujrFTmA/CEsxJ5 ilTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=QGxyz9XvI6i8L8OxE3B5rz9v+eMalc1yUkh2r4l+aSM=; b=kXcQceKg4Td8tE4xnHBepwWJ8QrKo/lRWaVZQn4ORAO3L3EaY21JFzDxl5+XEq3xHX cASvKcY7ABakZSF+v8Y+tZkmj44Iaa5/3ghgg9JU4NEU6ZnDitnb717AD1G0W1jAzPFv AZHTzYeald/mFzcyJjEBdVDeEj3LUIQjCYn5kmXci7QrvKUMtZTiRP+aUt9SB7jZbz0B nXywwOT/xvqI3eQkZW57A1ZOfW0ZKP1hANfeAn9jJZIoH2DvjqJiTgd89fY9zODkucZY TZo5WSeKTocTiovBoCZlGJ0rS9gmsLAo/O14q1oEOZpWjjya/BhaJAiXAtLrT1G6daCv QmvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=IeiH3Dzt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si2864067pgv.764.2018.02.16.10.50.28; Fri, 16 Feb 2018 10:50:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=IeiH3Dzt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754367AbeBPI1F (ORCPT + 99 others); Fri, 16 Feb 2018 03:27:05 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39684 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754229AbeBPI06 (ORCPT ); Fri, 16 Feb 2018 03:26:58 -0500 Received: by mail-wr0-f194.google.com with SMTP id w77so2087507wrc.6; Fri, 16 Feb 2018 00:26:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QGxyz9XvI6i8L8OxE3B5rz9v+eMalc1yUkh2r4l+aSM=; b=IeiH3DztwZHXkMKbje59V8wL/5DWopNIfMyoOk7rlkoXlAR3V0cIFb2W+ENzp5C2Al 7e4DisgNsCOa5VJvnInY/fC0A/iOzBoK//maoiNHSxXA+Xoa7JSUxiJ06UAYJRs95vKo hREetEcNOkTWMcaancycGo13HZ0UnkB1uHNIbu9h8eEu6CeZE33Qzvx9sVE/0f2Dwowd cI4CUE3OZNP77Q24HaQpSD0YCNECmF/Vdy53Rudfz4Y+srnFV7sFBLQff+ayj56StNAb fNXd2J1d5yo+oDNQoeYHle8VrFCmyIXhz4LCtpRnZXXsZV2jTrb1TGnUXYPj60WSnjAi Wa/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=QGxyz9XvI6i8L8OxE3B5rz9v+eMalc1yUkh2r4l+aSM=; b=HNWSUQXwQztZZSTFVgKabf+pKdBqZnw6fMjQNGc07+Hr+padI3StEEcS22N33LlhgK glVxXAx66VN3gdwf5ryy9BIMmHFJsHREQJmdQ1d4lruuaO1e5vSXHvpyinF0bKCqZUWX dplPdcwsgkCRs6aWUtMbYxmVxXvz0XyHzMyjcjQIUK3GTjcafTyrQkVz6MYgJDADY5Tf 4LztlQtIS2YN0kaE4AYthCD1u0Phgi2skW5mhxLOgJQT+ppiZUtXiOmq78LR3ioYttwR y73TNGLCKqUy+g80QYGqQIzhZ5jnzvBWGYSjCcPkWW+fCbhqM7uSeEYPTJU9DRyUfGEu aIMA== X-Gm-Message-State: APf1xPC7nuRs7b6EtS0THnaYTUo+Dw0Oh152F+Pt5z7bBdqyG+OK/c3s u3uKnrOGXgQDVbiolby06Kk= X-Received: by 10.223.134.104 with SMTP id 37mr4509368wrw.150.1518769616857; Fri, 16 Feb 2018 00:26:56 -0800 (PST) Received: from satan.home ([2a00:23c4:f78b:2a00:9520:864c:b8f0:f03d]) by smtp.gmail.com with ESMTPSA id s126sm7846552wmd.43.2018.02.16.00.26.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 00:26:56 -0800 (PST) From: Carlo Caione 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 Subject: [PATCH v2 1/3] ACPI: AC/battery: Add quirk to avoid using PMIC Date: Fri, 16 Feb 2018 08:26:14 +0000 Message-Id: <20180216082616.25084-2-carlo@caione.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180216082616.25084-1-carlo@caione.org> References: <20180216082616.25084-1-carlo@caione.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Carlo Caione 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 --- 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