diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2022-12-09 09:36:14 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-16 22:19:17 +0000 |
commit | 7554aa4591ce85be86c2094364bf8799d2660b12 (patch) | |
tree | 6a06e6f914d82b39f0cc063062205d2355489480 | |
parent | 67d86e1de04c13ef9fb2009c7e22ff15d249dbac (diff) | |
download | chrome-ec-7554aa4591ce85be86c2094364bf8799d2660b12.tar.gz |
CTN730: Add RF charge
This patch adds RF charge in CTN730.
BUG=b:245764044
TEST=Redrix
BRANCH=None
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: If8d90d8679c43e5f6c2490e32c949fb9dc82f527
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4090562
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | driver/nfc/ctn730.c | 40 | ||||
-rw-r--r-- | driver/nfc/ctn730.h | 3 |
2 files changed, 40 insertions, 3 deletions
diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c index c19b440824..c8fa1fbdc2 100644 --- a/driver/nfc/ctn730.c +++ b/driver/nfc/ctn730.c @@ -319,6 +319,16 @@ static int _process_payload_response(struct pchg *ctx, struct ctn730_msg *res) ctx->event = PCHG_EVENT_UPDATE_WRITTEN; } break; + case WLC_HOST_CTRL_BIST: + if (len != WLC_HOST_CTRL_BIST_CMD_SIZE) + return EC_ERROR_UNKNOWN; + if (buf[0] != WLC_HOST_STATUS_OK) { + CPRINTS("BIST command failed for %s", + _text_status_code(buf[0])); + ctx->event = PCHG_EVENT_ERROR; + ctx->error |= PCHG_ERROR_MASK(PCHG_ERROR_RESPONSE); + } + break; case WLC_CHG_CTRL_ENABLE: if (len != WLC_CHG_CTRL_ENABLE_RSP_SIZE) return EC_ERROR_UNKNOWN; @@ -348,9 +358,6 @@ static int _process_payload_response(struct pchg *ctx, struct ctn730_msg *res) ctx->event = PCHG_EVENT_CHARGE_UPDATE; } break; - case WLC_HOST_CTRL_BIST: - CPRINTS("Received BIST response"); - break; default: CPRINTS("Received unknown response (%d)", res->instruction); break; @@ -618,6 +625,32 @@ static int ctn730_passthru(struct pchg *ctx, bool enable) return EC_SUCCESS; } +static int ctn730_bist(struct pchg *ctx, uint8_t test_id) +{ + uint8_t buf[sizeof(struct ctn730_msg) + WLC_HOST_CTRL_BIST_CMD_SIZE]; + struct ctn730_msg *cmd = (void *)buf; + uint8_t *id = cmd->payload; + int rv; + + cmd->message_type = CTN730_MESSAGE_TYPE_COMMAND; + cmd->instruction = WLC_HOST_CTRL_BIST; + *id = test_id; + + switch (test_id) { + case PCHG_BIST_CMD_RF_CHARGE_ON: + cmd->length = 1; + break; + default: + return EC_ERROR_UNIMPLEMENTED; + } + + rv = _send_command(ctx, cmd); + if (rv) + return rv; + + return EC_SUCCESS_IN_PROGRESS; +} + /** * Send command in blocking loop * @@ -690,6 +723,7 @@ const struct pchg_drv ctn730_drv = { .update_write = ctn730_update_write, .update_close = ctn730_update_close, .passthru = ctn730_passthru, + .bist = ctn730_bist, }; static int cc_ctn730(int argc, const char **argv) diff --git a/driver/nfc/ctn730.h b/driver/nfc/ctn730.h index e1ae7ab754..80a7f134d8 100644 --- a/driver/nfc/ctn730.h +++ b/driver/nfc/ctn730.h @@ -59,6 +59,9 @@ #define WLC_HOST_CTRL_DL_COMMIT_SESSION_CMD_SIZE 4 #define WLC_HOST_CTRL_DL_COMMIT_SESSION_RSP_SIZE 1 +/* WLC_HOST_CTRL_BIST constants */ +#define WLC_HOST_CTRL_BIST_CMD_SIZE 1 + /* WLC_CHG_CTRL_ENABLE constants */ #define WLC_CHG_CTRL_ENABLE_CMD_SIZE 2 #define WLC_CHG_CTRL_ENABLE_RSP_SIZE 1 |