0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __LINUX_DEVFREQ_EVENT_H__
0010 #define __LINUX_DEVFREQ_EVENT_H__
0011
0012 #include <linux/device.h>
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 struct devfreq_event_dev {
0027 struct list_head node;
0028
0029 struct device dev;
0030 struct mutex lock;
0031 u32 enable_count;
0032
0033 const struct devfreq_event_desc *desc;
0034 };
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 struct devfreq_event_data {
0048 unsigned long load_count;
0049 unsigned long total_count;
0050 };
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 struct devfreq_event_ops {
0066
0067 int (*enable)(struct devfreq_event_dev *edev);
0068 int (*disable)(struct devfreq_event_dev *edev);
0069 int (*reset)(struct devfreq_event_dev *edev);
0070
0071
0072 int (*set_event)(struct devfreq_event_dev *edev);
0073 int (*get_event)(struct devfreq_event_dev *edev,
0074 struct devfreq_event_data *edata);
0075 };
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 struct devfreq_event_desc {
0093 const char *name;
0094 u32 event_type;
0095 void *driver_data;
0096
0097 const struct devfreq_event_ops *ops;
0098 };
0099
0100 #if defined(CONFIG_PM_DEVFREQ_EVENT)
0101 extern int devfreq_event_enable_edev(struct devfreq_event_dev *edev);
0102 extern int devfreq_event_disable_edev(struct devfreq_event_dev *edev);
0103 extern bool devfreq_event_is_enabled(struct devfreq_event_dev *edev);
0104 extern int devfreq_event_set_event(struct devfreq_event_dev *edev);
0105 extern int devfreq_event_get_event(struct devfreq_event_dev *edev,
0106 struct devfreq_event_data *edata);
0107 extern int devfreq_event_reset_event(struct devfreq_event_dev *edev);
0108 extern struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
0109 struct device *dev,
0110 const char *phandle_name,
0111 int index);
0112 extern int devfreq_event_get_edev_count(struct device *dev,
0113 const char *phandle_name);
0114 extern struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
0115 struct devfreq_event_desc *desc);
0116 extern int devfreq_event_remove_edev(struct devfreq_event_dev *edev);
0117 extern struct devfreq_event_dev *devm_devfreq_event_add_edev(struct device *dev,
0118 struct devfreq_event_desc *desc);
0119 extern void devm_devfreq_event_remove_edev(struct device *dev,
0120 struct devfreq_event_dev *edev);
0121 static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
0122 {
0123 return edev->desc->driver_data;
0124 }
0125 #else
0126 static inline int devfreq_event_enable_edev(struct devfreq_event_dev *edev)
0127 {
0128 return -EINVAL;
0129 }
0130
0131 static inline int devfreq_event_disable_edev(struct devfreq_event_dev *edev)
0132 {
0133 return -EINVAL;
0134 }
0135
0136 static inline bool devfreq_event_is_enabled(struct devfreq_event_dev *edev)
0137 {
0138 return false;
0139 }
0140
0141 static inline int devfreq_event_set_event(struct devfreq_event_dev *edev)
0142 {
0143 return -EINVAL;
0144 }
0145
0146 static inline int devfreq_event_get_event(struct devfreq_event_dev *edev,
0147 struct devfreq_event_data *edata)
0148 {
0149 return -EINVAL;
0150 }
0151
0152 static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev)
0153 {
0154 return -EINVAL;
0155 }
0156
0157 static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
0158 struct device *dev,
0159 const char *phandle_name,
0160 int index)
0161 {
0162 return ERR_PTR(-EINVAL);
0163 }
0164
0165 static inline int devfreq_event_get_edev_count(struct device *dev,
0166 const char *phandle_name)
0167 {
0168 return -EINVAL;
0169 }
0170
0171 static inline struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
0172 struct devfreq_event_desc *desc)
0173 {
0174 return ERR_PTR(-EINVAL);
0175 }
0176
0177 static inline int devfreq_event_remove_edev(struct devfreq_event_dev *edev)
0178 {
0179 return -EINVAL;
0180 }
0181
0182 static inline struct devfreq_event_dev *devm_devfreq_event_add_edev(
0183 struct device *dev,
0184 struct devfreq_event_desc *desc)
0185 {
0186 return ERR_PTR(-EINVAL);
0187 }
0188
0189 static inline void devm_devfreq_event_remove_edev(struct device *dev,
0190 struct devfreq_event_dev *edev)
0191 {
0192 }
0193
0194 static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
0195 {
0196 return NULL;
0197 }
0198 #endif
0199
0200 #endif