summaryrefslogtreecommitdiff
path: root/include/device_event.h
blob: 7a9992b0dfe24bf026f1bde191cc8904349cc711 (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
47
48
49
50
51
52
53
/* Copyright 2017 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Device event module for Chrome EC */

#ifndef __CROS_EC_DEVICE_EVENT_H
#define __CROS_EC_DEVICE_EVENT_H

#include "common.h"
#include "ec_commands.h"

/**
 * Return the raw device event state.
 */
uint32_t device_get_events(void);

/**
 * Set one or more device event bits.
 *
 * Call device_clear_events to unset event bits.
 *
 * @param mask          Event bits to set (use EC_DEVICE_EVENT_MASK()).
 */
void device_set_events(uint32_t mask);

/**
 * Clear one or more device event bits.
 *
 * @param mask          Event bits to clear (use EC_DEVICE_EVENT_MASK()).
 *                      Write 1 to a bit to clear it.
 */
void device_clear_events(uint32_t mask);

/**
 * Set a single device event.
 *
 * @param event         Event to set (EC_DEVICE_EVENT_*).
 */
static inline void device_set_single_event(int event)
{
	device_set_events(EC_DEVICE_EVENT_MASK(event));
}

/**
 * Enable device event.
 *
 * @param event         Event to enable (EC_DEVICE_EVENT_*)
 */
void device_enable_event(enum ec_device_event event);

#endif /* __CROS_EC_DEVICE_EVENT_H */