1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2a3c98b8bSMyungJoo Ham /*
3a3c98b8bSMyungJoo Ham * devfreq: Generic Dynamic Voltage and Frequency Scaling (DVFS) Framework
4a3c98b8bSMyungJoo Ham * for Non-CPU Devices.
5a3c98b8bSMyungJoo Ham *
6a3c98b8bSMyungJoo Ham * Copyright (C) 2011 Samsung Electronics
7a3c98b8bSMyungJoo Ham * MyungJoo Ham <[email protected]>
8a3c98b8bSMyungJoo Ham */
9a3c98b8bSMyungJoo Ham
10a3c98b8bSMyungJoo Ham #ifndef __LINUX_DEVFREQ_H__
11a3c98b8bSMyungJoo Ham #define __LINUX_DEVFREQ_H__
12a3c98b8bSMyungJoo Ham
13a3c98b8bSMyungJoo Ham #include <linux/device.h>
14a3c98b8bSMyungJoo Ham #include <linux/notifier.h>
15e4db1c74SNishanth Menon #include <linux/pm_opp.h>
1627dbc542SLeonard Crestez #include <linux/pm_qos.h>
17a3c98b8bSMyungJoo Ham
18aa7c352fSChanwoo Choi /* DEVFREQ governor name */
19aa7c352fSChanwoo Choi #define DEVFREQ_GOV_SIMPLE_ONDEMAND "simple_ondemand"
20aa7c352fSChanwoo Choi #define DEVFREQ_GOV_PERFORMANCE "performance"
21aa7c352fSChanwoo Choi #define DEVFREQ_GOV_POWERSAVE "powersave"
22aa7c352fSChanwoo Choi #define DEVFREQ_GOV_USERSPACE "userspace"
23aa7c352fSChanwoo Choi #define DEVFREQ_GOV_PASSIVE "passive"
24aa7c352fSChanwoo Choi
250fe3a664SChanwoo Choi /* DEVFREQ notifier interface */
260fe3a664SChanwoo Choi #define DEVFREQ_TRANSITION_NOTIFIER (0)
270fe3a664SChanwoo Choi
280fe3a664SChanwoo Choi /* Transition notifiers of DEVFREQ_TRANSITION_NOTIFIER */
290fe3a664SChanwoo Choi #define DEVFREQ_PRECHANGE (0)
300fe3a664SChanwoo Choi #define DEVFREQ_POSTCHANGE (1)
310fe3a664SChanwoo Choi
324dc3bab8SChanwoo Choi /* DEVFREQ work timers */
334dc3bab8SChanwoo Choi enum devfreq_timer {
344dc3bab8SChanwoo Choi DEVFREQ_TIMER_DEFERRABLE = 0,
354dc3bab8SChanwoo Choi DEVFREQ_TIMER_DELAYED,
364dc3bab8SChanwoo Choi DEVFREQ_TIMER_NUM,
374dc3bab8SChanwoo Choi };
384dc3bab8SChanwoo Choi
39a3c98b8bSMyungJoo Ham struct devfreq;
403ea6b700SChanwoo Choi struct devfreq_governor;
41a03dacb0SSaravana Kannan struct devfreq_cpu_data;
421224451bSDaniel Lezcano struct thermal_cooling_device;
43a3c98b8bSMyungJoo Ham
44a3c98b8bSMyungJoo Ham /**
45a3c98b8bSMyungJoo Ham * struct devfreq_dev_status - Data given from devfreq user device to
46a3c98b8bSMyungJoo Ham * governors. Represents the performance
47a3c98b8bSMyungJoo Ham * statistics.
48e09651fcSNishanth Menon * @total_time: The total time represented by this instance of
49a3c98b8bSMyungJoo Ham * devfreq_dev_status
50e09651fcSNishanth Menon * @busy_time: The time that the device was working among the
51a3c98b8bSMyungJoo Ham * total_time.
52e09651fcSNishanth Menon * @current_frequency: The operating frequency.
53e09651fcSNishanth Menon * @private_data: An entry not specified by the devfreq framework.
54a3c98b8bSMyungJoo Ham * A device and a specific governor may have their
55a3c98b8bSMyungJoo Ham * own protocol with private_data. However, because
56a3c98b8bSMyungJoo Ham * this is governor-specific, a governor using this
57a3c98b8bSMyungJoo Ham * will be only compatible with devices aware of it.
58a3c98b8bSMyungJoo Ham */
59a3c98b8bSMyungJoo Ham struct devfreq_dev_status {
60a3c98b8bSMyungJoo Ham /* both since the last measure */
61a3c98b8bSMyungJoo Ham unsigned long total_time;
62a3c98b8bSMyungJoo Ham unsigned long busy_time;
63a3c98b8bSMyungJoo Ham unsigned long current_frequency;
641a51cfdcSJonathan Corbet void *private_data;
65a3c98b8bSMyungJoo Ham };
66a3c98b8bSMyungJoo Ham
67ab5f299fSMyungJoo Ham /*
68ab5f299fSMyungJoo Ham * The resulting frequency should be at most this. (this bound is the
69ab5f299fSMyungJoo Ham * least upper bound; thus, the resulting freq should be lower or same)
70ab5f299fSMyungJoo Ham * If the flag is not set, the resulting frequency should be at most the
71ab5f299fSMyungJoo Ham * bound (greatest lower bound)
72ab5f299fSMyungJoo Ham */
73ab5f299fSMyungJoo Ham #define DEVFREQ_FLAG_LEAST_UPPER_BOUND 0x1
74ab5f299fSMyungJoo Ham
75a3c98b8bSMyungJoo Ham /**
76a3c98b8bSMyungJoo Ham * struct devfreq_dev_profile - Devfreq's user device profile
77e09651fcSNishanth Menon * @initial_freq: The operating frequency when devfreq_add_device() is
78a3c98b8bSMyungJoo Ham * called.
79e09651fcSNishanth Menon * @polling_ms: The polling interval in ms. 0 disables polling.
804dc3bab8SChanwoo Choi * @timer: Timer type is either deferrable or delayed timer.
81e09651fcSNishanth Menon * @target: The device should set its operating frequency at
82a3c98b8bSMyungJoo Ham * freq or lowest-upper-than-freq value. If freq is
83a3c98b8bSMyungJoo Ham * higher than any operable frequency, set maximum.
84a3c98b8bSMyungJoo Ham * Before returning, target function should set
85a3c98b8bSMyungJoo Ham * freq at the current frequency.
86ab5f299fSMyungJoo Ham * The "flags" parameter's possible values are
87ab5f299fSMyungJoo Ham * explained above with "DEVFREQ_FLAG_*" macros.
88e09651fcSNishanth Menon * @get_dev_status: The device should provide the current performance
89d54cdf3fSMyungJoo Ham * status to devfreq. Governors are recommended not to
90d54cdf3fSMyungJoo Ham * use this directly. Instead, governors are recommended
91d54cdf3fSMyungJoo Ham * to use devfreq_update_stats() along with
92d54cdf3fSMyungJoo Ham * devfreq.last_status.
93e09651fcSNishanth Menon * @get_cur_freq: The device should provide the current frequency
947f98a905SRajagopal Venkat * at which it is operating.
95e09651fcSNishanth Menon * @exit: An optional callback that is called when devfreq
96a3c98b8bSMyungJoo Ham * is removing the devfreq object due to error or
97a3c98b8bSMyungJoo Ham * from devfreq_remove_device() call. If the user
98a3c98b8bSMyungJoo Ham * has registered devfreq->nb at a notifier-head,
99a3c98b8bSMyungJoo Ham * this is the time to unregister it.
100416b46a2SChanwoo Choi * @freq_table: Optional list of frequencies to support statistics
101416b46a2SChanwoo Choi * and freq_table must be generated in ascending order.
102e552bbafSJonghwa Lee * @max_state: The size of freq_table.
1031224451bSDaniel Lezcano *
1041224451bSDaniel Lezcano * @is_cooling_device: A self-explanatory boolean giving the device a
1051224451bSDaniel Lezcano * cooling effect property.
106a3c98b8bSMyungJoo Ham */
107a3c98b8bSMyungJoo Ham struct devfreq_dev_profile {
108a3c98b8bSMyungJoo Ham unsigned long initial_freq;
109a3c98b8bSMyungJoo Ham unsigned int polling_ms;
1104dc3bab8SChanwoo Choi enum devfreq_timer timer;
111a3c98b8bSMyungJoo Ham
112ab5f299fSMyungJoo Ham int (*target)(struct device *dev, unsigned long *freq, u32 flags);
113a3c98b8bSMyungJoo Ham int (*get_dev_status)(struct device *dev,
114a3c98b8bSMyungJoo Ham struct devfreq_dev_status *stat);
1157f98a905SRajagopal Venkat int (*get_cur_freq)(struct device *dev, unsigned long *freq);
116a3c98b8bSMyungJoo Ham void (*exit)(struct device *dev);
117e552bbafSJonghwa Lee
1180ec09ac2SChanwoo Choi unsigned long *freq_table;
119e552bbafSJonghwa Lee unsigned int max_state;
120*4a3a2c32SChristophe JAILLET
121*4a3a2c32SChristophe JAILLET bool is_cooling_device;
122a3c98b8bSMyungJoo Ham };
123a3c98b8bSMyungJoo Ham
124a3c98b8bSMyungJoo Ham /**
1251ebd0bc0SKamil Konieczny * struct devfreq_stats - Statistics of devfreq device behavior
1261ebd0bc0SKamil Konieczny * @total_trans: Number of devfreq transitions.
1271ebd0bc0SKamil Konieczny * @trans_table: Statistics of devfreq transitions.
1281ebd0bc0SKamil Konieczny * @time_in_state: Statistics of devfreq states.
1291ebd0bc0SKamil Konieczny * @last_update: The last time stats were updated.
1301ebd0bc0SKamil Konieczny */
1311ebd0bc0SKamil Konieczny struct devfreq_stats {
1321ebd0bc0SKamil Konieczny unsigned int total_trans;
1331ebd0bc0SKamil Konieczny unsigned int *trans_table;
1341ebd0bc0SKamil Konieczny u64 *time_in_state;
1351ebd0bc0SKamil Konieczny u64 last_update;
1361ebd0bc0SKamil Konieczny };
1371ebd0bc0SKamil Konieczny
1381ebd0bc0SKamil Konieczny /**
139a3c98b8bSMyungJoo Ham * struct devfreq - Device devfreq structure
140e09651fcSNishanth Menon * @node: list node - contains the devices with devfreq that have been
141a3c98b8bSMyungJoo Ham * registered.
142e09651fcSNishanth Menon * @lock: a mutex to protect accessing devfreq.
143e09651fcSNishanth Menon * @dev: device registered by devfreq class. dev.parent is the device
144a3c98b8bSMyungJoo Ham * using devfreq.
145e09651fcSNishanth Menon * @profile: device-specific devfreq profile
146e09651fcSNishanth Menon * @governor: method how to choose frequency based on the usage.
14726f9c7ccSSaravana Kannan * @opp_table: Reference to OPP table of dev.parent, if one exists.
148e09651fcSNishanth Menon * @nb: notifier block used to notify devfreq object that it should
149a3c98b8bSMyungJoo Ham * reevaluate operable frequencies. Devfreq users may use
150a3c98b8bSMyungJoo Ham * devfreq.nb to the corresponding register notifier call chain.
151e09651fcSNishanth Menon * @work: delayed work for load monitoring.
152b5d281f6SChristian Marangi * @freq_table: current frequency table used by the devfreq driver.
153b5d281f6SChristian Marangi * @max_state: count of entry present in the frequency table.
154e09651fcSNishanth Menon * @previous_freq: previously configured frequency value.
15554cb5740SRandy Dunlap * @last_status: devfreq user device info, performance statistics
1565fdded84SKant Fan * @data: devfreq driver pass to governors, governor should not change it.
1575fdded84SKant Fan * @governor_data: private data for governors, devfreq core doesn't touch it.
15827dbc542SLeonard Crestez * @user_min_freq_req: PM QoS minimum frequency request from user (via sysfs)
15927dbc542SLeonard Crestez * @user_max_freq_req: PM QoS maximum frequency request from user (via sysfs)
160f1d981eaSChanwoo Choi * @scaling_min_freq: Limit minimum frequency requested by OPP interface
161f1d981eaSChanwoo Choi * @scaling_max_freq: Limit maximum frequency requested by OPP interface
162e09651fcSNishanth Menon * @stop_polling: devfreq polling status of a device.
16383f8ca45SLukasz Luba * @suspend_freq: frequency of a device set during suspend phase.
16483f8ca45SLukasz Luba * @resume_freq: frequency of a device set in resume phase.
16583f8ca45SLukasz Luba * @suspend_count: suspend requests counter for a device.
1661ebd0bc0SKamil Konieczny * @stats: Statistics of devfreq device behavior
1670fe3a664SChanwoo Choi * @transition_notifier_list: list head of DEVFREQ_TRANSITION_NOTIFIER notifier
1681224451bSDaniel Lezcano * @cdev: Cooling device pointer if the devfreq has cooling property
16905d7ae15SLeonard Crestez * @nb_min: Notifier block for DEV_PM_QOS_MIN_FREQUENCY
17005d7ae15SLeonard Crestez * @nb_max: Notifier block for DEV_PM_QOS_MAX_FREQUENCY
171a3c98b8bSMyungJoo Ham *
17254cb5740SRandy Dunlap * This structure stores the devfreq information for a given device.
173a3c98b8bSMyungJoo Ham *
174a3c98b8bSMyungJoo Ham * Note that when a governor accesses entries in struct devfreq in its
175a3c98b8bSMyungJoo Ham * functions except for the context of callbacks defined in struct
176a3c98b8bSMyungJoo Ham * devfreq_governor, the governor should protect its access with the
177a3c98b8bSMyungJoo Ham * struct mutex lock in struct devfreq. A governor may use this mutex
1787a51320eSMauro Carvalho Chehab * to protect its own private data in ``void *data`` as well.
179a3c98b8bSMyungJoo Ham */
180a3c98b8bSMyungJoo Ham struct devfreq {
181a3c98b8bSMyungJoo Ham struct list_head node;
182a3c98b8bSMyungJoo Ham
183a3c98b8bSMyungJoo Ham struct mutex lock;
184a3c98b8bSMyungJoo Ham struct device dev;
185a3c98b8bSMyungJoo Ham struct devfreq_dev_profile *profile;
186a3c98b8bSMyungJoo Ham const struct devfreq_governor *governor;
18726f9c7ccSSaravana Kannan struct opp_table *opp_table;
188a3c98b8bSMyungJoo Ham struct notifier_block nb;
1897e6fdd4bSRajagopal Venkat struct delayed_work work;
190a3c98b8bSMyungJoo Ham
191b5d281f6SChristian Marangi unsigned long *freq_table;
192b5d281f6SChristian Marangi unsigned int max_state;
193b5d281f6SChristian Marangi
194a3c98b8bSMyungJoo Ham unsigned long previous_freq;
19508e75e75SJavi Merino struct devfreq_dev_status last_status;
196a3c98b8bSMyungJoo Ham
1975fdded84SKant Fan void *data;
1985fdded84SKant Fan void *governor_data;
199a3c98b8bSMyungJoo Ham
20027dbc542SLeonard Crestez struct dev_pm_qos_request user_min_freq_req;
20127dbc542SLeonard Crestez struct dev_pm_qos_request user_max_freq_req;
202f1d981eaSChanwoo Choi unsigned long scaling_min_freq;
203f1d981eaSChanwoo Choi unsigned long scaling_max_freq;
2047e6fdd4bSRajagopal Venkat bool stop_polling;
205e552bbafSJonghwa Lee
20683f8ca45SLukasz Luba unsigned long suspend_freq;
20783f8ca45SLukasz Luba unsigned long resume_freq;
20883f8ca45SLukasz Luba atomic_t suspend_count;
20983f8ca45SLukasz Luba
2101ebd0bc0SKamil Konieczny /* information for device frequency transitions */
2111ebd0bc0SKamil Konieczny struct devfreq_stats stats;
2120fe3a664SChanwoo Choi
2130fe3a664SChanwoo Choi struct srcu_notifier_head transition_notifier_list;
21405d7ae15SLeonard Crestez
2151224451bSDaniel Lezcano /* Pointer to the cooling device if used for thermal mitigation */
2161224451bSDaniel Lezcano struct thermal_cooling_device *cdev;
2171224451bSDaniel Lezcano
21805d7ae15SLeonard Crestez struct notifier_block nb_min;
21905d7ae15SLeonard Crestez struct notifier_block nb_max;
2200fe3a664SChanwoo Choi };
2210fe3a664SChanwoo Choi
2220fe3a664SChanwoo Choi struct devfreq_freqs {
2230fe3a664SChanwoo Choi unsigned long old;
2240fe3a664SChanwoo Choi unsigned long new;
225a3c98b8bSMyungJoo Ham };
226a3c98b8bSMyungJoo Ham
227a3c98b8bSMyungJoo Ham #if defined(CONFIG_PM_DEVFREQ)
2286d743493SChanwoo Choi struct devfreq *devfreq_add_device(struct device *dev,
229a3c98b8bSMyungJoo Ham struct devfreq_dev_profile *profile,
2301b5c1be2SNishanth Menon const char *governor_name,
231a3c98b8bSMyungJoo Ham void *data);
2326d743493SChanwoo Choi int devfreq_remove_device(struct devfreq *devfreq);
2336d743493SChanwoo Choi struct devfreq *devm_devfreq_add_device(struct device *dev,
2348cd84092SChanwoo Choi struct devfreq_dev_profile *profile,
2358cd84092SChanwoo Choi const char *governor_name,
2368cd84092SChanwoo Choi void *data);
2376d743493SChanwoo Choi void devm_devfreq_remove_device(struct device *dev, struct devfreq *devfreq);
238de9c7394SMyungJoo Ham
239464ed18eSRafael J. Wysocki /* Supposed to be called by PM callbacks */
2406d743493SChanwoo Choi int devfreq_suspend_device(struct devfreq *devfreq);
2416d743493SChanwoo Choi int devfreq_resume_device(struct devfreq *devfreq);
242a3c98b8bSMyungJoo Ham
2436d743493SChanwoo Choi void devfreq_suspend(void);
2446d743493SChanwoo Choi void devfreq_resume(void);
24559031956SLukasz Luba
2463e2ac979SMauro Carvalho Chehab /* update_devfreq() - Reevaluate the device and configure frequency */
2476d743493SChanwoo Choi int update_devfreq(struct devfreq *devfreq);
248b596d895SMatthias Kaehlcke
249a3c98b8bSMyungJoo Ham /* Helper functions for devfreq user device driver with OPP. */
2506d743493SChanwoo Choi struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
251ab5f299fSMyungJoo Ham unsigned long *freq, u32 flags);
2526d743493SChanwoo Choi int devfreq_register_opp_notifier(struct device *dev,
253a3c98b8bSMyungJoo Ham struct devfreq *devfreq);
2546d743493SChanwoo Choi int devfreq_unregister_opp_notifier(struct device *dev,
255a3c98b8bSMyungJoo Ham struct devfreq *devfreq);
2566d743493SChanwoo Choi int devm_devfreq_register_opp_notifier(struct device *dev,
257d5b040d0SChanwoo Choi struct devfreq *devfreq);
2586d743493SChanwoo Choi void devm_devfreq_unregister_opp_notifier(struct device *dev,
259d5b040d0SChanwoo Choi struct devfreq *devfreq);
2606d743493SChanwoo Choi int devfreq_register_notifier(struct devfreq *devfreq,
2610fe3a664SChanwoo Choi struct notifier_block *nb,
2620fe3a664SChanwoo Choi unsigned int list);
2636d743493SChanwoo Choi int devfreq_unregister_notifier(struct devfreq *devfreq,
2640fe3a664SChanwoo Choi struct notifier_block *nb,
2650fe3a664SChanwoo Choi unsigned int list);
2666d743493SChanwoo Choi int devm_devfreq_register_notifier(struct device *dev,
2670fe3a664SChanwoo Choi struct devfreq *devfreq,
2680fe3a664SChanwoo Choi struct notifier_block *nb,
2690fe3a664SChanwoo Choi unsigned int list);
2706d743493SChanwoo Choi void devm_devfreq_unregister_notifier(struct device *dev,
2710fe3a664SChanwoo Choi struct devfreq *devfreq,
2720fe3a664SChanwoo Choi struct notifier_block *nb,
2730fe3a664SChanwoo Choi unsigned int list);
2747b38b7b0SLeonard Crestez struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node);
27586d90fd9SChanwoo Choi struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
27686d90fd9SChanwoo Choi const char *phandle_name, int index);
277dbd7a2a9SRob Clark #endif /* CONFIG_PM_DEVFREQ */
2788f510aebSChanwoo Choi
279ce26c5bbSMyungJoo Ham /**
2807a51320eSMauro Carvalho Chehab * struct devfreq_simple_ondemand_data - ``void *data`` fed to struct devfreq
281ce26c5bbSMyungJoo Ham * and devfreq_add_device
282e09651fcSNishanth Menon * @upthreshold: If the load is over this value, the frequency jumps.
283ce26c5bbSMyungJoo Ham * Specify 0 to use the default. Valid value = 0 to 100.
284e09651fcSNishanth Menon * @downdifferential: If the load is under upthreshold - downdifferential,
285ce26c5bbSMyungJoo Ham * the governor may consider slowing the frequency down.
286ce26c5bbSMyungJoo Ham * Specify 0 to use the default. Valid value = 0 to 100.
287ce26c5bbSMyungJoo Ham * downdifferential < upthreshold must hold.
288ce26c5bbSMyungJoo Ham *
289ce26c5bbSMyungJoo Ham * If the fed devfreq_simple_ondemand_data pointer is NULL to the governor,
290ce26c5bbSMyungJoo Ham * the governor uses the default values.
291ce26c5bbSMyungJoo Ham */
292ce26c5bbSMyungJoo Ham struct devfreq_simple_ondemand_data {
293ce26c5bbSMyungJoo Ham unsigned int upthreshold;
294ce26c5bbSMyungJoo Ham unsigned int downdifferential;
295ce26c5bbSMyungJoo Ham };
296ce26c5bbSMyungJoo Ham
297a03dacb0SSaravana Kannan enum devfreq_parent_dev_type {
298a03dacb0SSaravana Kannan DEVFREQ_PARENT_DEV,
299a03dacb0SSaravana Kannan CPUFREQ_PARENT_DEV,
300a03dacb0SSaravana Kannan };
301a03dacb0SSaravana Kannan
30299613311SChanwoo Choi /**
3037a51320eSMauro Carvalho Chehab * struct devfreq_passive_data - ``void *data`` fed to struct devfreq
30499613311SChanwoo Choi * and devfreq_add_device
30599613311SChanwoo Choi * @parent: the devfreq instance of parent device.
30699613311SChanwoo Choi * @get_target_freq: Optional callback, Returns desired operating frequency
30799613311SChanwoo Choi * for the device using passive governor. That is called
30899613311SChanwoo Choi * when passive governor should decide the next frequency
30999613311SChanwoo Choi * by using the new frequency of parent devfreq device
31099613311SChanwoo Choi * using governors except for passive governor.
31199613311SChanwoo Choi * If the devfreq device has the specific method to decide
31299613311SChanwoo Choi * the next frequency, should use this callback.
313a03dacb0SSaravana Kannan * @parent_type: the parent type of the device.
31499613311SChanwoo Choi * @this: the devfreq instance of own device.
315a03dacb0SSaravana Kannan * @nb: the notifier block for DEVFREQ_TRANSITION_NOTIFIER or
316a03dacb0SSaravana Kannan * CPUFREQ_TRANSITION_NOTIFIER list.
31726984d9dSChanwoo Choi * @cpu_data_list: the list of cpu frequency data for all cpufreq_policy.
31899613311SChanwoo Choi *
31999613311SChanwoo Choi * The devfreq_passive_data have to set the devfreq instance of parent
32099613311SChanwoo Choi * device with governors except for the passive governor. But, don't need to
32199613311SChanwoo Choi * initialize the 'this' and 'nb' field because the devfreq core will handle
32299613311SChanwoo Choi * them.
32399613311SChanwoo Choi */
32499613311SChanwoo Choi struct devfreq_passive_data {
32599613311SChanwoo Choi /* Should set the devfreq instance of parent device */
32699613311SChanwoo Choi struct devfreq *parent;
32799613311SChanwoo Choi
32899613311SChanwoo Choi /* Optional callback to decide the next frequency of passvice device */
32999613311SChanwoo Choi int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
33099613311SChanwoo Choi
331a03dacb0SSaravana Kannan /* Should set the type of parent device */
332a03dacb0SSaravana Kannan enum devfreq_parent_dev_type parent_type;
333a03dacb0SSaravana Kannan
33499613311SChanwoo Choi /* For passive governor's internal use. Don't need to set them */
33599613311SChanwoo Choi struct devfreq *this;
33699613311SChanwoo Choi struct notifier_block nb;
33726984d9dSChanwoo Choi struct list_head cpu_data_list;
33899613311SChanwoo Choi };
33999613311SChanwoo Choi
340dbd7a2a9SRob Clark #if !defined(CONFIG_PM_DEVFREQ)
devfreq_add_device(struct device * dev,struct devfreq_dev_profile * profile,const char * governor_name,void * data)3415faaa035SRajagopal Venkat static inline struct devfreq *devfreq_add_device(struct device *dev,
342a3c98b8bSMyungJoo Ham struct devfreq_dev_profile *profile,
3431b5c1be2SNishanth Menon const char *governor_name,
344a95e1f5dSMyungJoo Ham void *data)
345a3c98b8bSMyungJoo Ham {
3468cd84092SChanwoo Choi return ERR_PTR(-ENOSYS);
347a3c98b8bSMyungJoo Ham }
348a3c98b8bSMyungJoo Ham
devfreq_remove_device(struct devfreq * devfreq)3495faaa035SRajagopal Venkat static inline int devfreq_remove_device(struct devfreq *devfreq)
350a3c98b8bSMyungJoo Ham {
351a3c98b8bSMyungJoo Ham return 0;
352a3c98b8bSMyungJoo Ham }
353a3c98b8bSMyungJoo Ham
devm_devfreq_add_device(struct device * dev,struct devfreq_dev_profile * profile,const char * governor_name,void * data)3548cd84092SChanwoo Choi static inline struct devfreq *devm_devfreq_add_device(struct device *dev,
3558cd84092SChanwoo Choi struct devfreq_dev_profile *profile,
3568cd84092SChanwoo Choi const char *governor_name,
3578cd84092SChanwoo Choi void *data)
3588cd84092SChanwoo Choi {
3598cd84092SChanwoo Choi return ERR_PTR(-ENOSYS);
3608cd84092SChanwoo Choi }
3618cd84092SChanwoo Choi
devm_devfreq_remove_device(struct device * dev,struct devfreq * devfreq)3628cd84092SChanwoo Choi static inline void devm_devfreq_remove_device(struct device *dev,
3638cd84092SChanwoo Choi struct devfreq *devfreq)
3648cd84092SChanwoo Choi {
3658cd84092SChanwoo Choi }
3668cd84092SChanwoo Choi
devfreq_suspend_device(struct devfreq * devfreq)3675faaa035SRajagopal Venkat static inline int devfreq_suspend_device(struct devfreq *devfreq)
368206c30cfSRajagopal Venkat {
369206c30cfSRajagopal Venkat return 0;
370206c30cfSRajagopal Venkat }
371206c30cfSRajagopal Venkat
devfreq_resume_device(struct devfreq * devfreq)3725faaa035SRajagopal Venkat static inline int devfreq_resume_device(struct devfreq *devfreq)
373206c30cfSRajagopal Venkat {
374206c30cfSRajagopal Venkat return 0;
375206c30cfSRajagopal Venkat }
376206c30cfSRajagopal Venkat
devfreq_suspend(void)37759031956SLukasz Luba static inline void devfreq_suspend(void) {}
devfreq_resume(void)37859031956SLukasz Luba static inline void devfreq_resume(void) {}
37959031956SLukasz Luba
devfreq_recommended_opp(struct device * dev,unsigned long * freq,u32 flags)38047d43ba7SNishanth Menon static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
381ab5f299fSMyungJoo Ham unsigned long *freq, u32 flags)
382a3c98b8bSMyungJoo Ham {
3835faaa035SRajagopal Venkat return ERR_PTR(-EINVAL);
384a3c98b8bSMyungJoo Ham }
385a3c98b8bSMyungJoo Ham
devfreq_register_opp_notifier(struct device * dev,struct devfreq * devfreq)3865faaa035SRajagopal Venkat static inline int devfreq_register_opp_notifier(struct device *dev,
387a3c98b8bSMyungJoo Ham struct devfreq *devfreq)
388a3c98b8bSMyungJoo Ham {
389a3c98b8bSMyungJoo Ham return -EINVAL;
390a3c98b8bSMyungJoo Ham }
391a3c98b8bSMyungJoo Ham
devfreq_unregister_opp_notifier(struct device * dev,struct devfreq * devfreq)3925faaa035SRajagopal Venkat static inline int devfreq_unregister_opp_notifier(struct device *dev,
393a3c98b8bSMyungJoo Ham struct devfreq *devfreq)
394a3c98b8bSMyungJoo Ham {
395a3c98b8bSMyungJoo Ham return -EINVAL;
396a3c98b8bSMyungJoo Ham }
397a3c98b8bSMyungJoo Ham
devm_devfreq_register_opp_notifier(struct device * dev,struct devfreq * devfreq)398d5b040d0SChanwoo Choi static inline int devm_devfreq_register_opp_notifier(struct device *dev,
399d5b040d0SChanwoo Choi struct devfreq *devfreq)
400d5b040d0SChanwoo Choi {
401d5b040d0SChanwoo Choi return -EINVAL;
402d5b040d0SChanwoo Choi }
403d5b040d0SChanwoo Choi
devm_devfreq_unregister_opp_notifier(struct device * dev,struct devfreq * devfreq)404d5b040d0SChanwoo Choi static inline void devm_devfreq_unregister_opp_notifier(struct device *dev,
405d5b040d0SChanwoo Choi struct devfreq *devfreq)
406d5b040d0SChanwoo Choi {
407d5b040d0SChanwoo Choi }
40808e75e75SJavi Merino
devfreq_register_notifier(struct devfreq * devfreq,struct notifier_block * nb,unsigned int list)4090fe3a664SChanwoo Choi static inline int devfreq_register_notifier(struct devfreq *devfreq,
4100fe3a664SChanwoo Choi struct notifier_block *nb,
4110fe3a664SChanwoo Choi unsigned int list)
4120fe3a664SChanwoo Choi {
4130fe3a664SChanwoo Choi return 0;
4140fe3a664SChanwoo Choi }
4150fe3a664SChanwoo Choi
devfreq_unregister_notifier(struct devfreq * devfreq,struct notifier_block * nb,unsigned int list)4160fe3a664SChanwoo Choi static inline int devfreq_unregister_notifier(struct devfreq *devfreq,
4170fe3a664SChanwoo Choi struct notifier_block *nb,
4180fe3a664SChanwoo Choi unsigned int list)
4190fe3a664SChanwoo Choi {
4200fe3a664SChanwoo Choi return 0;
4210fe3a664SChanwoo Choi }
4220fe3a664SChanwoo Choi
devm_devfreq_register_notifier(struct device * dev,struct devfreq * devfreq,struct notifier_block * nb,unsigned int list)4230fe3a664SChanwoo Choi static inline int devm_devfreq_register_notifier(struct device *dev,
4240fe3a664SChanwoo Choi struct devfreq *devfreq,
4250fe3a664SChanwoo Choi struct notifier_block *nb,
4260fe3a664SChanwoo Choi unsigned int list)
4270fe3a664SChanwoo Choi {
4280fe3a664SChanwoo Choi return 0;
4290fe3a664SChanwoo Choi }
4300fe3a664SChanwoo Choi
devm_devfreq_unregister_notifier(struct device * dev,struct devfreq * devfreq,struct notifier_block * nb,unsigned int list)4310fe3a664SChanwoo Choi static inline void devm_devfreq_unregister_notifier(struct device *dev,
4320fe3a664SChanwoo Choi struct devfreq *devfreq,
4330fe3a664SChanwoo Choi struct notifier_block *nb,
4340fe3a664SChanwoo Choi unsigned int list)
4350fe3a664SChanwoo Choi {
4360fe3a664SChanwoo Choi }
4370fe3a664SChanwoo Choi
devfreq_get_devfreq_by_node(struct device_node * node)4387b38b7b0SLeonard Crestez static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
4397b38b7b0SLeonard Crestez {
4407b38b7b0SLeonard Crestez return ERR_PTR(-ENODEV);
4417b38b7b0SLeonard Crestez }
4427b38b7b0SLeonard Crestez
devfreq_get_devfreq_by_phandle(struct device * dev,const char * phandle_name,int index)4438f510aebSChanwoo Choi static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
44486d90fd9SChanwoo Choi const char *phandle_name, int index)
4458f510aebSChanwoo Choi {
4468f510aebSChanwoo Choi return ERR_PTR(-ENODEV);
4478f510aebSChanwoo Choi }
4488f510aebSChanwoo Choi
devfreq_update_stats(struct devfreq * df)44908e75e75SJavi Merino static inline int devfreq_update_stats(struct devfreq *df)
45008e75e75SJavi Merino {
45108e75e75SJavi Merino return -EINVAL;
45208e75e75SJavi Merino }
453a3c98b8bSMyungJoo Ham #endif /* CONFIG_PM_DEVFREQ */
454a3c98b8bSMyungJoo Ham
455a3c98b8bSMyungJoo Ham #endif /* __LINUX_DEVFREQ_H__ */
456