pm_opp.h 3.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Generic OPP Interface
 *
 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
 *	Nishanth Menon
 *	Romit Dasgupta
 *	Kevin Hilman
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef __LINUX_OPP_H__
#define __LINUX_OPP_H__

#include <linux/err.h>
18
#include <linux/notifier.h>
19

20
struct dev_pm_opp;
21
struct device;
22

23
enum dev_pm_opp_event {
24
	OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
25 26
};

27 28
#if defined(CONFIG_PM_OPP)

29
unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
30

31
unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
32

33
int dev_pm_opp_get_opp_count(struct device *dev);
34
unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
35

36 37 38
struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
					      unsigned long freq,
					      bool available);
39

40 41
struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
					      unsigned long *freq);
42

43 44
struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
					     unsigned long *freq);
45

46 47
int dev_pm_opp_add(struct device *dev, unsigned long freq,
		   unsigned long u_volt);
48
void dev_pm_opp_remove(struct device *dev, unsigned long freq);
49

50
int dev_pm_opp_enable(struct device *dev, unsigned long freq);
51

52
int dev_pm_opp_disable(struct device *dev, unsigned long freq);
53

54
struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
55
#else
56
static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
57 58 59 60
{
	return 0;
}

61
static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
62 63 64 65
{
	return 0;
}

66
static inline int dev_pm_opp_get_opp_count(struct device *dev)
67 68 69 70
{
	return 0;
}

71 72 73 74 75
static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
{
	return 0;
}

76
static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
77 78 79 80 81
					unsigned long freq, bool available)
{
	return ERR_PTR(-EINVAL);
}

82
static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
83 84 85 86 87
					unsigned long *freq)
{
	return ERR_PTR(-EINVAL);
}

88
static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
89 90 91 92 93
					unsigned long *freq)
{
	return ERR_PTR(-EINVAL);
}

94
static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
95 96 97 98 99
					unsigned long u_volt)
{
	return -EINVAL;
}

100 101 102 103
static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
{
}

104
static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
105 106 107 108
{
	return 0;
}

109
static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
110 111 112
{
	return 0;
}
113

114 115
static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
							struct device *dev)
116 117 118
{
	return ERR_PTR(-EINVAL);
}
119
#endif		/* CONFIG_PM_OPP */
120

121 122
#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
int of_init_opp_table(struct device *dev);
123
void of_free_opp_table(struct device *dev);
124 125 126 127 128
#else
static inline int of_init_opp_table(struct device *dev)
{
	return -EINVAL;
}
129 130 131 132

static inline void of_free_opp_table(struct device *dev)
{
}
133 134
#endif

135
#endif		/* __LINUX_OPP_H__ */