summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin Lu <Devin.Lu@quantatw.com>2014-04-03 18:22:10 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-17 16:38:47 +0000
commitbb16a635394e35adea755bea67d66a5bf600d16d (patch)
treef364268332be94439c98926a9d65b1f0490b3aa1
parentccdce3f83dcdc72b08dc76faced5acca710e6f8d (diff)
downloadchrome-ec-bb16a635394e35adea755bea67d66a5bf600d16d.tar.gz
blaze: add battery configuration
Set battery cut off command and config battery configuration for blaze. BUG=chrome-os-partner:27120 BRANCH=ToT TEST=manual build ec and flash to blaze board, verify battery works. Verify battery cut off function is workable. Change-Id: I2e1f7de9c6370a2a02fb56fc4520f4bc062b4d6b Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193000 Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
-rw-r--r--board/blaze/battery.c75
1 files changed, 30 insertions, 45 deletions
diff --git a/board/blaze/battery.c b/board/blaze/battery.c
index ae93eb0edc..569822a88a 100644
--- a/board/blaze/battery.c
+++ b/board/blaze/battery.c
@@ -15,9 +15,8 @@
/* Console output macros */
#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
-/* These 2 defines are for cut_off command for 3S battery */
-#define SB_SHIP_MODE_ADDR 0x3a
-#define SB_SHIP_MODE_DATA 0xc574
+/* Shutdown mode parameter to write to manufacturer access register */
+#define SB_SHUTDOWN_DATA 0x0010
static struct battery_info *battery_info;
static int battery_cut_off;
@@ -30,37 +29,10 @@ struct battery_device {
int support_cut_off;
};
-static struct battery_info info_2s = {
- /*
- * Design voltage
- * max = 8.4V
- * normal = 7.4V
- * min = 6.0V
- */
- .voltage_max = 8400,
- .voltage_normal = 7400,
- .voltage_min = 6000,
-
- /* Pre-charge current: I <= 0.01C */
- .precharge_current = 64, /* mA */
-
- /*
- * Operational temperature range
- * 0 <= T_charge <= 50 deg C
- * -20 <= T_discharge <= 60 deg C
- */
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 50,
- .discharging_min_c = -20,
- .discharging_max_c = 60,
-};
-
static struct battery_info info_3s = {
- .voltage_max = 12600,
- .voltage_normal = 11100, /* Average of max & min */
+ .voltage_max = 13050,
+ .voltage_normal = 11400, /* Average of max & min */
.voltage_min = 9000,
/* Pre-charge values. */
@@ -71,28 +43,28 @@ static struct battery_info info_3s = {
.charging_min_c = 0,
.charging_max_c = 60,
.discharging_min_c = 0,
- .discharging_max_c = 50,
+ .discharging_max_c = 60,
};
static struct battery_device support_batteries[] = {
{
- .manuf = "NVT",
- .device = "ARROW",
- .design_mv = 7400,
- .battery_info = &info_2s,
- .support_cut_off = 0,
+ .manuf = "13-1B",
+ .device = "BO03037X",
+ .design_mv = 11400,
+ .battery_info = &info_3s,
+ .support_cut_off = 1,
},
{
- .manuf = "SANYO",
- .device = "AP13J3K",
- .design_mv = 11250,
+ .manuf = "13-1C",
+ .device = "BO03037X",
+ .design_mv = 11400,
.battery_info = &info_3s,
.support_cut_off = 1,
},
{
- .manuf = "SONYCorp",
- .device = "AP13J4K",
- .design_mv = 11400,
+ .manuf = "13-1B",
+ .device = "BO03032X",
+ .design_mv = 11100,
.battery_info = &info_3s,
.support_cut_off = 1,
}
@@ -231,10 +203,23 @@ const struct battery_info *battery_get_info(void)
return NULL;
}
+static int cutoff(void)
+{
+ int rv;
+
+ /* Ship mode command must be sent twice to take effect */
+ rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
+
+ if (rv != EC_SUCCESS)
+ return rv;
+
+ return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
+}
+
int battery_command_cut_off(struct host_cmd_handler_args *args)
{
if (battery_cut_off)
- return sb_write(SB_SHIP_MODE_ADDR, SB_SHIP_MODE_DATA);
+ return cutoff() ? EC_RES_ERROR : EC_RES_SUCCESS;
else
return EC_RES_INVALID_COMMAND;
}