summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2022-01-26 10:04:10 -0800
committerSebastian Reichel <sre@kernel.org>2022-02-13 22:20:12 +0100
commit845301001308aab8fb7902548f6c3256d28b8c48 (patch)
treeade9acb160a4230acb5318e9f4cd9160f8d8ef3c /drivers/power
parent21ad180d0fdfb2ab6df0f19c7dedce829a9ed1ed (diff)
downloadlinux-845301001308aab8fb7902548f6c3256d28b8c48.tar.bz2
power: supply: PCHG: Use MKBP for device event handling
This change makes the PCHG driver receive device events through MKBP protocol since CrOS EC switched to deliver all peripheral charge events to the MKBP protocol. This will unify PCHG event handling on X86 and ARM. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/cros_peripheral_charger.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/drivers/power/supply/cros_peripheral_charger.c b/drivers/power/supply/cros_peripheral_charger.c
index 305f10dfc06d..9fe6d826148d 100644
--- a/drivers/power/supply/cros_peripheral_charger.c
+++ b/drivers/power/supply/cros_peripheral_charger.c
@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include <linux/stringify.h>
#include <linux/types.h>
+#include <asm/unaligned.h>
#define DRV_NAME "cros-ec-pchg"
#define PCHG_DIR_PREFIX "peripheral"
@@ -237,46 +238,22 @@ static int cros_pchg_event(const struct charger_data *charger,
return NOTIFY_OK;
}
-static u32 cros_get_device_event(const struct charger_data *charger)
-{
- struct ec_params_device_event req;
- struct ec_response_device_event rsp;
- struct device *dev = charger->dev;
- int ret;
-
- req.param = EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS;
- ret = cros_pchg_ec_command(charger, 0, EC_CMD_DEVICE_EVENT,
- &req, sizeof(req), &rsp, sizeof(rsp));
- if (ret < 0) {
- dev_warn(dev, "Unable to get device events (err:%d)\n", ret);
- return 0;
- }
-
- return rsp.event_mask;
-}
-
static int cros_ec_notify(struct notifier_block *nb,
unsigned long queued_during_suspend,
void *data)
{
- struct cros_ec_device *ec_dev = (struct cros_ec_device *)data;
- u32 host_event = cros_ec_get_host_event(ec_dev);
+ struct cros_ec_device *ec_dev = data;
struct charger_data *charger =
container_of(nb, struct charger_data, notifier);
- u32 device_event_mask;
+ u32 host_event;
- if (!host_event)
+ if (ec_dev->event_data.event_type != EC_MKBP_EVENT_PCHG ||
+ ec_dev->event_size != sizeof(host_event))
return NOTIFY_DONE;
- if (!(host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_DEVICE)))
- return NOTIFY_DONE;
+ host_event = get_unaligned_le32(&ec_dev->event_data.data.host_event);
- /*
- * todo: Retrieve device event mask in common place
- * (e.g. cros_ec_proto.c).
- */
- device_event_mask = cros_get_device_event(charger);
- if (!(device_event_mask & EC_DEVICE_EVENT_MASK(EC_DEVICE_EVENT_WLC)))
+ if (!(host_event & EC_MKBP_PCHG_DEVICE_EVENT))
return NOTIFY_DONE;
return cros_pchg_event(charger, host_event);