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: 9220183 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 41C1D6044F for ; Fri, 8 Jul 2016 09:05:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F8A9285F9 for ; Fri, 8 Jul 2016 09:05:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 234BD285F4; Fri, 8 Jul 2016 09:05:40 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C55C6285F4 for ; Fri, 8 Jul 2016 09:05:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9BEF66E8C7; Fri, 8 Jul 2016 09:05:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id 33F846E8C7 for ; Fri, 8 Jul 2016 09:05:34 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id i123so5406526pfg.3 for ; Fri, 08 Jul 2016 02:05:34 -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=g0/vTaXyzK+y7BUadDsmBiO9uwlEgYSomdhUa9Wh0sI/p63K46/7TjsBLs4x3eX4a3 rc6FwoWAfGHC1A8eR1bb1nxQRGaZNkf+N1FTGDLY67Jq5sxuAPcC1ULKF7ug/dAZmjfZ IHygo/fecMdACGVCDU12c+cIwKBTGyRSSQkkwKPVpCzEwUFVj1sZHhyHkbCq/yFkw08a QGnRn7K65oSfC1XsWDH6jB7IB7uZIkmJRpNYBUq1BjOYqMJbTpVPomWrnOENHGDBR7MN gJEF1zpySbOg9umRS4mXFpQtq4EqN5turK9JNa1PD6Hg7D1/VSWUE+79jAIr6/+FTBqz 1tgQ== X-Gm-Message-State: ALyK8tJ2SE5YVCp516IgpCdv0V7doEahLR22gohcL051wXQjBlxNC+JzBHZtHL2TS5I89g== 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> 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 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);