]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/pm_opp.h
Merge branch 'for-linus' of git://git.samba.org/sfrench/cifs-2.6
[mirror_ubuntu-bionic-kernel.git] / include / linux / pm_opp.h
CommitLineData
e1f60b29
NM
1/*
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>
03ca370f 19#include <linux/notifier.h>
e1f60b29 20
47d43ba7 21struct dev_pm_opp;
313162d0 22struct device;
e1f60b29 23
47d43ba7 24enum dev_pm_opp_event {
03ca370f
MH
25 OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
26};
27
e1f60b29
NM
28#if defined(CONFIG_PM_OPP)
29
47d43ba7 30unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
e1f60b29 31
47d43ba7 32unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
e1f60b29 33
5d4879cd 34int dev_pm_opp_get_opp_count(struct device *dev);
e1f60b29 35
47d43ba7
NM
36struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
37 unsigned long freq,
38 bool available);
e1f60b29 39
47d43ba7
NM
40struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
41 unsigned long *freq);
e1f60b29 42
47d43ba7
NM
43struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
44 unsigned long *freq);
e1f60b29 45
5d4879cd
NM
46int dev_pm_opp_add(struct device *dev, unsigned long freq,
47 unsigned long u_volt);
e1f60b29 48
5d4879cd 49int dev_pm_opp_enable(struct device *dev, unsigned long freq);
e1f60b29 50
5d4879cd 51int dev_pm_opp_disable(struct device *dev, unsigned long freq);
e1f60b29 52
5d4879cd 53struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
e1f60b29 54#else
47d43ba7 55static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
e1f60b29
NM
56{
57 return 0;
58}
59
47d43ba7 60static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
e1f60b29
NM
61{
62 return 0;
63}
64
5d4879cd 65static inline int dev_pm_opp_get_opp_count(struct device *dev)
e1f60b29
NM
66{
67 return 0;
68}
69
47d43ba7 70static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
e1f60b29
NM
71 unsigned long freq, bool available)
72{
73 return ERR_PTR(-EINVAL);
74}
75
47d43ba7 76static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
e1f60b29
NM
77 unsigned long *freq)
78{
79 return ERR_PTR(-EINVAL);
80}
81
47d43ba7 82static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
e1f60b29
NM
83 unsigned long *freq)
84{
85 return ERR_PTR(-EINVAL);
86}
87
5d4879cd 88static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
e1f60b29
NM
89 unsigned long u_volt)
90{
91 return -EINVAL;
92}
93
5d4879cd 94static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
e1f60b29
NM
95{
96 return 0;
97}
98
5d4879cd 99static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
e1f60b29
NM
100{
101 return 0;
102}
03ca370f 103
5d4879cd
NM
104static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
105 struct device *dev)
03ca370f
MH
106{
107 return ERR_PTR(-EINVAL);
108}
a96d69d1 109#endif /* CONFIG_PM_OPP */
e1f60b29 110
d6561bb2
SG
111#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
112int of_init_opp_table(struct device *dev);
113#else
114static inline int of_init_opp_table(struct device *dev)
115{
116 return -EINVAL;
117}
118#endif
119
e1f60b29 120#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
5d4879cd 121int dev_pm_opp_init_cpufreq_table(struct device *dev,
e1f60b29 122 struct cpufreq_frequency_table **table);
5d4879cd 123void dev_pm_opp_free_cpufreq_table(struct device *dev,
99f381d3 124 struct cpufreq_frequency_table **table);
e1f60b29 125#else
5d4879cd 126static inline int dev_pm_opp_init_cpufreq_table(struct device *dev,
e1f60b29
NM
127 struct cpufreq_frequency_table **table)
128{
129 return -EINVAL;
130}
99f381d3
NM
131
132static inline
5d4879cd 133void dev_pm_opp_free_cpufreq_table(struct device *dev,
99f381d3
NM
134 struct cpufreq_frequency_table **table)
135{
136}
e1f60b29
NM
137#endif /* CONFIG_CPU_FREQ */
138
139#endif /* __LINUX_OPP_H__ */