From patchwork Thu Dec 8 02:47:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9467373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9717560231 for ; Fri, 9 Dec 2016 01:42:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 884D028534 for ; Fri, 9 Dec 2016 01:42:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CB3328618; Fri, 9 Dec 2016 01:42:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E037B28534 for ; Fri, 9 Dec 2016 01:42:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5DA8E6E8BF; Fri, 9 Dec 2016 01:41:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 966BF89269 for ; Thu, 8 Dec 2016 02:47:21 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3tZ0Bv5H90z3hjBF; Thu, 8 Dec 2016 03:47:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3tZ0Bv4pkVzvlms; Thu, 8 Dec 2016 03:47:19 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id 6vgu4WDWvL0m; Thu, 8 Dec 2016 03:47:18 +0100 (CET) X-Auth-Info: ++5FwKZTmmGFtN0+32oC4rMNAJdqaZOF+c6zJIPNIDs= Received: from chi.lan (unknown [195.140.253.167]) by mail.mnet-online.de (Postfix) with ESMTPA; Thu, 8 Dec 2016 03:47:18 +0100 (CET) From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: mxsfb: Add PM support to MXSFB Date: Thu, 8 Dec 2016 03:47:15 +0100 Message-Id: <20161208024715.12634-1-marex@denx.de> X-Mailer: git-send-email 2.10.2 X-Mailman-Approved-At: Fri, 09 Dec 2016 01:39:51 +0000 Cc: Marek Vasut , Daniel Vetter , Dave Airlie X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Daniel Vetter Cc: Dave Airlie Cc: Stefan Agner --- 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, }, };