David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2010 Google, Inc |
| 4 | * Copyright (c) 2014 NVIDIA Corporation |
| 5 | * |
| 6 | * Author: |
| 7 | * Colin Cross <ccross@google.com> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 | |
| 17 | struct clk; |
| 18 | struct reset_control; |
| 19 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 20 | bool tegra_pmc_cpu_is_powered(unsigned int cpuid); |
| 21 | int tegra_pmc_cpu_power_on(unsigned int cpuid); |
| 22 | int tegra_pmc_cpu_remove_clamping(unsigned int cpuid); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 | */ |
| 69 | enum 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, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 82 | TEGRA_IO_PAD_CSIG, |
| 83 | TEGRA_IO_PAD_CSIH, |
| 84 | TEGRA_IO_PAD_DAP3, |
| 85 | TEGRA_IO_PAD_DAP5, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 98 | TEGRA_IO_PAD_EQOS, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 99 | TEGRA_IO_PAD_GPIO, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 100 | TEGRA_IO_PAD_GP_PWM2, |
| 101 | TEGRA_IO_PAD_GP_PWM3, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 102 | TEGRA_IO_PAD_HDMI, |
| 103 | TEGRA_IO_PAD_HDMI_DP0, |
| 104 | TEGRA_IO_PAD_HDMI_DP1, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 105 | TEGRA_IO_PAD_HDMI_DP2, |
| 106 | TEGRA_IO_PAD_HDMI_DP3, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 116 | TEGRA_IO_PAD_PEX_CLK2_BIAS, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 117 | TEGRA_IO_PAD_PEX_CLK3, |
| 118 | TEGRA_IO_PAD_PEX_CNTRL, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 119 | TEGRA_IO_PAD_PEX_CTL2, |
| 120 | TEGRA_IO_PAD_PEX_L0_RST_N, |
| 121 | TEGRA_IO_PAD_PEX_L1_RST_N, |
| 122 | TEGRA_IO_PAD_PEX_L5_RST_N, |
| 123 | TEGRA_IO_PAD_PWR_CTL, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 124 | TEGRA_IO_PAD_SDMMC1, |
| 125 | TEGRA_IO_PAD_SDMMC1_HV, |
| 126 | TEGRA_IO_PAD_SDMMC2, |
| 127 | TEGRA_IO_PAD_SDMMC2_HV, |
| 128 | TEGRA_IO_PAD_SDMMC3, |
| 129 | TEGRA_IO_PAD_SDMMC3_HV, |
| 130 | TEGRA_IO_PAD_SDMMC4, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 131 | TEGRA_IO_PAD_SOC_GPIO10, |
| 132 | TEGRA_IO_PAD_SOC_GPIO12, |
| 133 | TEGRA_IO_PAD_SOC_GPIO13, |
| 134 | TEGRA_IO_PAD_SOC_GPIO53, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 135 | TEGRA_IO_PAD_SPI, |
| 136 | TEGRA_IO_PAD_SPI_HV, |
| 137 | TEGRA_IO_PAD_SYS_DDC, |
| 138 | TEGRA_IO_PAD_UART, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 139 | TEGRA_IO_PAD_UART4, |
| 140 | TEGRA_IO_PAD_UART5, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 141 | TEGRA_IO_PAD_UFS, |
| 142 | TEGRA_IO_PAD_USB0, |
| 143 | TEGRA_IO_PAD_USB1, |
| 144 | TEGRA_IO_PAD_USB2, |
| 145 | TEGRA_IO_PAD_USB3, |
| 146 | TEGRA_IO_PAD_USB_BIAS, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 147 | TEGRA_IO_PAD_AO_HV, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | /* deprecated, use TEGRA_IO_PAD_{HDMI,LVDS} instead */ |
| 151 | #define TEGRA_IO_RAIL_HDMI TEGRA_IO_PAD_HDMI |
| 152 | #define TEGRA_IO_RAIL_LVDS TEGRA_IO_PAD_LVDS |
| 153 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 154 | #ifdef CONFIG_SOC_TEGRA_PMC |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 155 | int tegra_powergate_power_on(unsigned int id); |
| 156 | int tegra_powergate_power_off(unsigned int id); |
| 157 | int tegra_powergate_remove_clamping(unsigned int id); |
| 158 | |
| 159 | /* Must be called with clk disabled, and returns with clk enabled */ |
| 160 | int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk, |
| 161 | struct reset_control *rst); |
| 162 | |
| 163 | int tegra_io_pad_power_enable(enum tegra_io_pad id); |
| 164 | int tegra_io_pad_power_disable(enum tegra_io_pad id); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 165 | |
| 166 | /* deprecated, use tegra_io_pad_power_{enable,disable}() instead */ |
| 167 | int tegra_io_rail_power_on(unsigned int id); |
| 168 | int tegra_io_rail_power_off(unsigned int id); |
| 169 | |
| 170 | enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void); |
| 171 | void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode); |
| 172 | void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode); |
| 173 | |
| 174 | #else |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 175 | static inline int tegra_powergate_power_on(unsigned int id) |
| 176 | { |
| 177 | return -ENOSYS; |
| 178 | } |
| 179 | |
| 180 | static inline int tegra_powergate_power_off(unsigned int id) |
| 181 | { |
| 182 | return -ENOSYS; |
| 183 | } |
| 184 | |
| 185 | static inline int tegra_powergate_remove_clamping(unsigned int id) |
| 186 | { |
| 187 | return -ENOSYS; |
| 188 | } |
| 189 | |
| 190 | static inline int tegra_powergate_sequence_power_up(unsigned int id, |
| 191 | struct clk *clk, |
| 192 | struct reset_control *rst) |
| 193 | { |
| 194 | return -ENOSYS; |
| 195 | } |
| 196 | |
| 197 | static inline int tegra_io_pad_power_enable(enum tegra_io_pad id) |
| 198 | { |
| 199 | return -ENOSYS; |
| 200 | } |
| 201 | |
| 202 | static inline int tegra_io_pad_power_disable(enum tegra_io_pad id) |
| 203 | { |
| 204 | return -ENOSYS; |
| 205 | } |
| 206 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 207 | static inline int tegra_io_pad_get_voltage(enum tegra_io_pad id) |
| 208 | { |
| 209 | return -ENOSYS; |
| 210 | } |
| 211 | |
| 212 | static inline int tegra_io_rail_power_on(unsigned int id) |
| 213 | { |
| 214 | return -ENOSYS; |
| 215 | } |
| 216 | |
| 217 | static inline int tegra_io_rail_power_off(unsigned int id) |
| 218 | { |
| 219 | return -ENOSYS; |
| 220 | } |
| 221 | |
| 222 | static inline enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void) |
| 223 | { |
| 224 | return TEGRA_SUSPEND_NONE; |
| 225 | } |
| 226 | |
| 227 | static inline void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode) |
| 228 | { |
| 229 | } |
| 230 | |
| 231 | static inline void tegra_pmc_enter_suspend_mode(enum tegra_suspend_mode mode) |
| 232 | { |
| 233 | } |
| 234 | |
| 235 | #endif /* CONFIG_SOC_TEGRA_PMC */ |
| 236 | |
| 237 | #endif /* __SOC_TEGRA_PMC_H__ */ |