summaryrefslogtreecommitdiff
path: root/include/charger_profile_override.h
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2016-12-14 10:58:32 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-02 14:04:12 -0800
commit63ca2d693f39bdf8cad3f92234f4c757df20e87d (patch)
tree1bc47795ed25d303e82be603d400a493e38a2c0b /include/charger_profile_override.h
parentfd498b77c5adb8ac4b17770b99797ab6ce90d0d7 (diff)
downloadchrome-ec-63ca2d693f39bdf8cad3f92234f4c757df20e87d.tar.gz
charger_profile: Add common code for charger profile override
Added common code for charger profile override for fast charging. Fast charging configs can be defined in the respective board battery file and use the common code for imposing the custom data. BUG=chrome-os-partner:59393 BRANCH=none TEST=Enabled the config on Reef. Manually overrode the temperature and voltage. Observed correct charge profile config is selected for each tests. Change-Id: I075d271258470b98d38e4d5395d749469d3fd469 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/407928 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'include/charger_profile_override.h')
-rw-r--r--include/charger_profile_override.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/include/charger_profile_override.h b/include/charger_profile_override.h
new file mode 100644
index 0000000000..ba2ef09a4e
--- /dev/null
+++ b/include/charger_profile_override.h
@@ -0,0 +1,92 @@
+/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Charger profile override for fast charging
+ */
+
+#ifndef __CROS_EC_CHARGER_PROFILE_OVERRIDE_H
+#define __CROS_EC_CHARGER_PROFILE_OVERRIDE_H
+
+#include "charge_state_v2.h"
+
+#define TEMPC_TENTHS_OF_DEG(c) ((c) * 10)
+
+#define CHARGER_PROF_TEMP_C_LAST_RANGE 0xFFFF
+
+enum fast_chg_voltage_ranges {
+ VOLTAGE_RANGE_LOW,
+ VOLTAGE_RANGE_HIGH,
+ VOLTAGE_RANGE_NUM,
+};
+
+/* Charge profile override info */
+struct fast_charge_profile {
+ /* temperature in 10ths of a degree C */
+ int temp_c;
+ /* charge current at lower & higher battery voltage limit in mA */
+ int current_mA[VOLTAGE_RANGE_NUM];
+};
+
+/* Charge profile override parameters */
+struct fast_charge_params {
+ /* Total temperature ranges of the charge profile */
+ const int total_temp_ranges;
+ /* Default temperature range of the charge profile */
+ const int default_temp_range_profile;
+ /*
+ * Lower limit of battery voltage in mV
+ * If the battery voltage reading is bad or the battery voltage is
+ * greater than or equal to the lower limit or the battery voltage is
+ * not in the charger profile voltage range, consider battery has high
+ * voltage range so that we charge at lower current limit.
+ */
+ const int vtg_low_limit_mV;
+ const struct fast_charge_profile *chg_profile_info;
+};
+
+/**
+ * Optional customization of charger profile override for fast charging.
+ *
+ * On input, the struct reflects the default behavior. The function can make
+ * changes to the state, requested_voltage, or requested_current.
+ *
+ * @param curr Charge state machine data.
+ *
+ * @return
+ * >0 Desired time in usec for this poll period.
+ * 0 Use the default poll period (which varies with the state).
+ * <0 An error occurred. The poll time will be shorter than usual.
+ * Too many errors in a row may trigger some corrective action.
+ */
+int charger_profile_override(struct charge_state_data *curr);
+
+/**
+ * Common code of charger profile override for fast charging.
+ *
+ * @param curr Charge state machine data.
+ * @param fast_chg_params Fast charge profile parameters.
+ * @param prev_chg_prof_info Previous charge profile info.
+ * @param batt_vtg_max Maximum battery voltage.
+ *
+ * @return
+ * >0 Desired time in usec for this poll period.
+ * 0 Use the default poll period (which varies with the state).
+ * <0 An error occurred. The poll time will be shorter than usual.
+ * Too many errors in a row may trigger some corrective action.
+ */
+int charger_profile_override_common(struct charge_state_data *curr,
+ const struct fast_charge_params *fast_chg_params,
+ const struct fast_charge_profile **prev_chg_prof_info,
+ int batt_vtg_max);
+
+/*
+ * Access to custom profile params through host commands.
+ * What this does is up to the implementation.
+ */
+enum ec_status charger_profile_override_get_param(uint32_t param,
+ uint32_t *value);
+enum ec_status charger_profile_override_set_param(uint32_t param,
+ uint32_t value);
+
+#endif /* __CROS_EC_CHARGER_PROFILE_OVERRIDE_H */