summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-03-09 09:05:39 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-26 00:27:57 +0000
commitf7e2b7ec38b416ce5965521ac2984b97ab38ecc1 (patch)
treecac85cba31f0d1a4eb2899a1e1d581135449c6b1
parent71f8dd80c9380a839365dc82ac5ed4ce87e116b4 (diff)
downloadchrome-ec-release-R90-13816.B-main.tar.gz
This patch makes ctn730 driver print the firmware version. EC_CMD_PCHG is updated to version 1 and returns firmware version of a charger chip. Version 0 of EC_CMD_PCHG is deprecated. BUG=b:182600604, b:173235954, b:183151376 BRANCH=Trogdor TEST=Verify firmware version is printed on EC console. TEST=ectool pchg 0 (for version 1) TEST=cat /sys/class/power_supply/PCHG0/* (for version 0) "ERR kernel: [ 33.394847] cros-ec-pchg cros-ec-pchg.13.auto: Unable to get port.0 status (err:-524)" Cq-Depend: chromium:2786072 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib7bb9a7225fe914bc6c8d600d0f4766dbf75ace8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757098 (cherry picked from commit 774ff171f1ff84e7f3daa2f367b9563e00656488) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2787469
-rw-r--r--common/peripheral_charger.c12
-rw-r--r--driver/nfc/ctn730.c1
-rw-r--r--include/ec_commands.h5
-rw-r--r--include/peripheral_charger.h2
-rw-r--r--util/ectool.c8
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;
}