Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 1 | /* |
Varun Wadekar | 5528325 | 2020-01-09 08:58:34 -0800 | [diff] [blame] | 2 | * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved. |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Varun Wadekar | 5528325 | 2020-01-09 08:58:34 -0800 | [diff] [blame] | 7 | #ifndef MCE_PRIVATE_H |
| 8 | #define MCE_PRIVATE_H |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 9 | |
Vignesh Radhakrishnan | 3ad7983 | 2017-12-11 13:17:58 -0800 | [diff] [blame] | 10 | #include <stdbool.h> |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 11 | #include <tegra_def.h> |
| 12 | |
| 13 | /******************************************************************************* |
| 14 | * Macros to prepare CSTATE info request |
| 15 | ******************************************************************************/ |
| 16 | /* Description of the parameters for UPDATE_CSTATE_INFO request */ |
Anthony Zhou | c46150f | 2017-09-20 17:18:56 +0800 | [diff] [blame] | 17 | #define CLUSTER_CSTATE_MASK 0x7U |
| 18 | #define CLUSTER_CSTATE_SHIFT 0X0U |
| 19 | #define CLUSTER_CSTATE_UPDATE_BIT (1U << 7) |
Vignesh Radhakrishnan | 706b9fe | 2017-11-04 16:36:23 -0700 | [diff] [blame] | 20 | #define CCPLEX_CSTATE_MASK 0x7U |
Anthony Zhou | c46150f | 2017-09-20 17:18:56 +0800 | [diff] [blame] | 21 | #define CCPLEX_CSTATE_SHIFT 8U |
| 22 | #define CCPLEX_CSTATE_UPDATE_BIT (1U << 15) |
| 23 | #define SYSTEM_CSTATE_MASK 0xFU |
| 24 | #define SYSTEM_CSTATE_SHIFT 16U |
| 25 | #define SYSTEM_CSTATE_UPDATE_BIT (1U << 23) |
| 26 | #define CSTATE_WAKE_MASK_UPDATE_BIT (1U << 31) |
| 27 | #define CSTATE_WAKE_MASK_SHIFT 32U |
| 28 | #define CSTATE_WAKE_MASK_CLEAR 0xFFFFFFFFU |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 29 | |
| 30 | /******************************************************************************* |
Steven Kao | 2cdb678 | 2017-01-05 17:04:40 +0800 | [diff] [blame] | 31 | * Core ID mask (bits 3:0 in the online request) |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 32 | ******************************************************************************/ |
Anthony Zhou | c46150f | 2017-09-20 17:18:56 +0800 | [diff] [blame] | 33 | #define MCE_CORE_ID_MASK 0xFU |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 34 | |
| 35 | /******************************************************************************* |
Krishna Sitaraman | 09f6817 | 2017-05-24 17:21:22 -0700 | [diff] [blame] | 36 | * C-state statistics macros |
| 37 | ******************************************************************************/ |
Anthony Zhou | c46150f | 2017-09-20 17:18:56 +0800 | [diff] [blame] | 38 | #define MCE_STAT_ID_SHIFT 16U |
Krishna Sitaraman | 09f6817 | 2017-05-24 17:21:22 -0700 | [diff] [blame] | 39 | |
Dilan Lee | 4e7a63c | 2017-08-10 16:01:42 +0800 | [diff] [blame] | 40 | /******************************************************************************* |
| 41 | * Security config macros |
| 42 | ******************************************************************************/ |
| 43 | #define STRICT_CHECKING_ENABLED_SET (1UL << 0) |
| 44 | #define STRICT_CHECKING_LOCKED_SET (1UL << 1) |
| 45 | |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 46 | /* declarations for NVG handler functions */ |
Steven Kao | 2cdb678 | 2017-01-05 17:04:40 +0800 | [diff] [blame] | 47 | uint64_t nvg_get_version(void); |
Steven Kao | 2cdb678 | 2017-01-05 17:04:40 +0800 | [diff] [blame] | 48 | void nvg_set_wake_time(uint32_t wake_time); |
| 49 | void nvg_update_cstate_info(uint32_t cluster, uint32_t ccplex, |
| 50 | uint32_t system, uint32_t wake_mask, uint8_t update_wake_mask); |
Steven Kao | 2cdb678 | 2017-01-05 17:04:40 +0800 | [diff] [blame] | 51 | int32_t nvg_set_cstate_stat_query_value(uint64_t data); |
| 52 | uint64_t nvg_get_cstate_stat_query_value(void); |
| 53 | int32_t nvg_is_sc7_allowed(void); |
| 54 | int32_t nvg_online_core(uint32_t core); |
Steven Kao | 2cdb678 | 2017-01-05 17:04:40 +0800 | [diff] [blame] | 55 | int32_t nvg_update_ccplex_gsc(uint32_t gsc_idx); |
Steven Kao | 2cdb678 | 2017-01-05 17:04:40 +0800 | [diff] [blame] | 56 | int32_t nvg_enter_cstate(uint32_t state, uint32_t wake_time); |
Varun Wadekar | 64c8490 | 2018-05-14 15:54:59 -0700 | [diff] [blame] | 57 | void nvg_enable_strict_checking_mode(void); |
| 58 | void nvg_system_shutdown(void); |
| 59 | void nvg_system_reboot(void); |
| 60 | |
| 61 | /* declarations for assembly functions */ |
Steven Kao | 2cdb678 | 2017-01-05 17:04:40 +0800 | [diff] [blame] | 62 | void nvg_set_request_data(uint64_t req, uint64_t data); |
| 63 | void nvg_set_request(uint64_t req); |
| 64 | uint64_t nvg_get_result(void); |
Steven Kao | 238d6d2 | 2017-08-16 20:12:00 +0800 | [diff] [blame] | 65 | uint64_t nvg_cache_clean(void); |
| 66 | uint64_t nvg_cache_clean_inval(void); |
| 67 | uint64_t nvg_cache_inval_all(void); |
Dilan Lee | 4e7a63c | 2017-08-10 16:01:42 +0800 | [diff] [blame] | 68 | |
| 69 | /* MCE helper functions */ |
| 70 | void mce_enable_strict_checking(void); |
Vignesh Radhakrishnan | 3ad7983 | 2017-12-11 13:17:58 -0800 | [diff] [blame] | 71 | void mce_system_shutdown(void); |
| 72 | void mce_system_reboot(void); |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 73 | |
Varun Wadekar | 5528325 | 2020-01-09 08:58:34 -0800 | [diff] [blame] | 74 | #endif /* MCE_PRIVATE_H */ |