162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2010 Google, Inc
462306a36Sopenharmony_ci * Copyright (c) 2014 NVIDIA Corporation
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Author:
762306a36Sopenharmony_ci *	Colin Cross <ccross@google.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __SOC_TEGRA_PMC_H__
1162306a36Sopenharmony_ci#define __SOC_TEGRA_PMC_H__
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <linux/reboot.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <soc/tegra/pm.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_cistruct clk;
1862306a36Sopenharmony_cistruct reset_control;
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cibool tegra_pmc_cpu_is_powered(unsigned int cpuid);
2162306a36Sopenharmony_ciint tegra_pmc_cpu_power_on(unsigned int cpuid);
2262306a36Sopenharmony_ciint tegra_pmc_cpu_remove_clamping(unsigned int cpuid);
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/*
2562306a36Sopenharmony_ci * powergate and I/O rail APIs
2662306a36Sopenharmony_ci */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define TEGRA_POWERGATE_CPU	0
2962306a36Sopenharmony_ci#define TEGRA_POWERGATE_3D	1
3062306a36Sopenharmony_ci#define TEGRA_POWERGATE_VENC	2
3162306a36Sopenharmony_ci#define TEGRA_POWERGATE_PCIE	3
3262306a36Sopenharmony_ci#define TEGRA_POWERGATE_VDEC	4
3362306a36Sopenharmony_ci#define TEGRA_POWERGATE_L2	5
3462306a36Sopenharmony_ci#define TEGRA_POWERGATE_MPE	6
3562306a36Sopenharmony_ci#define TEGRA_POWERGATE_HEG	7
3662306a36Sopenharmony_ci#define TEGRA_POWERGATE_SATA	8
3762306a36Sopenharmony_ci#define TEGRA_POWERGATE_CPU1	9
3862306a36Sopenharmony_ci#define TEGRA_POWERGATE_CPU2	10
3962306a36Sopenharmony_ci#define TEGRA_POWERGATE_CPU3	11
4062306a36Sopenharmony_ci#define TEGRA_POWERGATE_CELP	12
4162306a36Sopenharmony_ci#define TEGRA_POWERGATE_3D1	13
4262306a36Sopenharmony_ci#define TEGRA_POWERGATE_CPU0	14
4362306a36Sopenharmony_ci#define TEGRA_POWERGATE_C0NC	15
4462306a36Sopenharmony_ci#define TEGRA_POWERGATE_C1NC	16
4562306a36Sopenharmony_ci#define TEGRA_POWERGATE_SOR	17
4662306a36Sopenharmony_ci#define TEGRA_POWERGATE_DIS	18
4762306a36Sopenharmony_ci#define TEGRA_POWERGATE_DISB	19
4862306a36Sopenharmony_ci#define TEGRA_POWERGATE_XUSBA	20
4962306a36Sopenharmony_ci#define TEGRA_POWERGATE_XUSBB	21
5062306a36Sopenharmony_ci#define TEGRA_POWERGATE_XUSBC	22
5162306a36Sopenharmony_ci#define TEGRA_POWERGATE_VIC	23
5262306a36Sopenharmony_ci#define TEGRA_POWERGATE_IRAM	24
5362306a36Sopenharmony_ci#define TEGRA_POWERGATE_NVDEC	25
5462306a36Sopenharmony_ci#define TEGRA_POWERGATE_NVJPG	26
5562306a36Sopenharmony_ci#define TEGRA_POWERGATE_AUD	27
5662306a36Sopenharmony_ci#define TEGRA_POWERGATE_DFD	28
5762306a36Sopenharmony_ci#define TEGRA_POWERGATE_VE2	29
5862306a36Sopenharmony_ci#define TEGRA_POWERGATE_MAX	TEGRA_POWERGATE_VE2
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define TEGRA_POWERGATE_3D0	TEGRA_POWERGATE_3D
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci/**
6362306a36Sopenharmony_ci * enum tegra_io_pad - I/O pad group identifier
6462306a36Sopenharmony_ci *
6562306a36Sopenharmony_ci * I/O pins on Tegra SoCs are grouped into so-called I/O pads. Each such pad
6662306a36Sopenharmony_ci * can be used to control the common voltage signal level and power state of
6762306a36Sopenharmony_ci * the pins of the given pad.
6862306a36Sopenharmony_ci */
6962306a36Sopenharmony_cienum tegra_io_pad {
7062306a36Sopenharmony_ci	TEGRA_IO_PAD_AUDIO,
7162306a36Sopenharmony_ci	TEGRA_IO_PAD_AUDIO_HV,
7262306a36Sopenharmony_ci	TEGRA_IO_PAD_BB,
7362306a36Sopenharmony_ci	TEGRA_IO_PAD_CAM,
7462306a36Sopenharmony_ci	TEGRA_IO_PAD_COMP,
7562306a36Sopenharmony_ci	TEGRA_IO_PAD_CONN,
7662306a36Sopenharmony_ci	TEGRA_IO_PAD_CSIA,
7762306a36Sopenharmony_ci	TEGRA_IO_PAD_CSIB,
7862306a36Sopenharmony_ci	TEGRA_IO_PAD_CSIC,
7962306a36Sopenharmony_ci	TEGRA_IO_PAD_CSID,
8062306a36Sopenharmony_ci	TEGRA_IO_PAD_CSIE,
8162306a36Sopenharmony_ci	TEGRA_IO_PAD_CSIF,
8262306a36Sopenharmony_ci	TEGRA_IO_PAD_CSIG,
8362306a36Sopenharmony_ci	TEGRA_IO_PAD_CSIH,
8462306a36Sopenharmony_ci	TEGRA_IO_PAD_DAP3,
8562306a36Sopenharmony_ci	TEGRA_IO_PAD_DAP5,
8662306a36Sopenharmony_ci	TEGRA_IO_PAD_DBG,
8762306a36Sopenharmony_ci	TEGRA_IO_PAD_DEBUG_NONAO,
8862306a36Sopenharmony_ci	TEGRA_IO_PAD_DMIC,
8962306a36Sopenharmony_ci	TEGRA_IO_PAD_DMIC_HV,
9062306a36Sopenharmony_ci	TEGRA_IO_PAD_DP,
9162306a36Sopenharmony_ci	TEGRA_IO_PAD_DSI,
9262306a36Sopenharmony_ci	TEGRA_IO_PAD_DSIB,
9362306a36Sopenharmony_ci	TEGRA_IO_PAD_DSIC,
9462306a36Sopenharmony_ci	TEGRA_IO_PAD_DSID,
9562306a36Sopenharmony_ci	TEGRA_IO_PAD_EDP,
9662306a36Sopenharmony_ci	TEGRA_IO_PAD_EMMC,
9762306a36Sopenharmony_ci	TEGRA_IO_PAD_EMMC2,
9862306a36Sopenharmony_ci	TEGRA_IO_PAD_EQOS,
9962306a36Sopenharmony_ci	TEGRA_IO_PAD_GPIO,
10062306a36Sopenharmony_ci	TEGRA_IO_PAD_GP_PWM2,
10162306a36Sopenharmony_ci	TEGRA_IO_PAD_GP_PWM3,
10262306a36Sopenharmony_ci	TEGRA_IO_PAD_HDMI,
10362306a36Sopenharmony_ci	TEGRA_IO_PAD_HDMI_DP0,
10462306a36Sopenharmony_ci	TEGRA_IO_PAD_HDMI_DP1,
10562306a36Sopenharmony_ci	TEGRA_IO_PAD_HDMI_DP2,
10662306a36Sopenharmony_ci	TEGRA_IO_PAD_HDMI_DP3,
10762306a36Sopenharmony_ci	TEGRA_IO_PAD_HSIC,
10862306a36Sopenharmony_ci	TEGRA_IO_PAD_HV,
10962306a36Sopenharmony_ci	TEGRA_IO_PAD_LVDS,
11062306a36Sopenharmony_ci	TEGRA_IO_PAD_MIPI_BIAS,
11162306a36Sopenharmony_ci	TEGRA_IO_PAD_NAND,
11262306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_BIAS,
11362306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CLK_BIAS,
11462306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CLK1,
11562306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CLK2,
11662306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CLK3,
11762306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CLK_2_BIAS,
11862306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CLK_2,
11962306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CNTRL,
12062306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_CTL2,
12162306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_L0_RST,
12262306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_L1_RST,
12362306a36Sopenharmony_ci	TEGRA_IO_PAD_PEX_L5_RST,
12462306a36Sopenharmony_ci	TEGRA_IO_PAD_PWR_CTL,
12562306a36Sopenharmony_ci	TEGRA_IO_PAD_SDMMC1,
12662306a36Sopenharmony_ci	TEGRA_IO_PAD_SDMMC1_HV,
12762306a36Sopenharmony_ci	TEGRA_IO_PAD_SDMMC2,
12862306a36Sopenharmony_ci	TEGRA_IO_PAD_SDMMC2_HV,
12962306a36Sopenharmony_ci	TEGRA_IO_PAD_SDMMC3,
13062306a36Sopenharmony_ci	TEGRA_IO_PAD_SDMMC3_HV,
13162306a36Sopenharmony_ci	TEGRA_IO_PAD_SDMMC4,
13262306a36Sopenharmony_ci	TEGRA_IO_PAD_SOC_GPIO10,
13362306a36Sopenharmony_ci	TEGRA_IO_PAD_SOC_GPIO12,
13462306a36Sopenharmony_ci	TEGRA_IO_PAD_SOC_GPIO13,
13562306a36Sopenharmony_ci	TEGRA_IO_PAD_SOC_GPIO53,
13662306a36Sopenharmony_ci	TEGRA_IO_PAD_SPI,
13762306a36Sopenharmony_ci	TEGRA_IO_PAD_SPI_HV,
13862306a36Sopenharmony_ci	TEGRA_IO_PAD_SYS_DDC,
13962306a36Sopenharmony_ci	TEGRA_IO_PAD_UART,
14062306a36Sopenharmony_ci	TEGRA_IO_PAD_UART4,
14162306a36Sopenharmony_ci	TEGRA_IO_PAD_UART5,
14262306a36Sopenharmony_ci	TEGRA_IO_PAD_UFS,
14362306a36Sopenharmony_ci	TEGRA_IO_PAD_USB0,
14462306a36Sopenharmony_ci	TEGRA_IO_PAD_USB1,
14562306a36Sopenharmony_ci	TEGRA_IO_PAD_USB2,
14662306a36Sopenharmony_ci	TEGRA_IO_PAD_USB3,
14762306a36Sopenharmony_ci	TEGRA_IO_PAD_USB_BIAS,
14862306a36Sopenharmony_ci	TEGRA_IO_PAD_AO_HV,
14962306a36Sopenharmony_ci};
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/* deprecated, use TEGRA_IO_PAD_{HDMI,LVDS} instead */
15262306a36Sopenharmony_ci#define TEGRA_IO_RAIL_HDMI	TEGRA_IO_PAD_HDMI
15362306a36Sopenharmony_ci#define TEGRA_IO_RAIL_LVDS	TEGRA_IO_PAD_LVDS
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci#ifdef CONFIG_SOC_TEGRA_PMC
15662306a36Sopenharmony_ciint tegra_powergate_power_on(unsigned int id);
15762306a36Sopenharmony_ciint tegra_powergate_power_off(unsigned int id);
15862306a36Sopenharmony_ciint tegra_powergate_remove_clamping(unsigned int id);
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci/* Must be called with clk disabled, and returns with clk enabled */
16162306a36Sopenharmony_ciint tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk,
16262306a36Sopenharmony_ci				      struct reset_control *rst);
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ciint tegra_io_pad_power_enable(enum tegra_io_pad id);
16562306a36Sopenharmony_ciint tegra_io_pad_power_disable(enum tegra_io_pad id);
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci/* deprecated, use tegra_io_pad_power_{enable,disable}() instead */
16862306a36Sopenharmony_ciint tegra_io_rail_power_on(unsigned int id);
16962306a36Sopenharmony_ciint tegra_io_rail_power_off(unsigned int id);
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_civoid tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode);
17262306a36Sopenharmony_civoid tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode);
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_cibool tegra_pmc_core_domain_state_synced(void);
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci#else
17762306a36Sopenharmony_cistatic inline int tegra_powergate_power_on(unsigned int id)
17862306a36Sopenharmony_ci{
17962306a36Sopenharmony_ci	return -ENOSYS;
18062306a36Sopenharmony_ci}
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_cistatic inline int tegra_powergate_power_off(unsigned int id)
18362306a36Sopenharmony_ci{
18462306a36Sopenharmony_ci	return -ENOSYS;
18562306a36Sopenharmony_ci}
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_cistatic inline int tegra_powergate_remove_clamping(unsigned int id)
18862306a36Sopenharmony_ci{
18962306a36Sopenharmony_ci	return -ENOSYS;
19062306a36Sopenharmony_ci}
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_cistatic inline int tegra_powergate_sequence_power_up(unsigned int id,
19362306a36Sopenharmony_ci						    struct clk *clk,
19462306a36Sopenharmony_ci						    struct reset_control *rst)
19562306a36Sopenharmony_ci{
19662306a36Sopenharmony_ci	return -ENOSYS;
19762306a36Sopenharmony_ci}
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_cistatic inline int tegra_io_pad_power_enable(enum tegra_io_pad id)
20062306a36Sopenharmony_ci{
20162306a36Sopenharmony_ci	return -ENOSYS;
20262306a36Sopenharmony_ci}
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_cistatic inline int tegra_io_pad_power_disable(enum tegra_io_pad id)
20562306a36Sopenharmony_ci{
20662306a36Sopenharmony_ci	return -ENOSYS;
20762306a36Sopenharmony_ci}
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_cistatic inline int tegra_io_pad_get_voltage(enum tegra_io_pad id)
21062306a36Sopenharmony_ci{
21162306a36Sopenharmony_ci	return -ENOSYS;
21262306a36Sopenharmony_ci}
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_cistatic inline int tegra_io_rail_power_on(unsigned int id)
21562306a36Sopenharmony_ci{
21662306a36Sopenharmony_ci	return -ENOSYS;
21762306a36Sopenharmony_ci}
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_cistatic inline int tegra_io_rail_power_off(unsigned int id)
22062306a36Sopenharmony_ci{
22162306a36Sopenharmony_ci	return -ENOSYS;
22262306a36Sopenharmony_ci}
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_cistatic inline void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode)
22562306a36Sopenharmony_ci{
22662306a36Sopenharmony_ci}
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_cistatic inline void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode)
22962306a36Sopenharmony_ci{
23062306a36Sopenharmony_ci}
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_cistatic inline bool tegra_pmc_core_domain_state_synced(void)
23362306a36Sopenharmony_ci{
23462306a36Sopenharmony_ci	return false;
23562306a36Sopenharmony_ci}
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci#endif /* CONFIG_SOC_TEGRA_PMC */
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci#if defined(CONFIG_SOC_TEGRA_PMC) && defined(CONFIG_PM_SLEEP)
24062306a36Sopenharmony_cienum tegra_suspend_mode tegra_pmc_get_suspend_mode(void);
24162306a36Sopenharmony_ci#else
24262306a36Sopenharmony_cistatic inline enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void)
24362306a36Sopenharmony_ci{
24462306a36Sopenharmony_ci	return TEGRA_SUSPEND_NONE;
24562306a36Sopenharmony_ci}
24662306a36Sopenharmony_ci#endif
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci#endif /* __SOC_TEGRA_PMC_H__ */
249