summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-12-19 23:58:12 +0800
committerChromeBot <chrome-bot@google.com>2013-01-08 08:58:36 -0800
commit40c79398a63e8192246ff79900a3974041c9d48d (patch)
treebdd54584127c8134b3fdc2e9eec5820463a10eba /common
parent6eb8a6e9999618e6111db7549b46edddaa09313c (diff)
downloadchrome-ec-40c79398a63e8192246ff79900a3974041c9d48d.tar.gz
spring: Sense attached device type
This adds USB port control to charger task. For now, it only senses attached device type and log it to console. BUG=chrome-os-partner:14319 TEST=Attach/detach charger and see console output. BRANCH=none Change-Id: I1218d520c292d9d398c868122ae3876d3fc889bc Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/40078 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/pmu_tps65090_charger.c17
-rw-r--r--common/tsu6721.c5
2 files changed, 22 insertions, 0 deletions
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index 4e474451fc..14475a1c71 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -16,6 +16,7 @@
#include "system.h"
#include "task.h"
#include "timer.h"
+#include "tsu6721.h"
#include "util.h"
#define CPUTS(outstr) cputs(CC_CHARGER, outstr)
@@ -388,10 +389,26 @@ void pmu_charger_task(void)
enable_charging(0);
disable_sleep(SLEEP_MASK_CHARGING);
+#ifdef CONFIG_TSU6721
+ /*
+ * Somehow TSU6721 comes up slowly. Let's wait for a moment before
+ * accessing it.
+ * TODO(victoryang): Investigate slow init issue.
+ */
+ msleep(500);
+
+ tsu6721_init(); /* Init here until we can do with HOOK_INIT */
+ gpio_enable_interrupt(GPIO_USB_CHG_INT);
+#endif
+
while (1) {
last_waken = get_time();
pmu_clear_irq();
+#ifdef CONFIG_TSU6721
+ board_usb_charge_update();
+#endif
+
/*
* When battery is extremely low, the internal voltage can not
* power on its gas guage IC. Charging loop will enable the
diff --git a/common/tsu6721.c b/common/tsu6721.c
index af562a579b..d6fc67ce23 100644
--- a/common/tsu6721.c
+++ b/common/tsu6721.c
@@ -110,6 +110,11 @@ void tsu6721_init(void)
settings = tsu6721_read(TSU6721_REG_TIMER);
settings = (settings & ~0x38);
tsu6721_write(TSU6721_REG_TIMER, settings);
+
+ tsu6721_enable_interrupts(TSU6721_INT_ATTACH |
+ TSU6721_INT_DETACH |
+ TSU6721_INT_ADC_CHANGE |
+ TSU6721_INT_VBUS);
}
/*
* TODO(vpalatin): using the I2C early in the HOOK_INIT