From patchwork Mon Jan 16 10:08:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9518359 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 7695F6020B for ; Mon, 16 Jan 2017 10:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43D2728364 for ; Mon, 16 Jan 2017 10:09:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38799283FD; Mon, 16 Jan 2017 10:09: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=-2.0 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM,URIBL_BLACK 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 AA26E28438 for ; Mon, 16 Jan 2017 10:09:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A722B6E2C3; Mon, 16 Jan 2017 10:09:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F14C6E2C3 for ; Mon, 16 Jan 2017 10:09:07 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id t6so952280pgt.1 for ; Mon, 16 Jan 2017 02:09:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tKVYFfiQxfSEehdnUfahx5l0z6uVUEVYGqt04ljVAbQ=; b=p1W18npjijYZu5yyIEnezHmOOhJeawtZHI7sS84PmvfRXj7XtVrgvw66UtoOznS/TL jbMC52Ykom3Rl+N2cUICcRnuLvuKZV2MMHbf/Vq//FHIqp1kRFRKXfn/aO5ygTb4/CZW HSOkRJY5XkZ2FO4hR/0yHAbbvqGNvyGX4SEjXzdaJMK9R7a7821pSKincDxwRHiL+X2k Z3Y5lFjExIgQLIZXIiOs9SUFBjzjpa9J2AG8REMPAM3Z4EV+PDUCJUH2FcOk/M+8Erda zCCQcnusDsSb/tUmV1rgsjGHm2iAvQYKohQCHI6cp2DU9pBdsJhrDi15aUQdeMloQ7Nn Wamg== X-Gm-Message-State: AIkVDXJpQIVzFdsPf3jJ9yH3dQgV+aXxO9mS77Ii6c3kZkQvcQ1zOMA7Ue0QSBm9wCTrBQ== X-Received: by 10.84.225.20 with SMTP id t20mr50095055plj.154.1484561346708; Mon, 16 Jan 2017 02:09:06 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id k78sm46351848pfb.93.2017.01.16.02.09.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jan 2017 02:09:06 -0800 (PST) From: Chris Zhong To: dianders@chromium.org, tfiga@chromium.org, heiko@sntech.de, yzq@rock-chips.com, mark.rutland@arm.com, devicetree@vger.kernel.org, robh+dt@kernel.org, galak@codeaurora.org, pawel.moll@arm.com, seanpaul@chromium.org Subject: [PATCH v2 05/11] drm/rockchip/dsi: add dw-mipi power domain support Date: Mon, 16 Jan 2017 18:08:25 +0800 Message-Id: <1484561311-494-6-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1484561311-494-1-git-send-email-zyw@rock-chips.com> References: <1484561311-494-1-git-send-email-zyw@rock-chips.com> Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Chris Zhong , linux-arm-kernel@lists.infradead.org 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 Reference the power domain incase dw-mipi power down when in use. Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 8f8d48a..d2a3efb 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -291,6 +292,7 @@ struct dw_mipi_dsi { struct clk *pclk; struct clk *phy_cfg_clk; + int dpms_mode; unsigned int lane_mbps; /* per lane */ u32 channel; u32 lanes; @@ -842,6 +844,9 @@ static void dw_mipi_dsi_encoder_mode_set(struct drm_encoder *encoder, struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder); int ret; + if (dsi->dpms_mode == DRM_MODE_DPMS_ON) + return; + dsi->mode = adjusted_mode; ret = dw_mipi_dsi_get_lane_bps(dsi); @@ -853,6 +858,8 @@ static void dw_mipi_dsi_encoder_mode_set(struct drm_encoder *encoder, return; } + pm_runtime_get_sync(dsi->dev); + dw_mipi_dsi_init(dsi); dw_mipi_dsi_dpi_config(dsi, mode); dw_mipi_dsi_packet_handler_config(dsi); @@ -874,6 +881,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) { struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder); + if (dsi->dpms_mode != DRM_MODE_DPMS_ON) + return; + drm_panel_disable(dsi->panel); if (clk_prepare_enable(dsi->pclk)) { @@ -893,7 +903,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) dw_mipi_dsi_set_mode(dsi, DW_MIPI_DSI_CMD_MODE); dw_mipi_dsi_disable(dsi); + pm_runtime_put(dsi->dev); clk_disable_unprepare(dsi->pclk); + dsi->dpms_mode = DRM_MODE_DPMS_OFF; } static void dw_mipi_dsi_encoder_commit(struct drm_encoder *encoder) @@ -927,6 +939,7 @@ static void dw_mipi_dsi_encoder_commit(struct drm_encoder *encoder) regmap_write(dsi->grf_regmap, pdata->grf_switch_reg, val); dev_dbg(dsi->dev, "vop %s output to dsi0\n", (mux) ? "LIT" : "BIG"); + dsi->dpms_mode = DRM_MODE_DPMS_ON; } static int @@ -1094,6 +1107,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, dsi->dev = dev; dsi->pdata = pdata; + dsi->dpms_mode = DRM_MODE_DPMS_OFF; ret = rockchip_mipi_parse_dt(dsi); if (ret) @@ -1139,6 +1153,8 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, dev_set_drvdata(dev, dsi); + pm_runtime_enable(dev); + dsi->dsi_host.ops = &dw_mipi_dsi_host_ops; dsi->dsi_host.dev = dev; return mipi_dsi_host_register(&dsi->dsi_host); @@ -1154,6 +1170,7 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master, struct dw_mipi_dsi *dsi = dev_get_drvdata(dev); mipi_dsi_host_unregister(&dsi->dsi_host); + pm_runtime_disable(dev); clk_disable_unprepare(dsi->pllref_clk); }