Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2017 22:03:59 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r313068 - head/sys/arm/ti/am335x
Message-ID:  <201702012203.v11M3xs2013913@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gonzo
Date: Wed Feb  1 22:03:59 2017
New Revision: 313068
URL: https://svnweb.freebsd.org/changeset/base/313068

Log:
  [am335x] Fallback to standard video interface bindings when using Linux dts
  
  Historically AM335x LCDC driver used non-standard "hdmi" property to
  refer to HDMI framer. There is no such thing in upstream DTS, so to
  handle both cases fallback to bindings described in
  bindings/media/video-interfaces.txt in Linux documentation.
  
  We still make some assumptions that are not universally true: we
  assume that if remote endpoint is available it's going to be HDMI
  framer. Which is true for AM335x-based devices currently supported
  but may be not true for some custom hardware.
  
  MFC after:	1 week

Modified:
  head/sys/arm/ti/am335x/am335x_lcd.c

Modified: head/sys/arm/ti/am335x/am335x_lcd.c
==============================================================================
--- head/sys/arm/ti/am335x/am335x_lcd.c	Wed Feb  1 21:57:07 2017	(r313067)
+++ head/sys/arm/ti/am335x/am335x_lcd.c	Wed Feb  1 22:03:59 2017	(r313068)
@@ -343,15 +343,46 @@ static void
 am335x_read_hdmi_property(device_t dev)
 {
 	phandle_t node;
+	phandle_t endpoint;
 	phandle_t hdmi_xref;
 	struct am335x_lcd_softc *sc;
 
 	sc = device_get_softc(dev);
 	node = ofw_bus_get_node(dev);
-	if (OF_getencprop(node, "hdmi", &hdmi_xref, sizeof(hdmi_xref)) == -1)
-		sc->sc_hdmi_framer = 0;
-	else
-		sc->sc_hdmi_framer = hdmi_xref; 
+	sc->sc_hdmi_framer = 0;
+
+	/*
+	 * Old FreeBSD way of referencing to HDMI framer
+	 */
+	if (OF_getencprop(node, "hdmi", &hdmi_xref, sizeof(hdmi_xref)) != -1) {
+		sc->sc_hdmi_framer = hdmi_xref;
+		return;
+	}
+
+	/*
+	 * Use bindings described in Linux docs:
+	 * bindings/media/video-interfaces.txt
+	 * We assume that the only endpoint in LCDC node
+	 * is HDMI framer.
+	 */
+	node = ofw_bus_find_child(node, "port");
+
+	/* No media bindings */
+	if (node == 0)
+		return;
+
+	for (endpoint = OF_child(node); endpoint != 0; endpoint = OF_peer(endpoint)) {
+		if (OF_getencprop(endpoint, "remote-endpoint", &node, sizeof(node)) != -1) {
+			/* port node of remote endpoint */
+			node = OF_node_from_xref(node);
+			/* port/ node */
+			node = OF_parent(node);
+			/* actual owner of port/endpoint, in our case HDMI framer */
+			sc->sc_hdmi_framer = OF_parent(node);
+			if (sc->sc_hdmi_framer != 0)
+				return;
+		}
+	}
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702012203.v11M3xs2013913>