From patchwork Wed Nov 30 11:17:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 9453991 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 B0A8E60585 for ; Wed, 30 Nov 2016 11:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97EA92842C for ; Wed, 30 Nov 2016 11:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AD832843B; Wed, 30 Nov 2016 11:18:26 +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]) (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 DCE912842C for ; Wed, 30 Nov 2016 11:18:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EA9D6E278; Wed, 30 Nov 2016 11:18:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73E636E104 for ; Wed, 30 Nov 2016 11:18:07 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id uAUBI5bJ017405; Wed, 30 Nov 2016 05:18:05 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id uAUBI4ui019277; Wed, 30 Nov 2016 05:18:04 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Wed, 30 Nov 2016 05:18:03 -0600 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id uAUBHnV0013328; Wed, 30 Nov 2016 05:18:03 -0600 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCH 10/36] drm/omap: add omapdss_of_get_endpoint() helper Date: Wed, 30 Nov 2016 13:17:12 +0200 Message-ID: <1480504658-11775-11-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480504658-11775-1-git-send-email-tomi.valkeinen@ti.com> References: <1480504658-11775-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 Cc: Tomi Valkeinen 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add omapdss_of_get_endpoint() helper function to get the endpoint node for the given port index and endpoint index. Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/dss/dss-of.c | 61 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ++ 2 files changed, 64 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c index dfd4e9621e3b..aa9415d3c60b 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c @@ -180,3 +180,64 @@ omapdss_of_find_source_for_first_ep(struct device_node *node) return src ? src : ERR_PTR(-EPROBE_DEFER); } EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep); + +static struct device_node *omapdss_of_get_port_by_index(struct device_node *parent, + int index) +{ + struct device_node *port; + + for (port = omapdss_of_get_next_port(parent, NULL); + port != NULL; + port = omapdss_of_get_next_port(parent, port)) { + u32 reg; + int r; + + r = of_property_read_u32(port, "reg", ®); + if (r) + reg = 0; + + if (reg == index) + return port; + } + + return NULL; +} + +static struct device_node *omapdss_of_get_endpoint_by_index(struct device_node *port, + int index) +{ + struct device_node *ep; + + for (ep = omapdss_of_get_next_endpoint(port, NULL); + ep != NULL; + ep = omapdss_of_get_next_endpoint(port, ep)) { + u32 reg; + int r; + + r = of_property_read_u32(ep, "reg", ®); + if (r) + reg = 0; + + if (reg == index) + return ep; + } + + return NULL; +} + +struct device_node *omapdss_of_get_endpoint(struct device_node *parent, + int port_index, int ep_index) +{ + struct device_node *port, *ep; + + port = omapdss_of_get_port_by_index(parent, port_index); + if (port == NULL) + return NULL; + + ep = omapdss_of_get_endpoint_by_index(port, ep_index); + + of_node_put(port); + + return ep; +} +EXPORT_SYMBOL_GPL(omapdss_of_get_endpoint); diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index b420dde8c0fb..403bab718738 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -844,6 +844,9 @@ omapdss_of_get_first_endpoint(const struct device_node *parent); struct omap_dss_device * omapdss_of_find_source_for_first_ep(struct device_node *node); +struct device_node *omapdss_of_get_endpoint(struct device_node *parent, + int port_index, int ep_index); + u32 dispc_read_irqstatus(void); void dispc_clear_irqstatus(u32 mask); u32 dispc_read_irqenable(void);