Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2020 Linaro Ltd
0004  *
0005  * Author: Daniel Lezcano <daniel.lezcano@linaro.org>
0006  */
0007 #ifndef ___DTPM_H__
0008 #define ___DTPM_H__
0009 
0010 #include <linux/powercap.h>
0011 
0012 #define MAX_DTPM_DESCR 8
0013 #define MAX_DTPM_CONSTRAINTS 1
0014 
0015 struct dtpm {
0016     struct powercap_zone zone;
0017     struct dtpm *parent;
0018     struct list_head sibling;
0019     struct list_head children;
0020     struct dtpm_ops *ops;
0021     unsigned long flags;
0022     u64 power_limit;
0023     u64 power_max;
0024     u64 power_min;
0025     int weight;
0026 };
0027 
0028 struct dtpm_ops {
0029     u64 (*set_power_uw)(struct dtpm *, u64);
0030     u64 (*get_power_uw)(struct dtpm *);
0031     int (*update_power_uw)(struct dtpm *);
0032     void (*release)(struct dtpm *);
0033 };
0034 
0035 struct device_node;
0036 
0037 struct dtpm_subsys_ops {
0038     const char *name;
0039     int (*init)(void);
0040     void (*exit)(void);
0041     int (*setup)(struct dtpm *, struct device_node *);
0042 };
0043 
0044 enum DTPM_NODE_TYPE {
0045     DTPM_NODE_VIRTUAL = 0,
0046     DTPM_NODE_DT,
0047 };
0048 
0049 struct dtpm_node {
0050     enum DTPM_NODE_TYPE type;
0051     const char *name;
0052     struct dtpm_node *parent;
0053 };
0054 
0055 static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
0056 {
0057     return container_of(zone, struct dtpm, zone);
0058 }
0059 
0060 int dtpm_update_power(struct dtpm *dtpm);
0061 
0062 int dtpm_release_zone(struct powercap_zone *pcz);
0063 
0064 void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops);
0065 
0066 void dtpm_unregister(struct dtpm *dtpm);
0067 
0068 int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);
0069 
0070 int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table);
0071 
0072 void dtpm_destroy_hierarchy(void);
0073 #endif