summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-02-01 15:48:48 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-03 08:21:36 +0000
commitfd9dd63e5c9cb76692501280dcb09a31f3154b12 (patch)
treec64234a6d43b0d6c47b641eb8eb0c551dff49ef6 /include
parent0cfc6a087f103dfa1a03d5e6671844ddd4ac8c14 (diff)
downloadchrome-ec-fd9dd63e5c9cb76692501280dcb09a31f3154b12.tar.gz
samus: automatically recover from charge circuit failuresstabilize-6752.B
Occasionally the charge circuit on samus gets wedged and will not charge. This change detects when the charge circuit has failed and automatically recovers from it. It uses the BQ PROCHOT warning to detect the failure by setting PROCHOT to trigger when the BQ thinks input current is higher than the input current limit. When the failure is detected, the EC disables charging and tells PD MCU to disable CHARGE_EN, then a couple seconds later, it re-enables charging. This CL also adds more communication between EC and PD for the EC to be able to set the charge state for the PD. Valid charge states are: No charging allowed, 5V charging only, and max charging. The EC uses this as such: - When the EC gets AC present interrupt, it sets off a deferred function to change charge state to max charging after some delay to give time for the charge circuit to settle down. - When the EC gets AC disconnect interrupt, it disables charging briefly, enables learn mode, and then sets 5V charging allowed. This allows for the same starting conditions in the charge circuit for every AC attach. - When the EC detects a wedged charge circuit, it disables charging and waits a few seconds before re-enabling 5V only charging. Additionally, this change moves the charging cutoff in S3/S5/G3 when the battery is full to the EC. With the added control for the EC to set the PD charging state, it is more convenient for the EC to manage cutting off charging when battery is full. BUG=chrome-os-partner:36081 BRANCH=samus TEST=test the basics: - connect/disconnect zinger a bunch of times - connect and disconnect two zingers in different order - connect two zingers and charge override between the two test the automatic charge wedge recover: - wedge the charge circuit by setting charger voltage under battery voltage: "charger voltage 7000" - wait a few seconds for the system to recover and check it is charging with "battery" command test full battery charge cutoff: - added console command to change battery soc in board/samus/extpower.c: static int cmd_battfake(int argc, char **argv) { char *e; battery_soc = strtoi(argv[1], &e, 10); batt_soc_change(); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(battfake, cmd_battfake, "", "", NULL); - in S0, tested "battfake 100" does not disable charging. - in G3, tested "battfake 100" disables charging and "battfake 99" re-enables charging. - set "battfake 100" and tested transitioning to S0 enables charging and transitioning to S5 disables charging. - attached two chargers and used charge override to select active port. then toggled "battfake 100" to "battfake 99" back and forth and verified charge override port is still the same. test third-party 12V charger: - plug in a bunch of times and make sure we stay at 5V for 500ms and then transition to 12V test with no battery: - tested five different units with no battery and just zinger. 3/5 boot, while the other 2 don't. But, the 2 that don't boot without battery also can't boot w/o battery when this CL is reverted, so I don't think this change is causing the problem, I think there is an electrical limitation. test with EVT zinger: - EVT zingers (P2 - C2) negotiate very quickly after connection, which can cause INA problems w/o this CL. Tested an EVT zinger with samus and did a bunch of connections and disconnections and verified that we always wait at 5V for 500ms and that we don't wedge the INA circuit on connect. test backwards compatibility: - test new PD with old EC and make sure we can charge with zinger. (note that if the charge circuit wedges, we won't be able to unwedge it). - test old PD with new EC and make sure we can charge with zinger. Change-Id: I7703b7a2ab1209d7f559b265b03517e79c74b16a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245253 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/config.h15
-rw-r--r--include/ec_commands.h10
-rw-r--r--include/host_command.h4
-rw-r--r--include/usb_pd.h8
4 files changed, 29 insertions, 8 deletions
diff --git a/include/config.h b/include/config.h
index 435a8889d0..e3983eb064 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1157,18 +1157,18 @@
/* Include all USB Power Delivery modules */
#undef CONFIG_USB_POWER_DELIVERY
-/* Alternative configuration keeping only the TX part of PHY */
-#undef CONFIG_USB_PD_TX_PHY_ONLY
-
-/* Default state of PD communication enabled flag */
-#define CONFIG_USB_PD_COMM_ENABLED 1
-
/* Support for USB PD alternate mode */
#undef CONFIG_USB_PD_ALT_MODE
/* Support for USB PD alternate mode of Downward Facing Port */
#undef CONFIG_USB_PD_ALT_MODE_DFP
+/* Check if max voltage request is allowed before each request */
+#undef CONIFG_USB_PD_CHECK_MAX_REQUEST_ALLOWED
+
+/* Default state of PD communication enabled flag */
+#define CONFIG_USB_PD_COMM_ENABLED 1
+
/* Respond to custom vendor-defined messages over PD */
#undef CONFIG_USB_PD_CUSTOM_VDM
@@ -1206,6 +1206,9 @@
/* Use comparator module for PD RX interrupt */
#define CONFIG_USB_PD_RX_COMP_IRQ
+/* Alternative configuration keeping only the TX part of PHY */
+#undef CONFIG_USB_PD_TX_PHY_ONLY
+
/* Support for USB type-c superspeed mux */
#undef CONFIG_USBC_SS_MUX
diff --git a/include/ec_commands.h b/include/ec_commands.h
index f42e525c4a..304cb9acda 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -2680,9 +2680,17 @@ struct ec_params_reboot_ec {
/* EC to PD MCU exchange status command */
#define EC_CMD_PD_EXCHANGE_STATUS 0x100
+enum pd_charge_state {
+ PD_CHARGE_NO_CHANGE = 0, /* Don't change charge state */
+ PD_CHARGE_NONE, /* No charging allowed */
+ PD_CHARGE_5V, /* 5V charging only */
+ PD_CHARGE_MAX /* Charge at max voltage */
+};
+
/* Status of EC being sent to PD */
struct ec_params_pd_status {
- int8_t batt_soc; /* battery state of charge */
+ int8_t batt_soc; /* battery state of charge */
+ uint8_t charge_state; /* charging state (from enum pd_charge_state) */
} __packed;
/* Status of PD being sent back to EC */
diff --git a/include/host_command.h b/include/host_command.h
index e833b96101..4661e59dd6 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -210,8 +210,10 @@ void host_throttle_cpu(int throttle);
/**
* Signal host command task to send status to PD MCU.
+ *
+ * @new_chg_state PD MCU charge state
*/
-void host_command_pd_send_status(void);
+void host_command_pd_send_status(enum pd_charge_state new_chg_state);
/**
* Ask the PD MCU for its status, obtaining the current charge_port as a
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 543b939682..410251775f 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -759,6 +759,14 @@ int pd_build_request(int cnt, uint32_t *src_caps, uint32_t *rdo,
uint32_t *ma, uint32_t *mv, enum pd_request_type req_type);
/**
+ * Check if max voltage request is allowed (only used if
+ * CONFIG_USB_PD_CHECK_MAX_REQUEST_ALLOWED is defined).
+ *
+ * @return True if max voltage request allowed, False otherwise
+ */
+int pd_is_max_request_allowed(void);
+
+/**
* Process source capabilities packet
*
* @param port USB-C port number