From patchwork Fri Jul 8 09:04:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9220213 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 7CE0E6044F for ; Fri, 8 Jul 2016 09:06:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C0BC2860D for ; Fri, 8 Jul 2016 09:06:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60C7028610; Fri, 8 Jul 2016 09:06:43 +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=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BA96285F9 for ; Fri, 8 Jul 2016 09:06:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bLRk9-00012e-Ov; Fri, 08 Jul 2016 09:06:41 +0000 Received: from mail-pf0-f196.google.com ([209.85.192.196]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bLRjN-00007E-UX; Fri, 08 Jul 2016 09:06:05 +0000 Received: by mail-pf0-f196.google.com with SMTP id c74so5475573pfb.0; Fri, 08 Jul 2016 02:05:33 -0700 (PDT) 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=ePGq04A0v7AMKXgeFpoVAZdfPRSB7gpm96HCG3vTlrc=; b=TQbn8K0S7S8TYt9SUQGa3ml088NIkZbR+BVlFskRGpS+7wSpz/g6QRzhK/jfhqxtln OfuDSJ3NqKNTRUPaWbfnH0tIm24D9I3H0mtaHa9iI59RdEjZkroEgzlF+qmy5kABYmNi nKTLDEURE0N7OWyd9Y7rk7eg3ifViwlvIC7rKBGht0Sogp3HbXqZMWH1DnkdDcLU5fx7 aGUkLjsJwuZeVIp/dIyGj8hwciiEx2IPE8CZXZCrzipBdJc6Ij83H7d55Wwpts5jKn5z uft36Jw4qDS8gwKtxDHzu81t1U1ac1hB73BFI5GlfV3pc73JDMfi5+2dtP3rPy5NM39p u2qw== X-Gm-Message-State: ALyK8tKIUsI1vPyTiTrnlce9v/K1EXL5XIWKVf7/99/VmBeTWJCXUPhr2YgIle7rWFrbuw== X-Received: by 10.98.90.193 with SMTP id o184mr8067014pfb.101.1467968733047; Fri, 08 Jul 2016 02:05:33 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id by5sm3289881pad.36.2016.07.08.02.05.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jul 2016 02:05:31 -0700 (PDT) From: Chris Zhong To: dianders@chromium.org, tfiga@chromium.org, heiko@sntech.de, yzq@rock-chips.com Subject: [PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll Date: Fri, 8 Jul 2016 17:04:59 +0800 Message-Id: <1467968701-15620-6-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1467968701-15620-1-git-send-email-zyw@rock-chips.com> References: <1467968701-15620-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160708_020554_430945_09831177 X-CRM114-Status: GOOD ( 13.78 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Chris Zhong , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP At the first time of bind, there is no any panel attach in mipi. Add a DRM_CONNECTOR_POLL_HPD porperty to detect the panel status, when panel probe, the dw_mipi_dsi_host_attach would be called, then mipi-dsi will trigger a event to notify the drm framework. Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 41 ++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 15ba796..72d7f48 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -285,6 +285,7 @@ struct dw_mipi_dsi { struct drm_encoder encoder; struct drm_connector connector; struct mipi_dsi_host dsi_host; + struct device_node *panel_node; struct drm_panel *panel; struct device *dev; struct regmap *grf_regmap; @@ -462,7 +463,6 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi) dsi_write(dsi, DSI_PHY_RSTZ, PHY_ENFORCEPLL | PHY_ENABLECLK | PHY_UNRSTZ | PHY_UNSHUTDOWNZ); - ret = readx_poll_timeout(readl, dsi->base + DSI_PHY_STATUS, val, val & LOCK, 1000, PHY_STATUS_TIMEOUT_US); if (ret < 0) { @@ -550,11 +550,11 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host, dsi->lanes = device->lanes; dsi->channel = device->channel; dsi->format = device->format; - dsi->panel = of_drm_find_panel(device->dev.of_node); - if (dsi->panel) - return drm_panel_attach(dsi->panel, &dsi->connector); + dsi->panel_node = device->dev.of_node; + if (dsi->connector.dev) + drm_helper_hpd_irq_event(dsi->connector.dev); - return -EINVAL; + return 0; } static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, @@ -562,7 +562,10 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, { struct dw_mipi_dsi *dsi = host_to_dsi(host); - drm_panel_detach(dsi->panel); + dsi->panel_node = NULL; + + if (dsi->connector.dev) + drm_helper_hpd_irq_event(dsi->connector.dev); return 0; } @@ -1022,13 +1025,33 @@ static struct drm_connector_helper_funcs dw_mipi_dsi_connector_helper_funcs = { static enum drm_connector_status dw_mipi_dsi_detect(struct drm_connector *connector, bool force) { - return connector_status_connected; + struct dw_mipi_dsi *dsi = con_to_dsi(connector); + + + if (!dsi->panel) { + dsi->panel = of_drm_find_panel(dsi->panel_node); + if (dsi->panel) + drm_panel_attach(dsi->panel, &dsi->connector); + } else if (!dsi->panel_node) { + struct drm_encoder *encoder; + + encoder = platform_get_drvdata(to_platform_device(dsi->dev)); + dw_mipi_dsi_encoder_disable(encoder); + drm_panel_detach(dsi->panel); + dsi->panel = NULL; + } + + if (dsi->panel) + return connector_status_connected; + + return connector_status_disconnected; } static void dw_mipi_dsi_drm_connector_destroy(struct drm_connector *connector) { drm_connector_unregister(connector); drm_connector_cleanup(connector); + connector->dev = NULL; } static struct drm_connector_funcs dw_mipi_dsi_atomic_connector_funcs = { @@ -1069,6 +1092,8 @@ static int dw_mipi_dsi_register(struct drm_device *drm, return ret; } + connector->polled = DRM_CONNECTOR_POLL_HPD; + drm_connector_helper_add(connector, &dw_mipi_dsi_connector_helper_funcs); @@ -1225,6 +1250,8 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master, { struct dw_mipi_dsi *dsi = dev_get_drvdata(dev); + dw_mipi_dsi_encoder_disable(&dsi->encoder); + mipi_dsi_host_unregister(&dsi->dsi_host); pm_runtime_disable(dev); clk_disable_unprepare(dsi->pllref_clk);