blob: cec2d45409142c5888142ac8e8c63a24590a21f9 [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;
Nishanth Menone1f60b22010-10-13 00:13:10 +020022
Nishanth Menon47d43ba2013-09-19 16:03:51 -050023enum dev_pm_opp_event {
Viresh Kumar129eec52014-11-27 08:54:06 +053024 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
MyungJoo Ham03ca3702011-09-30 22:35:12 +020025};
26
Nishanth Menone1f60b22010-10-13 00:13:10 +020027#if defined(CONFIG_PM_OPP)
28
Nishanth Menon47d43ba2013-09-19 16:03:51 -050029unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
Nishanth Menone1f60b22010-10-13 00:13:10 +020030
Nishanth Menon47d43ba2013-09-19 16:03:51 -050031unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
Nishanth Menone1f60b22010-10-13 00:13:10 +020032
Nishanth Menon5d4879c2013-09-19 16:03:50 -050033int dev_pm_opp_get_opp_count(struct device *dev);
Nishanth Menone1f60b22010-10-13 00:13:10 +020034
Nishanth Menon47d43ba2013-09-19 16:03:51 -050035struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
36 unsigned long freq,
37 bool available);
Nishanth Menone1f60b22010-10-13 00:13:10 +020038
Nishanth Menon47d43ba2013-09-19 16:03:51 -050039struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
40 unsigned long *freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020041
Nishanth Menon47d43ba2013-09-19 16:03:51 -050042struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
43 unsigned long *freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020044
Nishanth Menon5d4879c2013-09-19 16:03:50 -050045int dev_pm_opp_add(struct device *dev, unsigned long freq,
46 unsigned long u_volt);
Viresh Kumar129eec52014-11-27 08:54:06 +053047void dev_pm_opp_remove(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020048
Nishanth Menon5d4879c2013-09-19 16:03:50 -050049int dev_pm_opp_enable(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020050
Nishanth Menon5d4879c2013-09-19 16:03:50 -050051int dev_pm_opp_disable(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020052
Nishanth Menon5d4879c2013-09-19 16:03:50 -050053struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
Nishanth Menone1f60b22010-10-13 00:13:10 +020054#else
Nishanth Menon47d43ba2013-09-19 16:03:51 -050055static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
Nishanth Menone1f60b22010-10-13 00:13:10 +020056{
57 return 0;
58}
59
Nishanth Menon47d43ba2013-09-19 16:03:51 -050060static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
Nishanth Menone1f60b22010-10-13 00:13:10 +020061{
62 return 0;
63}
64
Nishanth Menon5d4879c2013-09-19 16:03:50 -050065static inline int dev_pm_opp_get_opp_count(struct device *dev)
Nishanth Menone1f60b22010-10-13 00:13:10 +020066{
67 return 0;
68}
69
Nishanth Menon47d43ba2013-09-19 16:03:51 -050070static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +020071 unsigned long freq, bool available)
72{
73 return ERR_PTR(-EINVAL);
74}
75
Nishanth Menon47d43ba2013-09-19 16:03:51 -050076static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +020077 unsigned long *freq)
78{
79 return ERR_PTR(-EINVAL);
80}
81
Nishanth Menon47d43ba2013-09-19 16:03:51 -050082static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +020083 unsigned long *freq)
84{
85 return ERR_PTR(-EINVAL);
86}
87
Nishanth Menon5d4879c2013-09-19 16:03:50 -050088static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
Nishanth Menone1f60b22010-10-13 00:13:10 +020089 unsigned long u_volt)
90{
91 return -EINVAL;
92}
93
Viresh Kumar129eec52014-11-27 08:54:06 +053094static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
95{
96}
97
Nishanth Menon5d4879c2013-09-19 16:03:50 -050098static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
Nishanth Menone1f60b22010-10-13 00:13:10 +020099{
100 return 0;
101}
102
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500103static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
Nishanth Menone1f60b22010-10-13 00:13:10 +0200104{
105 return 0;
106}
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200107
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500108static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
109 struct device *dev)
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200110{
111 return ERR_PTR(-EINVAL);
112}
Tony Lindgrena96d69d2011-11-03 10:12:27 +0100113#endif /* CONFIG_PM_OPP */
Nishanth Menone1f60b22010-10-13 00:13:10 +0200114
Shawn Guod6561bb2013-02-21 11:04:45 +0000115#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
116int of_init_opp_table(struct device *dev);
Viresh Kumar129eec52014-11-27 08:54:06 +0530117void of_free_opp_table(struct device *dev);
Shawn Guod6561bb2013-02-21 11:04:45 +0000118#else
119static inline int of_init_opp_table(struct device *dev)
120{
121 return -EINVAL;
122}
Viresh Kumar129eec52014-11-27 08:54:06 +0530123
124static inline void of_free_opp_table(struct device *dev)
125{
126}
Shawn Guod6561bb2013-02-21 11:04:45 +0000127#endif
128
Nishanth Menone1f60b22010-10-13 00:13:10 +0200129#endif /* __LINUX_OPP_H__ */