pmc.h 6.8 KB

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