summaryrefslogtreecommitdiff
path: root/board/bds
diff options
context:
space:
mode:
authorRong Chang <rongchang@google.com>2012-02-06 20:51:48 -0800
committerRong Chang <rongchang@google.com>2012-02-07 12:54:28 -0800
commit812b3f8cb692ae5f9c616f570e5973e9c66eddcb (patch)
treea816e0ea5552b3b8c17bd6adbba0753a9a7cb8b1 /board/bds
parentd3e1de758cfa3a7dd990f0fb63eddbb1ae870418 (diff)
downloadchrome-ec-812b3f8cb692ae5f9c616f570e5973e9c66eddcb.tar.gz
Initial bq24725 charger driver import
Battery charging state machine contains many file changes. This is the 1st part of the break down. Refactor original test code into board dummy driver. Normalize charger API. And import link's charger IC driver. Signed-off-by: Rong Chang <rongchang@google.com> BUG=chrome-os-partner:7855 TEST=build without warning and error BOARD=bds make BOARD=link make BOARD=discovery make Change-Id: I34b6e9862a45331378916bc77653d4adb22ca548
Diffstat (limited to 'board/bds')
-rw-r--r--board/bds/build.mk5
-rw-r--r--board/bds/dummy_charger.c88
2 files changed, 93 insertions, 0 deletions
diff --git a/board/bds/build.mk b/board/bds/build.mk
index c3fae48c4b..73f193751f 100644
--- a/board/bds/build.mk
+++ b/board/bds/build.mk
@@ -1,8 +1,13 @@
+# 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.
#
# Board specific files build
+#
# the IC is TI Stellaris LM4
CHIP:=lm4
board-y=board.o
+board-$(CONFIG_CHARGER)+=dummy_charger.o
board-$(CONFIG_TEMP_SENSOR)+=board_temp_sensor.o
diff --git a/board/bds/dummy_charger.c b/board/bds/dummy_charger.c
new file mode 100644
index 0000000000..c4ee308e1c
--- /dev/null
+++ b/board/bds/dummy_charger.c
@@ -0,0 +1,88 @@
+/* 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.
+ */
+
+#include "board.h"
+#include "charger.h"
+#include "console.h"
+#include "i2c.h"
+#include "uart.h"
+#include "util.h"
+
+/* Address of battery charger */
+#define CHARGER_ADDR 0x12
+
+/* Address of battery */
+#define BATTERY_ADDR 0x16
+
+int charger_init(void)
+{
+ return EC_SUCCESS;
+}
+
+/*****************************************************************************/
+/* Console commands */
+
+static int command_charger(int argc, char **argv)
+{
+ int rv;
+ int d;
+
+ uart_puts("Reading battery charger...\n");
+
+ rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0xfe, &d);
+ if (rv)
+ return rv;
+ uart_printf(" Manufacturer ID: 0x%04x\n", d);
+
+ rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0xff, &d);
+ uart_printf(" Device ID: 0x%04x\n", d);
+
+ rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x12, &d);
+ uart_printf(" Option: 0x%04x\n", d);
+
+ rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x14, &d);
+ uart_printf(" Charge current: 0x%04x\n", d);
+
+ rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x15, &d);
+ uart_printf(" Charge voltage: 0x%04x\n", d);
+
+ rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x3f, &d);
+ uart_printf(" Input current: 0x%04x\n", d);
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(charger, command_charger);
+
+static int command_battery(int argc, char **argv)
+{
+ int rv;
+ int d;
+
+ uart_puts("Reading battery...\n");
+
+ rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x08, &d);
+ if (rv)
+ return rv;
+ uart_printf(" Temperature: 0x%04x = %d C\n",
+ d, (d-2731)/10);
+
+ rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x09, &d);
+ uart_printf(" Voltage: 0x%04x = %d mV\n", d, d);
+
+ rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x0f, &d);
+ uart_printf(" Remaining capacity: 0x%04x = %d mAh\n", d, d);
+ rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x10, &d);
+ uart_printf(" Full charge capacity: 0x%04x = %d mAh\n", d, d);
+
+ rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x14, &d);
+ uart_printf(" Desired charge current: 0x%04x = %d mA\n", d, d);
+ rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x15, &d);
+ uart_printf(" Desired charge voltage: 0x%04x = %d mV\n", d, d);
+
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(battery, command_battery);
+