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