From patchwork Tue Apr 18 11:58:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9685437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E412E602C9 for ; Tue, 18 Apr 2017 11:59:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D93C82842E for ; Tue, 18 Apr 2017 11:59:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDDF42843B; Tue, 18 Apr 2017 11:59:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D5402842E for ; Tue, 18 Apr 2017 11:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752672AbdDRL7G (ORCPT ); Tue, 18 Apr 2017 07:59:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57904 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755671AbdDRL7B (ORCPT ); Tue, 18 Apr 2017 07:59:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E672D31F414; Tue, 18 Apr 2017 11:58:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E672D31F414 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E672D31F414 Received: from shalem.localdomain.com (unknown [10.36.118.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36A9D7E861; Tue, 18 Apr 2017 11:58:53 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Sebastian Reichel Cc: Hans de Goede , Andy Shevchenko , Lukas Wunner , Robert Moore , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v6 4/5] ACPI: ac: Add a blacklist with PMIC ACPI HIDs with a native charger driver Date: Tue, 18 Apr 2017 13:58:41 +0200 Message-Id: <20170418115842.16214-5-hdegoede@redhat.com> In-Reply-To: <20170418115842.16214-1-hdegoede@redhat.com> References: <20170418115842.16214-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 18 Apr 2017 11:58:55 +0000 (UTC) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On some systems we have a native PMIC driver which provides Mains monitoring, while the ACPI ac driver is broken on these systems due to bad DSTDs or because we do not support the proprietary and undocumented ACPI opregions these ACPI battery devices rely on (e.g. BMOP opregion). This leads for example to a ADP1 power_supply which reports itself as always online even if no mains are connected. This commit adds a blacklist with PMIC ACPI HIDs for which we've a native charger or extcon driver and makes the ACPI ac driver not register itself when a PMIC on this list is present. Signed-off-by: Hans de Goede --- Changes in v2: -This is a new patch in v2 of this patch-set replacing: "ACPI: ac: Add acpi_ac_unregister() function" "power: supply: axp288_charger: Unregister duplicate ACPI ac supply" And also this patch from my local patch-queue (not submitted yet): "i2c-cht-wc: remove broken ACPI AC power-supply" --- drivers/acpi/ac.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index f71b756..8df95a1 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -57,12 +57,23 @@ static int acpi_ac_add(struct acpi_device *device); static int acpi_ac_remove(struct acpi_device *device); static void acpi_ac_notify(struct acpi_device *device, u32 event); +struct acpi_ac_bl { + const char *hid; + int hrv; +}; + static const struct acpi_device_id ac_device_ids[] = { {"ACPI0003", 0}, {"", 0}, }; 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 @@ -424,11 +435,19 @@ static int acpi_ac_remove(struct acpi_device *device) static int __init acpi_ac_init(void) { - int result; + int i, result; 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("ACPI: 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(); if (!acpi_ac_dir)