From owner-svn-src-all@freebsd.org Wed Nov 25 20:05:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BDE134730D9; Wed, 25 Nov 2020 20:05:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ChBh24t8Tz4R0T; Wed, 25 Nov 2020 20:05:06 +0000 (UTC) (envelope-from ian@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B69C16C7C; Wed, 25 Nov 2020 20:05:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0APK56Fj012624; Wed, 25 Nov 2020 20:05:06 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0APK56qO012623; Wed, 25 Nov 2020 20:05:06 GMT (envelope-from ian@FreeBSD.org) Message-Id: <202011252005.0APK56qO012623@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Wed, 25 Nov 2020 20:05:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368030 - head/sys/arm/freescale/imx X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/arm/freescale/imx X-SVN-Commit-Revision: 368030 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 20:05:06 -0000 Author: ian Date: Wed Nov 25 20:05:05 2020 New Revision: 368030 URL: https://svnweb.freebsd.org/changeset/base/368030 Log: Extend the imx6 gpc->gic interrupt controller fixup of fdt data at runtime to work with the pmu and tempmon nodes as well as the soc node. This allows interrupts to work on the pmu and tempmon devices even though we don't have a driver for the low-power gpc interrupt controller (which is not a problem because we also don't have support for entering deep power-down modes where it gets used). Modified: head/sys/arm/freescale/imx/imx6_machdep.c Modified: head/sys/arm/freescale/imx/imx6_machdep.c ============================================================================== --- head/sys/arm/freescale/imx/imx6_machdep.c Wed Nov 25 19:10:20 2020 (r368029) +++ head/sys/arm/freescale/imx/imx6_machdep.c Wed Nov 25 20:05:05 2020 (r368030) @@ -78,6 +78,10 @@ static platform_cpu_reset_t imx6_cpu_reset; * node to refer to GIC instead of GPC. This will get us by until we write our * own GPC driver (or until linux changes its mind and the FDT data again). * + * 2020/11/25: The tempmon and pmu nodes are siblings (not children) of the soc + * node, so for them to use interrupts we need to apply the same fix as we do + * for the soc node. + * * We validate that we have data that looks like we expect before changing it: * - SOC node exists and has GPC as its interrupt parent. * - GPC node exists and has GIC as its interrupt parent. @@ -95,22 +99,30 @@ static platform_cpu_reset_t imx6_cpu_reset; * nodes by string matching we now have to search for both flavors of each node * name involved. */ + static void +fix_node_iparent(const char* nodepath, phandle_t gpcxref, phandle_t gicxref) +{ + static const char *propname = "interrupt-parent"; + phandle_t node, iparent; + + if ((node = OF_finddevice(nodepath)) == -1) + return; + if (OF_getencprop(node, propname, &iparent, sizeof(iparent)) <= 0) + return; + if (iparent != gpcxref) + return; + + OF_setprop(node, propname, &gicxref, sizeof(gicxref)); +} + +static void fix_fdt_interrupt_data(void) { phandle_t gicipar, gicnode, gicxref; phandle_t gpcipar, gpcnode, gpcxref; - phandle_t socipar, socnode; int result; - socnode = OF_finddevice("/soc"); - if (socnode == -1) - return; - result = OF_getencprop(socnode, "interrupt-parent", &socipar, - sizeof(socipar)); - if (result <= 0) - return; - /* GIC node may be child of soc node, or appear directly at root. */ gicnode = OF_finddevice("/soc/interrupt-controller@00a01000"); if (gicnode == -1) @@ -143,11 +155,13 @@ fix_fdt_interrupt_data(void) return; gpcxref = OF_xref_from_node(gpcnode); - if (socipar != gpcxref || gpcipar != gicxref || gicipar != gicxref) + if (gpcipar != gicxref || gicipar != gicxref) return; gicxref = cpu_to_fdt32(gicxref); - OF_setprop(socnode, "interrupt-parent", &gicxref, sizeof(gicxref)); + fix_node_iparent("/soc", gpcxref, gicxref); + fix_node_iparent("/pmu", gpcxref, gicxref); + fix_node_iparent("/tempmon", gpcxref, gicxref); } static void