19c92ab61SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
27232398aSThierry Reding /*
37232398aSThierry Reding * Copyright (c) 2010 Google, Inc
47232398aSThierry Reding * Copyright (c) 2014 NVIDIA Corporation
57232398aSThierry Reding *
67232398aSThierry Reding * Author:
77232398aSThierry Reding * Colin Cross <ccross@google.com>
87232398aSThierry Reding */
97232398aSThierry Reding
107232398aSThierry Reding #ifndef __SOC_TEGRA_PMC_H__
117232398aSThierry Reding #define __SOC_TEGRA_PMC_H__
127232398aSThierry Reding
137232398aSThierry Reding #include <linux/reboot.h>
147232398aSThierry Reding
157232398aSThierry Reding #include <soc/tegra/pm.h>
167232398aSThierry Reding
177232398aSThierry Reding struct clk;
187232398aSThierry Reding struct reset_control;
197232398aSThierry Reding
2070293ed0SJon Hunter bool tegra_pmc_cpu_is_powered(unsigned int cpuid);
2170293ed0SJon Hunter int tegra_pmc_cpu_power_on(unsigned int cpuid);
2270293ed0SJon Hunter int tegra_pmc_cpu_remove_clamping(unsigned int cpuid);
237232398aSThierry Reding
247232398aSThierry Reding /*
257232398aSThierry Reding * powergate and I/O rail APIs
267232398aSThierry Reding */
277232398aSThierry Reding
287232398aSThierry Reding #define TEGRA_POWERGATE_CPU 0
297232398aSThierry Reding #define TEGRA_POWERGATE_3D 1
307232398aSThierry Reding #define TEGRA_POWERGATE_VENC 2
317232398aSThierry Reding #define TEGRA_POWERGATE_PCIE 3
327232398aSThierry Reding #define TEGRA_POWERGATE_VDEC 4
337232398aSThierry Reding #define TEGRA_POWERGATE_L2 5
347232398aSThierry Reding #define TEGRA_POWERGATE_MPE 6
357232398aSThierry Reding #define TEGRA_POWERGATE_HEG 7
367232398aSThierry Reding #define TEGRA_POWERGATE_SATA 8
377232398aSThierry Reding #define TEGRA_POWERGATE_CPU1 9
387232398aSThierry Reding #define TEGRA_POWERGATE_CPU2 10
397232398aSThierry Reding #define TEGRA_POWERGATE_CPU3 11
407232398aSThierry Reding #define TEGRA_POWERGATE_CELP 12
417232398aSThierry Reding #define TEGRA_POWERGATE_3D1 13
427232398aSThierry Reding #define TEGRA_POWERGATE_CPU0 14
437232398aSThierry Reding #define TEGRA_POWERGATE_C0NC 15
447232398aSThierry Reding #define TEGRA_POWERGATE_C1NC 16
457232398aSThierry Reding #define TEGRA_POWERGATE_SOR 17
467232398aSThierry Reding #define TEGRA_POWERGATE_DIS 18
477232398aSThierry Reding #define TEGRA_POWERGATE_DISB 19
487232398aSThierry Reding #define TEGRA_POWERGATE_XUSBA 20
497232398aSThierry Reding #define TEGRA_POWERGATE_XUSBB 21
507232398aSThierry Reding #define TEGRA_POWERGATE_XUSBC 22
517232398aSThierry Reding #define TEGRA_POWERGATE_VIC 23
527232398aSThierry Reding #define TEGRA_POWERGATE_IRAM 24
53c2fe4694SThierry Reding #define TEGRA_POWERGATE_NVDEC 25
54c2fe4694SThierry Reding #define TEGRA_POWERGATE_NVJPG 26
55c2fe4694SThierry Reding #define TEGRA_POWERGATE_AUD 27
56c2fe4694SThierry Reding #define TEGRA_POWERGATE_DFD 28
57c2fe4694SThierry Reding #define TEGRA_POWERGATE_VE2 29
58a3804512SJon Hunter #define TEGRA_POWERGATE_MAX TEGRA_POWERGATE_VE2
597232398aSThierry Reding
607232398aSThierry Reding #define TEGRA_POWERGATE_3D0 TEGRA_POWERGATE_3D
617232398aSThierry Reding
6221b49910SLaxman Dewangan /**
6321b49910SLaxman Dewangan * enum tegra_io_pad - I/O pad group identifier
6421b49910SLaxman Dewangan *
6521b49910SLaxman Dewangan * I/O pins on Tegra SoCs are grouped into so-called I/O pads. Each such pad
6621b49910SLaxman Dewangan * can be used to control the common voltage signal level and power state of
6721b49910SLaxman Dewangan * the pins of the given pad.
6821b49910SLaxman Dewangan */
6921b49910SLaxman Dewangan enum tegra_io_pad {
7021b49910SLaxman Dewangan TEGRA_IO_PAD_AUDIO,
7121b49910SLaxman Dewangan TEGRA_IO_PAD_AUDIO_HV,
7221b49910SLaxman Dewangan TEGRA_IO_PAD_BB,
7321b49910SLaxman Dewangan TEGRA_IO_PAD_CAM,
7421b49910SLaxman Dewangan TEGRA_IO_PAD_COMP,
75c641ec6eSThierry Reding TEGRA_IO_PAD_CONN,
7621b49910SLaxman Dewangan TEGRA_IO_PAD_CSIA,
7721b49910SLaxman Dewangan TEGRA_IO_PAD_CSIB,
7821b49910SLaxman Dewangan TEGRA_IO_PAD_CSIC,
7921b49910SLaxman Dewangan TEGRA_IO_PAD_CSID,
8021b49910SLaxman Dewangan TEGRA_IO_PAD_CSIE,
8121b49910SLaxman Dewangan TEGRA_IO_PAD_CSIF,
82eac9c48aSThierry Reding TEGRA_IO_PAD_CSIG,
83eac9c48aSThierry Reding TEGRA_IO_PAD_CSIH,
84eac9c48aSThierry Reding TEGRA_IO_PAD_DAP3,
85eac9c48aSThierry Reding TEGRA_IO_PAD_DAP5,
8621b49910SLaxman Dewangan TEGRA_IO_PAD_DBG,
8721b49910SLaxman Dewangan TEGRA_IO_PAD_DEBUG_NONAO,
8821b49910SLaxman Dewangan TEGRA_IO_PAD_DMIC,
89c641ec6eSThierry Reding TEGRA_IO_PAD_DMIC_HV,
9021b49910SLaxman Dewangan TEGRA_IO_PAD_DP,
9121b49910SLaxman Dewangan TEGRA_IO_PAD_DSI,
9221b49910SLaxman Dewangan TEGRA_IO_PAD_DSIB,
9321b49910SLaxman Dewangan TEGRA_IO_PAD_DSIC,
9421b49910SLaxman Dewangan TEGRA_IO_PAD_DSID,
95c641ec6eSThierry Reding TEGRA_IO_PAD_EDP,
9621b49910SLaxman Dewangan TEGRA_IO_PAD_EMMC,
9721b49910SLaxman Dewangan TEGRA_IO_PAD_EMMC2,
98eac9c48aSThierry Reding TEGRA_IO_PAD_EQOS,
9921b49910SLaxman Dewangan TEGRA_IO_PAD_GPIO,
100eac9c48aSThierry Reding TEGRA_IO_PAD_GP_PWM2,
101eac9c48aSThierry Reding TEGRA_IO_PAD_GP_PWM3,
10221b49910SLaxman Dewangan TEGRA_IO_PAD_HDMI,
103c641ec6eSThierry Reding TEGRA_IO_PAD_HDMI_DP0,
104c641ec6eSThierry Reding TEGRA_IO_PAD_HDMI_DP1,
105eac9c48aSThierry Reding TEGRA_IO_PAD_HDMI_DP2,
106eac9c48aSThierry Reding TEGRA_IO_PAD_HDMI_DP3,
10721b49910SLaxman Dewangan TEGRA_IO_PAD_HSIC,
10821b49910SLaxman Dewangan TEGRA_IO_PAD_HV,
10921b49910SLaxman Dewangan TEGRA_IO_PAD_LVDS,
11021b49910SLaxman Dewangan TEGRA_IO_PAD_MIPI_BIAS,
11121b49910SLaxman Dewangan TEGRA_IO_PAD_NAND,
11221b49910SLaxman Dewangan TEGRA_IO_PAD_PEX_BIAS,
113c641ec6eSThierry Reding TEGRA_IO_PAD_PEX_CLK_BIAS,
11421b49910SLaxman Dewangan TEGRA_IO_PAD_PEX_CLK1,
11521b49910SLaxman Dewangan TEGRA_IO_PAD_PEX_CLK2,
116c641ec6eSThierry Reding TEGRA_IO_PAD_PEX_CLK3,
11704fac241SVenkat Reddy Talla TEGRA_IO_PAD_PEX_CLK_2_BIAS,
11804fac241SVenkat Reddy Talla TEGRA_IO_PAD_PEX_CLK_2,
11921b49910SLaxman Dewangan TEGRA_IO_PAD_PEX_CNTRL,
120eac9c48aSThierry Reding TEGRA_IO_PAD_PEX_CTL2,
121*c9c4ddb2SPetlozu Pravareshwar TEGRA_IO_PAD_PEX_L0_RST,
122*c9c4ddb2SPetlozu Pravareshwar TEGRA_IO_PAD_PEX_L1_RST,
123*c9c4ddb2SPetlozu Pravareshwar TEGRA_IO_PAD_PEX_L5_RST,
124eac9c48aSThierry Reding TEGRA_IO_PAD_PWR_CTL,
12521b49910SLaxman Dewangan TEGRA_IO_PAD_SDMMC1,
126c641ec6eSThierry Reding TEGRA_IO_PAD_SDMMC1_HV,
127c641ec6eSThierry Reding TEGRA_IO_PAD_SDMMC2,
128c641ec6eSThierry Reding TEGRA_IO_PAD_SDMMC2_HV,
12921b49910SLaxman Dewangan TEGRA_IO_PAD_SDMMC3,
130c641ec6eSThierry Reding TEGRA_IO_PAD_SDMMC3_HV,
13121b49910SLaxman Dewangan TEGRA_IO_PAD_SDMMC4,
132eac9c48aSThierry Reding TEGRA_IO_PAD_SOC_GPIO10,
133eac9c48aSThierry Reding TEGRA_IO_PAD_SOC_GPIO12,
134eac9c48aSThierry Reding TEGRA_IO_PAD_SOC_GPIO13,
135eac9c48aSThierry Reding TEGRA_IO_PAD_SOC_GPIO53,
13621b49910SLaxman Dewangan TEGRA_IO_PAD_SPI,
13721b49910SLaxman Dewangan TEGRA_IO_PAD_SPI_HV,
13821b49910SLaxman Dewangan TEGRA_IO_PAD_SYS_DDC,
13921b49910SLaxman Dewangan TEGRA_IO_PAD_UART,
140eac9c48aSThierry Reding TEGRA_IO_PAD_UART4,
141eac9c48aSThierry Reding TEGRA_IO_PAD_UART5,
142c641ec6eSThierry Reding TEGRA_IO_PAD_UFS,
14321b49910SLaxman Dewangan TEGRA_IO_PAD_USB0,
14421b49910SLaxman Dewangan TEGRA_IO_PAD_USB1,
14521b49910SLaxman Dewangan TEGRA_IO_PAD_USB2,
14621b49910SLaxman Dewangan TEGRA_IO_PAD_USB3,
14721b49910SLaxman Dewangan TEGRA_IO_PAD_USB_BIAS,
14813136a47SAapo Vienamo TEGRA_IO_PAD_AO_HV,
14921b49910SLaxman Dewangan };
15021b49910SLaxman Dewangan
151bd737038SArnd Bergmann #ifdef CONFIG_SOC_TEGRA_PMC
15270293ed0SJon Hunter int tegra_powergate_power_on(unsigned int id);
15370293ed0SJon Hunter int tegra_powergate_power_off(unsigned int id);
15470293ed0SJon Hunter int tegra_powergate_remove_clamping(unsigned int id);
1557232398aSThierry Reding
1567232398aSThierry Reding /* Must be called with clk disabled, and returns with clk enabled */
15770293ed0SJon Hunter int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk,
1587232398aSThierry Reding struct reset_control *rst);
1597232398aSThierry Reding
16021b49910SLaxman Dewangan int tegra_io_pad_power_enable(enum tegra_io_pad id);
16121b49910SLaxman Dewangan int tegra_io_pad_power_disable(enum tegra_io_pad id);
16221b49910SLaxman Dewangan
163bd737038SArnd Bergmann void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode);
164bd737038SArnd Bergmann void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode);
165bd737038SArnd Bergmann
16641bafa69SDmitry Osipenko bool tegra_pmc_core_domain_state_synced(void);
16741bafa69SDmitry Osipenko
1687232398aSThierry Reding #else
tegra_powergate_power_on(unsigned int id)16970293ed0SJon Hunter static inline int tegra_powergate_power_on(unsigned int id)
1707232398aSThierry Reding {
1717232398aSThierry Reding return -ENOSYS;
1727232398aSThierry Reding }
1737232398aSThierry Reding
tegra_powergate_power_off(unsigned int id)17470293ed0SJon Hunter static inline int tegra_powergate_power_off(unsigned int id)
1757232398aSThierry Reding {
1767232398aSThierry Reding return -ENOSYS;
1777232398aSThierry Reding }
1787232398aSThierry Reding
tegra_powergate_remove_clamping(unsigned int id)17970293ed0SJon Hunter static inline int tegra_powergate_remove_clamping(unsigned int id)
1807232398aSThierry Reding {
1817232398aSThierry Reding return -ENOSYS;
1827232398aSThierry Reding }
1837232398aSThierry Reding
tegra_powergate_sequence_power_up(unsigned int id,struct clk * clk,struct reset_control * rst)18470293ed0SJon Hunter static inline int tegra_powergate_sequence_power_up(unsigned int id,
18570293ed0SJon Hunter struct clk *clk,
1867232398aSThierry Reding struct reset_control *rst)
1877232398aSThierry Reding {
1887232398aSThierry Reding return -ENOSYS;
1897232398aSThierry Reding }
1907232398aSThierry Reding
tegra_io_pad_power_enable(enum tegra_io_pad id)19121b49910SLaxman Dewangan static inline int tegra_io_pad_power_enable(enum tegra_io_pad id)
19221b49910SLaxman Dewangan {
19321b49910SLaxman Dewangan return -ENOSYS;
19421b49910SLaxman Dewangan }
19521b49910SLaxman Dewangan
tegra_io_pad_power_disable(enum tegra_io_pad id)19621b49910SLaxman Dewangan static inline int tegra_io_pad_power_disable(enum tegra_io_pad id)
19721b49910SLaxman Dewangan {
19821b49910SLaxman Dewangan return -ENOSYS;
19921b49910SLaxman Dewangan }
20021b49910SLaxman Dewangan
tegra_io_pad_get_voltage(enum tegra_io_pad id)20121b49910SLaxman Dewangan static inline int tegra_io_pad_get_voltage(enum tegra_io_pad id)
20221b49910SLaxman Dewangan {
20321b49910SLaxman Dewangan return -ENOSYS;
20421b49910SLaxman Dewangan }
20521b49910SLaxman Dewangan
tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode)206bd737038SArnd Bergmann static inline void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode)
207bd737038SArnd Bergmann {
208bd737038SArnd Bergmann }
209bd737038SArnd Bergmann
tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode)210bd737038SArnd Bergmann static inline void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode)
211bd737038SArnd Bergmann {
212bd737038SArnd Bergmann }
213bd737038SArnd Bergmann
tegra_pmc_core_domain_state_synced(void)21441bafa69SDmitry Osipenko static inline bool tegra_pmc_core_domain_state_synced(void)
21541bafa69SDmitry Osipenko {
21641bafa69SDmitry Osipenko return false;
21741bafa69SDmitry Osipenko }
21841bafa69SDmitry Osipenko
219bd737038SArnd Bergmann #endif /* CONFIG_SOC_TEGRA_PMC */
2207232398aSThierry Reding
221b1018eb7SArnd Bergmann #if defined(CONFIG_SOC_TEGRA_PMC) && defined(CONFIG_PM_SLEEP)
222b1018eb7SArnd Bergmann enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void);
223b1018eb7SArnd Bergmann #else
tegra_pmc_get_suspend_mode(void)224b1018eb7SArnd Bergmann static inline enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void)
225b1018eb7SArnd Bergmann {
226b1018eb7SArnd Bergmann return TEGRA_SUSPEND_NONE;
227b1018eb7SArnd Bergmann }
228b1018eb7SArnd Bergmann #endif
229b1018eb7SArnd Bergmann
2307232398aSThierry Reding #endif /* __SOC_TEGRA_PMC_H__ */
231