1
2
3
4
5
6
7
8
9#ifndef __LINUX_DEVFREQ_EVENT_H__
10#define __LINUX_DEVFREQ_EVENT_H__
11
12#include <linux/device.h>
13
14
15
16
17
18
19
20
21
22
23
24
25
26struct devfreq_event_dev {
27 struct list_head node;
28
29 struct device dev;
30 struct mutex lock;
31 u32 enable_count;
32
33 const struct devfreq_event_desc *desc;
34};
35
36
37
38
39
40
41
42
43
44
45
46
47struct devfreq_event_data {
48 unsigned long load_count;
49 unsigned long total_count;
50};
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65struct devfreq_event_ops {
66
67 int (*enable)(struct devfreq_event_dev *edev);
68 int (*disable)(struct devfreq_event_dev *edev);
69 int (*reset)(struct devfreq_event_dev *edev);
70
71
72 int (*set_event)(struct devfreq_event_dev *edev);
73 int (*get_event)(struct devfreq_event_dev *edev,
74 struct devfreq_event_data *edata);
75};
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92struct devfreq_event_desc {
93 const char *name;
94 u32 event_type;
95 void *driver_data;
96
97 const struct devfreq_event_ops *ops;
98};
99
100#if defined(CONFIG_PM_DEVFREQ_EVENT)
101extern int devfreq_event_enable_edev(struct devfreq_event_dev *edev);
102extern int devfreq_event_disable_edev(struct devfreq_event_dev *edev);
103extern bool devfreq_event_is_enabled(struct devfreq_event_dev *edev);
104extern int devfreq_event_set_event(struct devfreq_event_dev *edev);
105extern int devfreq_event_get_event(struct devfreq_event_dev *edev,
106 struct devfreq_event_data *edata);
107extern int devfreq_event_reset_event(struct devfreq_event_dev *edev);
108extern struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
109 struct device *dev,
110 const char *phandle_name,
111 int index);
112extern int devfreq_event_get_edev_count(struct device *dev,
113 const char *phandle_name);
114extern struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
115 struct devfreq_event_desc *desc);
116extern int devfreq_event_remove_edev(struct devfreq_event_dev *edev);
117extern struct devfreq_event_dev *devm_devfreq_event_add_edev(struct device *dev,
118 struct devfreq_event_desc *desc);
119extern void devm_devfreq_event_remove_edev(struct device *dev,
120 struct devfreq_event_dev *edev);
121static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
122{
123 return edev->desc->driver_data;
124}
125#else
126static inline int devfreq_event_enable_edev(struct devfreq_event_dev *edev)
127{
128 return -EINVAL;
129}
130
131static inline int devfreq_event_disable_edev(struct devfreq_event_dev *edev)
132{
133 return -EINVAL;
134}
135
136static inline bool devfreq_event_is_enabled(struct devfreq_event_dev *edev)
137{
138 return false;
139}
140
141static inline int devfreq_event_set_event(struct devfreq_event_dev *edev)
142{
143 return -EINVAL;
144}
145
146static inline int devfreq_event_get_event(struct devfreq_event_dev *edev,
147 struct devfreq_event_data *edata)
148{
149 return -EINVAL;
150}
151
152static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev)
153{
154 return -EINVAL;
155}
156
157static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
158 struct device *dev,
159 const char *phandle_name,
160 int index)
161{
162 return ERR_PTR(-EINVAL);
163}
164
165static inline int devfreq_event_get_edev_count(struct device *dev,
166 const char *phandle_name)
167{
168 return -EINVAL;
169}
170
171static inline struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
172 struct devfreq_event_desc *desc)
173{
174 return ERR_PTR(-EINVAL);
175}
176
177static inline int devfreq_event_remove_edev(struct devfreq_event_dev *edev)
178{
179 return -EINVAL;
180}
181
182static inline struct devfreq_event_dev *devm_devfreq_event_add_edev(
183 struct device *dev,
184 struct devfreq_event_desc *desc)
185{
186 return ERR_PTR(-EINVAL);
187}
188
189static inline void devm_devfreq_event_remove_edev(struct device *dev,
190 struct devfreq_event_dev *edev)
191{
192}
193
194static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
195{
196 return NULL;
197}
198#endif
199
200#endif
201