From patchwork Thu Dec 8 00:57:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9467361 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 7EB7860231 for ; Fri, 9 Dec 2016 01:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71D3528534 for ; Fri, 9 Dec 2016 01:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6618028615; Fri, 9 Dec 2016 01:41:12 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 13BA028534 for ; Fri, 9 Dec 2016 01:41:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 144446E8BE; Fri, 9 Dec 2016 01:40:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85F7F6E59B for ; Thu, 8 Dec 2016 00:59:42 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id 144so21306840pfv.0 for ; Wed, 07 Dec 2016 16:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7blztOi2fHLHN/lkHdl1Jjqly8dh29z0iXKh+qMiK/g=; b=p8O5P5aBXuTCTR4LtyW6qPokpb7gXp5KIEqAqocQz+3Su9AZGJlFVTpc8sTlP7AYsd ixRsBAXvFLdsHmRgcVunU0PJEp/8Zu+Hd3G3+iN4PRGwqp2QTfh/DD6nflW4e1NxpYjM qQkxiN4xJRKinjSmHkNbsvZ4IZuPNpkNSA8EzkU8ckkb4HTobPPv9ZlZTyDkRSvTbnX9 vtkXJ1naJRes+7i+znl/JHmFeVi2bQH4w6Aeiyb7VT/wEBqjAnNA5M87TdKpSLW5dnbk pvg/6d5dwYngwGU0+Vz15+ZGS/Exxso+JDkFdhTqFz5dJKLVBOSCvC6VvqCjl9ARaZ0W eIxQ== 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=7blztOi2fHLHN/lkHdl1Jjqly8dh29z0iXKh+qMiK/g=; b=aD7Zm26fXOgRTvikpL9XdO1QPNdklyyBoi3lIs7L8280slo1X1zfhTiO0gRfCgcKUp gFcKAZCV5XYSfRt5h2sQGjq2LyKzF4dlw48bsk/FBkXQwBG4j5+Zn62hRiD1fVmp9RUE qWPotLhltKu8GjgxXZbGIqBaQuDQjC3bFQqf+ozjAMlwcVVNffAfXZEsdnOUJp/TYbln ofXWxI7jaO/UKlozD9meKo7JrVikax1Gd7fgS/1ifwCiSfOZLCAlc/FRPEcTGoUvXUq6 JqNzILmvJeKM2l9xSI65lgvc4iyriihTK9peUpViuwqi7r0yiy8u7p43d2EMrhpeYmdj EgQw== X-Gm-Message-State: AKaTC02ZSUrWwyjSfxYUdipk8MoeVug1hF6fuvQ/MgVP1TmTnqtk99HCRPoRVfhMP7UNsg== X-Received: by 10.84.211.144 with SMTP id c16mr153201929pli.37.1481158781842; Wed, 07 Dec 2016 16:59:41 -0800 (PST) Received: from majic.sklembedded.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id n25sm45265872pfi.33.2016.12.07.16.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Dec 2016 16:59:41 -0800 (PST) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: shawnguo@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com, robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, tomi.valkeinen@ti.com, p.zabel@pengutronix.de Subject: [PATCH 11/12] gpu: ipu-v3: lookup ipu client nodes by name Date: Wed, 7 Dec 2016 16:57:52 -0800 Message-Id: <1481158673-15937-12-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481158673-15937-1-git-send-email-steve_longerbeam@mentor.com> References: <1481158673-15937-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 09 Dec 2016 01:39:51 +0000 Cc: devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, Steve Longerbeam , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, 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 To allow for IPU clients containing multiple ports, they are no longer a single port node name, but have a name of the format "ipu_". So we can no longer use of_graph_get_port_by_id() to lookup the client node. Create the function of_get_ipu_client_node() that looks up the client node by node name and unit id. The ipu_unit_type enumeration is added to the client_reg[] entries to compose the node names. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-common.c | 55 +++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 97218af..b6ca36b 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -1159,6 +1159,7 @@ struct ipu_platform_reg { static struct ipu_platform_reg client_reg[] = { { .pdata = { + .type = IPU_CSI, .csi = 0, .dma[0] = IPUV3_CHANNEL_CSI0, .dma[1] = -EINVAL, @@ -1166,6 +1167,7 @@ static struct ipu_platform_reg client_reg[] = { .name = "imx-ipuv3-csi", }, { .pdata = { + .type = IPU_CSI, .csi = 1, .dma[0] = IPUV3_CHANNEL_CSI1, .dma[1] = -EINVAL, @@ -1173,6 +1175,7 @@ static struct ipu_platform_reg client_reg[] = { .name = "imx-ipuv3-csi", }, { .pdata = { + .type = IPU_DI, .di = 0, .dc = 5, .dp = IPU_DP_FLOW_SYNC_BG, @@ -1182,6 +1185,7 @@ static struct ipu_platform_reg client_reg[] = { .name = "imx-ipuv3-crtc", }, { .pdata = { + .type = IPU_DI, .di = 1, .dc = 1, .dp = -EINVAL, @@ -1195,6 +1199,46 @@ static struct ipu_platform_reg client_reg[] = { static DEFINE_MUTEX(ipu_client_id_mutex); static int ipu_client_id; +static struct device_node * +of_get_ipu_client_node(struct ipu_soc *ipu, struct ipu_platform_reg *reg) +{ + struct device *dev = ipu->dev; + struct device_node *client; + char node_name[32]; + u32 id, client_id = 0; + + switch (reg->pdata.type) { + case IPU_CSI: + snprintf(node_name, sizeof(node_name), + "ipu%d_csi", ipu->id + 1); + client_id = reg->pdata.csi; + break; + case IPU_DI: + snprintf(node_name, sizeof(node_name), + "ipu%d_di", ipu->id + 1); + client_id = reg->pdata.di; + break; + default: + client = NULL; + goto out; + } + + for_each_child_of_node(dev->of_node, client) { + if (client->name && + (of_node_cmp(client->name, node_name) == 0)) { + of_property_read_u32(client, "reg", &id); + if (id == client_id) + break; + } + } +out: + if (!client) + dev_info(dev, "no %s%d node in %s, not using %s%d\n", + node_name, client_id, dev->of_node->full_name, + node_name, client_id); + return client; +} + static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base) { struct device *dev = ipu->dev; @@ -1211,15 +1255,10 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base) struct platform_device *pdev; struct device_node *of_node; - /* Associate subdevice with the corresponding port node */ - of_node = of_graph_get_port_by_id(dev->of_node, i); - if (!of_node) { - dev_info(dev, - "no port@%d node in %s, not using %s%d\n", - i, dev->of_node->full_name, - (i / 2) ? "DI" : "CSI", i % 2); + /* Associate subdevice with the corresponding client node */ + of_node = of_get_ipu_client_node(ipu, reg); + if (!of_node) continue; - } pdev = platform_device_alloc(reg->name, id++); if (!pdev) {