linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jernej Škrabec" <jernej.skrabec@siol.net>
To: Chen-Yu Tsai <wens@csie.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>,
	Rob Herring <robh+dt@kernel.org>, David Airlie <airlied@linux.ie>,
	Mark Rutland <mark.rutland@arm.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	devicetree <devicetree@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-sunxi <linux-sunxi@googlegroups.com>
Subject: Re: [PATCH v2 10/18] drm/sun4i: mixer: Read id from DT
Date: Wed, 11 Jul 2018 09:10:04 +0200	[thread overview]
Message-ID: <3034661.dpXlJLpBba@jernej-laptop> (raw)
In-Reply-To: <CAGb2v66vU4gBewGjLL-Ohx6mvKOVu4dDdwKNsXrkr3nZsSq3Cg@mail.gmail.com>

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 <jernej.skrabec@siol.net> 
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 <jernej.skrabec@siol.net>
> > ---
> > 
> >  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 <linux/component.h>
> >  #include <linux/dma-mapping.h>
> >  #include <linux/of_device.h>
> > 
> > +#include <linux/of_graph.h>
> > 
> >  #include <linux/reset.h>
> >  
> >  #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", &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




  reply	other threads:[~2018-07-11  7:10 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-10 20:34 [PATCH v2 00/18] Allwinner R40 HDMI refactoring Jernej Skrabec
2018-07-10 20:34 ` [PATCH v2 01/18] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
2018-07-10 20:34 ` [PATCH v2 02/18] drm/sun4i: " Jernej Skrabec
2018-07-10 20:34 ` [PATCH v2 03/18] ARM: dts: sun8i: r40: Remove fallback " Jernej Skrabec
2018-07-10 20:34 ` [PATCH v2 04/18] drm/sun4i: tcon-top: Cleanup clock handling Jernej Skrabec
2018-07-10 23:20   ` kbuild test robot
2018-07-11  2:54     ` Chen-Yu Tsai
2018-07-10 20:34 ` [PATCH v2 05/18] drm/sun4i: tcon: Release node when traversing of graph Jernej Skrabec
2018-07-10 20:34 ` [PATCH v2 06/18] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 07/18] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 08/18] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP Jernej Skrabec
2018-07-11  2:55   ` Chen-Yu Tsai
2018-07-10 20:35 ` [PATCH v2 09/18] drm/sun4i: mixer: Order includes alphabetically Jernej Skrabec
2018-07-11  2:56   ` Chen-Yu Tsai
2018-07-10 20:35 ` [PATCH v2 10/18] drm/sun4i: mixer: Read id from DT Jernej Skrabec
2018-07-11  3:11   ` Chen-Yu Tsai
2018-07-11  7:10     ` Jernej Škrabec [this message]
2018-07-11  7:11       ` Chen-Yu Tsai
2018-07-10 20:35 ` [PATCH v2 11/18] drm/sun4i: tcon-top: Add helpers for mux switching Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 12/18] drm/sun4i: tcon: Add another way for matching mixers with tcon Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 13/18] drm/sun4i: tcon: Add support for R40 TCON Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 14/18] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 15/18] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 16/18] ARM: dts: sun8i: r40: Disable TCONs by default Jernej Skrabec
2018-07-10 20:35 ` [PATCH v2 17/18] drm/sun4i: tcon-top: Remove mux configuration at probe time Jernej Skrabec
2018-07-11  3:15   ` Chen-Yu Tsai
2018-07-10 20:35 ` [PATCH v2 18/18] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles Jernej Skrabec
2018-07-11  8:30 ` [PATCH v2 00/18] Allwinner R40 HDMI refactoring Maxime Ripard
2018-07-11  8:37   ` Chen-Yu Tsai
2018-07-11  8:41   ` Jernej Škrabec
2018-07-11  9:30     ` Maxime Ripard
2018-07-11  9:34       ` [linux-sunxi] " Jernej Škrabec
2018-07-11 13:36         ` Maxime Ripard
2018-07-22 14:43   ` Jernej Škrabec
2018-07-24 12:37     ` Maxime Ripard
2018-07-24 16:04       ` Icenowy Zheng
2018-07-24 17:20         ` [linux-sunxi] " Jernej Škrabec
2018-07-24 17:23           ` Icenowy Zheng
2018-08-14  5:43       ` Icenowy Zheng
2018-08-14  5:47         ` [linux-sunxi] " Chen-Yu Tsai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3034661.dpXlJLpBba@jernej-laptop \
    --to=jernej.skrabec@siol.net \
    --cc=airlied@linux.ie \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mark.rutland@arm.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=robh+dt@kernel.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).