17482a983SStanimir Varbanov /* SPDX-License-Identifier: GPL-2.0-only */ 27482a983SStanimir Varbanov /* Copyright (C) 2019 Linaro Ltd. */ 37482a983SStanimir Varbanov #ifndef __VENUS_PM_HELPERS_H__ 47482a983SStanimir Varbanov #define __VENUS_PM_HELPERS_H__ 57482a983SStanimir Varbanov 67482a983SStanimir Varbanov struct device; 7*08b1cf47SBryan O'Donoghue struct venus_core; 87482a983SStanimir Varbanov 97482a983SStanimir Varbanov #define POWER_ON 1 107482a983SStanimir Varbanov #define POWER_OFF 0 117482a983SStanimir Varbanov 127482a983SStanimir Varbanov struct venus_pm_ops { 13*08b1cf47SBryan O'Donoghue int (*core_get)(struct venus_core *core); 14*08b1cf47SBryan O'Donoghue void (*core_put)(struct venus_core *core); 15*08b1cf47SBryan O'Donoghue int (*core_power)(struct venus_core *core, int on); 167482a983SStanimir Varbanov 177482a983SStanimir Varbanov int (*vdec_get)(struct device *dev); 187482a983SStanimir Varbanov void (*vdec_put)(struct device *dev); 197482a983SStanimir Varbanov int (*vdec_power)(struct device *dev, int on); 207482a983SStanimir Varbanov 217482a983SStanimir Varbanov int (*venc_get)(struct device *dev); 227482a983SStanimir Varbanov void (*venc_put)(struct device *dev); 237482a983SStanimir Varbanov int (*venc_power)(struct device *dev, int on); 247482a983SStanimir Varbanov 254ebf9693SAniket Masule int (*coreid_power)(struct venus_inst *inst, int on); 264ebf9693SAniket Masule 277482a983SStanimir Varbanov int (*load_scale)(struct venus_inst *inst); 287482a983SStanimir Varbanov }; 297482a983SStanimir Varbanov 307482a983SStanimir Varbanov const struct venus_pm_ops *venus_pm_get(enum hfi_version version); 317482a983SStanimir Varbanov venus_pm_load_scale(struct venus_inst * inst)327482a983SStanimir Varbanovstatic inline int venus_pm_load_scale(struct venus_inst *inst) 337482a983SStanimir Varbanov { 347482a983SStanimir Varbanov struct venus_core *core = inst->core; 357482a983SStanimir Varbanov 367482a983SStanimir Varbanov if (!core->pm_ops || !core->pm_ops->load_scale) 377482a983SStanimir Varbanov return 0; 387482a983SStanimir Varbanov 397482a983SStanimir Varbanov return core->pm_ops->load_scale(inst); 407482a983SStanimir Varbanov } 417482a983SStanimir Varbanov venus_pm_acquire_core(struct venus_inst * inst)424ebf9693SAniket Masulestatic inline int venus_pm_acquire_core(struct venus_inst *inst) 434ebf9693SAniket Masule { 444ebf9693SAniket Masule struct venus_core *core = inst->core; 454ebf9693SAniket Masule const struct venus_pm_ops *pm_ops = core->pm_ops; 464ebf9693SAniket Masule int ret = 0; 474ebf9693SAniket Masule 484ebf9693SAniket Masule if (pm_ops && pm_ops->coreid_power) 494ebf9693SAniket Masule ret = pm_ops->coreid_power(inst, POWER_ON); 504ebf9693SAniket Masule 514ebf9693SAniket Masule return ret; 524ebf9693SAniket Masule } 534ebf9693SAniket Masule venus_pm_release_core(struct venus_inst * inst)544ebf9693SAniket Masulestatic inline int venus_pm_release_core(struct venus_inst *inst) 554ebf9693SAniket Masule { 564ebf9693SAniket Masule struct venus_core *core = inst->core; 574ebf9693SAniket Masule const struct venus_pm_ops *pm_ops = core->pm_ops; 584ebf9693SAniket Masule int ret = 0; 594ebf9693SAniket Masule 604ebf9693SAniket Masule if (pm_ops && pm_ops->coreid_power) 614ebf9693SAniket Masule ret = pm_ops->coreid_power(inst, POWER_OFF); 624ebf9693SAniket Masule 634ebf9693SAniket Masule return ret; 644ebf9693SAniket Masule } 654ebf9693SAniket Masule 667482a983SStanimir Varbanov #endif 67