powercap/dtpm: Fixup kfree for virtual node
[linux-block.git] / include / linux / dtpm.h
CommitLineData
a20d0ef9
DL
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
15struct 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;
a20d0ef9
DL
26};
27
28struct dtpm_ops {
29 u64 (*set_power_uw)(struct dtpm *, u64);
30 u64 (*get_power_uw)(struct dtpm *);
4570ddda 31 int (*update_power_uw)(struct dtpm *);
a20d0ef9
DL
32 void (*release)(struct dtpm *);
33};
34
3759ec67
DL
35struct device_node;
36
b9794a82
DL
37struct dtpm_subsys_ops {
38 const char *name;
39 int (*init)(void);
3759ec67
DL
40 int (*setup)(struct dtpm *, struct device_node *);
41};
42
43enum DTPM_NODE_TYPE {
44 DTPM_NODE_VIRTUAL = 0,
45 DTPM_NODE_DT,
46};
47
48struct dtpm_node {
49 enum DTPM_NODE_TYPE type;
50 const char *name;
51 struct dtpm_node *parent;
a20d0ef9
DL
52};
53
a20d0ef9
DL
54static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
55{
56 return container_of(zone, struct dtpm, zone);
57}
58
4570ddda 59int dtpm_update_power(struct dtpm *dtpm);
a20d0ef9
DL
60
61int dtpm_release_zone(struct powercap_zone *pcz);
62
d2cdc6ad 63void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops);
a20d0ef9
DL
64
65void dtpm_unregister(struct dtpm *dtpm);
66
67int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);
68
3759ec67 69int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table);
a20d0ef9 70#endif