xref: /openbmc/linux/include/soc/tegra/pmc.h (revision 79a93295)
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 #ifdef CONFIG_PM_SLEEP
30 enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void);
31 void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode);
32 void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode);
33 #endif /* CONFIG_PM_SLEEP */
34 
35 #ifdef CONFIG_SMP
36 bool tegra_pmc_cpu_is_powered(unsigned int cpuid);
37 int tegra_pmc_cpu_power_on(unsigned int cpuid);
38 int tegra_pmc_cpu_remove_clamping(unsigned int cpuid);
39 #endif /* CONFIG_SMP */
40 
41 /*
42  * powergate and I/O rail APIs
43  */
44 
45 #define TEGRA_POWERGATE_CPU	0
46 #define TEGRA_POWERGATE_3D	1
47 #define TEGRA_POWERGATE_VENC	2
48 #define TEGRA_POWERGATE_PCIE	3
49 #define TEGRA_POWERGATE_VDEC	4
50 #define TEGRA_POWERGATE_L2	5
51 #define TEGRA_POWERGATE_MPE	6
52 #define TEGRA_POWERGATE_HEG	7
53 #define TEGRA_POWERGATE_SATA	8
54 #define TEGRA_POWERGATE_CPU1	9
55 #define TEGRA_POWERGATE_CPU2	10
56 #define TEGRA_POWERGATE_CPU3	11
57 #define TEGRA_POWERGATE_CELP	12
58 #define TEGRA_POWERGATE_3D1	13
59 #define TEGRA_POWERGATE_CPU0	14
60 #define TEGRA_POWERGATE_C0NC	15
61 #define TEGRA_POWERGATE_C1NC	16
62 #define TEGRA_POWERGATE_SOR	17
63 #define TEGRA_POWERGATE_DIS	18
64 #define TEGRA_POWERGATE_DISB	19
65 #define TEGRA_POWERGATE_XUSBA	20
66 #define TEGRA_POWERGATE_XUSBB	21
67 #define TEGRA_POWERGATE_XUSBC	22
68 #define TEGRA_POWERGATE_VIC	23
69 #define TEGRA_POWERGATE_IRAM	24
70 #define TEGRA_POWERGATE_NVDEC	25
71 #define TEGRA_POWERGATE_NVJPG	26
72 #define TEGRA_POWERGATE_AUD	27
73 #define TEGRA_POWERGATE_DFD	28
74 #define TEGRA_POWERGATE_VE2	29
75 #define TEGRA_POWERGATE_MAX	TEGRA_POWERGATE_VE2
76 
77 #define TEGRA_POWERGATE_3D0	TEGRA_POWERGATE_3D
78 
79 /**
80  * enum tegra_io_pad - I/O pad group identifier
81  *
82  * I/O pins on Tegra SoCs are grouped into so-called I/O pads. Each such pad
83  * can be used to control the common voltage signal level and power state of
84  * the pins of the given pad.
85  */
86 enum tegra_io_pad {
87 	TEGRA_IO_PAD_AUDIO,
88 	TEGRA_IO_PAD_AUDIO_HV,
89 	TEGRA_IO_PAD_BB,
90 	TEGRA_IO_PAD_CAM,
91 	TEGRA_IO_PAD_COMP,
92 	TEGRA_IO_PAD_CSIA,
93 	TEGRA_IO_PAD_CSIB,
94 	TEGRA_IO_PAD_CSIC,
95 	TEGRA_IO_PAD_CSID,
96 	TEGRA_IO_PAD_CSIE,
97 	TEGRA_IO_PAD_CSIF,
98 	TEGRA_IO_PAD_DBG,
99 	TEGRA_IO_PAD_DEBUG_NONAO,
100 	TEGRA_IO_PAD_DMIC,
101 	TEGRA_IO_PAD_DP,
102 	TEGRA_IO_PAD_DSI,
103 	TEGRA_IO_PAD_DSIB,
104 	TEGRA_IO_PAD_DSIC,
105 	TEGRA_IO_PAD_DSID,
106 	TEGRA_IO_PAD_EMMC,
107 	TEGRA_IO_PAD_EMMC2,
108 	TEGRA_IO_PAD_GPIO,
109 	TEGRA_IO_PAD_HDMI,
110 	TEGRA_IO_PAD_HSIC,
111 	TEGRA_IO_PAD_HV,
112 	TEGRA_IO_PAD_LVDS,
113 	TEGRA_IO_PAD_MIPI_BIAS,
114 	TEGRA_IO_PAD_NAND,
115 	TEGRA_IO_PAD_PEX_BIAS,
116 	TEGRA_IO_PAD_PEX_CLK1,
117 	TEGRA_IO_PAD_PEX_CLK2,
118 	TEGRA_IO_PAD_PEX_CNTRL,
119 	TEGRA_IO_PAD_SDMMC1,
120 	TEGRA_IO_PAD_SDMMC3,
121 	TEGRA_IO_PAD_SDMMC4,
122 	TEGRA_IO_PAD_SPI,
123 	TEGRA_IO_PAD_SPI_HV,
124 	TEGRA_IO_PAD_SYS_DDC,
125 	TEGRA_IO_PAD_UART,
126 	TEGRA_IO_PAD_USB0,
127 	TEGRA_IO_PAD_USB1,
128 	TEGRA_IO_PAD_USB2,
129 	TEGRA_IO_PAD_USB3,
130 	TEGRA_IO_PAD_USB_BIAS,
131 };
132 
133 /* deprecated, use TEGRA_IO_PAD_{HDMI,LVDS} instead */
134 #define TEGRA_IO_RAIL_HDMI	TEGRA_IO_PAD_HDMI
135 #define TEGRA_IO_RAIL_LVDS	TEGRA_IO_PAD_LVDS
136 
137 /**
138  * enum tegra_io_pad_voltage - voltage level of the I/O pad's source rail
139  * @TEGRA_IO_PAD_1800000UV: 1.8 V
140  * @TEGRA_IO_PAD_3300000UV: 3.3 V
141  */
142 enum tegra_io_pad_voltage {
143 	TEGRA_IO_PAD_1800000UV,
144 	TEGRA_IO_PAD_3300000UV,
145 };
146 
147 #ifdef CONFIG_ARCH_TEGRA
148 int tegra_powergate_is_powered(unsigned int id);
149 int tegra_powergate_power_on(unsigned int id);
150 int tegra_powergate_power_off(unsigned int id);
151 int tegra_powergate_remove_clamping(unsigned int id);
152 
153 /* Must be called with clk disabled, and returns with clk enabled */
154 int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk,
155 				      struct reset_control *rst);
156 
157 int tegra_io_pad_power_enable(enum tegra_io_pad id);
158 int tegra_io_pad_power_disable(enum tegra_io_pad id);
159 int tegra_io_pad_set_voltage(enum tegra_io_pad id,
160 			     enum tegra_io_pad_voltage voltage);
161 int tegra_io_pad_get_voltage(enum tegra_io_pad id);
162 
163 /* deprecated, use tegra_io_pad_power_{enable,disable}() instead */
164 int tegra_io_rail_power_on(unsigned int id);
165 int tegra_io_rail_power_off(unsigned int id);
166 #else
167 static inline int tegra_powergate_is_powered(unsigned int id)
168 {
169 	return -ENOSYS;
170 }
171 
172 static inline int tegra_powergate_power_on(unsigned int id)
173 {
174 	return -ENOSYS;
175 }
176 
177 static inline int tegra_powergate_power_off(unsigned int id)
178 {
179 	return -ENOSYS;
180 }
181 
182 static inline int tegra_powergate_remove_clamping(unsigned int id)
183 {
184 	return -ENOSYS;
185 }
186 
187 static inline int tegra_powergate_sequence_power_up(unsigned int id,
188 						    struct clk *clk,
189 						    struct reset_control *rst)
190 {
191 	return -ENOSYS;
192 }
193 
194 static inline int tegra_io_pad_power_enable(enum tegra_io_pad id)
195 {
196 	return -ENOSYS;
197 }
198 
199 static inline int tegra_io_pad_power_disable(enum tegra_io_pad id)
200 {
201 	return -ENOSYS;
202 }
203 
204 static inline int tegra_io_pad_set_voltage(enum tegra_io_pad id,
205 					   enum tegra_io_pad_voltage voltage)
206 {
207 	return -ENOSYS;
208 }
209 
210 static inline int tegra_io_pad_get_voltage(enum tegra_io_pad id)
211 {
212 	return -ENOSYS;
213 }
214 
215 static inline int tegra_io_rail_power_on(unsigned int id)
216 {
217 	return -ENOSYS;
218 }
219 
220 static inline int tegra_io_rail_power_off(unsigned int id)
221 {
222 	return -ENOSYS;
223 }
224 #endif /* CONFIG_ARCH_TEGRA */
225 
226 #endif /* __SOC_TEGRA_PMC_H__ */
227