blob: ee94b33080c207332e43291caaf240a62541a919 [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>
18#include <linux/cpufreq.h>
MyungJoo Ham03ca3702011-09-30 22:35:12 +020019#include <linux/notifier.h>
Nishanth Menone1f60b22010-10-13 00:13:10 +020020
21struct opp;
22
MyungJoo Ham03ca3702011-09-30 22:35:12 +020023enum opp_event {
24 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
29unsigned long opp_get_voltage(struct opp *opp);
30
31unsigned long opp_get_freq(struct opp *opp);
32
33int opp_get_opp_count(struct device *dev);
34
35struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
36 bool available);
37
38struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
39
40struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
41
42int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
43
44int opp_enable(struct device *dev, unsigned long freq);
45
46int opp_disable(struct device *dev, unsigned long freq);
47
MyungJoo Ham03ca3702011-09-30 22:35:12 +020048struct srcu_notifier_head *opp_get_notifier(struct device *dev);
49
Nishanth Menone1f60b22010-10-13 00:13:10 +020050#else
51static inline unsigned long opp_get_voltage(struct opp *opp)
52{
53 return 0;
54}
55
56static inline unsigned long opp_get_freq(struct opp *opp)
57{
58 return 0;
59}
60
61static inline int opp_get_opp_count(struct device *dev)
62{
63 return 0;
64}
65
66static inline struct opp *opp_find_freq_exact(struct device *dev,
67 unsigned long freq, bool available)
68{
69 return ERR_PTR(-EINVAL);
70}
71
72static inline struct opp *opp_find_freq_floor(struct device *dev,
73 unsigned long *freq)
74{
75 return ERR_PTR(-EINVAL);
76}
77
78static inline struct opp *opp_find_freq_ceil(struct device *dev,
79 unsigned long *freq)
80{
81 return ERR_PTR(-EINVAL);
82}
83
84static inline int opp_add(struct device *dev, unsigned long freq,
85 unsigned long u_volt)
86{
87 return -EINVAL;
88}
89
90static inline int opp_enable(struct device *dev, unsigned long freq)
91{
92 return 0;
93}
94
95static inline int opp_disable(struct device *dev, unsigned long freq)
96{
97 return 0;
98}
MyungJoo Ham03ca3702011-09-30 22:35:12 +020099
Tony Lindgrena96d69d2011-11-03 10:12:27 +0100100static inline struct srcu_notifier_head *opp_get_notifier(struct device *dev)
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200101{
102 return ERR_PTR(-EINVAL);
103}
Tony Lindgrena96d69d2011-11-03 10:12:27 +0100104#endif /* CONFIG_PM_OPP */
Nishanth Menone1f60b22010-10-13 00:13:10 +0200105
106#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
107int opp_init_cpufreq_table(struct device *dev,
108 struct cpufreq_frequency_table **table);
Nishanth Menon99f381d2011-06-10 20:24:57 +0200109void opp_free_cpufreq_table(struct device *dev,
110 struct cpufreq_frequency_table **table);
Nishanth Menone1f60b22010-10-13 00:13:10 +0200111#else
112static inline int opp_init_cpufreq_table(struct device *dev,
113 struct cpufreq_frequency_table **table)
114{
115 return -EINVAL;
116}
Nishanth Menon99f381d2011-06-10 20:24:57 +0200117
118static inline
119void opp_free_cpufreq_table(struct device *dev,
120 struct cpufreq_frequency_table **table)
121{
122}
Nishanth Menone1f60b22010-10-13 00:13:10 +0200123#endif /* CONFIG_CPU_FREQ */
124
125#endif /* __LINUX_OPP_H__ */