summaryrefslogtreecommitdiff
path: root/driver/nfc/ctn730.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/nfc/ctn730.c')
-rw-r--r--driver/nfc/ctn730.c40
1 files changed, 37 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)