summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-04-30 09:07:10 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-11 21:20:29 +0000
commit4a46ad60f03301f0184df4a0f977b02cfeb3a1f7 (patch)
tree8a69e9960bc058a88a0dfb8725d76108a62c645b /driver
parentfae894230df4f0e34dc4f13c587ee4d721dfa812 (diff)
downloadchrome-ec-4a46ad60f03301f0184df4a0f977b02cfeb3a1f7.tar.gz
PCHG: Handle WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DOCKED
We'll extend the period for a stylus to be statically charged so that EEPROM corruption can be avoided by not entering negotiated mode with a depleted battery. During this static charge period, the user currently doesn't see any charging indication. To prevent users from removing a stylus, we'll add a new state 'device docked' to ctn730. The EC firmware is updated to handle this new state as follows: - PCHG_STATE_DETECTED will be reused to indicate a device is in proximity but not ready for communication. - PCHG_STATE_CONNECTED will be added to indicate a device is ready for digital communication. This is formerly called DETECTED. - CTN730 driver produces PCHG_EVENT_DETECTED on 'docked' event and PCHG_EVENT_CONNECTED on 'detected' event. - When DEVICE_UNDOCKED is received in PCHG_STATE_DETECTED, transition to PCHG_STATE_ENABLED. BUG=b:189323070, b:173235954 BRANCH=trogdor TEST=Verify unpowered listener board can be detected. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7fa83f6dd31cf74eab7c158e557ddc09f8976798 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2920628 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/nfc/ctn730.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c
index b3da1bbb79..1fe5a48b1b 100644
--- a/driver/nfc/ctn730.c
+++ b/driver/nfc/ctn730.c
@@ -98,6 +98,8 @@ static const int _detection_interval_ms = 500;
#define WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DEACTIVATED 0x01
#define WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DEVICE_LOST 0x02
#define WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DEVICE_BAD_VERSION 0x03
+#define WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DOCKED 0x04
+#define WLC_CHG_CTRL_DEVICE_STATE_DEVICE_UNDOCKED 0x05
#define WLC_CHG_CTRL_DEVICE_STATE_EVT_SIZE_DETECTED 8
#define WLC_CHG_CTRL_DEVICE_STATE_EVT_SIZE 1
@@ -502,12 +504,18 @@ static int _process_payload_event(struct pchg *ctx, struct ctn730_msg *res)
break;
case WLC_CHG_CTRL_DEVICE_STATE:
switch (buf[0]) {
+ case WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DOCKED:
+ if (len != WLC_CHG_CTRL_DEVICE_STATE_EVT_SIZE)
+ return EC_ERROR_INVAL;
+ ctx->event = PCHG_EVENT_DEVICE_DETECTED;
+ break;
case WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DETECTED:
if (len != WLC_CHG_CTRL_DEVICE_STATE_EVT_SIZE_DETECTED)
return EC_ERROR_INVAL;
- ctx->event = PCHG_EVENT_DEVICE_DETECTED;
+ ctx->event = PCHG_EVENT_DEVICE_CONNECTED;
break;
case WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DEVICE_LOST:
+ case WLC_CHG_CTRL_DEVICE_STATE_DEVICE_UNDOCKED:
if (len != WLC_CHG_CTRL_DEVICE_STATE_EVT_SIZE)
return EC_ERROR_INVAL;
ctx->event = PCHG_EVENT_DEVICE_LOST;