1 /*	$NetBSD: cz_ppsmc.h,v 1.2 2021/12/18 23:45:26 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2014 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25 
26 #ifndef CZ_PP_SMC_H
27 #define CZ_PP_SMC_H
28 
29 #pragma pack(push, 1)
30 
31 /* Fan control algorithm:*/
32 #define FDO_MODE_HARDWARE 0
33 #define FDO_MODE_PIECE_WISE_LINEAR 1
34 
35 enum FAN_CONTROL {
36     FAN_CONTROL_FUZZY,
37     FAN_CONTROL_TABLE
38 };
39 
40 enum DPM_ARRAY {
41     DPM_ARRAY_HARD_MAX,
42     DPM_ARRAY_HARD_MIN,
43     DPM_ARRAY_SOFT_MAX,
44     DPM_ARRAY_SOFT_MIN
45 };
46 
47 /*
48  * Return codes for driver to SMC communication.
49  * Leave these #define-s, enums might not be exactly 8-bits on the microcontroller.
50  */
51 #define PPSMC_Result_OK             ((uint16_t)0x01)
52 #define PPSMC_Result_NoMore         ((uint16_t)0x02)
53 #define PPSMC_Result_NotNow         ((uint16_t)0x03)
54 #define PPSMC_Result_Failed         ((uint16_t)0xFF)
55 #define PPSMC_Result_UnknownCmd     ((uint16_t)0xFE)
56 #define PPSMC_Result_UnknownVT      ((uint16_t)0xFD)
57 
58 #define PPSMC_isERROR(x)            ((uint16_t)0x80 & (x))
59 
60 /*
61  * Supported driver messages
62  */
63 #define PPSMC_MSG_Test                        ((uint16_t) 0x1)
64 #define PPSMC_MSG_GetFeatureStatus            ((uint16_t) 0x2)
65 #define PPSMC_MSG_EnableAllSmuFeatures        ((uint16_t) 0x3)
66 #define PPSMC_MSG_DisableAllSmuFeatures       ((uint16_t) 0x4)
67 #define PPSMC_MSG_OptimizeBattery             ((uint16_t) 0x5)
68 #define PPSMC_MSG_MaximizePerf                ((uint16_t) 0x6)
69 #define PPSMC_MSG_UVDPowerOFF                 ((uint16_t) 0x7)
70 #define PPSMC_MSG_UVDPowerON                  ((uint16_t) 0x8)
71 #define PPSMC_MSG_VCEPowerOFF                 ((uint16_t) 0x9)
72 #define PPSMC_MSG_VCEPowerON                  ((uint16_t) 0xA)
73 #define PPSMC_MSG_ACPPowerOFF                 ((uint16_t) 0xB)
74 #define PPSMC_MSG_ACPPowerON                  ((uint16_t) 0xC)
75 #define PPSMC_MSG_SDMAPowerOFF                ((uint16_t) 0xD)
76 #define PPSMC_MSG_SDMAPowerON                 ((uint16_t) 0xE)
77 #define PPSMC_MSG_XDMAPowerOFF                ((uint16_t) 0xF)
78 #define PPSMC_MSG_XDMAPowerON                 ((uint16_t) 0x10)
79 #define PPSMC_MSG_SetMinDeepSleepSclk         ((uint16_t) 0x11)
80 #define PPSMC_MSG_SetSclkSoftMin              ((uint16_t) 0x12)
81 #define PPSMC_MSG_SetSclkSoftMax              ((uint16_t) 0x13)
82 #define PPSMC_MSG_SetSclkHardMin              ((uint16_t) 0x14)
83 #define PPSMC_MSG_SetSclkHardMax              ((uint16_t) 0x15)
84 #define PPSMC_MSG_SetLclkSoftMin              ((uint16_t) 0x16)
85 #define PPSMC_MSG_SetLclkSoftMax              ((uint16_t) 0x17)
86 #define PPSMC_MSG_SetLclkHardMin              ((uint16_t) 0x18)
87 #define PPSMC_MSG_SetLclkHardMax              ((uint16_t) 0x19)
88 #define PPSMC_MSG_SetUvdSoftMin               ((uint16_t) 0x1A)
89 #define PPSMC_MSG_SetUvdSoftMax               ((uint16_t) 0x1B)
90 #define PPSMC_MSG_SetUvdHardMin               ((uint16_t) 0x1C)
91 #define PPSMC_MSG_SetUvdHardMax               ((uint16_t) 0x1D)
92 #define PPSMC_MSG_SetEclkSoftMin              ((uint16_t) 0x1E)
93 #define PPSMC_MSG_SetEclkSoftMax              ((uint16_t) 0x1F)
94 #define PPSMC_MSG_SetEclkHardMin              ((uint16_t) 0x20)
95 #define PPSMC_MSG_SetEclkHardMax              ((uint16_t) 0x21)
96 #define PPSMC_MSG_SetAclkSoftMin              ((uint16_t) 0x22)
97 #define PPSMC_MSG_SetAclkSoftMax              ((uint16_t) 0x23)
98 #define PPSMC_MSG_SetAclkHardMin              ((uint16_t) 0x24)
99 #define PPSMC_MSG_SetAclkHardMax              ((uint16_t) 0x25)
100 #define PPSMC_MSG_SetNclkSoftMin              ((uint16_t) 0x26)
101 #define PPSMC_MSG_SetNclkSoftMax              ((uint16_t) 0x27)
102 #define PPSMC_MSG_SetNclkHardMin              ((uint16_t) 0x28)
103 #define PPSMC_MSG_SetNclkHardMax              ((uint16_t) 0x29)
104 #define PPSMC_MSG_SetPstateSoftMin            ((uint16_t) 0x2A)
105 #define PPSMC_MSG_SetPstateSoftMax            ((uint16_t) 0x2B)
106 #define PPSMC_MSG_SetPstateHardMin            ((uint16_t) 0x2C)
107 #define PPSMC_MSG_SetPstateHardMax            ((uint16_t) 0x2D)
108 #define PPSMC_MSG_DisableLowMemoryPstate      ((uint16_t) 0x2E)
109 #define PPSMC_MSG_EnableLowMemoryPstate       ((uint16_t) 0x2F)
110 #define PPSMC_MSG_UcodeAddressLow             ((uint16_t) 0x30)
111 #define PPSMC_MSG_UcodeAddressHigh            ((uint16_t) 0x31)
112 #define PPSMC_MSG_UcodeLoadStatus             ((uint16_t) 0x32)
113 #define PPSMC_MSG_DriverDramAddrHi            ((uint16_t) 0x33)
114 #define PPSMC_MSG_DriverDramAddrLo            ((uint16_t) 0x34)
115 #define PPSMC_MSG_CondExecDramAddrHi          ((uint16_t) 0x35)
116 #define PPSMC_MSG_CondExecDramAddrLo          ((uint16_t) 0x36)
117 #define PPSMC_MSG_LoadUcodes                  ((uint16_t) 0x37)
118 #define PPSMC_MSG_DriverResetMode             ((uint16_t) 0x38)
119 #define PPSMC_MSG_PowerStateNotify            ((uint16_t) 0x39)
120 #define PPSMC_MSG_SetDisplayPhyConfig         ((uint16_t) 0x3A)
121 #define PPSMC_MSG_GetMaxSclkLevel             ((uint16_t) 0x3B)
122 #define PPSMC_MSG_GetMaxLclkLevel             ((uint16_t) 0x3C)
123 #define PPSMC_MSG_GetMaxUvdLevel              ((uint16_t) 0x3D)
124 #define PPSMC_MSG_GetMaxEclkLevel             ((uint16_t) 0x3E)
125 #define PPSMC_MSG_GetMaxAclkLevel             ((uint16_t) 0x3F)
126 #define PPSMC_MSG_GetMaxNclkLevel             ((uint16_t) 0x40)
127 #define PPSMC_MSG_GetMaxPstate                ((uint16_t) 0x41)
128 #define PPSMC_MSG_DramAddrHiVirtual           ((uint16_t) 0x42)
129 #define PPSMC_MSG_DramAddrLoVirtual           ((uint16_t) 0x43)
130 #define PPSMC_MSG_DramAddrHiPhysical          ((uint16_t) 0x44)
131 #define PPSMC_MSG_DramAddrLoPhysical          ((uint16_t) 0x45)
132 #define PPSMC_MSG_DramBufferSize              ((uint16_t) 0x46)
133 #define PPSMC_MSG_SetMmPwrLogDramAddrHi       ((uint16_t) 0x47)
134 #define PPSMC_MSG_SetMmPwrLogDramAddrLo       ((uint16_t) 0x48)
135 #define PPSMC_MSG_SetClkTableAddrHi           ((uint16_t) 0x49)
136 #define PPSMC_MSG_SetClkTableAddrLo           ((uint16_t) 0x4A)
137 #define PPSMC_MSG_GetConservativePowerLimit   ((uint16_t) 0x4B)
138 
139 #define PPSMC_MSG_InitJobs                    ((uint16_t) 0x252)
140 #define PPSMC_MSG_ExecuteJob                  ((uint16_t) 0x254)
141 
142 #define PPSMC_MSG_NBDPM_Enable                ((uint16_t) 0x140)
143 #define PPSMC_MSG_NBDPM_Disable               ((uint16_t) 0x141)
144 
145 #define PPSMC_MSG_DPM_FPS_Mode                ((uint16_t) 0x15d)
146 #define PPSMC_MSG_DPM_Activity_Mode           ((uint16_t) 0x15e)
147 
148 #define PPSMC_MSG_PmStatusLogStart            ((uint16_t) 0x170)
149 #define PPSMC_MSG_PmStatusLogSample           ((uint16_t) 0x171)
150 
151 #define PPSMC_MSG_AllowLowSclkInterrupt       ((uint16_t) 0x184)
152 #define PPSMC_MSG_MmPowerMonitorStart         ((uint16_t) 0x18F)
153 #define PPSMC_MSG_MmPowerMonitorStop          ((uint16_t) 0x190)
154 #define PPSMC_MSG_MmPowerMonitorRestart       ((uint16_t) 0x191)
155 
156 #define PPSMC_MSG_SetClockGateMask            ((uint16_t) 0x260)
157 #define PPSMC_MSG_SetFpsThresholdLo           ((uint16_t) 0x264)
158 #define PPSMC_MSG_SetFpsThresholdHi           ((uint16_t) 0x265)
159 #define PPSMC_MSG_SetLowSclkIntrThreshold     ((uint16_t) 0x266)
160 
161 #define PPSMC_MSG_ClkTableXferToDram          ((uint16_t) 0x267)
162 #define PPSMC_MSG_ClkTableXferToSmu           ((uint16_t) 0x268)
163 #define PPSMC_MSG_GetAverageGraphicsActivity  ((uint16_t) 0x269)
164 #define PPSMC_MSG_GetAverageGioActivity       ((uint16_t) 0x26A)
165 #define PPSMC_MSG_SetLoggerBufferSize         ((uint16_t) 0x26B)
166 #define PPSMC_MSG_SetLoggerAddressHigh        ((uint16_t) 0x26C)
167 #define PPSMC_MSG_SetLoggerAddressLow         ((uint16_t) 0x26D)
168 #define PPSMC_MSG_SetWatermarkFrequency       ((uint16_t) 0x26E)
169 #define PPSMC_MSG_SetDisplaySizePowerParams   ((uint16_t) 0x26F)
170 
171 /* REMOVE LATER*/
172 #define PPSMC_MSG_DPM_ForceState              ((uint16_t) 0x104)
173 
174 /* Feature Enable Masks*/
175 #define NB_DPM_MASK             0x00000800
176 #define VDDGFX_MASK             0x00800000
177 #define VCE_DPM_MASK            0x00400000
178 #define ACP_DPM_MASK            0x00040000
179 #define UVD_DPM_MASK            0x00010000
180 #define GFX_CU_PG_MASK          0x00004000
181 #define SCLK_DPM_MASK           0x00080000
182 
183 #if !defined(SMC_MICROCODE)
184 #pragma pack(pop)
185 
186 #endif
187 
188 #endif
189