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: 9465517 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 EA3D860512 for ; Thu, 8 Dec 2016 01:01:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5ED928599 for ; Thu, 8 Dec 2016 01:01:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9C612859B; Thu, 8 Dec 2016 01:01:31 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FA5328565 for ; Thu, 8 Dec 2016 01:01:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933966AbcLHBA3 (ORCPT ); Wed, 7 Dec 2016 20:00:29 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33575 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753456AbcLHA7r (ORCPT ); Wed, 7 Dec 2016 19:59:47 -0500 Received: by mail-pf0-f195.google.com with SMTP id 144so21306837pfv.0; 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=KPnlyefHIbqaEjOqbE9wGRBaH0acA5u8QcgPRZdAgRTqUimXXP8mbhFSIim7ISRHR9 utf7JBxk1kZPNcsG9Y35ix427a33H19U469f+opokXUABVY9tq5dQ2Lp1r9TOlxjyld6 8zWMVKYyGhAejLmjaafh20rSdClxrrplckPt5yDnIDKS516iXrXjnu6hhjmdmrYvfIa+ cGYhdtmCF2Hzg76PfZryZ17nWiouhGkUbyznkfK9CbKJ0mErzoi6lLxi5lejTVA2Z3nW 0U8gJovzIwdWQ4vpq/qIA6YKnmJWNxX032dF4/UVatTSOQ46jtN6R0RSiuYm7qzXXyUN FPRQ== X-Gm-Message-State: AKaTC00A4TbTA5e/UhT+1FBTtyeegMtkn7/57kIQxZjsSaioMkRbyUzxFiSp4N6Y6EnZ3A== 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 Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Steve Longerbeam 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> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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) {