diff options
-rw-r--r-- | common/peripheral_charger.c | 12 | ||||
-rw-r--r-- | driver/nfc/ctn730.c | 1 | ||||
-rw-r--r-- | include/ec_commands.h | 5 | ||||
-rw-r--r-- | include/peripheral_charger.h | 2 | ||||
-rw-r--r-- | util/ectool.c | 8 |
5 files changed, 20 insertions, 8 deletions
diff --git a/common/peripheral_charger.c b/common/peripheral_charger.c index 1bf16fd4ae..1152ea8d79 100644 --- a/common/peripheral_charger.c +++ b/common/peripheral_charger.c @@ -442,12 +442,14 @@ static enum ec_status hc_pchg(struct host_cmd_handler_args *args) r->battery_percentage = ctx->battery_percent; r->error = ctx->error; + r->fw_version = ctx->fw_version; + r->dropped_event_count = ctx->dropped_event_count; args->response_size = sizeof(*r); return EC_RES_SUCCESS; } -DECLARE_HOST_COMMAND(EC_CMD_PCHG, hc_pchg, EC_VER_MASK(0)); +DECLARE_HOST_COMMAND(EC_CMD_PCHG, hc_pchg, EC_VER_MASK(1)); static int cc_pchg(int argc, char **argv) { @@ -464,11 +466,11 @@ static int cc_pchg(int argc, char **argv) ctx = &pchgs[port]; if (argc == 2) { - ccprintf("P%d STATE_%s EVENT_%s SOC=%d%%\n", port, - _text_state(ctx->state), _text_event(ctx->event), + ccprintf("P%d STATE_%s EVENT_%s SOC=%d%%\n", + port, _text_state(ctx->state), _text_event(ctx->event), ctx->battery_percent); - ccprintf("error=0x%x dropped=%u\n", - ctx->error, ctx->dropped_event_count); + ccprintf("error=0x%x dropped=%u fw_version=0x%x\n", + ctx->error, ctx->dropped_event_count, ctx->fw_version); return EC_SUCCESS; } diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c index 6efb75efb4..e7001ce45f 100644 --- a/driver/nfc/ctn730.c +++ b/driver/nfc/ctn730.c @@ -413,6 +413,7 @@ static int _process_payload_event(struct pchg *ctx, struct ctn730_msg *res) if (len != WLC_HOST_CTRL_RESET_EVT_NORMAL_MODE_SIZE) return EC_ERROR_INVAL; ctx->event = PCHG_EVENT_IN_NORMAL; + ctx->fw_version = (uint16_t)buf[1] << 8 | buf[2]; CPRINTS("Normal Mode (FW=0x%02x.%02x)", buf[1], buf[2]); /* * ctn730 isn't immediately ready for i2c write after diff --git a/include/ec_commands.h b/include/ec_commands.h index 6a73621cdd..8949077e8e 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -6799,6 +6799,11 @@ struct ec_response_pchg { uint32_t error; /* enum pchg_error */ uint8_t state; /* enum pchg_state state */ uint8_t battery_percentage; + uint8_t unused0; + uint8_t unused1; + /* Fields added in version 1 */ + uint32_t fw_version; + uint32_t dropped_event_count; } __ec_align2; enum pchg_state { diff --git a/include/peripheral_charger.h b/include/peripheral_charger.h index 2e535d4f3e..7944efd109 100644 --- a/include/peripheral_charger.h +++ b/include/peripheral_charger.h @@ -151,6 +151,8 @@ struct pchg { uint32_t dropped_event_count; /* enum pchg_mode */ uint8_t mode; + /* FW version */ + uint32_t fw_version; }; /** diff --git a/util/ectool.c b/util/ectool.c index a85166ebe7..4200f3f143 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -9389,7 +9389,7 @@ int cmd_pchg(int argc, char *argv[]) struct ec_response_pchg *r = ec_inbuf; p->port = port; - rv = ec_command(EC_CMD_PCHG, 0, ec_outbuf, sizeof(*p), + rv = ec_command(EC_CMD_PCHG, 1, ec_outbuf, sizeof(*p), ec_inbuf, ec_max_insize); if (rv < 0) { fprintf(stderr, "Error code: %d\n", rv); @@ -9400,8 +9400,10 @@ int cmd_pchg(int argc, char *argv[]) r->state < sizeof(pchg_state_text) ? pchg_state_text[r->state] : "UNDEF", r->state); - printf("Battery: %d%%\n", r->battery_percentage); - printf("Flags: 0x%x\n", r->error); + printf("Battery: %u%%\n", r->battery_percentage); + printf("Errors: 0x%x\n", r->error); + printf("FW Version: 0x%x\n", r->fw_version); + printf("Dropped events: %u\n", r->dropped_event_count); return 0; } |