blob: f6bc7650191281650823101bfb3bda175496a4f8 [file] [log] [blame]
Nishanth Menone1f60b22010-10-13 00:13:10 +02001/*
2 * Generic OPP Interface
3 *
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5 * Nishanth Menon
6 * Romit Dasgupta
7 * Kevin Hilman
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __LINUX_OPP_H__
15#define __LINUX_OPP_H__
16
17#include <linux/err.h>
MyungJoo Ham03ca3702011-09-30 22:35:12 +020018#include <linux/notifier.h>
Nishanth Menone1f60b22010-10-13 00:13:10 +020019
Nishanth Menon47d43ba2013-09-19 16:03:51 -050020struct dev_pm_opp;
Paul Gortmaker313162d2012-01-30 11:46:54 -050021struct device;
Stephen Boydc7a8a0a2016-11-30 16:21:25 +053022struct opp_table;
Nishanth Menone1f60b22010-10-13 00:13:10 +020023
Nishanth Menon47d43ba2013-09-19 16:03:51 -050024enum dev_pm_opp_event {
Viresh Kumar129eec52014-11-27 08:54:06 +053025 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
MyungJoo Ham03ca3702011-09-30 22:35:12 +020026};
27
Nishanth Menone1f60b22010-10-13 00:13:10 +020028#if defined(CONFIG_PM_OPP)
29
Nishanth Menon47d43ba2013-09-19 16:03:51 -050030unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
Nishanth Menone1f60b22010-10-13 00:13:10 +020031
Nishanth Menon47d43ba2013-09-19 16:03:51 -050032unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
Nishanth Menone1f60b22010-10-13 00:13:10 +020033
Bartlomiej Zolnierkiewicz19445b22015-07-09 17:43:35 +020034bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
35
Nishanth Menon5d4879c2013-09-19 16:03:50 -050036int dev_pm_opp_get_opp_count(struct device *dev);
Viresh Kumar3ca9bb32015-07-29 16:23:03 +053037unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
Viresh Kumar655c9df2016-02-09 10:30:35 +053038unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev);
Viresh Kumar21743442016-02-09 10:30:36 +053039unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev);
Bartlomiej Zolnierkiewicz4eafbd12015-09-08 18:41:01 +020040struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev);
Nishanth Menone1f60b22010-10-13 00:13:10 +020041
Nishanth Menon47d43ba2013-09-19 16:03:51 -050042struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
43 unsigned long freq,
44 bool available);
Nishanth Menone1f60b22010-10-13 00:13:10 +020045
Nishanth Menon47d43ba2013-09-19 16:03:51 -050046struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
47 unsigned long *freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020048
Nishanth Menon47d43ba2013-09-19 16:03:51 -050049struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
50 unsigned long *freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020051
Nishanth Menon5d4879c2013-09-19 16:03:50 -050052int dev_pm_opp_add(struct device *dev, unsigned long freq,
53 unsigned long u_volt);
Viresh Kumar129eec52014-11-27 08:54:06 +053054void dev_pm_opp_remove(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020055
Nishanth Menon5d4879c2013-09-19 16:03:50 -050056int dev_pm_opp_enable(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020057
Nishanth Menon5d4879c2013-09-19 16:03:50 -050058int dev_pm_opp_disable(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020059
Nishanth Menon5d4879c2013-09-19 16:03:50 -050060struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
Viresh Kumar7de36b02015-12-09 08:01:46 +053061int dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions,
62 unsigned int count);
63void dev_pm_opp_put_supported_hw(struct device *dev);
Viresh Kumar01fb4d32015-12-09 08:01:47 +053064int dev_pm_opp_set_prop_name(struct device *dev, const char *name);
65void dev_pm_opp_put_prop_name(struct device *dev);
Stephen Boydc7a8a0a2016-11-30 16:21:25 +053066struct opp_table *dev_pm_opp_set_regulator(struct device *dev, const char *name);
67void dev_pm_opp_put_regulator(struct opp_table *opp_table);
Viresh Kumar6a0712f2016-02-09 10:30:39 +053068int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
Arnd Bergmannddbb74b2016-04-30 13:33:29 +020069int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask);
70int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
Sudeep Holla411466c2016-05-03 15:05:04 +010071void dev_pm_opp_remove_table(struct device *dev);
72void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask);
Nishanth Menone1f60b22010-10-13 00:13:10 +020073#else
Nishanth Menon47d43ba2013-09-19 16:03:51 -050074static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
Nishanth Menone1f60b22010-10-13 00:13:10 +020075{
76 return 0;
77}
78
Nishanth Menon47d43ba2013-09-19 16:03:51 -050079static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
Nishanth Menone1f60b22010-10-13 00:13:10 +020080{
81 return 0;
82}
83
Bartlomiej Zolnierkiewicz19445b22015-07-09 17:43:35 +020084static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
85{
86 return false;
87}
88
Nishanth Menon5d4879c2013-09-19 16:03:50 -050089static inline int dev_pm_opp_get_opp_count(struct device *dev)
Nishanth Menone1f60b22010-10-13 00:13:10 +020090{
91 return 0;
92}
93
Viresh Kumar3ca9bb32015-07-29 16:23:03 +053094static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
95{
96 return 0;
97}
98
Viresh Kumar655c9df2016-02-09 10:30:35 +053099static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
100{
101 return 0;
102}
103
Viresh Kumar21743442016-02-09 10:30:36 +0530104static inline unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev)
105{
106 return 0;
107}
108
Bartlomiej Zolnierkiewicz4eafbd12015-09-08 18:41:01 +0200109static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
110{
111 return NULL;
112}
113
Nishanth Menon47d43ba2013-09-19 16:03:51 -0500114static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +0200115 unsigned long freq, bool available)
116{
Viresh Kumard708b382016-04-27 08:52:21 +0530117 return ERR_PTR(-ENOTSUPP);
Nishanth Menone1f60b22010-10-13 00:13:10 +0200118}
119
Nishanth Menon47d43ba2013-09-19 16:03:51 -0500120static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +0200121 unsigned long *freq)
122{
Viresh Kumard708b382016-04-27 08:52:21 +0530123 return ERR_PTR(-ENOTSUPP);
Nishanth Menone1f60b22010-10-13 00:13:10 +0200124}
125
Nishanth Menon47d43ba2013-09-19 16:03:51 -0500126static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +0200127 unsigned long *freq)
128{
Viresh Kumard708b382016-04-27 08:52:21 +0530129 return ERR_PTR(-ENOTSUPP);
Nishanth Menone1f60b22010-10-13 00:13:10 +0200130}
131
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500132static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
Nishanth Menone1f60b22010-10-13 00:13:10 +0200133 unsigned long u_volt)
134{
Viresh Kumard708b382016-04-27 08:52:21 +0530135 return -ENOTSUPP;
Nishanth Menone1f60b22010-10-13 00:13:10 +0200136}
137
Viresh Kumar129eec52014-11-27 08:54:06 +0530138static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
139{
140}
141
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500142static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
Nishanth Menone1f60b22010-10-13 00:13:10 +0200143{
144 return 0;
145}
146
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500147static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
Nishanth Menone1f60b22010-10-13 00:13:10 +0200148{
149 return 0;
150}
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200151
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500152static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
153 struct device *dev)
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200154{
Viresh Kumard708b382016-04-27 08:52:21 +0530155 return ERR_PTR(-ENOTSUPP);
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200156}
Viresh Kumar7de36b02015-12-09 08:01:46 +0530157
158static inline int dev_pm_opp_set_supported_hw(struct device *dev,
159 const u32 *versions,
160 unsigned int count)
161{
Viresh Kumard708b382016-04-27 08:52:21 +0530162 return -ENOTSUPP;
Viresh Kumar7de36b02015-12-09 08:01:46 +0530163}
164
165static inline void dev_pm_opp_put_supported_hw(struct device *dev) {}
166
Viresh Kumar01fb4d32015-12-09 08:01:47 +0530167static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name)
168{
Viresh Kumard708b382016-04-27 08:52:21 +0530169 return -ENOTSUPP;
Viresh Kumar01fb4d32015-12-09 08:01:47 +0530170}
171
172static inline void dev_pm_opp_put_prop_name(struct device *dev) {}
173
Stephen Boydc7a8a0a2016-11-30 16:21:25 +0530174static inline struct opp_table *dev_pm_opp_set_regulator(struct device *dev, const char *name)
Viresh Kumar9f8ea962016-02-09 10:30:33 +0530175{
Stephen Boydc7a8a0a2016-11-30 16:21:25 +0530176 return ERR_PTR(-ENOTSUPP);
Viresh Kumar9f8ea962016-02-09 10:30:33 +0530177}
178
Stephen Boydc7a8a0a2016-11-30 16:21:25 +0530179static inline void dev_pm_opp_put_regulator(struct opp_table *opp_table) {}
Viresh Kumar9f8ea962016-02-09 10:30:33 +0530180
Viresh Kumar6a0712f2016-02-09 10:30:39 +0530181static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
182{
Viresh Kumard708b382016-04-27 08:52:21 +0530183 return -ENOTSUPP;
Viresh Kumar6a0712f2016-02-09 10:30:39 +0530184}
185
Arnd Bergmannddbb74b2016-04-30 13:33:29 +0200186static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask)
Viresh Kumar642aa8c2016-04-21 14:28:55 +0530187{
Viresh Kumard708b382016-04-27 08:52:21 +0530188 return -ENOTSUPP;
Viresh Kumar642aa8c2016-04-21 14:28:55 +0530189}
190
Arnd Bergmannddbb74b2016-04-30 13:33:29 +0200191static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
Viresh Kumar6f707da2016-04-27 08:52:23 +0530192{
193 return -EINVAL;
194}
195
Sudeep Holla411466c2016-05-03 15:05:04 +0100196static inline void dev_pm_opp_remove_table(struct device *dev)
197{
198}
199
200static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask)
201{
202}
203
Tony Lindgrena96d69d2011-11-03 10:12:27 +0100204#endif /* CONFIG_PM_OPP */
Nishanth Menone1f60b22010-10-13 00:13:10 +0200205
Shawn Guod6561bb2013-02-21 11:04:45 +0000206#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530207int dev_pm_opp_of_add_table(struct device *dev);
208void dev_pm_opp_of_remove_table(struct device *dev);
Arnd Bergmannddbb74b2016-04-30 13:33:29 +0200209int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask);
210void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask);
211int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
Shawn Guod6561bb2013-02-21 11:04:45 +0000212#else
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530213static inline int dev_pm_opp_of_add_table(struct device *dev)
Shawn Guod6561bb2013-02-21 11:04:45 +0000214{
Viresh Kumard708b382016-04-27 08:52:21 +0530215 return -ENOTSUPP;
Shawn Guod6561bb2013-02-21 11:04:45 +0000216}
Viresh Kumar129eec52014-11-27 08:54:06 +0530217
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530218static inline void dev_pm_opp_of_remove_table(struct device *dev)
Viresh Kumar129eec52014-11-27 08:54:06 +0530219{
220}
Viresh Kumar8d4d4e92015-06-12 17:10:38 +0530221
Arnd Bergmannddbb74b2016-04-30 13:33:29 +0200222static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask)
Viresh Kumar8d4d4e92015-06-12 17:10:38 +0530223{
Viresh Kumard708b382016-04-27 08:52:21 +0530224 return -ENOTSUPP;
Viresh Kumar8d4d4e92015-06-12 17:10:38 +0530225}
226
Arnd Bergmannddbb74b2016-04-30 13:33:29 +0200227static inline void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask)
Viresh Kumar8d4d4e92015-06-12 17:10:38 +0530228{
229}
230
Arnd Bergmannddbb74b2016-04-30 13:33:29 +0200231static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
Viresh Kumar8d4d4e92015-06-12 17:10:38 +0530232{
Viresh Kumard708b382016-04-27 08:52:21 +0530233 return -ENOTSUPP;
Viresh Kumar8d4d4e92015-06-12 17:10:38 +0530234}
Shawn Guod6561bb2013-02-21 11:04:45 +0000235#endif
236
Nishanth Menone1f60b22010-10-13 00:13:10 +0200237#endif /* __LINUX_OPP_H__ */