blob: 214e0ebcb84d85a80b31ee98bf4647eb25fd538c [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;
Paul Gortmaker313162d2012-01-30 11:46:54 -050022struct device;
Nishanth Menone1f60b22010-10-13 00:13:10 +020023
MyungJoo Ham03ca3702011-09-30 22:35:12 +020024enum opp_event {
25 OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
26};
27
Nishanth Menone1f60b22010-10-13 00:13:10 +020028#if defined(CONFIG_PM_OPP)
29
30unsigned long opp_get_voltage(struct opp *opp);
31
32unsigned long opp_get_freq(struct opp *opp);
33
34int opp_get_opp_count(struct device *dev);
35
36struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
37 bool available);
38
39struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
40
41struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
42
43int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
44
45int opp_enable(struct device *dev, unsigned long freq);
46
47int opp_disable(struct device *dev, unsigned long freq);
48
MyungJoo Ham03ca3702011-09-30 22:35:12 +020049struct srcu_notifier_head *opp_get_notifier(struct device *dev);
50
Shawn Guob496dfb2012-09-05 01:09:12 +020051#ifdef CONFIG_OF
52int of_init_opp_table(struct device *dev);
53#else
54static inline int of_init_opp_table(struct device *dev)
55{
56 return -EINVAL;
57}
58#endif /* CONFIG_OF */
Nishanth Menone1f60b22010-10-13 00:13:10 +020059#else
60static inline unsigned long opp_get_voltage(struct opp *opp)
61{
62 return 0;
63}
64
65static inline unsigned long opp_get_freq(struct opp *opp)
66{
67 return 0;
68}
69
70static inline int opp_get_opp_count(struct device *dev)
71{
72 return 0;
73}
74
75static inline struct opp *opp_find_freq_exact(struct device *dev,
76 unsigned long freq, bool available)
77{
78 return ERR_PTR(-EINVAL);
79}
80
81static inline struct opp *opp_find_freq_floor(struct device *dev,
82 unsigned long *freq)
83{
84 return ERR_PTR(-EINVAL);
85}
86
87static inline struct opp *opp_find_freq_ceil(struct device *dev,
88 unsigned long *freq)
89{
90 return ERR_PTR(-EINVAL);
91}
92
93static inline int opp_add(struct device *dev, unsigned long freq,
94 unsigned long u_volt)
95{
96 return -EINVAL;
97}
98
99static inline int opp_enable(struct device *dev, unsigned long freq)
100{
101 return 0;
102}
103
104static inline int opp_disable(struct device *dev, unsigned long freq)
105{
106 return 0;
107}
MyungJoo Ham03ca3702011-09-30 22:35:12 +0200108
Tony Lindgrena96d69d2011-11-03 10:12:27 +0100109static inline struct srcu_notifier_head *opp_get_notifier(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
115#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
116int opp_init_cpufreq_table(struct device *dev,
117 struct cpufreq_frequency_table **table);
Nishanth Menon99f381d2011-06-10 20:24:57 +0200118void opp_free_cpufreq_table(struct device *dev,
119 struct cpufreq_frequency_table **table);
Nishanth Menone1f60b22010-10-13 00:13:10 +0200120#else
121static inline int opp_init_cpufreq_table(struct device *dev,
122 struct cpufreq_frequency_table **table)
123{
124 return -EINVAL;
125}
Nishanth Menon99f381d2011-06-10 20:24:57 +0200126
127static inline
128void opp_free_cpufreq_table(struct device *dev,
129 struct cpufreq_frequency_table **table)
130{
131}
Nishanth Menone1f60b22010-10-13 00:13:10 +0200132#endif /* CONFIG_CPU_FREQ */
133
134#endif /* __LINUX_OPP_H__ */