diff options
author | Vic Yang <victoryang@chromium.org> | 2014-08-15 15:52:31 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-25 20:52:32 +0000 |
commit | 050c7df0118855ea4c33003c176132821c18c794 (patch) | |
tree | 877eaf25e1f3ffc9f78896b9ed1087e9062f0ec7 /common | |
parent | b0f622543c098d3335bcf12a859c33ff215d7530 (diff) | |
download | chrome-ec-050c7df0118855ea4c33003c176132821c18c794.tar.gz |
Add inductive charging control module
This module controls the inductive charging transmitter. For now, the
policy is to charge whenever possible.
BUG=chrome-os-partner:31392
TEST=Unit test passed
BRANCH=None
Change-Id: Ie48a38ad92fe2bc3329c4962e96572f2bc40b4e6
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212715
Diffstat (limited to 'common')
-rw-r--r-- | common/build.mk | 1 | ||||
-rw-r--r-- | common/inductive_charging.c | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/common/build.mk b/common/build.mk index eeb079181c..c44711a655 100644 --- a/common/build.mk +++ b/common/build.mk @@ -45,6 +45,7 @@ common-$(CONFIG_FLASH)+=flash.o common-$(CONFIG_FMAP)+=fmap.o common-$(CONFIG_I2C)+=i2c.o common-$(CONFIG_I2C_ARBITRATION)+=i2c_arbitration.o +common-$(CONFIG_INDUCTIVE_CHARGING)+=inductive_charging.o common-$(CONFIG_KEYBOARD_PROTOCOL_8042)+=keyboard_8042.o common-$(CONFIG_KEYBOARD_PROTOCOL_MKBP)+=keyboard_mkbp.o common-$(CONFIG_KEYBOARD_TEST)+=keyboard_test.o diff --git a/common/inductive_charging.c b/common/inductive_charging.c new file mode 100644 index 0000000000..3a2448933f --- /dev/null +++ b/common/inductive_charging.c @@ -0,0 +1,37 @@ +/* Copyright 2014 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. + */ + +/* Inductive charging control */ + +#include "common.h" +#include "gpio.h" +#include "hooks.h" +#include "lid_switch.h" + +void inductive_charging_interrupt(enum gpio_signal signal) +{ + int charger_enabled = gpio_get_level(GPIO_BASE_CHG_VDD_EN); + int charge_done = gpio_get_level(GPIO_CHARGE_DONE); + + if (!charger_enabled || charge_done) + gpio_set_level(GPIO_CHARGE_EN, 0); + else + gpio_set_level(GPIO_CHARGE_EN, 1); +} + +static void inductive_charging_lid_update(void) +{ + int lid_open = lid_is_open(); + gpio_set_level(GPIO_BASE_CHG_VDD_EN, !lid_open); + inductive_charging_interrupt(GPIO_LID_OPEN); +} +DECLARE_HOOK(HOOK_LID_CHANGE, inductive_charging_lid_update, HOOK_PRIO_DEFAULT); + +static void inductive_charging_init(void) +{ + gpio_enable_interrupt(GPIO_CHARGE_DONE); + inductive_charging_lid_update(); +} +DECLARE_HOOK(HOOK_INIT, inductive_charging_init, HOOK_PRIO_DEFAULT); |