Skip to content

Commit ec9a652

Browse files
Jagadeesh Konastorulf
authored andcommitted
venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode on V6
The Venus driver requires vcodec GDSC to be ON in SW mode for clock operations and move it back to HW mode to gain power benefits. Earlier, as there is no interface to switch the GDSC mode from GenPD framework, the GDSC is moved to HW control mode as part of GDSC enable callback and venus driver is writing to its POWER_CONTROL register to keep the GDSC ON from SW whereever required. But the POWER_CONTROL register addresses are not constant and can vary across the variants. Also as per the HW recommendation, the GDSC mode switching needs to be controlled from respective GDSC register and this is a uniform approach across all the targets. Hence use dev_pm_genpd_set_hwmode() API which controls GDSC mode switching using its respective GDSC register. In venus V6 variants, the vcodec gdsc gets enabled in SW mode by default with new HW_CTRL_TRIGGER flag and there is no need to switch it to SW mode again after enable, hence add check to avoid switching gdsc to SW mode again after gdsc enable. Similarly add check to avoid switching GDSC to HW mode before disabling the GDSC, so GDSC gets enabled in SW mode in the next enable. Signed-off-by: Jagadeesh Kona <[email protected]> Signed-off-by: Abel Vesa <[email protected]> Tested-by: Bryan O'Donoghue <[email protected]> Reviewed-by: Taniya Das <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 4c2aeca commit ec9a652

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

drivers/media/platform/qcom/venus/pm_helpers.c

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,9 @@ static int vcodec_control_v4(struct venus_core *core, u32 coreid, bool enable)
412412
u32 val;
413413
int ret;
414414

415-
if (IS_V6(core)) {
416-
ctrl = core->wrapper_base + WRAPPER_CORE_POWER_CONTROL_V6;
417-
stat = core->wrapper_base + WRAPPER_CORE_POWER_STATUS_V6;
418-
} else if (coreid == VIDC_CORE_ID_1) {
415+
if (IS_V6(core))
416+
return dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[coreid], !enable);
417+
else if (coreid == VIDC_CORE_ID_1) {
419418
ctrl = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL;
420419
stat = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_STATUS;
421420
} else {
@@ -451,9 +450,11 @@ static int poweroff_coreid(struct venus_core *core, unsigned int coreid_mask)
451450

452451
vcodec_clks_disable(core, core->vcodec0_clks);
453452

454-
ret = vcodec_control_v4(core, VIDC_CORE_ID_1, false);
455-
if (ret)
456-
return ret;
453+
if (!IS_V6(core)) {
454+
ret = vcodec_control_v4(core, VIDC_CORE_ID_1, false);
455+
if (ret)
456+
return ret;
457+
}
457458

458459
ret = pm_runtime_put_sync(core->pmdomains->pd_devs[1]);
459460
if (ret < 0)
@@ -467,9 +468,11 @@ static int poweroff_coreid(struct venus_core *core, unsigned int coreid_mask)
467468

468469
vcodec_clks_disable(core, core->vcodec1_clks);
469470

470-
ret = vcodec_control_v4(core, VIDC_CORE_ID_2, false);
471-
if (ret)
472-
return ret;
471+
if (!IS_V6(core)) {
472+
ret = vcodec_control_v4(core, VIDC_CORE_ID_2, false);
473+
if (ret)
474+
return ret;
475+
}
473476

474477
ret = pm_runtime_put_sync(core->pmdomains->pd_devs[2]);
475478
if (ret < 0)
@@ -488,9 +491,11 @@ static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
488491
if (ret < 0)
489492
return ret;
490493

491-
ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
492-
if (ret)
493-
return ret;
494+
if (!IS_V6(core)) {
495+
ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
496+
if (ret)
497+
return ret;
498+
}
494499

495500
ret = vcodec_clks_enable(core, core->vcodec0_clks);
496501
if (ret)
@@ -506,9 +511,11 @@ static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
506511
if (ret < 0)
507512
return ret;
508513

509-
ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
510-
if (ret)
511-
return ret;
514+
if (!IS_V6(core)) {
515+
ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
516+
if (ret)
517+
return ret;
518+
}
512519

513520
ret = vcodec_clks_enable(core, core->vcodec1_clks);
514521
if (ret)

0 commit comments

Comments
 (0)