Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: Combine field toggle macro and sequence write macro.

[Why]
field toggle write is actual field sequence write with the same
field name.

[How]
Use REG_UPDATE_SEQ_2 for both sequence write and toggle.
Rename REG_UPDATE_1by1_3 to REG_UPDATE_SEQ_3.

Signed-off-by: Yongqiang Sun <yongqiang.sun@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Yongqiang Sun and committed by
Alex Deucher
30eb85ff 5d87a3fd

+16 -20
+11 -11
drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
··· 171 171 (request->action == I2CAUX_TRANSACTION_ACTION_I2C_WRITE_MOT))); 172 172 if (REG(AUXN_IMPCAL)) { 173 173 /* clear_aux_error */ 174 - REG_UPDATE_SEQ(AUXN_IMPCAL, AUXN_CALOUT_ERROR_AK, 175 - 1, 176 - 0); 174 + REG_UPDATE_SEQ_2(AUXN_IMPCAL, 175 + AUXN_CALOUT_ERROR_AK, 1, 176 + AUXN_CALOUT_ERROR_AK, 0); 177 177 178 - REG_UPDATE_SEQ(AUXP_IMPCAL, AUXP_CALOUT_ERROR_AK, 179 - 1, 180 - 0); 178 + REG_UPDATE_SEQ_2(AUXP_IMPCAL, 179 + AUXP_CALOUT_ERROR_AK, 1, 180 + AUXP_CALOUT_ERROR_AK, 0); 181 181 182 182 /* force_default_calibrate */ 183 - REG_UPDATE_1BY1_2(AUXN_IMPCAL, 183 + REG_UPDATE_SEQ_2(AUXN_IMPCAL, 184 184 AUXN_IMPCAL_ENABLE, 1, 185 185 AUXN_IMPCAL_OVERRIDE_ENABLE, 0); 186 186 187 187 /* bug? why AUXN update EN and OVERRIDE_EN 1 by 1 while AUX P toggles OVERRIDE? */ 188 188 189 - REG_UPDATE_SEQ(AUXP_IMPCAL, AUXP_IMPCAL_OVERRIDE_ENABLE, 190 - 1, 191 - 0); 189 + REG_UPDATE_SEQ_2(AUXP_IMPCAL, 190 + AUXP_IMPCAL_OVERRIDE_ENABLE, 1, 191 + AUXP_IMPCAL_OVERRIDE_ENABLE, 0); 192 192 } 193 193 /* set the delay and the number of bytes to write */ 194 194 ··· 267 267 if (!bytes_replied) 268 268 return -1; 269 269 270 - REG_UPDATE_1BY1_3(AUX_SW_DATA, 270 + REG_UPDATE_SEQ_3(AUX_SW_DATA, 271 271 AUX_SW_INDEX, 0, 272 272 AUX_SW_AUTOINCREMENT_DISABLE, 1, 273 273 AUX_SW_DATA_RW, 1);
+3 -2
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c
··· 258 258 { 259 259 struct dcn10_hubbub *hubbub1 = TO_DCN10_HUBBUB(hubbub); 260 260 261 - REG_UPDATE_SEQ(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, 262 - DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, 0, 1); 261 + REG_UPDATE_SEQ_2(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, 262 + DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, 0, 263 + DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, 1); 263 264 } 264 265 265 266 void hubbub1_program_watermarks(
+2 -7
drivers/gpu/drm/amd/display/dc/inc/reg_helper.h
··· 379 379 /* macro to update a register field to specified values in given sequences. 380 380 * useful when toggling bits 381 381 */ 382 - #define REG_UPDATE_SEQ(reg, field, value1, value2) \ 383 - { uint32_t val = REG_UPDATE(reg, field, value1); \ 384 - REG_SET(reg, val, field, value2); } 385 - 386 - /* macro to update fields in register 1 field at a time in given order */ 387 - #define REG_UPDATE_1BY1_2(reg, f1, v1, f2, v2) \ 382 + #define REG_UPDATE_SEQ_2(reg, f1, v1, f2, v2) \ 388 383 { uint32_t val = REG_UPDATE(reg, f1, v1); \ 389 384 REG_SET(reg, val, f2, v2); } 390 385 391 - #define REG_UPDATE_1BY1_3(reg, f1, v1, f2, v2, f3, v3) \ 386 + #define REG_UPDATE_SEQ_3(reg, f1, v1, f2, v2, f3, v3) \ 392 387 { uint32_t val = REG_UPDATE(reg, f1, v1); \ 393 388 val = REG_SET(reg, val, f2, v2); \ 394 389 REG_SET(reg, val, f3, v3); }