summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2017-09-08 12:05:33 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-26 13:25:38 -0800
commite5c6f97d1a4a1fa5ad17c2bab4e316a47b8def9a (patch)
tree88986d177cc58fd4c4f039cca41bc532ccb1a418 /include
parentecfa69663813ec41aa79ed01c4af2f36723fe194 (diff)
downloadchrome-ec-e5c6f97d1a4a1fa5ad17c2bab4e316a47b8def9a.tar.gz
charge_state_v2: Basic dual-battery charging algorithm
First version of the algorithm, some TODOs are left in the code but this, generally, works reasonably well. When charging, we allocate input current in this general order: - Base system (fixed, low, number) - Lid system (based on PSYS) - Lid battery (estimating how much current the battery actually requires) - Base battery (similar estimation) - Provide everything else to lid When discharging, we generally: - First discharge the base battery - Then discharge the lid battery BRANCH=none BUG=b:71881017 TEST=Flash lux and wand, EC-EC communication works, adapter power is split in a sensible way, and discharging works fine. Change-Id: I8a4f87963962fc5466b2fedf1347eb4dadd35740 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/659460 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/charge_state_v2.h15
-rw-r--r--include/ec_commands.h2
2 files changed, 16 insertions, 1 deletions
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index f9f5d39edf..3fc9a94181 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -6,6 +6,7 @@
#include "battery.h"
#include "battery_smart.h"
#include "charger.h"
+#include "ec_ec_comm_master.h"
#include "timer.h"
#ifndef __CROS_EC_CHARGE_STATE_V2_H
@@ -41,6 +42,9 @@ struct charge_state_data {
#ifdef CONFIG_CHARGER_OTG
int output_current;
#endif
+#ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER
+ int input_voltage;
+#endif
};
/**
@@ -74,5 +78,16 @@ int charge_set_input_current_limit(int ma, int mv);
int charge_get_charge_state_debug(int param, uint32_t *value);
#endif /* CONFIG_CHARGE_STATE_DEBUG */
+/**
+ * Board-specific routine to indicate if the base is connected.
+ */
+int board_is_base_connected(void);
+
+/**
+ * Board-specific routine to enable power distribution between lid and base
+ * (current can flow both ways).
+ */
+void board_enable_base_power(int enable);
+
#endif /* __CROS_EC_CHARGE_STATE_V2_H */
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 10ac439215..00c6dad089 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -163,7 +163,7 @@
#define EC_BATT_FLAG_DISCHARGING 0x04
#define EC_BATT_FLAG_CHARGING 0x08
#define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
-/* Set if some of the dynamic data is invalid (or outdated). */
+/* Set if some of the static/dynamic data is invalid (or outdated). */
#define EC_BATT_FLAG_INVALID_DATA 0x20
/* Switch flags at EC_MEMMAP_SWITCHES */