summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Parent <fparent@baylibre.com>2018-05-05 13:59:00 +0200
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-05-29 14:54:03 +0000
commit787ec2236a8e295f7627ec9fbb75c5d07154f102 (patch)
tree6ca89fa887c90f2bb346a2917e5b093b607c585c
parentba63740c410f4e31ee65ccbe3724da864da0e93a (diff)
downloadchrome-ec-787ec2236a8e295f7627ec9fbb75c5d07154f102.tar.gz
charge_manager: add host cmd to get port count
The kernel is only able to know the number of USB PD port through EC_CMD_USB_PD_PORTS, but the kernel needs also to be able to know that there is a dedicated port. Add a host command that will return the total number of charge port (USB PD + BJ). BRANCH=None BUG=chromium:841944 TEST=Called command from kernel driver and checked that the port count was the expected value. Change-Id: I6ccd8a2dee35bbe8bb66dfbe09d1cc09c54b73a0 Signed-off-by: Fabien Parent <fparent@baylibre.com> Reviewed-on: https://chromium-review.googlesource.com/1046593 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit 7034d8b711398d5627fab5fe787fc33e24d76c48) Reviewed-on: https://chromium-review.googlesource.com/1072288 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/charge_manager.c13
-rw-r--r--include/ec_commands.h11
2 files changed, 24 insertions, 0 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c
index e4f54b58c4..dfaab4fe18 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -1091,6 +1091,19 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_POWER_INFO,
EC_VER_MASK(0));
#endif /* TEST_BUILD */
+static int hc_charge_port_count(struct host_cmd_handler_args *args)
+{
+ struct ec_response_charge_port_count *resp = args->response;
+
+ args->response_size = sizeof(*resp);
+ resp->port_count = CHARGE_PORT_COUNT;
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_CHARGE_PORT_COUNT,
+ hc_charge_port_count,
+ EC_VER_MASK(0));
+
static int hc_charge_port_override(struct host_cmd_handler_args *args)
{
const struct ec_params_charge_port_override *p = args->params;
diff --git a/include/ec_commands.h b/include/ec_commands.h
index c7a2d76230..022a3c82df 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4310,6 +4310,17 @@ struct __ec_align4 ec_response_usb_pd_power_info {
uint32_t max_power;
};
+
+/*
+ * This command will return the number of USB PD charge port + the number
+ * of dedicated port present.
+ * EC_CMD_USB_PD_PORTS does NOT include the dedicated ports
+ */
+#define EC_CMD_CHARGE_PORT_COUNT 0x0105
+struct __ec_align1 ec_response_charge_port_count {
+ uint8_t port_count;
+};
+
/* Write USB-PD device FW */
#define EC_CMD_USB_PD_FW_UPDATE 0x0110