summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-06-06 10:38:24 -0700
committerChromeBot <chrome-bot@google.com>2013-06-07 10:52:14 -0700
commitcf5b6daee3ee20ae70d87b599a76ec2decc01c62 (patch)
tree507c14b5c4024a80947354bc7d8c48efd4655ed6
parent710cadde7c4112d88b078838521aabce72cf7920 (diff)
downloadchrome-ec-cf5b6daee3ee20ae70d87b599a76ec2decc01c62.tar.gz
Initial support for Slippy battery
This adds the initial support for Slippy's battery. The data I have is unclear and incomplete, so this is NOT the final form. It seems to work right now, and hasn't caught fire or anything, but it will need futher tweaks. BUG=chrome-os-partner:19976 BRANCH=none TEST=manual (and watch it!) Connect the EC console and watch what happens. You should see the battery charging, discharging, etc. Keep an eye on it, though, and never leave it unattended when on AC - we don't have the full data sheets available yet. Change-Id: Id9bf93dc04a1399a9cdbc2156b3fac74be62038f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/57814 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/slippy/board.h25
-rw-r--r--board/slippy/ec.tasklist2
-rw-r--r--common/battery_link.c2
-rw-r--r--common/battery_slippy.c52
-rw-r--r--common/build.mk1
-rw-r--r--include/battery_pack.h2
6 files changed, 76 insertions, 8 deletions
diff --git a/board/slippy/board.h b/board/slippy/board.h
index 4261d6d3d0..6b87496bdf 100644
--- a/board/slippy/board.h
+++ b/board/slippy/board.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* Configuration for Link mainboard */
+/* Configuration for Slippy mainboard */
#ifndef __BOARD_H
#define __BOARD_H
@@ -15,9 +15,10 @@
#define CONFIG_TASK_PROFILING
/* Optional features */
-/*HEY #define CONFIG_SMART_BATTERY */
-/*HEY #define CONFIG_BATTERY_LINK */
-/*HEY #define CONFIG_CHARGER_BQ24725 */
+#define CONFIG_SMART_BATTERY
+#define CONFIG_BATTERY_SLIPPY
+#define CONFIG_CHARGER
+#define CONFIG_CHARGER_BQ24707A
#ifdef HAS_TASK_CHIPSET
#define CONFIG_CHIPSET_X86_HASWELL
#endif
@@ -44,7 +45,7 @@
/* I2C ports */
#define I2C_PORT_BATTERY 0
#define I2C_PORT_CHARGER 0
-#define I2C_PORT_THERMAL 2
+#define I2C_PORT_THERMAL 5
/* There are only two I2C ports used because battery and charger share a port */
#define I2C_PORTS_USED 2
@@ -138,6 +139,19 @@ enum gpio_signal {
GPIO_COUNT
};
+/* Charger module */
+/* Set charger input current limit
+ * Note - this value should depend on external power adapter,
+ * designed charging voltage, and the maximum power of
+ * a running system.
+ * Following value 4032 mA is the maximum input limit
+ * on Link's design.
+ */
+#define CONFIG_BQ24707A_R_SNS 10 /* 10 mOhm charge sense resistor */
+#define CONFIG_BQ24707A_R_AC 10 /* 10 mOhm input current sense resistor */
+#define CONFIG_CHARGER_INPUT_CURRENT 4032 /* mA, about half max */
+
+
enum adc_channel {
/* EC internal die temperature in degrees K. */
ADC_CH_EC_TEMP = 0,
@@ -145,6 +159,7 @@ enum adc_channel {
/* HEY: Slippy MB has only one discrete thermal sensor, but it has two
* values (one internal and one external). Both should be here.
* HEY: There may be a BAT_TEMP sensor on the battery pack too.
+ * On Slippy, that's PB4/AIN10
*/
/* HEY: Be prepared to read this (ICMNT). */
diff --git a/board/slippy/ec.tasklist b/board/slippy/ec.tasklist
index fa89bc836b..091e8b340e 100644
--- a/board/slippy/ec.tasklist
+++ b/board/slippy/ec.tasklist
@@ -19,7 +19,7 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(VBOOTHASH, vboot_hash_task, NULL, LARGER_TASK_STACK_SIZE) \
- /*HEY TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) */ \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(THERMAL, thermal_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
diff --git a/common/battery_link.c b/common/battery_link.c
index b20ab45fc1..97d080d876 100644
--- a/common/battery_link.c
+++ b/common/battery_link.c
@@ -14,8 +14,6 @@
*/
#define DESIGN_CAPACITY 8200
-#define CELSIUS_TO_DECI_KELVIN(temp_c) ((temp_c) * 10 + 2731)
-
enum {
TEMP_RANGE_10,
TEMP_RANGE_23,
diff --git a/common/battery_slippy.c b/common/battery_slippy.c
new file mode 100644
index 0000000000..75c9c2d4fb
--- /dev/null
+++ b/common/battery_slippy.c
@@ -0,0 +1,52 @@
+/* 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"
+
+/* FIXME: We need REAL values for all this stuff */
+static const struct battery_info info = {
+
+ .voltage_max = 12600,
+ .voltage_normal = 11100,
+ .voltage_min = 6000,
+
+ /*
+ * Operational temperature range
+ * 0 <= T_charge <= 50 deg C
+ * -20 <= T_discharge <= 60 deg C
+ */
+ .temp_charge_min = CELSIUS_TO_DECI_KELVIN(0),
+ .temp_charge_max = CELSIUS_TO_DECI_KELVIN(50),
+ .temp_discharge_min = CELSIUS_TO_DECI_KELVIN(-20),
+ .temp_discharge_max = CELSIUS_TO_DECI_KELVIN(60),
+
+ /* Pre-charge values. */
+ .precharge_current = 256, /* mA */
+};
+
+const struct battery_info *battery_get_info(void)
+{
+ return &info;
+}
+
+/* FIXME: The smart battery should do the right thing - that's why it's
+ * called "smart". Do we really want to second-guess it? For now, let's not. */
+void battery_vendor_params(struct batt_params *batt)
+{
+#if 0
+ /* Limit charging voltage */
+ if (batt->desired_voltage > info.voltage_max)
+ batt->desired_voltage = info.voltage_max;
+
+ /* Don't charge if outside of allowable temperature range */
+ if (batt->temperature >= info.temp_charge_max ||
+ batt->temperature <= info.temp_charge_min) {
+ batt->desired_voltage = 0;
+ batt->desired_current = 0;
+ }
+#endif
+}
diff --git a/common/build.mk b/common/build.mk
index d4f4174d45..5981790e4c 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -11,6 +11,7 @@ common-y+=memory_commands.o shared_mem.o system_common.o hooks.o
common-y+=gpio_common.o version.o printf.o queue.o
common-$(CONFIG_BATTERY_BQ20Z453)+=battery_bq20z453.o
common-$(CONFIG_BATTERY_LINK)+=battery_link.o
+common-$(CONFIG_BATTERY_SLIPPY)+=battery_slippy.o
common-$(CONFIG_BATTERY_SPRING)+=battery_spring.o
common-$(CONFIG_CHARGER)+=charge_state.o battery_precharge.o charger_common.o
common-$(CONFIG_CHARGER_BQ24725)+=charger_bq24725.o
diff --git a/include/battery_pack.h b/include/battery_pack.h
index 10022ddac1..620b99e374 100644
--- a/include/battery_pack.h
+++ b/include/battery_pack.h
@@ -7,6 +7,8 @@
#ifndef __CROS_EC_BATTERY_PACK_H
#define __CROS_EC_BATTERY_PACK_H
+#define CELSIUS_TO_DECI_KELVIN(temp_c) ((temp_c) * 10 + 2731)
+
/* Battery parameters */
struct batt_params {
int temperature; /* Temperature in 0.1 K */