Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5804471ybl; Tue, 14 Jan 2020 15:28:52 -0800 (PST) X-Google-Smtp-Source: APXvYqx/M+P3slV5eW4cUCKmIaF8KcjLuJ7Rz5lATaj5XtvKsK5FiA9vLdHAqC30UB/4E2/O3tXu X-Received: by 2002:a05:6830:1503:: with SMTP id k3mr639194otp.213.1579044532132; Tue, 14 Jan 2020 15:28:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579044532; cv=none; d=google.com; s=arc-20160816; b=sT4YOAWXIRH9mFMhfTSZcwu3hzHs/9hyRD+GITPJDjW6Qkkv5DFtOGWiPtNY9z+Sq1 8FNLiOJgfUa43I/4VSPvd9S8qf6K4mHb287ILNKZjjV99WfTJIth6xGrreWtpm4uDTGK eWvJgbMB4UxIx0IE2J7U6uZ+GNhTwX5Fj/pxvSjvwfvKvAUpRgCj3xk/eD7Dw1eE0Aai a900MywTckfXf7QcAsm//60IvbjOK+cQvTU7o/KFmi1+L+mL7lbaPjdrk21jDnuuNejm NMKtg//SLUkmjs4uzDJLcndwwhwVQo9/t6IaYMIRtJ/jNkgljoFtBymkMkdLlI9/7rYi vNww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FjlR2GDiNviLLUnZLpM2xF4e4vLYisf90J5psoo45v0=; b=FCcGFck8uPK4htpVHE5vzEPSNqcINQ62wA+y8ZJ7Qj13SbYebCRi9Sb7wMuDkg6lSY ePRUc6aYOmK0gpA/FNztySpeY26MQ8KILMjkfhh5yDZdDtCmZgOSx0pQA305Wz6CGoWs ShF/HNhBPoWOo+TMHiXCxuO9UkFl3P3oXab5ImIw6+s9CRR1AwuuIJb7oEX3SoFp/nlH fHiCLeLJhq3PRw825+ZOIUxPfvyO1d65eSpfiH7norl9UApSpAjm8KnjRR+EFW5vBAPz x49UZw1XExE/nPUwcoNeAdUptB9XqsbCk7AiBVGYBFmc756OcEFyDd2rYpTIXzBxIPVw KHYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gBSNJE45; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j70si8805128oib.219.2020.01.14.15.28.40; Tue, 14 Jan 2020 15:28:52 -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=pass header.i=@chromium.org header.s=google header.b=gBSNJE45; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728880AbgANX1p (ORCPT + 99 others); Tue, 14 Jan 2020 18:27:45 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44471 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728757AbgANX1o (ORCPT ); Tue, 14 Jan 2020 18:27:44 -0500 Received: by mail-pf1-f194.google.com with SMTP id 62so731102pfu.11 for ; Tue, 14 Jan 2020 15:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FjlR2GDiNviLLUnZLpM2xF4e4vLYisf90J5psoo45v0=; b=gBSNJE45auewf9yu41Jxx90LA/dvCD7dhGxGpC0eEVxntCV/YQ1saVcFOQRaaeA7cl K7kwv+IypGXC1ddYEe/94PFryKsx+mNaK26ojYkMpzLutPE8YylmoKQN40y8pW6gcPPo mayG3BljWAw0auet19NA/z1PwsDttjdENN8T4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FjlR2GDiNviLLUnZLpM2xF4e4vLYisf90J5psoo45v0=; b=pQ/UDnBP64c6hmot39KmwogGiggLAEYplg9gFvGXnR8Kp4F+alUdU0mcuPOcz2pvTe 9BY3zl9UfswvZ0pikTM924pp+ksWThA2caX+LAx0TlsK9lgj134gO9ABgZ56zSIBi7Qz 57O0aeK/Wu2yTffJXyjtAEoEUaIElzeJwBWlBumYUssswEHcnPLKUKo4Fmi6820TVgVo Nim8zACWPIzwI8oWQPBpeHTyJAnOq3wIZuk/3i7WXq2Bmqf2OwUzQ3KqjRvP0q0GQu2x +GU+gKksvTlB/eNU0ZyfYx5XlNEm8wvsEelpOfYMdm8gxVwcK0PclMmKWdysknRRZjZh 9Q2w== X-Gm-Message-State: APjAAAXwSPjS97JcB1VK10/jo2KVAhskHajSYJvRI3lcxSsZxKsYa+bn 6NAKIT2uTKtRlPCKsnEGsTLhcg== X-Received: by 2002:a63:484b:: with SMTP id x11mr30224921pgk.148.1579044463438; Tue, 14 Jan 2020 15:27:43 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id u18sm18521839pgn.9.2020.01.14.15.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 15:27:43 -0800 (PST) From: Prashant Malani To: enric.balletbo@collabora.com, groeck@chromium.org, bleung@chromium.org, lee.jones@linaro.org, sre@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Jon Flatley , Prashant Malani Subject: [PATCH v6 3/3] power: supply: cros-ec-usbpd-charger: Fix host events Date: Tue, 14 Jan 2020 15:22:22 -0800 Message-Id: <20200114232219.93171-3-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200114232219.93171-1-pmalani@chromium.org> References: <20200114232219.93171-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jon Flatley There's a bug on ACPI platforms where host events from the ECPD ACPI device never make their way to the cros-ec-usbpd-charger driver. This makes it so the only time the charger driver updates its state is when user space accesses its sysfs attributes. Now that these events have been unified into a single notifier chain on both ACPI and non-ACPI platforms, update the charger driver to use this new notifier. Signed-off-by: Jon Flatley Signed-off-by: Prashant Malani --- Changes in v6(pmalani@chromium.org): - Patch first introduced into the series in v6. drivers/power/supply/Kconfig | 2 +- drivers/power/supply/cros_usbpd-charger.c | 50 ++++++++--------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 27164a1d3c7c4..ba74ddd793c3d 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -659,7 +659,7 @@ config CHARGER_RT9455 config CHARGER_CROS_USBPD tristate "ChromeOS EC based USBPD charger" - depends on CROS_EC + depends on CROS_USBPD_NOTIFY default n help Say Y here to enable ChromeOS EC based USBPD charger diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c index 6cc7c3910e098..7f7e051262170 100644 --- a/drivers/power/supply/cros_usbpd-charger.c +++ b/drivers/power/supply/cros_usbpd-charger.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -524,32 +525,21 @@ static int cros_usbpd_charger_property_is_writeable(struct power_supply *psy, } static int cros_usbpd_charger_ec_event(struct notifier_block *nb, - unsigned long queued_during_suspend, + unsigned long host_event, void *_notify) { - struct cros_ec_device *ec_device; - struct charger_data *charger; - u32 host_event; + struct charger_data *charger = container_of(nb, struct charger_data, + notifier); - charger = container_of(nb, struct charger_data, notifier); - ec_device = charger->ec_device; - - host_event = cros_ec_get_host_event(ec_device); - if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { - cros_usbpd_charger_power_changed(charger->ports[0]->psy); - return NOTIFY_OK; - } else { - return NOTIFY_DONE; - } + cros_usbpd_charger_power_changed(charger->ports[0]->psy); + return NOTIFY_OK; } static void cros_usbpd_charger_unregister_notifier(void *data) { struct charger_data *charger = data; - struct cros_ec_device *ec_device = charger->ec_device; - blocking_notifier_chain_unregister(&ec_device->event_notifier, - &charger->notifier); + cros_usbpd_unregister_notify(&charger->notifier); } static int cros_usbpd_charger_probe(struct platform_device *pd) @@ -683,21 +673,17 @@ static int cros_usbpd_charger_probe(struct platform_device *pd) goto fail; } - if (ec_device->mkbp_event_supported) { - /* Get PD events from the EC */ - charger->notifier.notifier_call = cros_usbpd_charger_ec_event; - ret = blocking_notifier_chain_register( - &ec_device->event_notifier, - &charger->notifier); - if (ret < 0) { - dev_warn(dev, "failed to register notifier\n"); - } else { - ret = devm_add_action_or_reset(dev, - cros_usbpd_charger_unregister_notifier, - charger); - if (ret < 0) - goto fail; - } + /* Get PD events from the EC */ + charger->notifier.notifier_call = cros_usbpd_charger_ec_event; + ret = cros_usbpd_register_notify(&charger->notifier); + if (ret < 0) { + dev_warn(dev, "failed to register notifier\n"); + } else { + ret = devm_add_action_or_reset(dev, + cros_usbpd_charger_unregister_notifier, + charger); + if (ret < 0) + goto fail; } return 0; -- 2.25.0.341.g760bfbb309-goog