Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp188212imm; Wed, 11 Jul 2018 00:12:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdI+UajhtbS38Cc8YPycL+ZjZdHCRl5CJ0JNIc/h/xWb2OasTVgkdxavSHrRFebi4Dfp8fT X-Received: by 2002:a17:902:988c:: with SMTP id s12-v6mr15928006plp.199.1531293178448; Wed, 11 Jul 2018 00:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531293178; cv=none; d=google.com; s=arc-20160816; b=p7lZ2IoDae2Q/vwQQlw1Jljw5QAQDLP86sUqVcfWcxW+706wZlxU6jnVjigx6JWiid 5eFoBeeOSXDruQTzkEMX/nRhzssj5EynAo+bZNJm4fZ/1yl+QXXTDoNMirklH0X38E4U lrO/D/pDUzO5at/cFlMi/llpPA+FV7eyY3Doi+YQnO/U88qUeU7sMT+3Ybvcuh2WlbNu HoW2LX2AU9rs15dnGNSJlO9ohrcfCqPm0vMlYsyjB91IRmLFgtI2UNXteItyQo4tWJLX V5tjVfEKkgVT/DjXPOm+xpmgXhPcazs4ApVoHT/bu64ZK4F88SbsrqgVXEIuwJhzB/eo xFwA== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :arc-authentication-results; bh=iA8hj7GW2J3KoSaDTXfxeQLke5jS4m86tBTQsqlBOUk=; b=oZlInLaLjWx111DoFr6ilIJZ1vfBhqEIile92W2hFjRlNYshsIoMvAfrusCY62ENzm ylQ9UPZLbS1OJ87VvR8yGcHfvrFN/oq2nz5wlH5Ukqv8f9uBZq3jRafAKxK0kpbw3SrK 6kr00YSuuU7RKML4BL9SDdJpvOrpqbd3W5G/68q3cSeDe4IwnEVeiQ+oxGfHxTfysaiY mXZ1HSGLgo39fD2VJI8vcv/EjVM7eXuSS8n8Tn0OluG4nNRr1P4R00DkaVjEL1kWooOi 4Qd1kTs38L7BpVuunuGCR2isDwRQAcN2ZPZIyDoS8XVm7x0M8UaKf7enFPDN6VxF/hmU 3ycw== 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.12.43; Wed, 11 Jul 2018 00:12:58 -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 S1726703AbeGKHOo convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Jul 2018 03:14:44 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:39391 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726294AbeGKHOn (ORCPT ); Wed, 11 Jul 2018 03:14:43 -0400 Received: by mail-ed1-f66.google.com with SMTP id w14-v6so18386667eds.6; Wed, 11 Jul 2018 00:11:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=E9+Qa+eJcgOUUDXFI8y+mug42fVGMlbpPRlnCIicivY=; b=o38LPxcjF6qSSeHxTdijKHACb5y5PxJ8PSQV1AKyASbwQssQ2obFvO5uyK2K1A5FsK 0eGAZFpO4yUuRN3z9xMX0ZSmqsY8fzXdEyb9I9y3vpHLkDr/+bDDgj1ipl2roLfom1nH Iqt5i/avszhbzX+ZceAeKopP7Ig/G6VKeTf5vNUa3Pq5bVp7ZyBT1gWwIPN1NK1+/kKp 8FgVUHKIoZ/0Cb1lhgYHQt0y1ixVUaIhZac4KoYvnK8Nnonza1tlHTe2mEugOM6dpcuq MGiODkFPfeyLdswTdo9rhWThKYAEPGhu1gx0v7MEOqKv1tNIhp0gxy0VNWPaYKmI5cnh 1QUg== X-Gm-Message-State: APt69E3NiAHUUS0q7JViwqZ7LXpcD3BMkv6rISNupZ0ySRp7/YJWfAVX SaE5j/xYNRll2PCuHOOqUZiv2MTI X-Received: by 2002:a50:9f6f:: with SMTP id b102-v6mr30338618edf.219.1531293112039; Wed, 11 Jul 2018 00:11:52 -0700 (PDT) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com. [74.125.82.43]) by smtp.gmail.com with ESMTPSA id o89-v6sm735314eda.18.2018.07.11.00.11.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 00:11:51 -0700 (PDT) Received: by mail-wm0-f43.google.com with SMTP id v128-v6so1299037wme.5; Wed, 11 Jul 2018 00:11:51 -0700 (PDT) X-Received: by 2002:a1c:6fdd:: with SMTP id c90-v6mr16204965wmi.16.1531293111207; Wed, 11 Jul 2018 00:11:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:adf:a15a:0:0:0:0:0 with HTTP; Wed, 11 Jul 2018 00:11:30 -0700 (PDT) In-Reply-To: <3034661.dpXlJLpBba@jernej-laptop> References: <20180710203511.18454-1-jernej.skrabec@siol.net> <20180710203511.18454-11-jernej.skrabec@siol.net> <3034661.dpXlJLpBba@jernej-laptop> From: Chen-Yu Tsai Date: Wed, 11 Jul 2018 15:11:30 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 10/18] drm/sun4i: mixer: Read id from DT To: =?UTF-8?Q?Jernej_=C5=A0krabec?= Cc: Maxime Ripard , Rob Herring , David Airlie , Mark Rutland , dri-devel , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 11, 2018 at 3:10 PM, Jernej Škrabec wrote: > 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. Yes. Please. We'll leave the rest till later. I plan to fix up the missing IDs for all the other SoCs anyway. ChenYu