On Thu, Jul 30, 2020 at 5:35 PM Maxime Ripard <maxime@xxxxxxxxxx> wrote: > > The current code to parse the DT, deal with the older device trees, and > register either the RGB or LVDS output has so far grown organically into > the bind function and has become quite hard to extend properly. > > Let's move it into a single function that grabs all the resources it needs > and registers the proper panel output. > > Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx> Reviewed-by: Chen-Yu Tsai <wens@xxxxxxxx> > --- > drivers/gpu/drm/sun4i/sun4i_tcon.c | 139 +++++++++++++++--------------- > 1 file changed, 70 insertions(+), 69 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c > index 2a5a9903c4c6..d03ad75f9900 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c > +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c > @@ -875,6 +875,75 @@ static int sun4i_tcon_init_regmap(struct device *dev, > return 0; > } > > +static int sun4i_tcon_register_panel(struct drm_device *drm, > + struct sun4i_tcon *tcon) > +{ > + struct device_node *companion; > + struct device_node *remote; > + struct device *dev = tcon->dev; > + bool has_lvds_alt; > + bool has_lvds_rst; > + int ret; > + > + /* > + * If we have an LVDS panel connected to the TCON, we should > + * just probe the LVDS connector. Otherwise, let's just register > + * an RGB panel. > + */ > + remote = of_graph_get_remote_node(dev->of_node, 1, 0); > + if (!tcon->quirks->supports_lvds || > + !of_device_is_compatible(remote, "panel-lvds")) > + return sun4i_rgb_init(drm, tcon); Slightly related: IIRC there are a few LVDS panels supported in panel-simple so they don't use the panel-lvds compatible. Any idea how to deal with those?