summaryrefslogtreecommitdiff
path: root/lib/vbexport/misc.c
blob: f4f73e47635bdab96ccd671dda1cc021518a8a51 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (c) 2011 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.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 */

#include <common.h>
#include <chromeos/common.h>
#include <chromeos/cros_gpio.h>
#include <vboot_api.h>

#define PREFIX			"misc: "

uint32_t VbExIsShutdownRequested(void)
{
	cros_gpio_t lidsw, pwrsw;

	if (cros_gpio_fetch(CROS_GPIO_LIDSW, &lidsw) ||
			cros_gpio_fetch(CROS_GPIO_PWRSW, &pwrsw)) {
		VBDEBUG(PREFIX "Failed to fetch GPIO!\n");
		/* still return 0, No-Shutdown-Requested */
		return 0;
	}

	/* if lid is NOT OPEN */
	if (!lidsw.value) {
		VBDEBUG(PREFIX "Lid-closed is detected.\n");
		return 1;
	}

	if (pwrsw.value) {
		VBDEBUG(PREFIX "Power-key-pressed is detected.\n");
		return 1;
	}

	return 0;
}

int vbexport_init(void)
{
	return 0;
}