Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp559722ybh; Tue, 10 Mar 2020 04:07:22 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtw4tGnF53vSssJbHsVZT7ymc6EceJ1LehmSXB6jok0UaiVMKatSCIluIO2aq6KQlMZKQI0 X-Received: by 2002:a9d:7d0c:: with SMTP id v12mr16506814otn.171.1583838442079; Tue, 10 Mar 2020 04:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583838442; cv=none; d=google.com; s=arc-20160816; b=f+eeNkq9JUj93zDlR5nipSDC9RjOTTtkYduGaGr+6Oyox0b1Ry8N1SmXTADI/KnBzT /aalMMBhLmYrfFwni6oIAOaQyRWLJfsBd8FevNXbr36T0QDSWLZe4VJnIV5riUExKL2M ijzjFo+MP0EHW/Cs84Sfb9gqbQfgvdF80FguD7pSPAYInPSq8SiC7eXd6nW7R1ciQH2g lTRq95RZPUAbXJO5+ldkkFKXeIFsSkQbPi9BYgum8my1McmZICS56EIW2UqneEWCJIpy OAO/82QQWQVQO2jVUh5AJzp9m2J5QLa5l9aSA/k4MT2yU21oRdXpMwgyiRCNV3DrOs/V BS7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=UQd/e5bwpUErlPsfyAlXEvoC7WcKNTN/SsHA9l+2T7Y=; b=eqjWJHQ+xHyJ8IVioQqJ7gTKtUpEBcoxJSwtF2GJbN2y+wARgcvS2Sv6SNwxb7cPqe wlnFcPxG/nctebdNuAs10nbhZC82vuAdja5kEK8H21jnHz768u6aUZTIeSwa3LlRWWjV RUzisd3l5TUon96I1586yfNalAbGJPXxDduJCSoWg4jpFAAuNcZcKZui4//RR8EQr7QU y7mm6SSzogouGBxG1EFxgGTu/DfNgfXdpfbPssvdyVHLYs8HnjoPoZtAIVGUGc9aWlqf nt6kHeiqgdYXzWkPLPL0Vbh5Dl8aEon/Wy/FSaMsGihWJ8Pj2XOQl4vsmVQ2oFZ8aTfu b1Ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c203si2055083oib.273.2020.03.10.04.07.09; Tue, 10 Mar 2020 04:07:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726464AbgCJLGo (ORCPT + 99 others); Tue, 10 Mar 2020 07:06:44 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:25631 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726269AbgCJLGo (ORCPT ); Tue, 10 Mar 2020 07:06:44 -0400 X-IronPort-AV: E=Sophos;i="5.70,536,1574089200"; d="scan'208";a="41493390" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Mar 2020 20:06:43 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 85C74420C2EB; Tue, 10 Mar 2020 20:06:41 +0900 (JST) From: Lad Prabhakar To: Mauro Carvalho Chehab , Niklas Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Lad Prabhakar , Lad Prabhakar Subject: [PATCH v2 1/3] media: rcar-csi2: Add support to match fwnode against remote or parent port Date: Tue, 10 Mar 2020 11:06:02 +0000 Message-Id: <1583838364-12932-2-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583838364-12932-1-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <1583838364-12932-1-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rcar-csi2 driver uses the v4l2-async framework to do endpoint matching instead of node matching. This is needed as it needs to work with the adv748x driver which register it self in v4l2-async using endpoints instead of nodes. The reason for this is that from a single DT node it creates multiple subdevices, one for each endpoint. But when using subdevs which register itself in v4l2-async using nodes, the rcar-csi2 driver failed to find the matching endpoint because the match.fwnode was pointing to remote endpoint instead of remote parent port. This commit adds support in rcar-csi2 driver to handle both the cases where subdev registers in v4l2-async using endpoints/nodes, by using match_type as V4L2_ASYNC_MATCH_CUSTOM and implementing the match() callback to compare the fwnode of either remote/parent. Signed-off-by: Lad Prabhakar --- drivers/media/platform/rcar-vin/rcar-csi2.c | 41 ++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index faa9fb2..39e1639 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -808,6 +808,41 @@ static int rcsi2_parse_v4l2(struct rcar_csi2 *priv, return 0; } +static bool rcsi2_asd_match(struct device *dev, + struct v4l2_async_subdev *async_sd) +{ + struct rcar_csi2 *priv = (struct rcar_csi2 *) + async_sd->match.custom.priv; + struct fwnode_handle *endpoint; + struct fwnode_handle *remote; + struct fwnode_handle *parent; + struct device_node *np; + bool matched = false; + + np = of_graph_get_endpoint_by_regs(priv->dev->of_node, 0, 0); + if (!np) { + dev_err(priv->dev, "Not connected to subdevice\n"); + return -EINVAL; + } + + endpoint = of_fwnode_handle(np); + remote = fwnode_graph_get_remote_endpoint(endpoint); + parent = fwnode_graph_get_remote_port_parent(endpoint); + if (parent) { + if (parent == dev->fwnode || + parent == &dev->of_node->fwnode) + matched = true; + } else if (remote && !matched) { + if (remote == dev->fwnode || + remote == &dev->of_node->fwnode) + matched = true; + } + + of_node_put(np); + + return matched; +} + static int rcsi2_parse_dt(struct rcar_csi2 *priv) { struct device_node *ep; @@ -833,9 +868,9 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv) return ret; } - priv->asd.match.fwnode = - fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep)); - priv->asd.match_type = V4L2_ASYNC_MATCH_FWNODE; + priv->asd.match.custom.match = &rcsi2_asd_match; + priv->asd.match.custom.priv = priv; + priv->asd.match_type = V4L2_ASYNC_MATCH_CUSTOM; of_node_put(ep); -- 2.7.4