summaryrefslogtreecommitdiff
path: root/common/extpower_common.c
blob: 9021b77626273b658c6709d58a4aa777c934f7fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Copyright 2020 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.
 */

#include "extpower.h"
#include "hooks.h"
#include "host_command.h"

__overridable void board_check_extpower(void)
{
}

void extpower_handle_update(int is_present)
{
	uint8_t *memmap_batt_flags;

	hook_notify(HOOK_AC_CHANGE);
	memmap_batt_flags = host_get_memmap(EC_MEMMAP_BATT_FLAG);

	/* Forward notification to host */
	if (is_present) {
		*memmap_batt_flags |= EC_BATT_FLAG_AC_PRESENT;
		host_set_single_event(EC_HOST_EVENT_AC_CONNECTED);
	} else {
		*memmap_batt_flags &= ~EC_BATT_FLAG_AC_PRESENT;
		host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED);
	}
}