aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/dvfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/dvfs.h')
-rw-r--r--arch/arm/mach-tegra/dvfs.h180
1 files changed, 180 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/dvfs.h b/arch/arm/mach-tegra/dvfs.h
new file mode 100644
index 00000000000..eaecf425fe8
--- /dev/null
+++ b/arch/arm/mach-tegra/dvfs.h
@@ -0,0 +1,180 @@
1/*
2 *
3 * Copyright (C) 2010 Google, Inc.
4 *
5 * Author:
6 * Colin Cross <ccross@google.com>
7 *
8 * Copyright (C) 2010-2011 NVIDIA Corporation.
9 *
10 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and
12 * may be copied, distributed, and modified under those terms.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 */
20
21#ifndef _TEGRA_DVFS_H_
22#define _TEGRA_DVFS_H_
23
24#define MAX_DVFS_FREQS 18
25#define DVFS_RAIL_STATS_TOP_BIN 40
26
27struct clk;
28struct dvfs_rail;
29
30/*
31 * dvfs_relationship between to rails, "from" and "to"
32 * when the rail changes, it will call dvfs_rail_update on the rails
33 * in the relationship_to list.
34 * when determining the voltage to set a rail to, it will consider each
35 * rail in the relationship_from list.
36 */
37struct dvfs_relationship {
38 struct dvfs_rail *to;
39 struct dvfs_rail *from;
40 int (*solve)(struct dvfs_rail *, struct dvfs_rail *);
41
42 struct list_head to_node; /* node in relationship_to list */
43 struct list_head from_node; /* node in relationship_from list */
44 bool solved_at_nominal;
45};
46
47struct rail_stats {
48 ktime_t time_at_mv[DVFS_RAIL_STATS_TOP_BIN + 1];
49 ktime_t last_update;
50 int last_index;
51 bool off;
52};
53
54struct dvfs_rail {
55 const char *reg_id;
56 int min_millivolts;
57 int max_millivolts;
58 int nominal_millivolts;
59 int step;
60 bool jmp_to_zero;
61 bool disabled;
62 bool updating;
63 bool resolving_to;
64
65 struct list_head node; /* node in dvfs_rail_list */
66 struct list_head dvfs; /* list head of attached dvfs clocks */
67 struct list_head relationships_to;
68 struct list_head relationships_from;
69 struct regulator *reg;
70 int millivolts;
71 int new_millivolts;
72 bool suspended;
73 struct rail_stats stats;
74};
75
76enum dvfs_alt_freqs {
77 ALT_FREQS_NOT_SUPPORTED = 0,
78 ALT_FREQS_DISABLED,
79 ALT_FREQS_ENABLED,
80};
81
82struct dvfs {
83 /* Used only by tegra2_clock.c */
84 const char *clk_name;
85 int speedo_id;
86 int process_id;
87
88 /* Must be initialized before tegra_dvfs_init */
89 int freqs_mult;
90 unsigned long freqs[MAX_DVFS_FREQS];
91 unsigned long alt_freqs[MAX_DVFS_FREQS];
92 const int *millivolts;
93 struct dvfs_rail *dvfs_rail;
94 bool auto_dvfs;
95 enum dvfs_alt_freqs alt_freqs_state;
96
97 /* Filled in by tegra_dvfs_init */
98 int max_millivolts;
99 int num_freqs;
100
101 int cur_millivolts;
102 unsigned long cur_rate;
103 struct list_head node;
104 struct list_head debug_node;
105 struct list_head reg_node;
106};
107
108extern struct dvfs_rail *tegra_cpu_rail;
109
110#ifdef CONFIG_TEGRA_SILICON_PLATFORM
111void tegra_soc_init_dvfs(void);
112int tegra_enable_dvfs_on_clk(struct clk *c, struct dvfs *d);
113int dvfs_debugfs_init(struct dentry *clk_debugfs_root);
114int tegra_dvfs_late_init(void);
115int tegra_dvfs_init_rails(struct dvfs_rail *dvfs_rails[], int n);
116void tegra_dvfs_add_relationships(struct dvfs_relationship *rels, int n);
117void tegra_dvfs_rail_enable(struct dvfs_rail *rail);
118void tegra_dvfs_rail_disable(struct dvfs_rail *rail);
119bool tegra_dvfs_rail_updating(struct clk *clk);
120void tegra_dvfs_rail_off(struct dvfs_rail *rail, ktime_t now);
121void tegra_dvfs_rail_on(struct dvfs_rail *rail, ktime_t now);
122void tegra_dvfs_rail_pause(struct dvfs_rail *rail, ktime_t delta, bool on);
123struct dvfs_rail *tegra_dvfs_get_rail_by_name(const char *reg_id);
124int tegra_dvfs_predict_millivolts(struct clk *c, unsigned long rate);
125void tegra_dvfs_core_cap_enable(bool enable);
126void tegra_dvfs_core_cap_level_set(int level);
127int tegra_dvfs_alt_freqs_set(struct dvfs *d, bool enable);
128void tegra_cpu_dvfs_alter(int edp_thermal_index, bool before_clk_update);
129#else
130static inline void tegra_soc_init_dvfs(void)
131{}
132static inline int tegra_enable_dvfs_on_clk(struct clk *c, struct dvfs *d)
133{ return 0; }
134static inline int dvfs_debugfs_init(struct dentry *clk_debugfs_root)
135{ return 0; }
136static inline int tegra_dvfs_late_init(void)
137{ return 0; }
138static inline int tegra_dvfs_init_rails(struct dvfs_rail *dvfs_rails[], int n)
139{ return 0; }
140static inline void tegra_dvfs_add_relationships(struct dvfs_relationship *rels, int n)
141{}
142static inline void tegra_dvfs_rail_enable(struct dvfs_rail *rail)
143{}
144static inline void tegra_dvfs_rail_disable(struct dvfs_rail *rail)
145{}
146static inline bool tegra_dvfs_rail_updating(struct clk *clk)
147{ return false; }
148static inline void tegra_dvfs_rail_off(struct dvfs_rail *rail, ktime_t now)
149{}
150static inline void tegra_dvfs_rail_on(struct dvfs_rail *rail, ktime_t now)
151{}
152static inline void tegra_dvfs_rail_pause(
153 struct dvfs_rail *rail, ktime_t delta, bool on)
154{}
155static inline struct dvfs_rail *tegra_dvfs_get_rail_by_name(const char *reg_id)
156{ return NULL; }
157static inline int tegra_dvfs_predict_millivolts(struct clk *c, unsigned long rate)
158{ return 0; }
159static inline void tegra_dvfs_core_cap_enable(bool enable)
160{}
161static inline void tegra_dvfs_core_cap_level_set(int level)
162{}
163static inline int tegra_dvfs_alt_freqs_set(struct dvfs *d, bool enable)
164{ return 0; }
165static inline void tegra_cpu_dvfs_alter(int edp_thermal_index,
166 bool before_clk_update)
167{}
168#endif
169
170#ifndef CONFIG_ARCH_TEGRA_2x_SOC
171int tegra_dvfs_rail_disable_prepare(struct dvfs_rail *rail);
172int tegra_dvfs_rail_post_enable(struct dvfs_rail *rail);
173#else
174static inline int tegra_dvfs_rail_disable_prepare(struct dvfs_rail *rail)
175{ return 0; }
176static inline int tegra_dvfs_rail_post_enable(struct dvfs_rail *rail)
177{ return 0; }
178#endif
179
180#endif