From owner-svn-src-all@freebsd.org Sun Jan 12 04:05:20 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 9087022265E; Sun, 12 Jan 2020 04:05:20 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) 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 47wNRN1BTPz3QCT; Sun, 12 Jan 2020 04:05:20 +0000 (UTC) (envelope-from kevans@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 F0B10DE46; Sun, 12 Jan 2020 04:05:19 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00C45JCC077914; Sun, 12 Jan 2020 04:05:19 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C45J0R077913; Sun, 12 Jan 2020 04:05:19 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120405.00C45J0R077913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:05:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356648 - in stable: 11/sys/dev/usb/controller 12/sys/dev/usb/controller X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/dev/usb/controller 12/sys/dev/usb/controller X-SVN-Commit-Revision: 356648 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.29 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: Sun, 12 Jan 2020 04:05:20 -0000 Author: kevans Date: Sun Jan 12 04:05:18 2020 New Revision: 356648 URL: https://svnweb.freebsd.org/changeset/base/356648 Log: MFC r356564: dwc_otg: fix fdt attachment for newer bcm2708-usb nodes The newer versions of RPi FDT flipped the order of the interrupts specification and added an 'interrupt-names' property for driver aide in finding the correct interrupt, rather than assuming the positions. Use it if it's available, or fallback to the old method if there is no interrupt-names property with a usb value. This has been tested with both old RPi3B FDT and new RPi3B FDT, USB again works on the latter. Modified: stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/usb/controller/dwc_otg_fdt.c ============================================================================== --- stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:02:53 2020 (r356647) +++ stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:05:18 2020 (r356648) @@ -80,6 +80,20 @@ dwc_otg_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +static int +dwc_otg_irq_index(device_t dev, int *rid) +{ + int idx, rv; + phandle_t node; + + node = ofw_bus_get_node(dev); + rv = ofw_bus_find_string_index(node, "interrupt-names", "usb", &idx); + if (rv != 0) + return (rv); + *rid = idx; + return (0); +} + int dwc_otg_attach(device_t dev) { @@ -130,10 +144,16 @@ dwc_otg_attach(device_t dev) /* - * brcm,bcm2708-usb FDT provides two interrupts, - * we need only second one (VC_USB) + * brcm,bcm2708-usb FDT provides two interrupts, we need only the USB + * interrupt (VC_USB). The latest FDT for it provides an + * interrupt-names property and swapped them around, while older ones + * did not have interrupt-names and put the usb interrupt in the second + * position. We'll attempt to use interrupt-names first with a fallback + * to the old method of assuming the index based on the compatible + * string. */ - rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; + if (dwc_otg_irq_index(dev, &rid) != 0) + rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; sc->sc_otg.sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->sc_otg.sc_irq_res == NULL)