blob: 0330217abfad912506ae3c4153ff93ee6ee84c21 [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 {
MyungJoo Ham03ca3702011-09-30 22:35:12 +020024 OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
25};
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);
Nishanth Menone1f60b22010-10-13 00:13:10 +020047
Nishanth Menon5d4879c2013-09-19 16:03:50 -050048int dev_pm_opp_enable(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020049
Nishanth Menon5d4879c2013-09-19 16:03:50 -050050int dev_pm_opp_disable(struct device *dev, unsigned long freq);
Nishanth Menone1f60b22010-10-13 00:13:10 +020051
Nishanth Menon5d4879c2013-09-19 16:03:50 -050052struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
Nishanth Menone1f60b22010-10-13 00:13:10 +020053#else
Nishanth Menon47d43ba2013-09-19 16:03:51 -050054static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
Nishanth Menone1f60b22010-10-13 00:13:10 +020055{
56 return 0;
57}
58
Nishanth Menon47d43ba2013-09-19 16:03:51 -050059static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
Nishanth Menone1f60b22010-10-13 00:13:10 +020060{
61 return 0;
62}
63
Nishanth Menon5d4879c2013-09-19 16:03:50 -050064static inline int dev_pm_opp_get_opp_count(struct device *dev)
Nishanth Menone1f60b22010-10-13 00:13:10 +020065{
66 return 0;
67}
68
Nishanth Menon47d43ba2013-09-19 16:03:51 -050069static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +020070 unsigned long freq, bool available)
71{
72 return ERR_PTR(-EINVAL);
73}
74
Nishanth Menon47d43ba2013-09-19 16:03:51 -050075static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +020076 unsigned long *freq)
77{
78 return ERR_PTR(-EINVAL);
79}
80
Nishanth Menon47d43ba2013-09-19 16:03:51 -050081static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
Nishanth Menone1f60b22010-10-13 00:13:10 +020082 unsigned long *freq)
83{
84 return ERR_PTR(-EINVAL);
85}
86
Nishanth Menon5d4879c2013-09-19 16:03:50 -050087static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
Nishanth Menone1f60b22010-10-13 00:13:10 +020088 unsigned long u_volt)
89{
90 return -EINVAL;
91}
92
Nishanth Menon5d4879c2013-09-19 16:03:50 -050093static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
Nishanth Menone1f60b22010-10-13 00:13:10 +020094{
95 return 0;
96}
97
Nishanth Menon5d4879c2013-09-19 16:03:50 -050098static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
Nishanth Menone1f60b22010-10-13 00:13:10 +020099{
100 return 0;
101}
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200102
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500103static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
104 struct device *dev)
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200105{
106 return ERR_PTR(-EINVAL);
107}
Tony Lindgrena96d69d2011-11-03 10:12:27 +0100108#endif /* CONFIG_PM_OPP */
Nishanth Menone1f60b22010-10-13 00:13:10 +0200109
Shawn Guod6561bb2013-02-21 11:04:45 +0000110#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
111int of_init_opp_table(struct device *dev);
112#else
113static inline int of_init_opp_table(struct device *dev)
114{
115 return -EINVAL;
116}
117#endif
118
Nishanth Menone1f60b22010-10-13 00:13:10 +0200119#endif /* __LINUX_OPP_H__ */