media: rc: meson-ir: support PM suspend/resume

IR Controller could be used and updated by other processor
while kernel has been suspended.
Reinitialize IR Controller just in case while kernel is resuming.

Signed-off-by: Zelong Dong <zelong.dong@amlogic.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Zelong Dong 2024-07-03 17:38:58 +08:00 committed by Hans Verkuil
parent 8400291e28
commit 512d1899b8

View File

@ -567,6 +567,32 @@ static void meson_ir_shutdown(struct platform_device *pdev)
spin_unlock_irqrestore(&ir->lock, flags);
}
static __maybe_unused int meson_ir_resume(struct device *dev)
{
struct meson_ir *ir = dev_get_drvdata(dev);
if (ir->param->support_hw_decoder)
meson_ir_hw_decoder_init(ir->rc, &ir->rc->enabled_protocols);
else
meson_ir_sw_decoder_init(ir->rc);
return 0;
}
static __maybe_unused int meson_ir_suspend(struct device *dev)
{
struct meson_ir *ir = dev_get_drvdata(dev);
unsigned long flags;
spin_lock_irqsave(&ir->lock, flags);
regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_ENABLE, 0);
spin_unlock_irqrestore(&ir->lock, flags);
return 0;
}
static SIMPLE_DEV_PM_OPS(meson_ir_pm_ops, meson_ir_suspend, meson_ir_resume);
static const struct meson_ir_param meson6_ir_param = {
.support_hw_decoder = false,
.max_register = IR_DEC_REG1,
@ -607,6 +633,7 @@ static struct platform_driver meson_ir_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = meson_ir_match,
.pm = pm_ptr(&meson_ir_pm_ops),
},
};