diff options
author | Duncan Laurie <dlaurie@chromium.org> | 2013-10-31 11:49:12 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-11-01 16:16:42 +0000 |
commit | fa13ac76b10847e133d654654f0a9418f87d11fb (patch) | |
tree | 24350ab2e8630f1c3742cb651381eddeb80482d0 /board/samus/extpower.c | |
parent | 6aa0a79f283b03df20af11d3776a10da67b112d6 (diff) | |
download | chrome-ec-fa13ac76b10847e133d654654f0a9418f87d11fb.tar.gz |
samus: Changes for Proto1b
- disable PP1800_PGOOD internal pullup
- add PP3300_DSW_EN control on PF6, turned on in S5 and off in G3
- change PCH_WAKE_L and PCH_PWRBTN_L to open drain signals
- add PCH_BL_EN interrupt on PM3 for rising edge to put backlight
controller into PWM mode, remove 1 second hook
- add samus-specific extpower handler for AC_PRESENT to buffer the
AC_PRESENT input to the new PCH_ACOK output on PM6. this is driven
high in S5/S3/S0 when AC_PRESENT is high, otherwise driven low.
BUG=chrome-os-partner:23752
BRANCH=samus
TEST=emerge-samus chromeos-ec
Change-Id: Ie8ab538610e41914212ee1f3a6287b63474fb85b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/175281
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'board/samus/extpower.c')
-rw-r--r-- | board/samus/extpower.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/board/samus/extpower.c b/board/samus/extpower.c new file mode 100644 index 0000000000..6100a83127 --- /dev/null +++ b/board/samus/extpower.c @@ -0,0 +1,64 @@ +/* Copyright (c) 2013 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. + */ + +/* + * Pure GPIO-based external power detection, buffered to PCH. + * Drive high in S5-S0 when AC_PRESENT is high, otherwise drive low. + */ + +#include "chipset.h" +#include "common.h" +#include "extpower.h" +#include "gpio.h" +#include "hooks.h" +#include "host_command.h" + +int extpower_is_present(void) +{ + return gpio_get_level(GPIO_AC_PRESENT); +} + +/** + * Deferred function to handle external power change + */ +static void extpower_deferred(void) +{ + hook_notify(HOOK_AC_CHANGE); + + /* Forward notification to host */ + if (extpower_is_present()) + host_set_single_event(EC_HOST_EVENT_AC_CONNECTED); + else + host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED); +} +DECLARE_DEFERRED(extpower_deferred); + +static void extpower_buffer_to_pch(void) +{ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) { + /* Drive low in G3 state */ + gpio_set_level(GPIO_PCH_ACOK, 0); + } else { + /* Buffer from extpower in S5+ (where 3.3DSW enabled) */ + gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); + } +} + +void extpower_interrupt(enum gpio_signal signal) +{ + extpower_buffer_to_pch(); + + /* Trigger deferred notification of external power change */ + hook_call_deferred(extpower_deferred, 0); +} + +static void extpower_init(void) +{ + extpower_buffer_to_pch(); + + /* Enable interrupts, now that we've initialized */ + gpio_enable_interrupt(GPIO_AC_PRESENT); +} +DECLARE_HOOK(HOOK_INIT, extpower_init, HOOK_PRIO_DEFAULT); |