summaryrefslogtreecommitdiff
path: root/arch/arm/plat-omap/include/plat/opp.h
blob: 09beb8c252ed9112b5b3b9ed39551e791f831833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
 * OMAP OPP Interface
 *
 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
 *	Nishanth Menon
 *	Romit Dasgupta <romit@ti.com>
 * Copyright (C) 2009 Deep Root Systems, LLC.
 *	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 __ASM_ARM_OMAP_OPP_H
#define __ASM_ARM_OMAP_OPP_H

#include <linux/err.h>
#include <linux/cpufreq.h>
#include <linux/clk.h>

#include <plat/common.h>
#include <plat/voltage.h>

/**
 * struct omap_opp_def - OMAP OPP Definition
 * @enabled:	True/false - is this OPP enabled/disabled by default
 * @freq:	Frequency in hertz corresponding to this OPP
 * @u_volt:	Nominal voltage in microvolts corresponding to this OPP
 *
 * OMAP SOCs have a standard set of tuples consisting of frequency and voltage
 * pairs that the device will support per voltage domain. This is called
 * Operating Points or OPP. The actual definitions of OMAP Operating Points
 * varies over silicon within the same family of devices. For a specific
 * domain, you can have a set of {frequency, voltage} pairs and this is denoted
 * by an array of omap_opp_def. As the kernel boots and more information is
 * available, a set of these are activated based on the precise nature of
 * device the kernel boots up on. It is interesting to remember that each IP
 * which belongs to a voltage domain may define their own set of OPPs on top
 * of this - but this is handled by the appropriate driver.
 */
struct omap_opp_def {
	char *hwmod_name;

	unsigned long freq;
	unsigned long u_volt;

	bool enabled;
};

/*
 * Initialization wrapper used to define an OPP.
 * To point at the end of a terminator of a list of OPPs,
 * use OMAP_OPP_DEF(0, 0, 0)
 */
#define OMAP_OPP_DEF(_hwmod_name, _enabled, _freq, _uv) \
{						\
	.hwmod_name	= _hwmod_name,		\
	.enabled	= _enabled,		\
	.freq		= _freq,		\
	.u_volt		= _uv,			\
}

struct omap_opp;

#ifdef CONFIG_PM

unsigned long opp_get_voltage(const struct omap_opp *opp);

unsigned long opp_get_freq(const struct omap_opp *opp);

int opp_get_opp_count(struct device *dev);

struct omap_opp *opp_find_freq_exact(struct device *dev,
				     unsigned long freq, bool enabled);

struct omap_opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);

struct omap_opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);

struct omap_opp *opp_find_voltage(struct device *dev, unsigned long volt,
				  unsigned long hack_freq);

int opp_set_rate(struct device *dev, unsigned long freq);

unsigned long opp_get_rate(struct device *dev);

void opp_populate_rate_fns(struct device *dev,
		int (*set_rate)(struct device *dev, unsigned long rate),
		unsigned long (*get_rate) (struct device *dev));

int opp_add(const struct omap_opp_def *opp_def);

int opp_enable(struct omap_opp *opp);

int opp_disable(struct omap_opp *opp);

struct omap_opp *__deprecated opp_find_by_opp_id(struct device *dev,
						  u8 opp_id);
u8 __deprecated opp_get_opp_id(struct omap_opp *opp);

void opp_init_cpufreq_table(struct device *dev,
			    struct cpufreq_frequency_table **table);

struct device **opp_init_voltage_params(struct voltagedomain *voltdm,
					int *dev_count);
#else
static inline unsigned long opp_get_voltage(const struct omap_opp *opp)
{
	return 0;
}

static inline unsigned long opp_get_freq(const struct omap_opp *opp)
{
	return 0;
}

static inline int opp_get_opp_count(struct device *dev)
{
	return 0;
}

static inline struct omap_opp *opp_find_freq_exact(struct device *dev,
						   unsigned long freq,
						   bool enabled)
{
	return ERR_PTR(-EINVAL);
}

static inline struct omap_opp *opp_find_freq_floor(struct device *dev,
						   unsigned long *freq)
{
	return ERR_PTR(-EINVAL);
}

static inline struct omap_opp *opp_find_freq_ceil(struct device *dev,
						  unsigned long *freq)
{
	return ERR_PTR(-EINVAL);
}

static inline struct omap_opp *opp_find_voltage(struct device *dev,
						unsigned long volt,
						unsigned long hack_freq)
{
	return ERR_PTR(-EINVAL);
}

static inline int opp_set_rate(struct device *dev, unsigned long freq)
{
	return -EINVAL;
}

static inline unsigned long opp_get_rate(struct device *dev)
{
	return 0;
}

static inline void opp_populate_rate_fns(struct device *dev,
		int (*set_rate)(struct device *dev, unsigned long rate),
		unsigned long (*get_rate) (struct device *dev))
{
	return;
}

static inline struct omap_opp *opp_add(struct omap_opp *oppl,
				       const struct omap_opp_def *opp_def)
{
	return ERR_PTR(-EINVAL);
}

static inline int opp_enable(struct omap_opp *opp)
{
	return 0;
}

static inline int opp_disable(struct omap_opp *opp)
{
	return 0;
}

static inline struct omap_opp *__deprecated
opp_find_by_opp_id(struct device *dev, u8 opp_id)
{
	return ERR_PTR(-EINVAL);
}

static inline u8 __deprecated opp_get_opp_id(struct omap_opp *opp)
{
	return 0;
}

static inline
void opp_init_cpufreq_table(struct device *dev,
			    struct cpufreq_frequency_table **table)
{
}

static inline struct device **opp_init_voltage_params(
			struct voltagedomain *voltdm, int *dev_count)
{
	return ERR_PTR(-EINVAL);
}

#endif		/* CONFIG_PM */
#endif		/* __ASM_ARM_OMAP_OPP_H */