drm/sysfb: ofdrm: Support power management

Set PM ops for the ofdrm driver. Suspend and resume the DRM state
on systems that support it.

Many systems lose the hardware's framebuffer settings on suspend,
hence resuming doesn't work there. Yet some systems, most notably
emulators, keep the hardware state across suspend/resume cycles.
There, DRM's suspend and resume helpers bring back the display on
resume.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patch.msgid.link/20260408120722.328769-4-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2026-04-08 14:03:16 +02:00
parent 3869948631
commit 41820323cc

View File

@ -4,6 +4,7 @@
#include <linux/of_address.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <drm/clients/drm_client_setup.h>
#include <drm/drm_atomic.h>
@ -20,6 +21,7 @@
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_modeset_helper.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
@ -1095,6 +1097,22 @@ static struct drm_driver ofdrm_driver = {
* Platform driver
*/
static int ofdrm_pm_suspend(struct device *dev)
{
struct drm_device *drm = dev_get_drvdata(dev);
return drm_mode_config_helper_suspend(drm);
}
static int ofdrm_pm_resume(struct device *dev)
{
struct drm_device *drm = dev_get_drvdata(dev);
return drm_mode_config_helper_resume(drm);
}
static DEFINE_SIMPLE_DEV_PM_OPS(ofdrm_pm_ops, ofdrm_pm_suspend, ofdrm_pm_resume);
static int ofdrm_probe(struct platform_device *pdev)
{
struct ofdrm_device *odev;
@ -1134,6 +1152,7 @@ static struct platform_driver ofdrm_platform_driver = {
.driver = {
.name = "of-display",
.of_match_table = ofdrm_of_match_display,
.pm = pm_sleep_ptr(&ofdrm_pm_ops),
},
.probe = ofdrm_probe,
.remove = ofdrm_remove,