Anson Huang | b629413 | 2018-06-05 16:05:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | /*! |
| 8 | * Header file containing the public API for the System Controller (SC) |
| 9 | * Power Management (PM) function. This includes functions for power state |
| 10 | * control, clock control, reset control, and wake-up event control. |
| 11 | * |
| 12 | * @addtogroup PM_SVC (SVC) Power Management Service |
| 13 | * |
| 14 | * Module for the Power Management (PM) service. |
| 15 | * |
| 16 | * @{ |
| 17 | */ |
| 18 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 19 | #ifndef SCI_PM_API_H |
| 20 | #define SCI_PM_API_H |
Anson Huang | b629413 | 2018-06-05 16:05:59 +0800 | [diff] [blame] | 21 | |
| 22 | /* Includes */ |
| 23 | |
| 24 | #include <sci/sci_types.h> |
| 25 | #include <sci/svc/rm/sci_rm_api.h> |
| 26 | |
| 27 | /* Defines */ |
| 28 | |
| 29 | /*! |
| 30 | * @name Defines for type widths |
| 31 | */ |
| 32 | /*@{*/ |
| 33 | #define SC_PM_POWER_MODE_W 2 /* Width of sc_pm_power_mode_t */ |
| 34 | #define SC_PM_CLOCK_MODE_W 3 /* Width of sc_pm_clock_mode_t */ |
| 35 | #define SC_PM_RESET_TYPE_W 2 /* Width of sc_pm_reset_type_t */ |
| 36 | #define SC_PM_RESET_REASON_W 3 /* Width of sc_pm_reset_reason_t */ |
| 37 | /*@}*/ |
| 38 | |
| 39 | /*! |
| 40 | * @name Defines for clock indexes (sc_pm_clk_t) |
| 41 | */ |
| 42 | /*@{*/ |
| 43 | /*@}*/ |
| 44 | |
| 45 | /*! |
| 46 | * @name Defines for ALL parameters |
| 47 | */ |
| 48 | /*@{*/ |
| 49 | #define SC_PM_CLK_ALL UINT8_MAX /* All clocks */ |
| 50 | /*@}*/ |
| 51 | |
| 52 | /*! |
| 53 | * @name Defines for sc_pm_power_mode_t |
| 54 | */ |
| 55 | /*@{*/ |
| 56 | #define SC_PM_PW_MODE_OFF 0U /* Power off */ |
| 57 | #define SC_PM_PW_MODE_STBY 1U /* Power in standby */ |
| 58 | #define SC_PM_PW_MODE_LP 2U /* Power in low-power */ |
| 59 | #define SC_PM_PW_MODE_ON 3U /* Power on */ |
| 60 | /*@}*/ |
| 61 | |
| 62 | /*! |
| 63 | * @name Defines for sc_pm_clk_t |
| 64 | */ |
| 65 | /*@{*/ |
| 66 | #define SC_PM_CLK_SLV_BUS 0U /* Slave bus clock */ |
| 67 | #define SC_PM_CLK_MST_BUS 1U /* Master bus clock */ |
| 68 | #define SC_PM_CLK_PER 2U /* Peripheral clock */ |
| 69 | #define SC_PM_CLK_PHY 3U /* Phy clock */ |
| 70 | #define SC_PM_CLK_MISC 4U /* Misc clock */ |
| 71 | #define SC_PM_CLK_MISC0 0U /* Misc 0 clock */ |
| 72 | #define SC_PM_CLK_MISC1 1U /* Misc 1 clock */ |
| 73 | #define SC_PM_CLK_MISC2 2U /* Misc 2 clock */ |
| 74 | #define SC_PM_CLK_MISC3 3U /* Misc 3 clock */ |
| 75 | #define SC_PM_CLK_MISC4 4U /* Misc 4 clock */ |
| 76 | #define SC_PM_CLK_CPU 2U /* CPU clock */ |
| 77 | #define SC_PM_CLK_PLL 4U /* PLL */ |
| 78 | #define SC_PM_CLK_BYPASS 4U /* Bypass clock */ |
| 79 | /*@}*/ |
| 80 | |
| 81 | /*! |
| 82 | * @name Defines for sc_pm_clk_mode_t |
| 83 | */ |
| 84 | /*@{*/ |
| 85 | #define SC_PM_CLK_MODE_ROM_INIT 0U /* Clock is initialized by ROM. */ |
| 86 | #define SC_PM_CLK_MODE_OFF 1U /* Clock is disabled */ |
| 87 | #define SC_PM_CLK_MODE_ON 2U /* Clock is enabled. */ |
| 88 | #define SC_PM_CLK_MODE_AUTOGATE_SW 3U /* Clock is in SW autogate mode */ |
| 89 | #define SC_PM_CLK_MODE_AUTOGATE_HW 4U /* Clock is in HW autogate mode */ |
| 90 | #define SC_PM_CLK_MODE_AUTOGATE_SW_HW 5U /* Clock is in SW-HW autogate mode */ |
| 91 | /*@}*/ |
| 92 | |
| 93 | /*! |
| 94 | * @name Defines for sc_pm_clk_parent_t |
| 95 | */ |
| 96 | /*@{*/ |
| 97 | #define SC_PM_PARENT_XTAL 0U /* Parent is XTAL. */ |
| 98 | #define SC_PM_PARENT_PLL0 1U /* Parent is PLL0 */ |
| 99 | #define SC_PM_PARENT_PLL1 2U /* Parent is PLL1 or PLL0/2 */ |
| 100 | #define SC_PM_PARENT_PLL2 3U /* Parent in PLL2 or PLL0/4 */ |
| 101 | #define SC_PM_PARENT_BYPS 4U /* Parent is a bypass clock. */ |
| 102 | /*@}*/ |
| 103 | |
| 104 | /*! |
| 105 | * @name Defines for sc_pm_reset_type_t |
| 106 | */ |
| 107 | /*@{*/ |
| 108 | #define SC_PM_RESET_TYPE_COLD 0U /* Cold reset */ |
| 109 | #define SC_PM_RESET_TYPE_WARM 1U /* Warm reset */ |
| 110 | #define SC_PM_RESET_TYPE_BOARD 2U /* Board reset */ |
| 111 | /*@}*/ |
| 112 | |
| 113 | /*! |
| 114 | * @name Defines for sc_pm_reset_cause_t |
| 115 | */ |
| 116 | /*@{*/ |
| 117 | #define SC_PM_RESET_CAUSE_TEMP 0U /* Reset due to temp panic alarm */ |
| 118 | #define SC_PM_RESET_CAUSE_FAULT 1U /* Reset due to fault exception */ |
| 119 | #define SC_PM_RESET_CAUSE_IRQ 2U /* Reset due to SCU reset IRQ */ |
| 120 | #define SC_PM_RESET_CAUSE_WDOG 3U /* Reset due to SW WDOG */ |
| 121 | #define SC_PM_RESET_CAUSE_API 4U /* Reset due to pm_reset() or monitor */ |
| 122 | /*@}*/ |
| 123 | |
| 124 | /*! |
| 125 | * @name Defines for sc_pm_reset_reason_t |
| 126 | */ |
| 127 | /*@{*/ |
| 128 | #define SC_PM_RESET_REASON_POR 0U /* Power on reset */ |
| 129 | #define SC_PM_RESET_REASON_WARM 1U /* Warm reset */ |
| 130 | #define SC_PM_RESET_REASON_SW 2U /* Software reset */ |
| 131 | #define SC_PM_RESET_REASON_WDOG 3U /* Watchdog reset */ |
| 132 | #define SC_PM_RESET_REASON_LOCKUP 4U /* Lockup reset */ |
| 133 | #define SC_PM_RESET_REASON_TAMPER 5U /* Tamper reset */ |
| 134 | #define SC_PM_RESET_REASON_TEMP 6U /* Temp reset */ |
| 135 | #define SC_PM_RESET_REASON_LOW_VOLT 7U /* Low voltage reset */ |
| 136 | /*@}*/ |
| 137 | |
| 138 | /*! |
| 139 | * @name Defines for sc_pm_sys_if_t |
| 140 | */ |
| 141 | /*@{*/ |
| 142 | #define SC_PM_SYS_IF_INTERCONNECT 0U /* System interconnect */ |
| 143 | #define SC_PM_SYS_IF_MU 1U /* AP -> SCU message units */ |
| 144 | #define SC_PM_SYS_IF_OCMEM 2U /* On-chip memory (ROM/OCRAM) */ |
| 145 | #define SC_PM_SYS_IF_DDR 3U /* DDR memory */ |
| 146 | /*@}*/ |
| 147 | |
| 148 | /*! |
| 149 | * @name Defines for sc_pm_wake_src_t |
| 150 | */ |
| 151 | /*@{*/ |
| 152 | #define SC_PM_WAKE_SRC_NONE 0U /* No wake source, used for self-kill */ |
| 153 | #define SC_PM_WAKE_SRC_SCU 1U /* Wakeup from SCU to resume CPU (IRQSTEER & GIC powered down) */ |
| 154 | #define SC_PM_WAKE_SRC_IRQSTEER 2U /* Wakeup from IRQSTEER to resume CPU (GIC powered down) */ |
| 155 | #define SC_PM_WAKE_SRC_IRQSTEER_GIC 3U /* Wakeup from IRQSTEER+GIC to wake CPU (GIC clock gated) */ |
| 156 | #define SC_PM_WAKE_SRC_GIC 4U /* Wakeup from GIC to wake CPU */ |
| 157 | /*@}*/ |
| 158 | |
| 159 | /* Types */ |
| 160 | |
| 161 | /*! |
| 162 | * This type is used to declare a power mode. Note resources only use |
| 163 | * SC_PM_PW_MODE_OFF and SC_PM_PW_MODE_ON. The other modes are used only |
| 164 | * as system power modes. |
| 165 | */ |
| 166 | typedef uint8_t sc_pm_power_mode_t; |
| 167 | |
| 168 | /*! |
| 169 | * This type is used to declare a clock. |
| 170 | */ |
| 171 | typedef uint8_t sc_pm_clk_t; |
| 172 | |
| 173 | /*! |
| 174 | * This type is used to declare a clock mode. |
| 175 | */ |
| 176 | typedef uint8_t sc_pm_clk_mode_t; |
| 177 | |
| 178 | /*! |
| 179 | * This type is used to declare the clock parent. |
| 180 | */ |
| 181 | typedef uint8_t sc_pm_clk_parent_t; |
| 182 | |
| 183 | /*! |
| 184 | * This type is used to declare clock rates. |
| 185 | */ |
| 186 | typedef uint32_t sc_pm_clock_rate_t; |
| 187 | |
| 188 | /*! |
| 189 | * This type is used to declare a desired reset type. |
| 190 | */ |
| 191 | typedef uint8_t sc_pm_reset_type_t; |
| 192 | |
| 193 | /*! |
| 194 | * This type is used to declare a desired reset type. |
| 195 | */ |
| 196 | typedef uint8_t sc_pm_reset_cause; |
| 197 | |
| 198 | /*! |
| 199 | * This type is used to declare a reason for a reset. |
| 200 | */ |
| 201 | typedef uint8_t sc_pm_reset_reason_t; |
| 202 | |
| 203 | /*! |
| 204 | * This type is used to specify a system-level interface to be power managed. |
| 205 | */ |
| 206 | typedef uint8_t sc_pm_sys_if_t; |
| 207 | |
| 208 | /*! |
| 209 | * This type is used to specify a wake source for CPU resources. |
| 210 | */ |
| 211 | typedef uint8_t sc_pm_wake_src_t; |
| 212 | |
| 213 | /* Functions */ |
| 214 | |
| 215 | /*! |
| 216 | * @name Power Functions |
| 217 | * @{ |
| 218 | */ |
| 219 | |
| 220 | /*! |
| 221 | * This function sets the system power mode. Only the owner of the |
| 222 | * SC_R_SYSTEM resource can do this. |
| 223 | * |
| 224 | * @param[in] ipc IPC handle |
| 225 | * @param[in] mode power mode to apply |
| 226 | * |
| 227 | * @return Returns an error code (SC_ERR_NONE = success). |
| 228 | * |
| 229 | * Return errors: |
| 230 | * - SC_ERR_PARM if invalid mode, |
| 231 | * - SC_ERR_NOACCESS if caller not the owner of SC_R_SYSTEM |
| 232 | * |
| 233 | * @see sc_pm_set_sys_power_mode(). |
| 234 | */ |
| 235 | sc_err_t sc_pm_set_sys_power_mode(sc_ipc_t ipc, sc_pm_power_mode_t mode); |
| 236 | |
| 237 | /*! |
| 238 | * This function sets the power mode of a partition. |
| 239 | * |
| 240 | * @param[in] ipc IPC handle |
| 241 | * @param[in] pt handle of partition |
| 242 | * @param[in] mode power mode to apply |
| 243 | * |
| 244 | * @return Returns an error code (SC_ERR_NONE = success). |
| 245 | * |
| 246 | * Return errors: |
| 247 | * - SC_ERR_PARM if invalid partition or mode, |
| 248 | * - SC_ERR_NOACCESS if caller's partition is not the owner or |
| 249 | * parent of \a pt |
| 250 | * |
| 251 | * The power mode of the partitions is a max power any resource will |
| 252 | * be set to. Calling this will result in all resources owned |
| 253 | * by \a pt to have their power changed to the lower of \a mode or the |
| 254 | * individual resource mode set using sc_pm_set_resource_power_mode(). |
| 255 | */ |
| 256 | sc_err_t sc_pm_set_partition_power_mode(sc_ipc_t ipc, sc_rm_pt_t pt, |
| 257 | sc_pm_power_mode_t mode); |
| 258 | |
| 259 | /*! |
| 260 | * This function gets the power mode of a partition. |
| 261 | * |
| 262 | * @param[in] ipc IPC handle |
| 263 | * @param[in] pt handle of partition |
| 264 | * @param[out] mode pointer to return power mode |
| 265 | * |
| 266 | * @return Returns an error code (SC_ERR_NONE = success). |
| 267 | * |
| 268 | * Return errors: |
| 269 | * - SC_ERR_PARM if invalid partition |
| 270 | */ |
| 271 | sc_err_t sc_pm_get_sys_power_mode(sc_ipc_t ipc, sc_rm_pt_t pt, |
| 272 | sc_pm_power_mode_t *mode); |
| 273 | |
| 274 | /*! |
| 275 | * This function sets the power mode of a resource. |
| 276 | * |
| 277 | * @param[in] ipc IPC handle |
| 278 | * @param[in] resource ID of the resource |
| 279 | * @param[in] mode power mode to apply |
| 280 | * |
| 281 | * @return Returns an error code (SC_ERR_NONE = success). |
| 282 | * |
| 283 | * Return errors: |
| 284 | * - SC_ERR_PARM if invalid resource or mode, |
| 285 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner |
| 286 | * or parent of the owner |
| 287 | * |
| 288 | * This function will record the individual resource power mode |
| 289 | * and change it if the requested mode is lower than or equal to the |
| 290 | * partition power mode set with sc_pm_set_partition_power_mode(). |
| 291 | * In other words, the power mode of the resource will be the minimum |
| 292 | * of the resource power mode and the partition power mode. |
| 293 | * |
| 294 | * Note some resources are still not accessible even when powered up if bus |
| 295 | * transactions go through a fabric not powered up. Examples of this are |
| 296 | * resources in display and capture subsystems which require the display |
Elyes Haouas | 2be03c0 | 2023-02-13 09:14:48 +0100 | [diff] [blame] | 297 | * controller or the imaging subsystem to be powered up first. |
Anson Huang | b629413 | 2018-06-05 16:05:59 +0800 | [diff] [blame] | 298 | * |
| 299 | * Not that resources are grouped into power domains by the underlying |
| 300 | * hardware. If any resource in the domain is on, the entire power domain |
| 301 | * will be on. Other power domains required to access the resource will |
| 302 | * also be turned on. Clocks required to access the peripheral will be |
| 303 | * turned on. Refer to the SoC RM for more info on power domains and access |
| 304 | * infrastructure (bus fabrics, clock domains, etc.). |
| 305 | */ |
| 306 | sc_err_t sc_pm_set_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, |
| 307 | sc_pm_power_mode_t mode); |
| 308 | |
| 309 | /*! |
| 310 | * This function gets the power mode of a resource. |
| 311 | * |
| 312 | * @param[in] ipc IPC handle |
| 313 | * @param[in] resource ID of the resource |
| 314 | * @param[out] mode pointer to return power mode |
| 315 | * |
| 316 | * @return Returns an error code (SC_ERR_NONE = success). |
| 317 | * |
| 318 | * Note only SC_PM_PW_MODE_OFF and SC_PM_PW_MODE_ON are valid. The value |
| 319 | * returned does not reflect the power mode of the partition.. |
| 320 | */ |
| 321 | sc_err_t sc_pm_get_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, |
| 322 | sc_pm_power_mode_t *mode); |
| 323 | |
| 324 | /*! |
| 325 | * This function requests the low power mode some of the resources |
| 326 | * can enter based on their state. This API is only valid for the |
| 327 | * following resources : SC_R_A53, SC_R_A53_0, SC_R_A53_1, SC_A53_2, |
| 328 | * SC_A53_3, SC_R_A72, SC_R_A72_0, SC_R_A72_1, SC_R_CC1, SC_R_A35, |
| 329 | * SC_R_A35_0, SC_R_A35_1, SC_R_A35_2, SC_R_A35_3. |
| 330 | * For all other resources it will return SC_ERR_PARAM. |
| 331 | * This function will set the low power mode the cores, cluster |
| 332 | * and cluster associated resources will enter when all the cores |
| 333 | * in a given cluster execute WFI |
| 334 | * |
| 335 | * @param[in] ipc IPC handle |
| 336 | * @param[in] resource ID of the resource |
| 337 | * @param[in] mode power mode to apply |
| 338 | * |
| 339 | * @return Returns an error code (SC_ERR_NONE = success). |
| 340 | * |
| 341 | */ |
| 342 | sc_err_t sc_pm_req_low_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, |
| 343 | sc_pm_power_mode_t mode); |
| 344 | |
| 345 | /*! |
| 346 | * This function requests low-power mode entry for CPU/cluster |
| 347 | * resources. This API is only valid for the following resources: |
| 348 | * SC_R_A53, SC_R_A53_x, SC_R_A72, SC_R_A72_x, SC_R_A35, SC_R_A35_x, |
| 349 | * SC_R_CCI. For all other resources it will return SC_ERR_PARAM. |
| 350 | * For individual core resources, the specified power mode |
| 351 | * and wake source will be applied after the core has entered |
| 352 | * WFI. For cluster resources, the specified power mode is |
| 353 | * applied after all cores in the cluster have entered low-power mode. |
| 354 | * For multicluster resources, the specified power mode is applied |
| 355 | * after all clusters have reached low-power mode. |
| 356 | * |
| 357 | * @param[in] ipc IPC handle |
| 358 | * @param[in] resource ID of the resource |
| 359 | * @param[in] mode power mode to apply |
| 360 | * @param[in] wake_src wake source for low-power exit |
| 361 | * |
| 362 | * @return Returns an error code (SC_ERR_NONE = success). |
| 363 | * |
| 364 | */ |
| 365 | sc_err_t sc_pm_req_cpu_low_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, |
| 366 | sc_pm_power_mode_t mode, |
| 367 | sc_pm_wake_src_t wake_src); |
| 368 | |
| 369 | /*! |
| 370 | * This function is used to set the resume address of a CPU. |
| 371 | * |
| 372 | * @param[in] ipc IPC handle |
| 373 | * @param[in] resource ID of the CPU resource |
| 374 | * @param[in] address 64-bit resume address |
| 375 | * |
| 376 | * @return Returns an error code (SC_ERR_NONE = success). |
| 377 | * |
| 378 | * Return errors: |
| 379 | * - SC_ERR_PARM if invalid resource or address, |
| 380 | * - SC_ERR_NOACCESS if caller's partition is not the parent of the |
| 381 | * resource (CPU) owner |
| 382 | */ |
| 383 | sc_err_t sc_pm_set_cpu_resume_addr(sc_ipc_t ipc, sc_rsrc_t resource, |
| 384 | sc_faddr_t address); |
| 385 | |
| 386 | /*! |
| 387 | * This function is used to set parameters for CPU resume from |
| 388 | * low-power mode. |
| 389 | * |
| 390 | * @param[in] ipc IPC handle |
| 391 | * @param[in] resource ID of the CPU resource |
| 392 | * @param[in] isPrimary set SC_TRUE if primary wake CPU |
| 393 | * @param[in] address 64-bit resume address |
| 394 | * |
| 395 | * @return Returns an error code (SC_ERR_NONE = success). |
| 396 | * |
| 397 | * Return errors: |
| 398 | * - SC_ERR_PARM if invalid resource or address, |
| 399 | * - SC_ERR_NOACCESS if caller's partition is not the parent of the |
| 400 | * resource (CPU) owner |
| 401 | */ |
| 402 | sc_err_t sc_pm_set_cpu_resume(sc_ipc_t ipc, sc_rsrc_t resource, |
| 403 | sc_bool_t isPrimary, sc_faddr_t address); |
| 404 | |
| 405 | /*! |
| 406 | * This function requests the power mode configuration for system-level |
| 407 | * interfaces including messaging units, interconnect, and memories. This API |
| 408 | * is only valid for the following resources : SC_R_A53, SC_R_A72, and |
| 409 | * SC_R_M4_x_PID_y. For all other resources, it will return SC_ERR_PARAM. |
| 410 | * The requested power mode will be captured and applied to system-level |
| 411 | * resources as system conditions allow. |
| 412 | * |
| 413 | * @param[in] ipc IPC handle |
| 414 | * @param[in] resource ID of the resource |
| 415 | * @param[in] sys_if system-level interface to be configured |
| 416 | * @param[in] hpm high-power mode for the system interface |
| 417 | * @param[in] lpm low-power mode for the system interface |
| 418 | * |
| 419 | * @return Returns an error code (SC_ERR_NONE = success). |
| 420 | * |
| 421 | */ |
| 422 | sc_err_t sc_pm_req_sys_if_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, |
| 423 | sc_pm_sys_if_t sys_if, |
| 424 | sc_pm_power_mode_t hpm, |
| 425 | sc_pm_power_mode_t lpm); |
| 426 | |
| 427 | /* @} */ |
| 428 | |
| 429 | /*! |
| 430 | * @name Clock/PLL Functions |
| 431 | * @{ |
| 432 | */ |
| 433 | |
| 434 | /*! |
| 435 | * This function sets the rate of a resource's clock/PLL. |
| 436 | * |
| 437 | * @param[in] ipc IPC handle |
| 438 | * @param[in] resource ID of the resource |
| 439 | * @param[in] clk clock/PLL to affect |
| 440 | * @param[in,out] rate pointer to rate to set, |
| 441 | * return actual rate |
| 442 | * @return Returns an error code (SC_ERR_NONE = success). |
| 443 | * |
| 444 | * Return errors: |
| 445 | * - SC_ERR_PARM if invalid resource or clock/PLL, |
| 446 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner |
| 447 | * or parent of the owner, |
| 448 | * - SC_ERR_UNAVAILABLE if clock/PLL not applicable to this resource, |
| 449 | * - SC_ERR_LOCKED if rate locked (usually because shared clock/PLL) |
| 450 | * |
| 451 | * Refer to the [Clock List](@ref CLOCKS) for valid clock/PLL values. |
| 452 | */ |
| 453 | sc_err_t sc_pm_set_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, |
| 454 | sc_pm_clk_t clk, sc_pm_clock_rate_t *rate); |
| 455 | |
| 456 | /*! |
| 457 | * This function gets the rate of a resource's clock/PLL. |
| 458 | * |
| 459 | * @param[in] ipc IPC handle |
| 460 | * @param[in] resource ID of the resource |
| 461 | * @param[in] clk clock/PLL to affect |
| 462 | * @param[out] rate pointer to return rate |
| 463 | * |
| 464 | * @return Returns an error code (SC_ERR_NONE = success). |
| 465 | * |
| 466 | * Return errors: |
| 467 | * - SC_ERR_PARM if invalid resource or clock/PLL, |
| 468 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner |
| 469 | * or parent of the owner, |
| 470 | * - SC_ERR_UNAVAILABLE if clock/PLL not applicable to this resource |
| 471 | * |
| 472 | * Refer to the [Clock List](@ref CLOCKS) for valid clock/PLL values. |
| 473 | */ |
| 474 | sc_err_t sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, |
| 475 | sc_pm_clk_t clk, sc_pm_clock_rate_t *rate); |
| 476 | |
| 477 | /*! |
| 478 | * This function enables/disables a resource's clock. |
| 479 | * |
| 480 | * @param[in] ipc IPC handle |
| 481 | * @param[in] resource ID of the resource |
| 482 | * @param[in] clk clock to affect |
| 483 | * @param[in] enable enable if SC_TRUE; otherwise disabled |
| 484 | * @param[in] autog HW auto clock gating |
| 485 | * |
| 486 | * If \a resource is SC_R_ALL then all resources owned will be affected. |
| 487 | * No error will be returned. |
| 488 | * |
| 489 | * If \a clk is SC_PM_CLK_ALL, then an error will be returned if any |
| 490 | * of the available clocks returns an error. |
| 491 | * |
| 492 | * @return Returns an error code (SC_ERR_NONE = success). |
| 493 | * |
| 494 | * Return errors: |
| 495 | * - SC_ERR_PARM if invalid resource or clock, |
| 496 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner |
| 497 | * or parent of the owner, |
| 498 | * - SC_ERR_UNAVAILABLE if clock not applicable to this resource |
| 499 | * |
| 500 | * Refer to the [Clock List](@ref CLOCKS) for valid clock values. |
| 501 | */ |
| 502 | sc_err_t sc_pm_clock_enable(sc_ipc_t ipc, sc_rsrc_t resource, |
| 503 | sc_pm_clk_t clk, sc_bool_t enable, sc_bool_t autog); |
| 504 | |
| 505 | /*! |
| 506 | * This function sets the parent of a resource's clock. |
| 507 | * This function should only be called when the clock is disabled. |
| 508 | * |
| 509 | * @param[in] ipc IPC handle |
| 510 | * @param[in] resource ID of the resource |
| 511 | * @param[in] clk clock to affect |
| 512 | * @param[in] parent New parent of the clock. |
| 513 | * |
| 514 | * @return Returns an error code (SC_ERR_NONE = success). |
| 515 | * |
| 516 | * Return errors: |
| 517 | * - SC_ERR_PARM if invalid resource or clock, |
| 518 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner |
| 519 | * or parent of the owner, |
| 520 | * - SC_ERR_UNAVAILABLE if clock not applicable to this resource |
| 521 | * - SC_ERR_BUSY if clock is currently enabled. |
| 522 | * - SC_ERR_NOPOWER if resource not powered |
| 523 | * |
| 524 | * Refer to the [Clock List](@ref CLOCKS) for valid clock values. |
| 525 | */ |
| 526 | sc_err_t sc_pm_set_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, |
| 527 | sc_pm_clk_t clk, sc_pm_clk_parent_t parent); |
| 528 | |
| 529 | /*! |
| 530 | * This function gets the parent of a resource's clock. |
| 531 | * |
| 532 | * @param[in] ipc IPC handle |
| 533 | * @param[in] resource ID of the resource |
| 534 | * @param[in] clk clock to affect |
| 535 | * @param[out] parent pointer to return parent of clock. |
| 536 | * |
| 537 | * @return Returns an error code (SC_ERR_NONE = success). |
| 538 | * |
| 539 | * Return errors: |
| 540 | * - SC_ERR_PARM if invalid resource or clock, |
| 541 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner |
| 542 | * or parent of the owner, |
| 543 | * - SC_ERR_UNAVAILABLE if clock not applicable to this resource |
| 544 | * |
| 545 | * Refer to the [Clock List](@ref CLOCKS) for valid clock values. |
| 546 | */ |
| 547 | sc_err_t sc_pm_get_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, |
| 548 | sc_pm_clk_t clk, sc_pm_clk_parent_t *parent); |
| 549 | |
| 550 | /* @} */ |
| 551 | |
| 552 | /*! |
| 553 | * @name Reset Functions |
| 554 | * @{ |
| 555 | */ |
| 556 | |
| 557 | /*! |
| 558 | * This function is used to reset the system. Only the owner of the |
| 559 | * SC_R_SYSTEM resource can do this. |
| 560 | * |
| 561 | * @param[in] ipc IPC handle |
| 562 | * @param[in] type reset type |
| 563 | * |
| 564 | * @return Returns an error code (SC_ERR_NONE = success). |
| 565 | * |
| 566 | * Return errors: |
| 567 | * - SC_ERR_PARM if invalid type, |
| 568 | * - SC_ERR_NOACCESS if caller not the owner of SC_R_SYSTEM |
| 569 | * |
| 570 | * If this function returns, then the reset did not occur due to an |
| 571 | * invalid parameter. |
| 572 | */ |
| 573 | sc_err_t sc_pm_reset(sc_ipc_t ipc, sc_pm_reset_type_t type); |
| 574 | |
| 575 | /*! |
| 576 | * This function gets a caller's reset reason. |
| 577 | * |
| 578 | * @param[in] ipc IPC handle |
| 579 | * @param[out] reason pointer to return reset reason |
| 580 | * |
| 581 | * @return Returns an error code (SC_ERR_NONE = success). |
| 582 | */ |
| 583 | sc_err_t sc_pm_reset_reason(sc_ipc_t ipc, sc_pm_reset_reason_t *reason); |
| 584 | |
| 585 | /*! |
| 586 | * This function is used to boot a partition. |
| 587 | * |
| 588 | * @param[in] ipc IPC handle |
| 589 | * @param[in] pt handle of partition to boot |
| 590 | * @param[in] resource_cpu ID of the CPU resource to start |
| 591 | * @param[in] boot_addr 64-bit boot address |
| 592 | * @param[in] resource_mu ID of the MU that must be powered |
| 593 | * @param[in] resource_dev ID of the boot device that must be powered |
| 594 | * |
| 595 | * @return Returns an error code (SC_ERR_NONE = success). |
| 596 | * |
| 597 | * Return errors: |
| 598 | * - SC_ERR_PARM if invalid partition, resource, or addr, |
| 599 | * - SC_ERR_NOACCESS if caller's partition is not the parent of the |
| 600 | * partition to boot |
| 601 | */ |
| 602 | sc_err_t sc_pm_boot(sc_ipc_t ipc, sc_rm_pt_t pt, |
| 603 | sc_rsrc_t resource_cpu, sc_faddr_t boot_addr, |
| 604 | sc_rsrc_t resource_mu, sc_rsrc_t resource_dev); |
| 605 | |
| 606 | /*! |
| 607 | * This function is used to reboot the caller's partition. |
| 608 | * |
| 609 | * @param[in] ipc IPC handle |
| 610 | * @param[in] type reset type |
| 611 | * |
| 612 | * If \a type is SC_PM_RESET_TYPE_COLD, then most peripherals owned by |
| 613 | * the calling partition will be reset if possible. SC state (partitions, |
| 614 | * power, clocks, etc.) is reset. The boot SW of the booting CPU must be |
| 615 | * able to handle peripherals that that are not reset. |
| 616 | * |
| 617 | * If \a type is SC_PM_RESET_TYPE_WARM, then only the boot CPU is reset. |
| 618 | * SC state (partitions, power, clocks, etc.) are NOT reset. The boot SW |
| 619 | * of the booting CPU must be able to handle peripherals and SC state that |
| 620 | * that are not reset. |
| 621 | * |
| 622 | * If \a type is SC_PM_RESET_TYPE_BOARD, then return with no action. |
| 623 | * |
| 624 | * If this function returns, then the reset did not occur due to an |
| 625 | * invalid parameter. |
| 626 | */ |
| 627 | void sc_pm_reboot(sc_ipc_t ipc, sc_pm_reset_type_t type); |
| 628 | |
| 629 | /*! |
| 630 | * This function is used to reboot a partition. |
| 631 | * |
| 632 | * @param[in] ipc IPC handle |
| 633 | * @param[in] pt handle of partition to reboot |
| 634 | * @param[in] type reset type |
| 635 | * |
| 636 | * If \a type is SC_PM_RESET_TYPE_COLD, then most peripherals owned by |
| 637 | * the calling partition will be reset if possible. SC state (partitions, |
| 638 | * power, clocks, etc.) is reset. The boot SW of the booting CPU must be |
| 639 | * able to handle peripherals that that are not reset. |
| 640 | * |
| 641 | * If \a type is SC_PM_RESET_TYPE_WARM, then only the boot CPU is reset. |
| 642 | * SC state (partitions, power, clocks, etc.) are NOT reset. The boot SW |
| 643 | * of the booting CPU must be able to handle peripherals and SC state that |
| 644 | * that are not reset. |
| 645 | * |
| 646 | * If \a type is SC_PM_RESET_TYPE_BOARD, then return with no action. |
| 647 | * |
| 648 | * @return Returns an error code (SC_ERR_NONE = success). |
| 649 | * |
| 650 | * Return errors: |
| 651 | * - SC_ERR_PARM if invalid partition or type |
| 652 | * - SC_ERR_NOACCESS if caller's partition is not the parent of \a pt, |
| 653 | * |
| 654 | * Most peripherals owned by the partition will be reset if |
| 655 | * possible. SC state (partitions, power, clocks, etc.) is reset. The |
| 656 | * boot SW of the booting CPU must be able to handle peripherals that |
| 657 | * that are not reset. |
| 658 | */ |
| 659 | sc_err_t sc_pm_reboot_partition(sc_ipc_t ipc, sc_rm_pt_t pt, |
| 660 | sc_pm_reset_type_t type); |
| 661 | |
| 662 | /*! |
| 663 | * This function is used to start/stop a CPU. |
| 664 | * |
| 665 | * @param[in] ipc IPC handle |
| 666 | * @param[in] resource ID of the CPU resource |
| 667 | * @param[in] enable start if SC_TRUE; otherwise stop |
| 668 | * @param[in] address 64-bit boot address |
| 669 | * |
| 670 | * @return Returns an error code (SC_ERR_NONE = success). |
| 671 | * |
| 672 | * Return errors: |
| 673 | * - SC_ERR_PARM if invalid resource or address, |
| 674 | * - SC_ERR_NOACCESS if caller's partition is not the parent of the |
| 675 | * resource (CPU) owner |
| 676 | */ |
| 677 | sc_err_t sc_pm_cpu_start(sc_ipc_t ipc, sc_rsrc_t resource, sc_bool_t enable, |
| 678 | sc_faddr_t address); |
| 679 | |
| 680 | /* @} */ |
| 681 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 682 | #endif /* SCI_PM_API_H */ |
Anson Huang | b629413 | 2018-06-05 16:05:59 +0800 | [diff] [blame] | 683 | |
| 684 | /**@}*/ |