summaryrefslogtreecommitdiff
path: root/common/battery_link.c
diff options
context:
space:
mode:
authorRong Chang <rongchang@chromium.org>2012-07-12 14:13:39 +0800
committerGerrit <chrome-bot@google.com>2012-07-12 02:09:45 -0700
commit54d14bf3fac5237e8c3b059c7019d6c7f88ee168 (patch)
tree881d459a9445d05cf9ba2ab058bf3df48a3b75d5 /common/battery_link.c
parent740ba3f576ffbf0e29a3db8faf33d1b936d567d4 (diff)
downloadchrome-ec-54d14bf3fac5237e8c3b059c7019d6c7f88ee168.tar.gz
Rename battery pack file and limit trickle charging current
The spec of link internal battery pack changed. This CL adds parameter for new pack, and renames vendor specific source file accordingly. The new trickle charging current limit should fix the slow pre-charging issue. Signed-off-by: Rong Chang <rongchang@chromium.org> BUG=chrome-os-partner:11298,10201 TEST=manual The minimum trickle charging current should be very close to 0.01 C (85mA). Previous battery pack firmware uses 5mA in pre- charging. Change-Id: I0bad679db7dd087894297e6eb0e85c9b12fdf444 Reviewed-on: https://gerrit.chromium.org/gerrit/27256 Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Ready: Rong Chang <rongchang@chromium.org> Tested-by: Rong Chang <rongchang@chromium.org>
Diffstat (limited to 'common/battery_link.c')
-rw-r--r--common/battery_link.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/common/battery_link.c b/common/battery_link.c
new file mode 100644
index 0000000000..74e7944684
--- /dev/null
+++ b/common/battery_link.c
@@ -0,0 +1,126 @@
+/* Copyright (c) 2012 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.
+ *
+ * Battery pack vendor provided charging profile
+ */
+
+#include "battery_pack.h"
+
+/* Design capacity
+ * Battery capacity = 8500 mAh
+ * 1C = 8500 mA
+ */
+#define C 8500
+#define C_001 (int)(C * 0.01)
+#define C_01 (int)(C * 0.1)
+#define C_02 (int)(C * 0.2)
+#define C_05 (int)(C * 0.5)
+#define C_07 (int)(C * 0.7)
+
+static const struct battery_info info = {
+ /* Designed voltage
+ * max = 8.4V
+ * normal = 7.4V
+ * min = 6.0V
+ */
+ .voltage_max = 8400,
+ .voltage_normal = 7400,
+ .voltage_min = 6000,
+
+ /* Operation temperation range
+ * 0 <= T_charge <= 45 deg C
+ * -20 <= T_discharge <= 60 deg C
+ *
+ * The temperature values below should be deci-Kelvin
+ */
+ .temp_charge_min = 0 * 10 + 2731,
+ .temp_charge_max = 45 * 10 + 2731,
+ .temp_discharge_min = -20 * 10 + 2731,
+ .temp_discharge_max = 60 * 10 + 2731,
+
+ /* Maximum discharging current
+ * TODO(rong): Check if we need this in power manager
+ *
+ * 1.0C
+ * 25 <= T_maxdischarge <= 45
+ *
+ * .current_discharge_max = C,
+ * .temp_maxdisch_max = 45,
+ * .temp_maxdisch_min = 25
+ *
+ */
+
+ /* Pre-charge voltage and current
+ * I <= 0.01C
+ */
+ .precharge_current = C_001,
+};
+
+/* Convert Celsius degree to Deci Kelvin degree */
+static inline int celsius_to_deci_kelvin(int degree_c)
+{
+ return degree_c * 10 + 2731;
+}
+
+static inline void limit_value(int *val, int limit)
+{
+ if (*val > limit)
+ *val = limit;
+}
+
+const struct battery_info *battery_get_info(void)
+{
+ return &info;
+}
+
+/* Vendor provided parameters for battery charging */
+void battery_vendor_params(struct batt_params *batt)
+{
+ int *desired_current = &batt->desired_current;
+
+ /* Hard limits
+ * - charging voltage < 8.4V
+ * - charging temperature range 0 ~ 45 degree Celcius
+ * */
+ if (batt->desired_voltage > info.voltage_max)
+ batt->desired_voltage = info.voltage_max;
+ if (batt->temperature >= info.temp_charge_max ||
+ batt->temperature <= info.temp_charge_min) {
+ batt->desired_voltage = 0;
+ batt->desired_current = 0;
+ return;
+ }
+
+ /* Vendor provided charging method
+ * temp : I - V , I - V
+ * - 0 ~ 10 : 0.2C - 8.0V, 0.1C to 8.4V
+ * - 10 ~ 23 : 0.5C - 8.0V, 0.2C to 8.4V
+ * - 23 ~ 45 : 0.7C - 8.0V, 0.2C to 8.4V
+ */
+ if (batt->temperature <= celsius_to_deci_kelvin(10)) {
+ if (batt->voltage < 8000)
+ limit_value(desired_current, C_02);
+ else
+ limit_value(desired_current, C_01);
+ } else if (batt->temperature <= celsius_to_deci_kelvin(23)) {
+ if (batt->voltage < 8000)
+ limit_value(desired_current, C_05);
+ else
+ limit_value(desired_current, C_02);
+ } else {
+ if (batt->voltage < 8000)
+ limit_value(desired_current, C_07);
+ else
+ limit_value(desired_current, C_02);
+ }
+
+#ifndef CONFIG_SLOW_PRECHARGE
+ /* Trickle charging and pre-charging current should be 0.01 C */
+ if (*desired_current < info.precharge_current)
+ *desired_current = info.precharge_current;
+#endif /* CONFIG_SLOW_PRECHARGE */
+
+}
+
+