Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp187224imm; Wed, 11 Jul 2018 00:11:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeBmzw19Mi4jvGcEi2oRbDTLWIJVcA2mf59Yd6LPF2e0MxFvlhIZXM0ZMP8FzQPYGdoLu2S X-Received: by 2002:a17:902:22:: with SMTP id 31-v6mr27923493pla.332.1531293107146; Wed, 11 Jul 2018 00:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531293107; cv=none; d=google.com; s=arc-20160816; b=LQDX0UBAFRGgBhrBo614oveoR0Z3yfWm9p0oSAqo5BflPR+fX34WHc299+l36xrc/J Ncj6Cjc77tgCqKgtVJ/HJ66rr1pTP1IG7fvLXS6omu/hkr9u1CcjoEbUtb9yHNioq9IJ 5XakkZO1HRkuBT/T8OKFmOEsC+00bpej0aOjpzLRRfB6ZJd7E5T/dytCvgkK5SqoR8ey xyDgllc7rie8E+cPJY1pZT5SjHxngA3v3MFn3KmYng2qm+Fg5pMy24Wyb80wOL/Bo1S/ d2bzr5Iwpnz07DiUIKtjz5a8Nh+LOUu9sMBIrepjkwduxeFBBqWyT+gj2Wrmhx5wOY61 5owg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=6a/nhZdXY2AsxAtLvr78kZAe/pjG/t8WTaBzfcuEVfk=; b=JxEqNhqfeuwC8d5kCC5i7rFavrxguIChqQgQG3iod0miqfBAUhc/HY+/ifPa5Pq8lm 2Cng3vdzVTE6xnYDWHYS6cN0/3TBbJTkac7H+LovgB/B2AgIg9RgpEcgABqET+SN+25p UINuRK9B/dN+5gKsU52S7weJt7ZYqolNhpym/u1b05ClJI29smHAvXnMmVyhoW47HMOQ a79RwA8q247yDp+snCUxxB35/KbxcuLddz1fHYtdpr0DP448XryeoMSIYOmviYOI08Mz +/Hc3caEpatSx+jUu8mYz5zNakPec9ARzDmavyIrpP+1ElUYMNlNCDkIEdNvHa8QhMg+ oItg== 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 v4-v6si19716135pfk.116.2018.07.11.00.11.31; Wed, 11 Jul 2018 00:11:47 -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 S1726730AbeGKHND (ORCPT + 99 others); Wed, 11 Jul 2018 03:13:03 -0400 Received: from mailoutvs12.siol.net ([185.57.226.203]:48173 "EHLO mail.siol.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726532AbeGKHND (ORCPT ); Wed, 11 Jul 2018 03:13:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id B3DA4521679; Wed, 11 Jul 2018 09:10:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta09.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta09.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id oO_tCHqkpfz4; Wed, 11 Jul 2018 09:10:11 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 02C8A52160C; Wed, 11 Jul 2018 09:10:11 +0200 (CEST) Received: from jernej-laptop.localnet (unknown [194.152.15.144]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPA id CD0E9521670; Wed, 11 Jul 2018 09:10:09 +0200 (CEST) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Chen-Yu Tsai Cc: Maxime Ripard , Rob Herring , David Airlie , Mark Rutland , dri-devel , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi Subject: Re: [PATCH v2 10/18] drm/sun4i: mixer: Read id from DT Date: Wed, 11 Jul 2018 09:10:04 +0200 Message-ID: <3034661.dpXlJLpBba@jernej-laptop> In-Reply-To: References: <20180710203511.18454-1-jernej.skrabec@siol.net> <20180710203511.18454-11-jernej.skrabec@siol.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dne sreda, 11. julij 2018 ob 05:11:56 CEST je Chen-Yu Tsai napisal(a): > On Wed, Jul 11, 2018 at 4:35 AM, Jernej Skrabec wrote: > > Currently, TCON supports 2 ways to match TCON with engine (mixer in this > > case). Old way is to just traverse of graph backwards and compare node > > pointer. New way is to match TCON and engine by their respective ids. > > All SoCs with DE2 enabled till now used the old way, which means mixer > > id was never used and thus never implemented. > > > > However, for R40, only the new way will be used. To prepare for that, > > implement mixer id fetching from DT. > > > > Signed-off-by: Jernej Skrabec > > --- > > > > drivers/gpu/drm/sun4i/sun8i_mixer.c | 40 +++++++++++++++++++++++++++-- > > 1 file changed, 38 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c > > b/drivers/gpu/drm/sun4i/sun8i_mixer.c index aa81b9838ae8..4bd4d8ccb34f > > 100644 > > --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c > > +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c > > @@ -22,6 +22,7 @@ > > > > #include > > #include > > #include > > > > +#include > > > > #include > > > > #include "sun4i_drv.h" > > > > @@ -322,6 +323,42 @@ static struct regmap_config sun8i_mixer_regmap_config > > = {> > > .max_register = 0xbfffc, /* guessed */ > > > > }; > > > > +static int sun8i_mixer_of_get_id(struct device_node *node) > > +{ > > + struct device_node *port, *ep; > > + int ret = -EINVAL; > > + > > + /* output is port 1 */ > > + port = of_graph_get_port_by_id(node, 1); > > + if (!port) > > + return -EINVAL; > > + > > + /* try to find downstream endpoint */ > > + for_each_available_child_of_node(port, ep) { > > + struct device_node *remote; > > + u32 reg; > > + > > + remote = of_graph_get_remote_endpoint(ep); > > + if (!remote) > > + continue; > > + > > + ret = of_property_read_u32(remote, "reg", ®); > > + if (!ret) { > > + of_node_put(remote); > > + of_node_put(ep); > > + of_node_put(port); > > + > > + return reg; > > + } > > + > > + of_node_put(remote); > > + } > > + > > + of_node_put(port); > > + > > + return ret; > > +} > > + > > The above looks good. > > > static int sun8i_mixer_bind(struct device *dev, struct device *master, > > > > void *data) > > > > { > > > > @@ -353,8 +390,7 @@ static int sun8i_mixer_bind(struct device *dev, struct > > device *master,> > > dev_set_drvdata(dev, mixer); > > mixer->engine.ops = &sun8i_engine_ops; > > mixer->engine.node = dev->of_node; > > > > - /* The ID of the mixer currently doesn't matter */ > > - mixer->engine.id = -1; > > + mixer->engine.id = sun8i_mixer_of_get_id(dev->of_node); > > Should you be handling error codes? Sadly, no. Other supported DE2 SoC miss reg property in DT and it would break them. Additionally, V3s has only one mixer and thus technically doesn't violate binding with omiting mixer id. Anyway, it was -1 all the time before and not really used, so having negative value doesn't change anything for other SoCs. If this fails and it's needed, it would stop at mixer <-> TCON matching stage anyway. I guess I should add comment for that. Best regards, Jernej