xref: /openbmc/linux/include/soc/tegra/pmc.h (revision 5ff32883)
1 /*
2  * Copyright (c) 2010 Google, Inc
3  * Copyright (c) 2014 NVIDIA Corporation
4  *
5  * Author:
6  *	Colin Cross <ccross@google.com>
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  */
18 
19 #ifndef __SOC_TEGRA_PMC_H__
20 #define __SOC_TEGRA_PMC_H__
21 
22 #include <linux/reboot.h>
23 
24 #include <soc/tegra/pm.h>
25 
26 struct clk;
27 struct reset_control;
28 
29 bool tegra_pmc_cpu_is_powered(unsigned int cpuid);
30 int tegra_pmc_cpu_power_on(unsigned int cpuid);
31 int tegra_pmc_cpu_remove_clamping(unsigned int cpuid);
32 
33 /*
34  * powergate and I/O rail APIs
35  */
36 
37 #define TEGRA_POWERGATE_CPU	0
38 #define TEGRA_POWERGATE_3D	1
39 #define TEGRA_POWERGATE_VENC	2
40 #define TEGRA_POWERGATE_PCIE	3
41 #define TEGRA_POWERGATE_VDEC	4
42 #define TEGRA_POWERGATE_L2	5
43 #define TEGRA_POWERGATE_MPE	6
44 #define TEGRA_POWERGATE_HEG	7
45 #define TEGRA_POWERGATE_SATA	8
46 #define TEGRA_POWERGATE_CPU1	9
47 #define TEGRA_POWERGATE_CPU2	10
48 #define TEGRA_POWERGATE_CPU3	11
49 #define TEGRA_POWERGATE_CELP	12
50 #define TEGRA_POWERGATE_3D1	13
51 #define TEGRA_POWERGATE_CPU0	14
52 #define TEGRA_POWERGATE_C0NC	15
53 #define TEGRA_POWERGATE_C1NC	16
54 #define TEGRA_POWERGATE_SOR	17
55 #define TEGRA_POWERGATE_DIS	18
56 #define TEGRA_POWERGATE_DISB	19
57 #define TEGRA_POWERGATE_XUSBA	20
58 #define TEGRA_POWERGATE_XUSBB	21
59 #define TEGRA_POWERGATE_XUSBC	22
60 #define TEGRA_POWERGATE_VIC	23
61 #define TEGRA_POWERGATE_IRAM	24
62 #define TEGRA_POWERGATE_NVDEC	25
63 #define TEGRA_POWERGATE_NVJPG	26
64 #define TEGRA_POWERGATE_AUD	27
65 #define TEGRA_POWERGATE_DFD	28
66 #define TEGRA_POWERGATE_VE2	29
67 #define TEGRA_POWERGATE_MAX	TEGRA_POWERGATE_VE2
68 
69 #define TEGRA_POWERGATE_3D0	TEGRA_POWERGATE_3D
70 
71 /**
72  * enum tegra_io_pad - I/O pad group identifier
73  *
74  * I/O pins on Tegra SoCs are grouped into so-called I/O pads. Each such pad
75  * can be used to control the common voltage signal level and power state of
76  * the pins of the given pad.
77  */
78 enum tegra_io_pad {
79 	TEGRA_IO_PAD_AUDIO,
80 	TEGRA_IO_PAD_AUDIO_HV,
81 	TEGRA_IO_PAD_BB,
82 	TEGRA_IO_PAD_CAM,
83 	TEGRA_IO_PAD_COMP,
84 	TEGRA_IO_PAD_CONN,
85 	TEGRA_IO_PAD_CSIA,
86 	TEGRA_IO_PAD_CSIB,
87 	TEGRA_IO_PAD_CSIC,
88 	TEGRA_IO_PAD_CSID,
89 	TEGRA_IO_PAD_CSIE,
90 	TEGRA_IO_PAD_CSIF,
91 	TEGRA_IO_PAD_CSIG,
92 	TEGRA_IO_PAD_CSIH,
93 	TEGRA_IO_PAD_DAP3,
94 	TEGRA_IO_PAD_DAP5,
95 	TEGRA_IO_PAD_DBG,
96 	TEGRA_IO_PAD_DEBUG_NONAO,
97 	TEGRA_IO_PAD_DMIC,
98 	TEGRA_IO_PAD_DMIC_HV,
99 	TEGRA_IO_PAD_DP,
100 	TEGRA_IO_PAD_DSI,
101 	TEGRA_IO_PAD_DSIB,
102 	TEGRA_IO_PAD_DSIC,
103 	TEGRA_IO_PAD_DSID,
104 	TEGRA_IO_PAD_EDP,
105 	TEGRA_IO_PAD_E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EGRA_IO_PAD_SYS_DDC,
147 	TEGRA_IO_PAD_UART,
148 	TEGRA_IO_PAD_UART4,
149 	TEGRA_IO_PAD_UART5,
150 	TEGRA_IO_PAD_UFS,
151 	TEGRA_IO_PAD_USB0,
152 	TEGRA_IO_PAD_USB1,
153 	TEGRA_IO_PAD_USB2,
154 	TEGRA_IO_PAD_USB3,
155 	TEGRA_IO_PAD_USB_BIAS,
156 	TEGRA_IO_PAD_AO_HV,
157 };
158 
159 /* deprecated, use TEGRA_IO_PAD_{HDMI,LVDS} instead */
160 #define TEGRA_IO_RAIL_HDMI	TEGRA_IO_PAD_HDMI
161 #define TEGRA_IO_RAIL_LVDS	TEGRA_IO_PAD_LVDS
162 
163 #ifdef CONFIG_SOC_TEGRA_PMC
164 int tegra_powergate_is_powered(unsigned int id);
165 int tegra_powergate_power_on(unsigned int id);
166 int tegra_powergate_power_off(unsigned int id);
167 int tegra_powergate_remove_clamping(unsigned int id);
168 
169 /* Must be called with clk disabled, and returns with clk enabled */
170 int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk,
171 				      struct reset_control *rst);
172 
173 int tegra_io_pad_power_enable(enum tegra_io_pad id);
174 int tegra_io_pad_power_disable(enum tegra_io_pad id);
175 
176 /* deprecated, use tegra_io_pad_power_{enable,disable}() instead */
177 int tegra_io_rail_power_on(unsigned int id);
178 int tegra_io_rail_power_off(unsigned int id);
179 
180 enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void);
181 void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode);
182 void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode);
183 
184 #else
185 static inline int tegra_powergate_is_powered(unsigned int id)
186 {
187 	return -ENOSYS;
188 }
189 
190 static inline int tegra_powergate_power_on(unsigned int id)
191 {
192 	return -ENOSYS;
193 }
194 
195 static inline int tegra_powergate_power_off(unsigned int id)
196 {
197 	return -ENOSYS;
198 }
199 
200 static inline int tegra_powergate_remove_clamping(unsigned int id)
201 {
202 	return -ENOSYS;
203 }
204 
205 static inline int tegra_powergate_sequence_power_up(unsigned int id,
206 						    struct clk *clk,
207 						    struct reset_control *rst)
208 {
209 	return -ENOSYS;
210 }
211 
212 static inline int tegra_io_pad_power_enable(enum tegra_io_pad id)
213 {
214 	return -ENOSYS;
215 }
216 
217 static inline int tegra_io_pad_power_disable(enum tegra_io_pad id)
218 {
219 	return -ENOSYS;
220 }
221 
222 static inline int tegra_io_pad_get_voltage(enum tegra_io_pad id)
223 {
224 	return -ENOSYS;
225 }
226 
227 static inline int tegra_io_rail_power_on(unsigned int id)
228 {
229 	return -ENOSYS;
230 }
231 
232 static inline int tegra_io_rail_power_off(unsigned int id)
233 {
234 	return -ENOSYS;
235 }
236 
237 static inline enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void)
238 {
239 	return TEGRA_SUSPEND_NONE;
240 }
241 
242 static inline void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode)
243 {
244 }
245 
246 static inline void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode)
247 {
248 }
249 
250 #endif /* CONFIG_SOC_TEGRA_PMC */
251 
252 #endif /* __SOC_TEGRA_PMC_H__ */
253