From patchwork Mon Jul 9 13:48:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 10514639 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 447036032C for ; Mon, 9 Jul 2018 13:49:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D3EC28AE0 for ; Mon, 9 Jul 2018 13:49:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2008828AE1; Mon, 9 Jul 2018 13:49:06 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9D6328B0C for ; Mon, 9 Jul 2018 13:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=iFXJL6B289EdTTHZAB/hmQUC398ei8LcLM2M9XnhVDg=; b=GWS4Ozzi9a9Rjo5X/wDYZiHJOg S/E+LIOnYuJdle3/NpuEc+tgUQf+lMU0PpdTV+7xp0NQHqrTvXoiRwRkb4yQ7y8xq9nuKrOPZH+8U unkOG/q6TVW8yxTn6aKgaibeZ4ynuhAWKsmideQJdIWh3+b/adqHcMrDtwJ9IAllQcTARKdx654kZ lQpPxsEnU/wGcA4grlPEgD9AukdtyBzWcQHVQl9X464OkL12rqtS1pOlJQKL0c1y84dfMcWRrwV9j XsK1YZev5Qg3XW1pzE1KZrMi1S1ad4lcwexA28jFJMbfOPUmw0XT+CTvkZoJyaKXerVfs0EI5B9h7 dLTR91zQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcWXH-0000Fi-Mu; Mon, 09 Jul 2018 13:49:03 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcWXC-0000Aa-JG for linux-rockchip@lists.infradead.org; Mon, 09 Jul 2018 13:49:01 +0000 Received: from wd0142.dip.tu-dresden.de ([141.76.108.142] helo=phil.dip.tu-dresden.de) by gloria.sntech.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1fcWWx-0005PY-Q5; Mon, 09 Jul 2018 15:48:43 +0200 From: Heiko Stuebner To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 6/8] drm/dsi: add helper function to find the second host in a dual-dsi setup Date: Mon, 9 Jul 2018 15:48:32 +0200 Message-Id: <20180709134834.11035-7-heiko@sntech.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180709134834.11035-1-heiko@sntech.de> References: <20180709134834.11035-1-heiko@sntech.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180709_064858_827962_C3062E6A X-CRM114-Status: GOOD ( 13.99 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, architt@codeaurora.org, Heiko Stuebner , a.hajda@samsung.com, briannorris@chromium.org, hoegsberg@gmail.com, philippe.cornu@st.com, yannick.fertre@st.com, linux-rockchip@lists.infradead.org, nickey.yang@rock-chips.com, robh+dt@kernel.org, thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com, seanpaul@chromium.org, mka@chromium.org 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 From a specified output port of one dsi controller this function allows to iterate over the list of registered dsi controllers trying to find a second instance connected to the same display, like it is used in dual-dsi setups. Signed-off-by: Heiko Stuebner --- drivers/gpu/drm/drm_mipi_dsi.c | 56 ++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 2 ++ 2 files changed, 58 insertions(+) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index bc73b7f5b9fc..0c3c9c7aa3b8 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -282,6 +283,61 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node) } EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node); +struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np, + int port, int endpoint) +{ + struct mipi_dsi_host *first, *host; + struct device_node *remote, *np, *second_np = NULL; + int num = 0; + + first = of_find_mipi_dsi_host_by_node(first_np); + if (!first) { + pr_err("no dsi-host for node %s\n", first_np->full_name); + return ERR_PTR(-ENODEV); + } + + /* output-node of the known dsi-host */ + remote = of_graph_get_remote_node(first_np, port, endpoint); + if (!remote) { + dev_err(first->dev, "no output node found\n"); + return ERR_PTR(-ENODEV); + } + + mutex_lock(&host_lock); + + list_for_each_entry(host, &host_list, list) { + np = of_graph_get_remote_node(host->dev->of_node, + port, endpoint); + + /* found a host connected to this panel */ + if (np == remote) + num++; + + /* found one second host */ + if (host->dev->of_node != first_np) + second_np = host->dev->of_node; + + of_node_put(np); + } + + /* of_node_get the node under host_lock */ + if (num == 2) + of_node_get(second_np); + + mutex_unlock(&host_lock); + + of_node_put(remote); + + if (num > 2) { + dev_err(first->dev, + "too many DSI links for output: %d links\n", num); + return ERR_PTR(-EINVAL); + } + + return second_np; +} +EXPORT_SYMBOL(of_mipi_dsi_find_second_host); + int mipi_dsi_host_register(struct mipi_dsi_host *host) { struct device_node *node; diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 4fef19064b0f..89532ae69c91 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -107,6 +107,8 @@ struct mipi_dsi_host { int mipi_dsi_host_register(struct mipi_dsi_host *host); void mipi_dsi_host_unregister(struct mipi_dsi_host *host); struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node); +struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np, + int port, int endpoint); /* DSI mode flags */