From owner-svn-src-head@freebsd.org Wed Feb 1 22:04:01 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 250F0CCC2D6; Wed, 1 Feb 2017 22:04:01 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C325A784; Wed, 1 Feb 2017 22:04:00 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v11M3xBu013914; Wed, 1 Feb 2017 22:03:59 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v11M3xs2013913; Wed, 1 Feb 2017 22:03:59 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201702012203.v11M3xs2013913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 1 Feb 2017 22:03:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313068 - head/sys/arm/ti/am335x X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Feb 2017 22:04:01 -0000 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