summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorHuangGe Haha <xiong.huang@bitland.corp-partner.google.com>2018-08-24 16:39:29 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-04 16:53:46 -0700
commit571eb5939ef2f353cc16d725c3ce33100eab60ec (patch)
tree1d20c9675e7a1eb3127c1edfb0e73fe1f6788618 /board
parentba968e1782979aabc4af5cf758d601d9dd4e1112 (diff)
downloadchrome-ec-571eb5939ef2f353cc16d725c3ce33100eab60ec.tar.gz
Phaser: support quick charge function of battery
It uses normal mode of battery in S0 state and quick charge mode is used in other states. BUG=b:77306829 BRANCH=none TEST=The maximum charging current is about 2000mA in S0 state and in other states is about 3500mA. Change-Id: I975fc51af6f15445dabea246c8beaf41547caa47 Reviewed-on: https://chromium-review.googlesource.com/1188206 Commit-Ready: Xiong Huang <xiong.huang@bitland.corp-partner.google.com> Tested-by: Xiong Huang <xiong.huang@bitland.corp-partner.google.com> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/phaser/board.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/board/phaser/board.c b/board/phaser/board.c
index def9f92519..e64e445674 100644
--- a/board/phaser/board.c
+++ b/board/phaser/board.c
@@ -30,6 +30,7 @@
#include "temp_sensor.h"
#include "thermistor.h"
#include "util.h"
+#include "battery_smart.h"
static uint16_t sku_id;
@@ -256,3 +257,46 @@ int board_is_lid_angle_tablet_mode(void)
{
return board_is_convertible();
}
+
+/* Battery functions */
+#define SB_OPTIONALMFG_FUNCTION2 0x3e
+/* Optional mfg function2 */
+#define SMART_QUICK_CHARGE (1<<12)
+/* Quick charge support */
+#define MODE_QUICK_CHARGE_SUPPORT (1<<4)
+
+static void sb_quick_charge_mode(int enable)
+{
+ int val, rv;
+
+ rv = sb_read(SB_BATTERY_MODE, &val);
+ if (rv || !(val & MODE_QUICK_CHARGE_SUPPORT))
+ return;
+
+ rv = sb_read(SB_OPTIONALMFG_FUNCTION2, &val);
+ if (rv)
+ return;
+
+ if (enable)
+ val |= SMART_QUICK_CHARGE;
+ else
+ val &= ~SMART_QUICK_CHARGE;
+
+ sb_write(SB_OPTIONALMFG_FUNCTION2, val);
+}
+
+/* Called on AP S3/S0ix -> S0 transition */
+static void board_chipset_resume(void)
+{
+ /* Normal charge current */
+ sb_quick_charge_mode(0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
+
+/* Called on AP S0 -> S3/S0ix transition */
+static void board_chipset_suspend(void)
+{
+ /* Quick charge current */
+ sb_quick_charge_mode(1);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);