Date: Sun, 12 Jan 2020 04:05:19 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356648 - in stable: 11/sys/dev/usb/controller 12/sys/dev/usb/controller Message-ID: <202001120405.00C45JL6077907@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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/11/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/dev/usb/controller/dwc_otg_fdt.c ============================================================================== --- stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:02:53 2020 (r356647) +++ stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:05:18 2020 (r356648) @@ -73,6 +73,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) { @@ -123,10 +137,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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001120405.00C45JL6077907>