mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 16:41:55 +00:00
The interrupt handler moved a while ago, but the code to enable the interrupt at init-time didn't. Fix that. BUG=chrome-os-partner:18256 BRANCH=none TEST=boot system. unplug AC. replug AC. UI charging indicator should update. Change-Id: Ie16aa7f6eb9e871a6e3e8ecf6733ecbdc883be0b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47041 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/* 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 */
|
|
|
|
#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);
|
|
|
|
void extpower_interrupt(enum gpio_signal signal)
|
|
{
|
|
/* Trigger deferred notification of external power change */
|
|
hook_call_deferred(extpower_deferred, 0);
|
|
}
|
|
|
|
static void extpower_init(void)
|
|
{
|
|
/* Enable interrupts, now that we've initialized */
|
|
gpio_enable_interrupt(GPIO_AC_PRESENT);
|
|
}
|
|
DECLARE_HOOK(HOOK_INIT, extpower_init, HOOK_PRIO_DEFAULT);
|