0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _GOVERNOR_H
0012 #define _GOVERNOR_H
0013
0014 #include <linux/devfreq.h>
0015
0016 #define DEVFREQ_NAME_LEN 16
0017
0018 #define to_devfreq(DEV) container_of((DEV), struct devfreq, dev)
0019
0020
0021 #define DEVFREQ_GOV_START 0x1
0022 #define DEVFREQ_GOV_STOP 0x2
0023 #define DEVFREQ_GOV_UPDATE_INTERVAL 0x3
0024 #define DEVFREQ_GOV_SUSPEND 0x4
0025 #define DEVFREQ_GOV_RESUME 0x5
0026
0027 #define DEVFREQ_MIN_FREQ 0
0028 #define DEVFREQ_MAX_FREQ ULONG_MAX
0029
0030
0031
0032
0033
0034
0035
0036
0037 #define DEVFREQ_GOV_FLAG_IMMUTABLE BIT(0)
0038 #define DEVFREQ_GOV_FLAG_IRQ_DRIVEN BIT(1)
0039
0040
0041
0042
0043
0044
0045
0046
0047 #define DEVFREQ_GOV_ATTR_POLLING_INTERVAL BIT(0)
0048 #define DEVFREQ_GOV_ATTR_TIMER BIT(1)
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 struct devfreq_cpu_data {
0064 struct list_head node;
0065
0066 struct device *dev;
0067 unsigned int first_cpu;
0068
0069 struct opp_table *opp_table;
0070 unsigned int cur_freq;
0071 unsigned int min_freq;
0072 unsigned int max_freq;
0073 };
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 struct devfreq_governor {
0093 struct list_head node;
0094
0095 const char name[DEVFREQ_NAME_LEN];
0096 const u64 attrs;
0097 const u64 flags;
0098 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
0099 int (*event_handler)(struct devfreq *devfreq,
0100 unsigned int event, void *data);
0101 };
0102
0103 void devfreq_monitor_start(struct devfreq *devfreq);
0104 void devfreq_monitor_stop(struct devfreq *devfreq);
0105 void devfreq_monitor_suspend(struct devfreq *devfreq);
0106 void devfreq_monitor_resume(struct devfreq *devfreq);
0107 void devfreq_update_interval(struct devfreq *devfreq, unsigned int *delay);
0108
0109 int devfreq_add_governor(struct devfreq_governor *governor);
0110 int devfreq_remove_governor(struct devfreq_governor *governor);
0111
0112 int devm_devfreq_add_governor(struct device *dev,
0113 struct devfreq_governor *governor);
0114
0115 int devfreq_update_status(struct devfreq *devfreq, unsigned long freq);
0116 int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
0117 void devfreq_get_freq_range(struct devfreq *devfreq, unsigned long *min_freq,
0118 unsigned long *max_freq);
0119
0120 static inline int devfreq_update_stats(struct devfreq *df)
0121 {
0122 if (!df->profile->get_dev_status)
0123 return -EINVAL;
0124
0125 return df->profile->get_dev_status(df->dev.parent, &df->last_status);
0126 }
0127 #endif