summaryrefslogtreecommitdiff
path: root/zephyr/subsys/ap_pwrseq/include/ap_power_host_sleep.h
blob: 7251f96b765fb701a8fbaa9e2c296e7df6ff1ed9 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Copyright 2022 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef __AP_POWER_HOST_SLEEP_H
#define __AP_POWER_HOST_SLEEP_H

#include <ap_power/ap_power_interface.h>
#include <power_host_sleep.h>

/*
 * Deferred call to set active mask according to current power state
 */
void ap_power_set_active_wake_mask(void);

/*
 * Get lazy wake masks for the sleep state provided
 *
 * @param state Power state
 * @param mask  Lazy wake mask.
 *
 * @return 0 for success; -EINVAL if power state is not S3/S5/S0ix
 */
int ap_power_get_lazy_wake_mask(enum power_states_ndsx state,
				host_event_t *mask);

#if CONFIG_AP_PWRSEQ_S0IX
/* For S0ix path, flag to notify sleep change */
enum ap_power_sleep_type {
	AP_POWER_SLEEP_NONE,
	AP_POWER_SLEEP_SUSPEND,
	AP_POWER_SLEEP_RESUME,
};

/*
 * Reset host sleep state and clean up
 */
void ap_power_reset_host_sleep_state(void);

/*
 * Get current sleep type notified.
 *
 * @return enum ap_power_sleep_type
 */
enum ap_power_sleep_type ap_power_sleep_get_notify(void);

/*
 * Check if the sleep type current power transition indicates is the same
 * as what is notified. If same, means host sleep event notified by AP
 * through Host Command and SLP_S0 are consistent. Process
 * the transition. Otherwise, no action.
 *
 * @param check_state Sleep type which is going to transit to.
 */
void ap_power_sleep_notify_transition(enum ap_power_sleep_type check_state);
#endif /* CONFIG_AP_PWRSEQ_S0IX */

/*
 * Get sleep timeout from host command context
 */
uint16_t host_get_sleep_timeout(void);

/*
 * Set sleep transitions for host command response
 *
 * @param val sleep transitions
 *
 */
void host_set_sleep_transitions(uint32_t val);

#endif /* __AP_PWRSEQ_HOST_SLEEP_H */