1 /* $OpenBSD: ofw_power.h,v 1.2 2021/11/26 11:44:01 kettenis Exp $ */
2 /*
3 * Copyright (c) 2016 Mark Kettenis
4 * Copyright (c) 2018 Patrick Wildt <patrick@blueri.se>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef _DEV_OFW_POWER_H_
20 #define _DEV_OFW_POWER_H_
21
22 struct power_domain_device {
23 int pd_node;
24 void *pd_cookie;
25 void (*pd_enable)(void *, uint32_t *, int);
26
27 LIST_ENTRY(power_domain_device) pd_list;
28 uint32_t pd_phandle;
29 uint32_t pd_cells;
30 };
31
32 void power_domain_register(struct power_domain_device *);
33 void power_domain_enable(int);
34 void power_domain_enable_idx(int, int);
35 void power_domain_disable(int);
36 void power_domain_disable_idx(int, int);
37
38 static inline void
power_domain_enable_all(int node)39 power_domain_enable_all(int node)
40 {
41 power_domain_enable_idx(node, -1);
42 }
43
44 static inline void
power_domain_disable_all(int node)45 power_domain_disable_all(int node)
46 {
47 power_domain_disable_idx(node, -1);
48 }
49
50 #endif /* _DEV_OFW_POWER_H_ */
51