Add simple PM hooks into the MXSFB controller to allow proper suspend both of the controller and optionally an attached panel. Signed-off-by: Marek Vasut <marex@xxxxxxx> Cc: Daniel Vetter <daniel.vetter@xxxxxxxx> Cc: Dave Airlie <airlied@xxxxxxxxxx> Cc: Stefan Agner <stefan@xxxxxxxx> --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index 79a18bf..e4eecb3 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -427,12 +427,49 @@ static int mxsfb_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused mxsfb_pm_suspend(struct device *dev) +{ + struct drm_device *drm = dev_get_drvdata(dev); + struct mxsfb_drm_private *mxsfb = drm ? drm->dev_private : NULL; + + if (!mxsfb) + return 0; + + drm_kms_helper_poll_disable(drm); + + mxsfb->state = drm_atomic_helper_suspend(drm); + if (IS_ERR(mxsfb->state)) { + drm_kms_helper_poll_enable(drm); + return PTR_ERR(mxsfb->state); + } + + return 0; +} + +static int __maybe_unused mxsfb_pm_resume(struct device *dev) +{ + struct drm_device *drm = dev_get_drvdata(dev); + struct mxsfb_drm_private *mxsfb = drm ? drm->dev_private : NULL; + + if (!mxsfb) + return 0; + + drm_atomic_helper_resume(drm, mxsfb->state); + drm_kms_helper_poll_enable(drm); + pm_runtime_set_active(dev); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(mxsfb_pm_ops, mxsfb_pm_suspend, mxsfb_pm_resume); + static struct platform_driver mxsfb_platform_driver = { .probe = mxsfb_probe, .remove = mxsfb_remove, .id_table = mxsfb_devtype, .driver = { .name = "mxsfb", + .pm = &mxsfb_pm_ops, .of_match_table = mxsfb_dt_ids, }, }; -- 2.10.2 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel