]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/linux/devfreq-event.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * devfreq-event: a framework to provide raw data and events of devfreq devices
5 * Copyright (C) 2014 Samsung Electronics
6 * Author: Chanwoo Choi <cw00.choi@samsung.com>
9 #ifndef __LINUX_DEVFREQ_EVENT_H__
10 #define __LINUX_DEVFREQ_EVENT_H__
12 #include <linux/device.h>
15 * struct devfreq_event_dev - the devfreq-event device
17 * @node : Contain the devfreq-event device that have been registered.
18 * @dev : the device registered by devfreq-event class. dev.parent is
19 * the device using devfreq-event.
20 * @lock : a mutex to protect accessing devfreq-event.
21 * @enable_count: the number of enable function have been called.
22 * @desc : the description for devfreq-event device.
24 * This structure contains devfreq-event device information.
26 struct devfreq_event_dev
{
27 struct list_head node
;
33 const struct devfreq_event_desc
*desc
;
37 * struct devfreq_event_data - the devfreq-event data
39 * @load_count : load count of devfreq-event device for the given period.
40 * @total_count : total count of devfreq-event device for the given period.
41 * each count may represent a clock cycle, a time unit
42 * (ns/us/...), or anything the device driver wants.
43 * Generally, utilization is load_count / total_count.
45 * This structure contains the data of devfreq-event device for polling period.
47 struct devfreq_event_data
{
48 unsigned long load_count
;
49 unsigned long total_count
;
53 * struct devfreq_event_ops - the operations of devfreq-event device
55 * @enable : Enable the devfreq-event device.
56 * @disable : Disable the devfreq-event device.
57 * @reset : Reset all setting of the devfreq-event device.
58 * @set_event : Set the specific event type for the devfreq-event device.
59 * @get_event : Get the result of the devfreq-event devie with specific
62 * This structure contains devfreq-event device operations which can be
63 * implemented by devfreq-event device drivers.
65 struct devfreq_event_ops
{
66 /* Optional functions */
67 int (*enable
)(struct devfreq_event_dev
*edev
);
68 int (*disable
)(struct devfreq_event_dev
*edev
);
69 int (*reset
)(struct devfreq_event_dev
*edev
);
71 /* Mandatory functions */
72 int (*set_event
)(struct devfreq_event_dev
*edev
);
73 int (*get_event
)(struct devfreq_event_dev
*edev
,
74 struct devfreq_event_data
*edata
);
78 * struct devfreq_event_desc - the descriptor of devfreq-event device
80 * @name : the name of devfreq-event device.
81 * @driver_data : the private data for devfreq-event driver.
82 * @ops : the operation to control devfreq-event device.
84 * Each devfreq-event device is described with a this structure.
85 * This structure contains the various data for devfreq-event device.
87 struct devfreq_event_desc
{
91 const struct devfreq_event_ops
*ops
;
94 #if defined(CONFIG_PM_DEVFREQ_EVENT)
95 extern int devfreq_event_enable_edev(struct devfreq_event_dev
*edev
);
96 extern int devfreq_event_disable_edev(struct devfreq_event_dev
*edev
);
97 extern bool devfreq_event_is_enabled(struct devfreq_event_dev
*edev
);
98 extern int devfreq_event_set_event(struct devfreq_event_dev
*edev
);
99 extern int devfreq_event_get_event(struct devfreq_event_dev
*edev
,
100 struct devfreq_event_data
*edata
);
101 extern int devfreq_event_reset_event(struct devfreq_event_dev
*edev
);
102 extern struct devfreq_event_dev
*devfreq_event_get_edev_by_phandle(
103 struct device
*dev
, int index
);
104 extern int devfreq_event_get_edev_count(struct device
*dev
);
105 extern struct devfreq_event_dev
*devfreq_event_add_edev(struct device
*dev
,
106 struct devfreq_event_desc
*desc
);
107 extern int devfreq_event_remove_edev(struct devfreq_event_dev
*edev
);
108 extern struct devfreq_event_dev
*devm_devfreq_event_add_edev(struct device
*dev
,
109 struct devfreq_event_desc
*desc
);
110 extern void devm_devfreq_event_remove_edev(struct device
*dev
,
111 struct devfreq_event_dev
*edev
);
112 static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev
*edev
)
114 return edev
->desc
->driver_data
;
117 static inline int devfreq_event_enable_edev(struct devfreq_event_dev
*edev
)
122 static inline int devfreq_event_disable_edev(struct devfreq_event_dev
*edev
)
127 static inline bool devfreq_event_is_enabled(struct devfreq_event_dev
*edev
)
132 static inline int devfreq_event_set_event(struct devfreq_event_dev
*edev
)
137 static inline int devfreq_event_get_event(struct devfreq_event_dev
*edev
,
138 struct devfreq_event_data
*edata
)
143 static inline int devfreq_event_reset_event(struct devfreq_event_dev
*edev
)
148 static inline struct devfreq_event_dev
*devfreq_event_get_edev_by_phandle(
149 struct device
*dev
, int index
)
151 return ERR_PTR(-EINVAL
);
154 static inline int devfreq_event_get_edev_count(struct device
*dev
)
159 static inline struct devfreq_event_dev
*devfreq_event_add_edev(struct device
*dev
,
160 struct devfreq_event_desc
*desc
)
162 return ERR_PTR(-EINVAL
);
165 static inline int devfreq_event_remove_edev(struct devfreq_event_dev
*edev
)
170 static inline struct devfreq_event_dev
*devm_devfreq_event_add_edev(
172 struct devfreq_event_desc
*desc
)
174 return ERR_PTR(-EINVAL
);
177 static inline void devm_devfreq_event_remove_edev(struct device
*dev
,
178 struct devfreq_event_dev
*edev
)
182 static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev
*edev
)
186 #endif /* CONFIG_PM_DEVFREQ_EVENT */
188 #endif /* __LINUX_DEVFREQ_EVENT_H__ */