From patchwork Thu Jan 30 21:19:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 3559501 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 C1FF19F381 for ; Thu, 30 Jan 2014 21:23:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1D5E20173 for ; Thu, 30 Jan 2014 21:23:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7D318201C0 for ; Thu, 30 Jan 2014 21:23:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1397347461; Thu, 30 Jan 2014 13:23:03 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f42.google.com (mail-qa0-f42.google.com [209.85.216.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 5195644408 for ; Thu, 30 Jan 2014 13:20:33 -0800 (PST) Received: by mail-qa0-f42.google.com with SMTP id k4so5326399qaq.29 for ; Thu, 30 Jan 2014 13:20:32 -0800 (PST) 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=2BZTEIvTm2y/Hx3rjL2QnTHhmn/+ryJFZDsMedw5phc=; b=VHbGo+pfxPIC6r4daF+5En0jn9tDawNBtzrLittLDiENLBDA8YGpFsqxw+ylaYNqp3 4GULbujiNBF90os6MdoGZmDfJHCFgwUKyWFktvwJl9FTQIUK+mVYafuG6HfKHPfM0eD+ qn+Hu/OzXFv/drsf2lLnK9Mr4EXHjat69fgwM= 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=2BZTEIvTm2y/Hx3rjL2QnTHhmn/+ryJFZDsMedw5phc=; b=Abz4oTq9duaAmP8dL9AK/A3XcYL8Gc1KMADyKt1SgE/uIU3KPxf/uo1DtW8hJQJwoO 6ZCB1dB6/SCniEdhuc6fn5C+ctozZzQmhEhagKx7bmmp8RSjZdL7Lmkw6FkKrUYHXllk Qw2tHoi67KCMcIJzSVso4/0RhdsY4NhqsNNPDK0Hp4dw2Yiy73wUBk0w2z+I3a9ffCj9 lEMa7+NboMfD/a76xkMnpgwrSmUF3CW0fHUApzIobDS2acrjg3YIycLVHrzhEAZB+Quw ny6eCOpC7jOEysxkfe86XUhbE8qS1s50Rf/SkqgXf0XNmqvZ4BiePqLi5M+b04cNXHh4 Sq1Q== X-Gm-Message-State: ALoCoQkJA/5tmjm+et6sTc31o5YjI9eTBfhBBmyKGBiBqSM5Hoh4uVuYOtGZfCiudHrAdZgPrqye X-Received: by 10.224.50.145 with SMTP id z17mr13861622qaf.38.1391116832841; Thu, 30 Jan 2014 13:20:32 -0800 (PST) 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 r13sm20673608qan.7.2014.01.30.13.20.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 13:20:32 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, inki.dae@samsung.com Subject: [PATCH v4 26/34] drm/exynos: Implement dpms display callback in DP Date: Thu, 30 Jan 2014 16:19:25 -0500 Message-Id: <1391116773-28471-27-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1391116773-28471-1-git-send-email-seanpaul@chromium.org> References: <1391116773-28471-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@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.5 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 Changes in v3: None Changes in v4: None drivers/gpu/drm/exynos/exynos_dp_core.c | 142 ++++++++++++++++++-------------- drivers/gpu/drm/exynos/exynos_dp_core.h | 1 + 2 files changed, 81 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c index 5c26161..05ce947 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.c +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c @@ -915,10 +915,78 @@ static int exynos_dp_check_mode(struct exynos_drm_display *display, return 0; } +static void exynos_dp_phy_init(struct exynos_dp_device *dp) +{ + if (dp->phy) { + phy_power_on(dp->phy); + } else if (dp->phy_addr) { + 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) +{ + if (dp->phy) { + phy_power_off(dp->phy); + } else if (dp->phy_addr) { + u32 reg; + + reg = __raw_readl(dp->phy_addr); + reg &= ~(dp->enable_mask); + __raw_writel(reg, dp->phy_addr); + } +} + +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 = { @@ -1040,54 +1108,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) -{ - if (dp->phy) { - phy_power_on(dp->phy); - } else if (dp->phy_addr) { - 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) -{ - if (dp->phy) { - phy_power_off(dp->phy); - } else if (dp->phy_addr) { - u32 reg; - - reg = __raw_readl(dp->phy_addr); - reg &= ~(dp->enable_mask); - __raw_writel(reg, dp->phy_addr); - } -} - -void exynos_dp_poweron(struct exynos_dp_device *dp) -{ - exynos_dp_phy_init(dp); - - clk_prepare_enable(dp->clock); - - exynos_dp_init_dp(dp); - - enable_irq(dp->irq); -} - -void exynos_dp_poweroff(struct exynos_dp_device *dp) -{ - disable_irq(dp->irq); - - flush_work(&dp->hotplug_work); - - exynos_dp_phy_exit(dp); - - clk_disable_unprepare(dp->clock); -} - static int exynos_dp_probe(struct platform_device *pdev) { struct resource *res; @@ -1103,6 +1123,7 @@ static int exynos_dp_probe(struct platform_device *pdev) } dp->dev = &pdev->dev; + dp->dpms_mode = DRM_MODE_DPMS_OFF; dp->video_info = exynos_dp_dt_parse_pdata(&pdev->dev); if (IS_ERR(dp->video_info)) @@ -1148,10 +1169,11 @@ static int exynos_dp_probe(struct platform_device *pdev) 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; @@ -1159,34 +1181,30 @@ static int exynos_dp_probe(struct platform_device *pdev) static int exynos_dp_remove(struct platform_device *pdev) { - 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); - - exynos_dp_phy_exit(dp); - - 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 4f14141..ccaeadc 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.h +++ b/drivers/gpu/drm/exynos/exynos_dp_core.h @@ -154,6 +154,7 @@ struct exynos_dp_device { struct link_train link_train; struct work_struct hotplug_work; struct phy *phy; + int dpms_mode; struct exynos_drm_panel_info panel; };