Files
OpenCellular/common/device_state.c
Mary Ruthven 96b7e491e8 cr50: notify chipset hooks when the AP state changes
Cr50 monitors UART1 RX to sense the state of the AP. This signal can be
used to tell if it is in S0. If the signal is pulled up then the AP is
on. If it is not pulled up then the AP is not in S0. This change
notifies HOOK_CHIPSET_SUSPEND when UART1 RX is not pulled up, and then
notifies HOOK_CHIPSET_RESUME when the signal is high again.

The AP usb can be disabled during suspend, so this change changes the
hook that triggers disabling the AP usb to be attached to
HOOK_CHIPSET_SUSPEND instead of HOOK_CHIPSET_RESUME.

BUG=chrome-os-partner:55747
BRANCH=none
TEST=buildall

Change-Id: I47fb38a4bbcd72424ec2535d61e87f820cf1bcd7
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/383978
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-09-22 18:04:57 +00:00

54 lines
1.2 KiB
C

/* Copyright 2016 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 "console.h"
#include "device_state.h"
#include "hooks.h"
int device_get_state(enum device_type device)
{
return device_states[device].state;
}
void device_set_state(enum device_type device, enum device_state state)
{
if (device_states[device].state == state)
return;
if (state != DEVICE_STATE_UNKNOWN)
device_states[device].last_known_state = state;
device_states[device].state = state;
}
static void check_device_state(void)
{
int i;
for (i = 0; i < DEVICE_COUNT; i++)
board_update_device_state(i);
}
DECLARE_HOOK(HOOK_SECOND, check_device_state, HOOK_PRIO_DEFAULT);
static void print_state(const char *name, enum device_state state)
{
ccprintf("%-9s %s\n", name, state == DEVICE_STATE_ON ? "on" :
state == DEVICE_STATE_OFF ? "off" : "unknown");
}
static int command_devices(int argc, char **argv)
{
int i;
for (i = 0; i < DEVICE_COUNT; i++)
print_state(device_states[i].name,
device_states[i].state);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(devices, command_devices,
"",
"Get the device states");