]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/dtpm.h
Merge tag 'gvt-fixes-2021-09-18' of https://github.com/intel/gvt-linux into drm-intel...
[mirror_ubuntu-jammy-kernel.git] / include / linux / dtpm.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2020 Linaro Ltd
4 *
5 * Author: Daniel Lezcano <daniel.lezcano@linaro.org>
6 */
7 #ifndef ___DTPM_H__
8 #define ___DTPM_H__
9
10 #include <linux/powercap.h>
11
12 #define MAX_DTPM_DESCR 8
13 #define MAX_DTPM_CONSTRAINTS 1
14
15 struct dtpm {
16 struct powercap_zone zone;
17 struct dtpm *parent;
18 struct list_head sibling;
19 struct list_head children;
20 struct dtpm_ops *ops;
21 unsigned long flags;
22 u64 power_limit;
23 u64 power_max;
24 u64 power_min;
25 int weight;
26 void *private;
27 };
28
29 struct dtpm_ops {
30 u64 (*set_power_uw)(struct dtpm *, u64);
31 u64 (*get_power_uw)(struct dtpm *);
32 void (*release)(struct dtpm *);
33 };
34
35 struct dtpm_descr;
36
37 typedef int (*dtpm_init_t)(struct dtpm_descr *);
38
39 struct dtpm_descr {
40 struct dtpm *parent;
41 const char *name;
42 dtpm_init_t init;
43 };
44
45 /* Init section thermal table */
46 extern struct dtpm_descr *__dtpm_table[];
47 extern struct dtpm_descr *__dtpm_table_end[];
48
49 #define DTPM_TABLE_ENTRY(name) \
50 static typeof(name) *__dtpm_table_entry_##name \
51 __used __section("__dtpm_table") = &name
52
53 #define DTPM_DECLARE(name) DTPM_TABLE_ENTRY(name)
54
55 #define for_each_dtpm_table(__dtpm) \
56 for (__dtpm = __dtpm_table; \
57 __dtpm < __dtpm_table_end; \
58 __dtpm++)
59
60 static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
61 {
62 return container_of(zone, struct dtpm, zone);
63 }
64
65 int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max);
66
67 int dtpm_release_zone(struct powercap_zone *pcz);
68
69 struct dtpm *dtpm_alloc(struct dtpm_ops *ops);
70
71 void dtpm_unregister(struct dtpm *dtpm);
72
73 int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);
74
75 int dtpm_register_cpu(struct dtpm *parent);
76
77 #endif