summaryrefslogtreecommitdiff
path: root/include/linux/dtpm.h
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2022-01-28 19:35:34 +0300
committerDaniel Lezcano <daniel.lezcano@linaro.org>2022-02-04 19:38:09 +0300
commit3759ec678e8944dc2ea70cab77a300408f78ae27 (patch)
tree49ccd70177019ceb73e7ec2e621c492e908cb23c /include/linux/dtpm.h
parentb9794a822281944ef3de5b1812a94cbdb8134320 (diff)
downloadlinux-3759ec678e8944dc2ea70cab77a300408f78ae27.tar.xz
powercap/drivers/dtpm: Add hierarchy creation
The DTPM framework is available but without a way to configure it. This change provides a way to create a hierarchy of DTPM node where the power consumption reflects the sum of the children's power consumption. It is up to the platform to specify an array of dtpm nodes where each element has a pointer to its parent, except the top most one. The type of the node gives the indication of which initialization callback to call. At this time, we can create a virtual node, where its purpose is to be a parent in the hierarchy, and a DT node where the name describes its path. In order to ensure a nice self-encapsulation, the DTPM subsys array contains a couple of initialization functions, one to setup the DTPM backend and one to initialize it up. With this approach, the DTPM framework has a very few material to export. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20220128163537.212248-3-daniel.lezcano@linaro.org
Diffstat (limited to 'include/linux/dtpm.h')
-rw-r--r--include/linux/dtpm.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/dtpm.h b/include/linux/dtpm.h
index 506048158a50..f7a25c70dd4c 100644
--- a/include/linux/dtpm.h
+++ b/include/linux/dtpm.h
@@ -32,9 +32,23 @@ struct dtpm_ops {
void (*release)(struct dtpm *);
};
+struct device_node;
+
struct dtpm_subsys_ops {
const char *name;
int (*init)(void);
+ int (*setup)(struct dtpm *, struct device_node *);
+};
+
+enum DTPM_NODE_TYPE {
+ DTPM_NODE_VIRTUAL = 0,
+ DTPM_NODE_DT,
+};
+
+struct dtpm_node {
+ enum DTPM_NODE_TYPE type;
+ const char *name;
+ struct dtpm_node *parent;
};
static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
@@ -52,4 +66,5 @@ void dtpm_unregister(struct dtpm *dtpm);
int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);
+int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table);
#endif