Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / drivers / gpu / drm / amd / powerplay / inc / smu_v11_0.h
1 /*
2  * Copyright 2019 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 __SMU_V11_0_H__
24 #define __SMU_V11_0_H__
25
26 #include "amdgpu_smu.h"
27
28 /* MP Apertures */
29 #define MP0_Public                      0x03800000
30 #define MP0_SRAM                        0x03900000
31 #define MP1_Public                      0x03b00000
32 #define MP1_SRAM                        0x03c00004
33 #define MP1_SMC_SIZE            0x40000
34
35 /* address block */
36 #define smnMP1_FIRMWARE_FLAGS           0x3010024
37 #define smnMP0_FW_INTF                  0x30101c0
38 #define smnMP1_PUB_CTRL                 0x3010b14
39
40 #define TEMP_RANGE_MIN                  (0)
41 #define TEMP_RANGE_MAX                  (80 * 1000)
42
43 #define SMU11_TOOL_SIZE                 0x19000
44
45 #define CLK_MAP(clk, index) \
46         [SMU_##clk] = index
47
48 #define FEA_MAP(fea) \
49         [SMU_FEATURE_##fea##_BIT] = FEATURE_##fea##_BIT
50
51 #define TAB_MAP(tab) \
52         [SMU_TABLE_##tab] = TABLE_##tab
53
54 #define PWR_MAP(tab) \
55         [SMU_POWER_SOURCE_##tab] = POWER_SOURCE_##tab
56
57 #define WORKLOAD_MAP(profile, workload) \
58         [profile] = workload
59
60 struct smu_11_0_max_sustainable_clocks {
61         uint32_t display_clock;
62         uint32_t phy_clock;
63         uint32_t pixel_clock;
64         uint32_t uclock;
65         uint32_t dcef_clock;
66         uint32_t soc_clock;
67 };
68
69 struct smu_11_0_dpm_table {
70         uint32_t    min;        /* MHz */
71         uint32_t    max;        /* MHz */
72 };
73
74 struct smu_11_0_dpm_tables {
75         struct smu_11_0_dpm_table        soc_table;
76         struct smu_11_0_dpm_table        gfx_table;
77         struct smu_11_0_dpm_table        uclk_table;
78         struct smu_11_0_dpm_table        eclk_table;
79         struct smu_11_0_dpm_table        vclk_table;
80         struct smu_11_0_dpm_table        dclk_table;
81         struct smu_11_0_dpm_table        dcef_table;
82         struct smu_11_0_dpm_table        pixel_table;
83         struct smu_11_0_dpm_table        display_table;
84         struct smu_11_0_dpm_table        phy_table;
85         struct smu_11_0_dpm_table        fclk_table;
86 };
87
88 struct smu_11_0_dpm_context {
89         struct smu_11_0_dpm_tables  dpm_tables;
90         uint32_t                    workload_policy_mask;
91         uint32_t                    dcef_min_ds_clk;
92 };
93
94 enum smu_11_0_power_state {
95         SMU_11_0_POWER_STATE__D0 = 0,
96         SMU_11_0_POWER_STATE__D1,
97         SMU_11_0_POWER_STATE__D3, /* Sleep*/
98         SMU_11_0_POWER_STATE__D4, /* Hibernate*/
99         SMU_11_0_POWER_STATE__D5, /* Power off*/
100 };
101
102 struct smu_11_0_power_context {
103         uint32_t        power_source;
104         uint8_t         in_power_limit_boost_mode;
105         enum smu_11_0_power_state power_state;
106 };
107
108 enum smu_v11_0_baco_seq {
109         BACO_SEQ_BACO = 0,
110         BACO_SEQ_MSR,
111         BACO_SEQ_BAMACO,
112         BACO_SEQ_ULPS,
113         BACO_SEQ_COUNT,
114 };
115
116 void smu_v11_0_set_smu_funcs(struct smu_context *smu);
117
118 #endif