From: Jon Flatley <jflat@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: bleung@chromium.org, groeck@chromium.org, sre@kernel.org,
jflat@chromium.org
Subject: [PATCH 2/3] power: supply: cros-ec-usbpd-charger: Fix host events
Date: Tue, 12 Nov 2019 19:10:43 -0800 [thread overview]
Message-ID: <20191113031044.136232-3-jflat@chromium.org> (raw)
In-Reply-To: <20191113031044.136232-1-jflat@chromium.org>
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 the charger driver can just be updated
to use this new notifer.
Signed-off-by: Jon Flatley <jflat@chromium.org>
---
drivers/power/supply/Kconfig | 2 +-
drivers/power/supply/cros_usbpd-charger.c | 45 ++++++++---------------
2 files changed, 17 insertions(+), 30 deletions(-)
diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index c84a7b1caeb6..7664849d7680 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_EC_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 6cc7c3910e09..58cf51b51179 100644
--- a/drivers/power/supply/cros_usbpd-charger.c
+++ b/drivers/power/supply/cros_usbpd-charger.c
@@ -8,6 +8,7 @@
#include <linux/mfd/cros_ec.h>
#include <linux/module.h>
#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_usbpd_notify.h>
#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
@@ -524,32 +525,22 @@ 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;
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_ec_usbpd_unregister_notify(&charger->notifier);
}
static int cros_usbpd_charger_probe(struct platform_device *pd)
@@ -683,21 +674,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_ec_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.24.0.432.g9d3f5f5b63-goog
next prev parent reply other threads:[~2019-11-13 3:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-13 3:10 [PATCH 0/3] ChromeOS EC USB-C Connector Class Jon Flatley
2019-11-13 3:10 ` [PATCH 1/3] platform: chrome: Add cros-ec-usbpd-notify driver Jon Flatley
2019-11-14 21:43 ` Enric Balletbo Serra
2019-11-13 3:10 ` Jon Flatley [this message]
2019-11-14 21:53 ` [PATCH 2/3] power: supply: cros-ec-usbpd-charger: Fix host events Enric Balletbo Serra
2019-11-13 3:10 ` [PATCH 3/3] platform: chrome: Added cros-ec-typec driver Jon Flatley
2019-11-13 12:55 ` kbuild test robot
2019-11-13 17:23 ` Jon Flatley
2019-11-14 0:55 ` [kbuild-all] " Rong Chen
2019-11-14 1:07 ` Guenter Roeck
2019-11-14 16:53 ` Heikki Krogerus
2019-11-13 17:51 ` [PATCH 0/3] ChromeOS EC USB-C Connector Class Benson Leung
2019-11-13 18:25 ` Heikki Krogerus
2019-11-14 1:09 ` Jon Flatley
2019-11-14 15:24 ` Heikki Krogerus
2019-11-14 21:00 ` Jon Flatley
2019-11-15 16:41 ` Heikki Krogerus
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=20191113031044.136232-3-jflat@chromium.org \
--to=jflat@chromium.org \
--cc=bleung@chromium.org \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sre@kernel.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