1 /*
2  * Copyright 2017 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 #ifndef _VEGA12_SMUMANAGER_H_
24 #define _VEGA12_SMUMANAGER_H_
25 
26 #include "hwmgr.h"
27 #include "vega12/smu9_driver_if.h"
28 #include "vega12_hwmgr.h"
29 
30 struct smu_table_entry {
31 	uint32_t version;
32 	uint32_t size;
33 	uint64_t mc_addr;
34 	void *table;
35 	struct amdgpu_bo *handle;
36 };
37 
38 struct smu_table_array {
39 	struct smu_table_entry entry[TABLE_COUNT];
40 };
41 
42 struct vega12_smumgr {
43 	struct smu_table_array            smu_tables;
44 };
45 
46 #define SMU_FEATURES_LOW_MASK        0x00000000FFFFFFFF
47 #define SMU_FEATURES_LOW_SHIFT       0
48 #define SMU_FEATURES_HIGH_MASK       0xFFFFFFFF00000000
49 #define SMU_FEATURES_HIGH_SHIFT      32
50 
51 int vega12_copy_table_from_smc(struct pp_hwmgr *hwmgr,
52 		uint8_t *table, int16_t table_id);
53 int vega12_copy_table_to_smc(struct pp_hwmgr *hwmgr,
54 		uint8_t *table, int16_t table_id);
55 int vega12_enable_smc_features(struct pp_hwmgr *hwmgr,
56 		bool enable, uint64_t feature_mask);
57 int vega12_get_enabled_smc_features(struct pp_hwmgr *hwmgr,
58 		uint64_t *features_enabled);
59 
60 #endif
61 
62