From patchwork Wed Oct 16 19:26:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 3057561 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 61F399F3E2 for ; Wed, 16 Oct 2013 21:03:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA4BF204B5 for ; Wed, 16 Oct 2013 21:03:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D206D2047C for ; Wed, 16 Oct 2013 21:03:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B043EE69B6 for ; Wed, 16 Oct 2013 14:03:22 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f177.google.com (mail-qc0-f177.google.com [209.85.216.177]) by gabe.freedesktop.org (Postfix) with ESMTP id A4F62E7866 for ; Wed, 16 Oct 2013 12:27:43 -0700 (PDT) Received: by mail-qc0-f177.google.com with SMTP id u18so850436qcx.22 for ; Wed, 16 Oct 2013 12:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RkORILb6zi6co/tQmCStqwdiepgJNjN/Se7PPccm37g=; b=OMYamsisZhwztJw3FGHdQ9Eb9pDjjI7kZ6d+txj5/zV0757piuwMM2Pw6K0bn6gV/A d58gGFrdjJW2YdY+Keq9IRwmKx0C9f2Z/q4Vc2N43TlcHmU4DZ5AqRdavTzogJbt3a6C Ca0gJ18i32LKujHEi3vWPTZvbHHPf4+pleuvw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RkORILb6zi6co/tQmCStqwdiepgJNjN/Se7PPccm37g=; b=axxzCTSKKt69+OLAWrxupdk1Olgo2bYLH9Ij/bingitxJE3G9AgjtE8X8b9Zmx9k6X DkLbKC1/fvMKJkLl/AaFwiOoEh6nG8U4+2MGvN0l7kjRMZkHudfq0jtiCanx8BQ4hHy0 4gfOhr+9gaYrTkdwMvtNdfheKNJ14K/WH6Ww1rln+i/8Hm0g6ZEk4ooGQ3uIKQqL8ToX 8VKF293DaAq+iiz4jfmvfbH3yAOnom/Frmyq+JRhcRpQDgYu5LA7F7Ds+zzLEtDHiw5H k374GSBliXDZk8+3LMsf+4qY0oIbyKxkj5TYPU05gQaVneGnfUPEipiDfJ6nFKRMmLGr vDlw== X-Gm-Message-State: ALoCoQnUTeq+Rf7lRT++PA8sD28zp363/Zu+tA4WCKItVsuOl0QXrCYR47MvJn1rkc1BKDntRpgb X-Received: by 10.49.5.231 with SMTP id v7mr6179178qev.58.1381951662769; Wed, 16 Oct 2013 12:27:42 -0700 (PDT) Received: from seanpaul-glaptop.roam.corp.google.com (cpe-173-095-180-236.nc.res.rr.com. [173.95.180.236]) by mx.google.com with ESMTPSA id 4sm167771575qak.11.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 12:27:42 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, inki.dae@samsung.com Subject: [PATCH v2 24/26] drm/exynos: Implement dpms display callback in DP Date: Wed, 16 Oct 2013 15:26:54 -0400 Message-Id: <1381951616-12548-25-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1381951616-12548-1-git-send-email-seanpaul@chromium.org> References: <1381951616-12548-1-git-send-email-seanpaul@chromium.org> Cc: marcheu@chromium.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements the dpms display callback for the DP driver. Signed-off-by: Sean Paul --- Changes in v2: - Added to the patchset drivers/gpu/drm/exynos/exynos_dp_core.c | 173 ++++++++++++++++---------------- drivers/gpu/drm/exynos/exynos_dp_core.h | 1 + 2 files changed, 85 insertions(+), 89 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c index 13ea8b7..476d3b0 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.c +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c @@ -914,10 +914,82 @@ static int exynos_dp_check_mode(struct exynos_drm_display *display, return 0; } +static void exynos_dp_phy_init(struct exynos_dp_device *dp) +{ + struct exynos_dp_platdata *pdata = dp->dev->platform_data; + u32 reg; + + if (dp->phy_addr) { + reg = readl(dp->phy_addr); + reg |= dp->enable_mask; + writel(reg, dp->phy_addr); + } + + if (pdata && pdata->phy_init) + pdata->phy_init(); +} + +static void exynos_dp_phy_exit(struct exynos_dp_device *dp) +{ + struct exynos_dp_platdata *pdata = dp->dev->platform_data; + u32 reg; + + if (dp->phy_addr) { + reg = readl(dp->phy_addr); + reg &= ~(dp->enable_mask); + writel(reg, dp->phy_addr); + } + + if (pdata && pdata->phy_exit) + pdata->phy_exit(); +} + +static void exynos_dp_poweron(struct exynos_dp_device *dp) +{ + if (dp->dpms_mode == DRM_MODE_DPMS_ON) + return; + + clk_prepare_enable(dp->clock); + exynos_dp_phy_init(dp); + exynos_dp_init_dp(dp); + enable_irq(dp->irq); +} + +static void exynos_dp_poweroff(struct exynos_dp_device *dp) +{ + if (dp->dpms_mode != DRM_MODE_DPMS_ON) + return; + + disable_irq(dp->irq); + flush_work(&dp->hotplug_work); + exynos_dp_phy_exit(dp); + clk_disable_unprepare(dp->clock); +} + +static void exynos_dp_dpms(struct exynos_drm_display *display, int mode) +{ + struct exynos_dp_device *dp = display->ctx; + + switch (mode) { + case DRM_MODE_DPMS_ON: + exynos_dp_poweron(dp); + break; + case DRM_MODE_DPMS_STANDBY: + case DRM_MODE_DPMS_SUSPEND: + case DRM_MODE_DPMS_OFF: + exynos_dp_poweroff(dp); + break; + default: + break; + }; + dp->dpms_mode = mode; +} + static struct exynos_drm_display_ops exynos_dp_display_ops = { .is_connected = exynos_dp_display_is_connected, .get_panel = exynos_dp_get_panel, .check_mode = exynos_dp_check_mode, + .dpms = exynos_dp_dpms, }; static struct exynos_drm_display exynos_dp_display = { @@ -1044,24 +1116,6 @@ static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp) } return 0; } - -static void exynos_dp_phy_init(struct exynos_dp_device *dp) -{ - u32 reg; - - reg = __raw_readl(dp->phy_addr); - reg |= dp->enable_mask; - __raw_writel(reg, dp->phy_addr); -} - -static void exynos_dp_phy_exit(struct exynos_dp_device *dp) -{ - u32 reg; - - reg = __raw_readl(dp->phy_addr); - reg &= ~(dp->enable_mask); - __raw_writel(reg, dp->phy_addr); -} #else static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) { @@ -1089,46 +1143,6 @@ static void exynos_dp_phy_exit(struct exynos_dp_device *dp) } #endif /* CONFIG_OF */ -void exynos_dp_poweron(struct exynos_dp_device *dp) -{ - struct device *dev = dp->dev; - struct exynos_dp_platdata *pdata = dev->platform_data; - - if (dev->of_node) { - if (dp->phy_addr) - exynos_dp_phy_init(dp); - } else { - if (pdata->phy_init) - pdata->phy_init(); - } - - clk_prepare_enable(dp->clock); - - exynos_dp_init_dp(dp); - - enable_irq(dp->irq); -} - -void exynos_dp_poweroff(struct exynos_dp_device *dp) -{ - struct device *dev = dp->dev; - struct exynos_dp_platdata *pdata = dev->platform_data; - - disable_irq(dp->irq); - - flush_work(&dp->hotplug_work); - - if (dev->of_node) { - if (dp->phy_addr) - exynos_dp_phy_exit(dp); - } else { - if (pdata->phy_exit) - pdata->phy_exit(); - } - - clk_disable_unprepare(dp->clock); -} - static int exynos_dp_probe(struct platform_device *pdev) { struct resource *res; @@ -1145,6 +1159,7 @@ static int exynos_dp_probe(struct platform_device *pdev) } dp->dev = &pdev->dev; + dp->dpms_mode = DRM_MODE_DPMS_OFF; if (pdev->dev.of_node) { pdata = exynos_dp_dt_parse_pdata(&pdev->dev); @@ -1190,26 +1205,17 @@ static int exynos_dp_probe(struct platform_device *pdev) dp->video_info = pdata->video_info; - if (pdev->dev.of_node) { - if (dp->phy_addr) - exynos_dp_phy_init(dp); - } else { - if (pdata->phy_init) - pdata->phy_init(); - } - - exynos_dp_init_dp(dp); - ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler, 0, "exynos-dp", dp); if (ret) { dev_err(&pdev->dev, "failed to request irq\n"); return ret; } - - platform_set_drvdata(pdev, dp); + disable_irq(dp->irq); exynos_dp_display.ctx = dp; + + platform_set_drvdata(pdev, &exynos_dp_display); exynos_drm_display_register(&exynos_dp_display); return 0; @@ -1217,41 +1223,30 @@ static int exynos_dp_probe(struct platform_device *pdev) static int exynos_dp_remove(struct platform_device *pdev) { - struct exynos_dp_platdata *pdata = pdev->dev.platform_data; - struct exynos_dp_device *dp = platform_get_drvdata(pdev); + struct exynos_drm_display *display = platform_get_drvdata(pdev); + exynos_dp_dpms(display, DRM_MODE_DPMS_OFF); exynos_drm_display_unregister(&exynos_dp_display); - flush_work(&dp->hotplug_work); - - if (pdev->dev.of_node) { - if (dp->phy_addr) - exynos_dp_phy_exit(dp); - } else { - if (pdata->phy_exit) - pdata->phy_exit(); - } - - clk_disable_unprepare(dp->clock); - - return 0; } #ifdef CONFIG_PM_SLEEP static int exynos_dp_suspend(struct device *dev) { - struct exynos_dp_device *dp = dev_get_drvdata(dev); + struct platform_device *pdev = to_platform_device(dev); + struct exynos_drm_display *display = platform_get_drvdata(pdev); - exynos_dp_poweroff(dp); + exynos_dp_dpms(display, DRM_MODE_DPMS_OFF); return 0; } static int exynos_dp_resume(struct device *dev) { - struct exynos_dp_device *dp = dev_get_drvdata(dev); + struct platform_device *pdev = to_platform_device(dev); + struct exynos_drm_display *display = platform_get_drvdata(pdev); - exynos_dp_poweron(dp); + exynos_dp_dpms(display, DRM_MODE_DPMS_ON); return 0; } #endif diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.h b/drivers/gpu/drm/exynos/exynos_dp_core.h index a5e9145..0c67c19 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.h +++ b/drivers/gpu/drm/exynos/exynos_dp_core.h @@ -45,6 +45,7 @@ struct exynos_dp_device { struct video_info *video_info; struct link_train link_train; struct work_struct hotplug_work; + int dpms_mode; struct exynos_drm_panel_info panel; };