Merge tag 'drm-misc-fixes-2017-11-20' of git://anongit.freedesktop.org/drm/drm-misc...
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / amd / powerplay / inc / smumgr.h
1 /*
2  * Copyright 2015 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 _SMUMGR_H_
24 #define _SMUMGR_H_
25 #include <linux/types.h>
26 #include "amd_powerplay.h"
27 #include "hwmgr.h"
28
29 #define smu_lower_32_bits(n) ((uint32_t)(n))
30 #define smu_upper_32_bits(n) ((uint32_t)(((n)>>16)>>16))
31
32
33
34 enum AVFS_BTC_STATUS {
35         AVFS_BTC_BOOT = 0,
36         AVFS_BTC_BOOT_STARTEDSMU,
37         AVFS_LOAD_VIRUS,
38         AVFS_BTC_VIRUS_LOADED,
39         AVFS_BTC_VIRUS_FAIL,
40         AVFS_BTC_COMPLETED_PREVIOUSLY,
41         AVFS_BTC_ENABLEAVFS,
42         AVFS_BTC_STARTED,
43         AVFS_BTC_FAILED,
44         AVFS_BTC_RESTOREVFT_FAILED,
45         AVFS_BTC_SAVEVFT_FAILED,
46         AVFS_BTC_DPMTABLESETUP_FAILED,
47         AVFS_BTC_COMPLETED_UNSAVED,
48         AVFS_BTC_COMPLETED_SAVED,
49         AVFS_BTC_COMPLETED_RESTORED,
50         AVFS_BTC_DISABLED,
51         AVFS_BTC_NOTSUPPORTED,
52         AVFS_BTC_SMUMSG_ERROR
53 };
54
55 enum SMU_TABLE {
56         SMU_UVD_TABLE = 0,
57         SMU_VCE_TABLE,
58         SMU_SAMU_TABLE,
59         SMU_BIF_TABLE,
60 };
61
62 enum SMU_TYPE {
63         SMU_SoftRegisters = 0,
64         SMU_Discrete_DpmTable,
65 };
66
67 enum SMU_MEMBER {
68         HandshakeDisables = 0,
69         VoltageChangeTimeout,
70         AverageGraphicsActivity,
71         PreVBlankGap,
72         VBlankTimeout,
73         UcodeLoadStatus,
74         UvdBootLevel,
75         VceBootLevel,
76         SamuBootLevel,
77         LowSclkInterruptThreshold,
78         DRAM_LOG_ADDR_H,
79         DRAM_LOG_ADDR_L,
80         DRAM_LOG_PHY_ADDR_H,
81         DRAM_LOG_PHY_ADDR_L,
82         DRAM_LOG_BUFF_SIZE,
83 };
84
85
86 enum SMU_MAC_DEFINITION {
87         SMU_MAX_LEVELS_GRAPHICS = 0,
88         SMU_MAX_LEVELS_MEMORY,
89         SMU_MAX_LEVELS_LINK,
90         SMU_MAX_ENTRIES_SMIO,
91         SMU_MAX_LEVELS_VDDC,
92         SMU_MAX_LEVELS_VDDGFX,
93         SMU_MAX_LEVELS_VDDCI,
94         SMU_MAX_LEVELS_MVDD,
95         SMU_UVD_MCLK_HANDSHAKE_DISABLE,
96 };
97
98 extern int smum_get_argument(struct pp_hwmgr *hwmgr);
99
100 extern int smum_download_powerplay_table(struct pp_hwmgr *hwmgr, void **table);
101
102 extern int smum_upload_powerplay_table(struct pp_hwmgr *hwmgr);
103
104 extern int smum_send_msg_to_smc(struct pp_hwmgr *hwmgr, uint16_t msg);
105
106 extern int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,
107                                         uint16_t msg, uint32_t parameter);
108
109 extern int smu_allocate_memory(void *device, uint32_t size,
110                          enum cgs_gpu_mem_type type,
111                          uint32_t byte_align, uint64_t *mc_addr,
112                          void **kptr, void *handle);
113
114 extern int smu_free_memory(void *device, void *handle);
115
116 extern int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr);
117
118 extern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type);
119 extern int smum_process_firmware_header(struct pp_hwmgr *hwmgr);
120 extern int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr);
121 extern int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr);
122 extern int smum_init_smc_table(struct pp_hwmgr *hwmgr);
123 extern int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr);
124 extern int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr);
125 extern int smum_initialize_mc_reg_table(struct pp_hwmgr *hwmgr);
126 extern uint32_t smum_get_offsetof(struct pp_hwmgr *hwmgr,
127                                 uint32_t type, uint32_t member);
128 extern uint32_t smum_get_mac_definition(struct pp_hwmgr *hwmgr, uint32_t value);
129
130 extern bool smum_is_dpm_running(struct pp_hwmgr *hwmgr);
131
132 extern int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
133                 struct amd_pp_profile *request);
134
135 extern bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr);
136
137
138 #endif