2 * Copyright 2020 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include "dcn302_hwseq.h"
28 #include "dce/dce_hwseq.h"
30 #include "reg_helper.h"
33 #define DC_LOGGER_INIT(logger)
41 #define FN(reg_name, field_name) \
42 hws->shifts->field_name, hws->masks->field_name
45 void dcn302_dpp_pg_control(struct dce_hwseq
*hws
, unsigned int dpp_inst
, bool power_on
)
47 uint32_t power_gate
= power_on
? 0 : 1;
48 uint32_t pwr_status
= power_on
? 0 : 2;
50 if (hws
->ctx
->dc
->debug
.disable_dpp_power_gate
)
52 if (REG(DOMAIN1_PG_CONFIG
) == 0)
57 REG_UPDATE(DOMAIN1_PG_CONFIG
,
58 DOMAIN1_POWER_GATE
, power_gate
);
60 REG_WAIT(DOMAIN1_PG_STATUS
,
61 DOMAIN1_PGFSM_PWR_STATUS
, pwr_status
,
65 REG_UPDATE(DOMAIN3_PG_CONFIG
,
66 DOMAIN3_POWER_GATE
, power_gate
);
68 REG_WAIT(DOMAIN3_PG_STATUS
,
69 DOMAIN3_PGFSM_PWR_STATUS
, pwr_status
,
73 REG_UPDATE(DOMAIN5_PG_CONFIG
,
74 DOMAIN5_POWER_GATE
, power_gate
);
76 REG_WAIT(DOMAIN5_PG_STATUS
,
77 DOMAIN5_PGFSM_PWR_STATUS
, pwr_status
,
81 REG_UPDATE(DOMAIN7_PG_CONFIG
,
82 DOMAIN7_POWER_GATE
, power_gate
);
84 REG_WAIT(DOMAIN7_PG_STATUS
,
85 DOMAIN7_PGFSM_PWR_STATUS
, pwr_status
,
90 * Do not power gate DPP4, should be left at HW default, power on permanently.
91 * PG on Pipe4 is De-featured, attempting to put it to PG state may result in hard
93 * REG_UPDATE(DOMAIN9_PG_CONFIG,
94 * DOMAIN9_POWER_GATE, power_gate);
96 * REG_WAIT(DOMAIN9_PG_STATUS,
97 * DOMAIN9_PGFSM_PWR_STATUS, pwr_status,
107 void dcn302_hubp_pg_control(struct dce_hwseq
*hws
, unsigned int hubp_inst
, bool power_on
)
109 uint32_t power_gate
= power_on
? 0 : 1;
110 uint32_t pwr_status
= power_on
? 0 : 2;
112 if (hws
->ctx
->dc
->debug
.disable_hubp_power_gate
)
114 if (REG(DOMAIN0_PG_CONFIG
) == 0)
118 case 0: /* DCHUBP0 */
119 REG_UPDATE(DOMAIN0_PG_CONFIG
,
120 DOMAIN0_POWER_GATE
, power_gate
);
122 REG_WAIT(DOMAIN0_PG_STATUS
,
123 DOMAIN0_PGFSM_PWR_STATUS
, pwr_status
,
126 case 1: /* DCHUBP1 */
127 REG_UPDATE(DOMAIN2_PG_CONFIG
,
128 DOMAIN2_POWER_GATE
, power_gate
);
130 REG_WAIT(DOMAIN2_PG_STATUS
,
131 DOMAIN2_PGFSM_PWR_STATUS
, pwr_status
,
134 case 2: /* DCHUBP2 */
135 REG_UPDATE(DOMAIN4_PG_CONFIG
,
136 DOMAIN4_POWER_GATE
, power_gate
);
138 REG_WAIT(DOMAIN4_PG_STATUS
,
139 DOMAIN4_PGFSM_PWR_STATUS
, pwr_status
,
142 case 3: /* DCHUBP3 */
143 REG_UPDATE(DOMAIN6_PG_CONFIG
,
144 DOMAIN6_POWER_GATE
, power_gate
);
146 REG_WAIT(DOMAIN6_PG_STATUS
,
147 DOMAIN6_PGFSM_PWR_STATUS
, pwr_status
,
150 case 4: /* DCHUBP4 */
152 * Do not power gate DCHUB4, should be left at HW default, power on permanently.
153 * PG on Pipe4 is De-featured, attempting to put it to PG state may result in hard
155 * REG_UPDATE(DOMAIN8_PG_CONFIG,
156 * DOMAIN8_POWER_GATE, power_gate);
158 * REG_WAIT(DOMAIN8_PG_STATUS,
159 * DOMAIN8_PGFSM_PWR_STATUS, pwr_status,
169 void dcn302_dsc_pg_control(struct dce_hwseq
*hws
, unsigned int dsc_inst
, bool power_on
)
171 uint32_t power_gate
= power_on
? 0 : 1;
172 uint32_t pwr_status
= power_on
? 0 : 2;
173 uint32_t org_ip_request_cntl
= 0;
175 if (hws
->ctx
->dc
->debug
.disable_dsc_power_gate
)
178 if (REG(DOMAIN16_PG_CONFIG
) == 0)
181 REG_GET(DC_IP_REQUEST_CNTL
, IP_REQUEST_EN
, &org_ip_request_cntl
);
182 if (org_ip_request_cntl
== 0)
183 REG_SET(DC_IP_REQUEST_CNTL
, 0, IP_REQUEST_EN
, 1);
187 REG_UPDATE(DOMAIN16_PG_CONFIG
,
188 DOMAIN16_POWER_GATE
, power_gate
);
190 REG_WAIT(DOMAIN16_PG_STATUS
,
191 DOMAIN16_PGFSM_PWR_STATUS
, pwr_status
,
195 REG_UPDATE(DOMAIN17_PG_CONFIG
,
196 DOMAIN17_POWER_GATE
, power_gate
);
198 REG_WAIT(DOMAIN17_PG_STATUS
,
199 DOMAIN17_PGFSM_PWR_STATUS
, pwr_status
,
203 REG_UPDATE(DOMAIN18_PG_CONFIG
,
204 DOMAIN18_POWER_GATE
, power_gate
);
206 REG_WAIT(DOMAIN18_PG_STATUS
,
207 DOMAIN18_PGFSM_PWR_STATUS
, pwr_status
,
211 REG_UPDATE(DOMAIN19_PG_CONFIG
,
212 DOMAIN19_POWER_GATE
, power_gate
);
214 REG_WAIT(DOMAIN19_PG_STATUS
,
215 DOMAIN19_PGFSM_PWR_STATUS
, pwr_status
,
219 REG_UPDATE(DOMAIN20_PG_CONFIG
,
220 DOMAIN20_POWER_GATE
, power_gate
);
222 REG_WAIT(DOMAIN20_PG_STATUS
,
223 DOMAIN20_PGFSM_PWR_STATUS
, pwr_status
,
231 if (org_ip_request_cntl
== 0)
232 REG_SET(DC_IP_REQUEST_CNTL
, 0, IP_REQUEST_EN
, 0);