Author: gonzo
Date: Tue Oct 18 19:15:43 2016
New Revision: 307575
URL: https://svnweb.freebsd.org/changeset/base/307575

Log:
  MFC r307067, r307068, r307087, r307088, r307089,
      r307091, r307092, r307093, r307095, r307098,
      r307115:
  
  r307067:
  Make intc driver compatible with upstream DTS
  
  - Fix compatibility strings
  - Properly decode upstream's two-cell interrupt specs. Our home-made dts
      does not have two-cell interrupts so no need to preserve backward
      compatibility
  
  r307068:
  Make Rapsberry Pi watchdog driver compatible with upstream DTS
  
  - Fix compatibility strings
  - Compensate the difference in base address for our custom DTS and
      upstream one (for backward compatibility)
  
  r307087:
  Make sure intc is attached before interrupt consumers
  
  If pass order is not specified devices are attached in the order they are
  defined in dts. Some interrupt consumers may be defined before intc. Also
  make sure intc interrupt-parent local_intc is attached before intc itself.
  
  r307088:
  Add compatible strings used in upstream dts files
  
  r307089:
  Make framebuffer driver compatible with upstream DT
  
  - Add compatibility string
  - Add simplebus as possible parent bus
  
  r307091:
  Add compatibility string from upstream DT
  
  r307092:
  Make BCM2835 GPIO driver compatible with upstream DT
  
  - Add compatibility string
  - Make reserverd and read-only properties optional
  
  r307093:
  Make BCM283x USB driver compatible with upstream DT
  
  - Make resource allocation logic depend on compatibility string
      to check what format of DTS node should be used - FreeBSD's or upstream
  
  r307095:
  Make VCHI driver compatible with upstream DT
  
  - Add compatibility string
  - Compensate difference in base address between our custom DTB and upstream 
one
  
  r307098:
  Make BCM28x USB driver compatible with upstream device tree
  
  This should have been committed in r307093: resource allocation depends
  on source of the device tree. upstream dts has extra interrupt that we can
  ignore
  
  r307115:
  Fix typo in comment
  
  Spotted by: loos

Modified:
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c
  stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c
  stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c
  stable/11/sys/dev/usb/controller/dwc_otg_fdt.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c    Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_bsc.c    Tue Oct 18 19:15:43 
2016        (r307575)
@@ -52,6 +52,12 @@ __FBSDID("$FreeBSD$");
 
 #include "iicbus_if.h"
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-bsc",        1},
+       {"brcm,bcm2708-i2c",            1},
+       {NULL,                          0}
+};
+
 static void bcm_bsc_intr(void *);
 static int bcm_bsc_detach(device_t);
 
@@ -214,7 +220,7 @@ bcm_bsc_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-bsc"))
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
 
        device_set_desc(dev, "BCM2708/2835 BSC controller");

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 18 19:15:43 
2016        (r307575)
@@ -56,7 +56,8 @@ fdt_intc_decode_ic(phandle_t node, pcell
     int *pol)
 {
 
-       if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic")) {
+       if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic") ||
+           fdt_is_compatible(node, "brcm,bcm2836-armctrl-ic")) {
                *interrupt = fdt32_to_cpu(intr[0]);
                *trig = INTR_TRIGGER_CONFORM;
                *pol = INTR_POLARITY_CONFORM;

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c    Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_dma.c    Tue Oct 18 19:15:43 
2016        (r307575)
@@ -154,6 +154,12 @@ struct bcm_dma_softc {
 static struct bcm_dma_softc *bcm_dma_sc = NULL;
 static uint32_t bcm_dma_channel_mask;
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-dma",        1},
+       {"brcm,bcm2835-dma",            1},
+       {NULL,                          0}
+};
+
 static void
 bcm_dmamap_cb(void *arg, bus_dma_segment_t *segs,
        int nseg, int err)
@@ -658,7 +664,7 @@ bcm_dma_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-dma"))
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
 
        device_set_desc(dev, "BCM2835 DMA Controller");

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c     Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c     Tue Oct 18 19:15:43 
2016        (r307575)
@@ -111,6 +111,12 @@ struct bcmsc_softc {
 
 static struct bcmsc_softc bcmsc;
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-fb",         1},
+       {"brcm,bcm2708-fb",             1},
+       {NULL,                          0}
+};
+
 static int bcm_fb_probe(device_t);
 static int bcm_fb_attach(device_t);
 static void bcmfb_update_margins(video_adapter_t *adp);
@@ -121,8 +127,9 @@ bcm_fb_probe(device_t dev)
 {
        int error;
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb"))
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
+
        device_set_desc(dev, "BCM2835 framebuffer device");
        error = sc_probe_unit(device_get_unit(dev), 
            device_get_flags(dev) | SC_AUTODETECT_KBD);
@@ -196,6 +203,7 @@ static driver_t bcm_fb_driver = {
 };
 
 DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
+DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
 
 /*
  * Video driver routines and glue.

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c    Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_fbd.c    Tue Oct 18 19:15:43 
2016        (r307575)
@@ -65,6 +65,12 @@ struct bcmsc_softc {
        device_t                        dev;
 };
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-fb",         1},
+       {"brcm,bcm2708-fb",             1},
+       {NULL,                          0}
+};
+
 static int bcm_fb_probe(device_t);
 static int bcm_fb_attach(device_t);
 
@@ -189,7 +195,8 @@ bcm_fb_sysctl_init(struct bcmsc_softc *s
 static int
 bcm_fb_probe(device_t dev)
 {
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb"))
+
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
 
        device_set_desc(dev, "BCM2835 VT framebuffer driver");
@@ -263,3 +270,4 @@ static driver_t bcm_fb_driver = {
 };
 
 DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
+DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0);

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c   Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_gpio.c   Tue Oct 18 19:15:43 
2016        (r307575)
@@ -82,8 +82,6 @@ static struct resource_spec bcm_gpio_res
        { SYS_RES_MEMORY, 0, RF_ACTIVE },
        { SYS_RES_IRQ, 0, RF_ACTIVE },  /* bank 0 interrupt */
        { SYS_RES_IRQ, 1, RF_ACTIVE },  /* bank 1 interrupt */
-       { SYS_RES_IRQ, 2, RF_ACTIVE },  /* bank 1 interrupt (mirrored) */
-       { SYS_RES_IRQ, 3, RF_ACTIVE },  /* bank 0-1 interrupt (united) */
        { -1, 0, 0 }
 };
 
@@ -159,6 +157,12 @@ enum bcm_gpio_pud {
 #define        BCM_GPIO_GPPUD(_bank)   (0x94)                  /* Pin Pull 
up/down */
 #define        BCM_GPIO_GPPUDCLK(_bank) (0x98 + _bank * 4)     /* Pin Pull up 
clock */
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-gpio",       1},
+       {"brcm,bcm2835-gpio",           1},
+       {NULL,                          0}
+};
+
 static struct bcm_gpio_softc *bcm_gpio_sc = NULL;
 
 #ifdef INTRNG
@@ -672,11 +676,11 @@ bcm_gpio_get_reserved_pins(struct bcm_gp
        phandle_t gpio, node, reserved;
        ssize_t len;
 
-       /* Get read-only pins. */
+       /* Get read-only pins if they're provided */
        gpio = ofw_bus_get_node(sc->sc_dev);
        if (bcm_gpio_get_ro_pins(sc, gpio, "broadcom,read-only",
            "read-only") != 0)
-               return (-1);
+               return (0);
        /* Traverse the GPIO subnodes to find the reserved pins node. */
        reserved = 0;
        node = OF_child(gpio);
@@ -742,7 +746,7 @@ bcm_gpio_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-gpio"))
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
 
        device_set_desc(dev, "BCM2708/2835 GPIO controller");

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c   Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_intr.c   Tue Oct 18 19:15:43 
2016        (r307575)
@@ -270,6 +270,7 @@ bcm_intc_map_intr(device_t dev, struct i
        u_int irq;
        struct intr_map_data_fdt *daf;
        struct bcm_intc_softc *sc;
+       bool valid;
 
        if (data->type != INTR_MAP_DATA_FDT)
                return (ENOTSUP);
@@ -277,8 +278,36 @@ bcm_intc_map_intr(device_t dev, struct i
        daf = (struct intr_map_data_fdt *)data;
        if (daf->ncells == 1)
                irq = daf->cells[0];
-       else if (daf->ncells == 2)
-               irq = daf->cells[0] * 32 + daf->cells[1];
+       else if (daf->ncells == 2) {
+               valid = true;
+               switch (daf->cells[0]) {
+               case 0:
+                       irq = daf->cells[1];
+                       if (irq >= BANK1_START)
+                               valid = false;
+                       break;
+               case 1:
+                       irq = daf->cells[1] + BANK1_START;
+                       if (irq > BANK1_END)
+                               valid = false;
+                       break;
+               case 2:
+                       irq = daf->cells[1] + BANK2_START;
+                       if (irq > BANK2_END)
+                               valid = false;
+                       break;
+               default:
+                       valid = false;
+                       break;
+               }
+
+               if (!valid) {
+                       device_printf(dev,
+                           "invalid IRQ config: bank=%d, irq=%d\n",
+                           daf->cells[0], daf->cells[1]);
+                       return (EINVAL);
+               }
+       }
        else
                return (EINVAL);
 
@@ -355,7 +384,8 @@ bcm_intc_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic"))
+       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic") &&
+           !ofw_bus_is_compatible(dev, "brcm,bcm2836-armctrl-ic"))
                return (ENXIO);
        device_set_desc(dev, "BCM2835 Interrupt Controller");
        return (BUS_PROBE_DEFAULT);
@@ -438,7 +468,8 @@ static driver_t bcm_intc_driver = {
 
 static devclass_t bcm_intc_devclass;
 
-DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass, 0, 0);
+EARLY_DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass,
+    0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE);
 
 #ifndef INTRNG
 int

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c   Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_mbox.c   Tue Oct 18 19:15:43 
2016        (r307575)
@@ -92,6 +92,12 @@ struct bcm_mbox_softc {
 #define        mbox_write_4(sc, reg, val)              \
     bus_space_write_4((sc)->bst, (sc)->bsh, reg, val)
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-mbox",       1},
+       {"brcm,bcm2835-mbox",           1},
+       {NULL,                          0}
+};
+
 static int
 bcm_mbox_read_msg(struct bcm_mbox_softc *sc, int *ochan)
 {
@@ -138,12 +144,12 @@ bcm_mbox_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-mbox")) {
-               device_set_desc(dev, "BCM2835 VideoCore Mailbox");
-               return(BUS_PROBE_DEFAULT);
-       }
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+               return (ENXIO);
+
+       device_set_desc(dev, "BCM2835 VideoCore Mailbox");
 
-       return (ENXIO);
+       return (BUS_PROBE_DEFAULT);
 }
 
 static int

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c  Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c  Tue Oct 18 19:15:43 
2016        (r307575)
@@ -71,6 +71,12 @@ __FBSDID("$FreeBSD$");
 static int bcm2835_sdhci_hs = 1;
 static int bcm2835_sdhci_pio_mode = 0;
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-sdhci",      1},
+       {"brcm,bcm2835-mmc",            1},
+       {NULL,                          0}
+};
+
 TUNABLE_INT("hw.bcm2835.sdhci.hs", &bcm2835_sdhci_hs);
 TUNABLE_INT("hw.bcm2835.sdhci.pio_mode", &bcm2835_sdhci_pio_mode);
 
@@ -126,10 +132,11 @@ bcm_sdhci_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-sdhci"))
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
 
        device_set_desc(dev, "Broadcom 2708 SDHCI controller");
+
        return (BUS_PROBE_DEFAULT);
 }
 

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c    Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_spi.c    Tue Oct 18 19:15:43 
2016        (r307575)
@@ -58,6 +58,12 @@ __FBSDID("$FreeBSD$");
 
 #include "spibus_if.h"
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-spi",        1},
+       {"brcm,bcm2835-spi",            1},
+       {NULL,                          0}
+};
+
 static void bcm_spi_intr(void *);
 
 #ifdef BCM_SPI_DEBUG
@@ -233,7 +239,7 @@ bcm_spi_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-spi"))
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
 
        device_set_desc(dev, "BCM2708/2835 SPI controller");

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c   Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_wdog.c   Tue Oct 18 19:15:43 
2016        (r307575)
@@ -53,8 +53,8 @@ __FBSDID("$FreeBSD$");
 #define BCM2835_WDOG_TIME_MASK 0x000fffff
 #define BCM2835_WDOG_TIME_SHIFT        0
 
-#define        READ(_sc, _r) bus_space_read_4((_sc)->bst, (_sc)->bsh, (_r))
-#define        WRITE(_sc, _r, _v) bus_space_write_4((_sc)->bst, (_sc)->bsh, 
(_r), (_v))
+#define        READ(_sc, _r) bus_space_read_4((_sc)->bst, (_sc)->bsh, (_r) + 
(_sc)->regs_offset)
+#define        WRITE(_sc, _r, _v) bus_space_write_4((_sc)->bst, (_sc)->bsh, 
(_r) + (_sc)->regs_offset, (_v))
 
 #define BCM2835_RSTC_WRCFG_CLR         0xffffffcf
 #define BCM2835_RSTC_WRCFG_SET         0x00000030
@@ -76,6 +76,17 @@ struct bcmwd_softc {
        int                     wdog_period;
        char                    wdog_passwd;
        struct mtx              mtx;
+       int                     regs_offset;
+};
+
+#define        BSD_DTB         1
+#define        UPSTREAM_DTB    2
+#define        UPSTREAM_DTB_REGS_OFFSET        0x1c
+
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-wdt",        BSD_DTB},
+       {"brcm,bcm2835-pm-wdt",         UPSTREAM_DTB},
+       {NULL,                          0}
 };
 
 static void bcmwd_watchdog_fn(void *private, u_int cmd, int *error);
@@ -87,12 +98,12 @@ bcmwd_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-wdt")) {
-               device_set_desc(dev, "BCM2708/2835 Watchdog");
-               return (BUS_PROBE_DEFAULT);
-       }
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+               return (ENXIO);
+
+       device_set_desc(dev, "BCM2708/2835 Watchdog");
 
-       return (ENXIO);
+       return (BUS_PROBE_DEFAULT);
 }
 
 static int
@@ -120,6 +131,11 @@ bcmwd_attach(device_t dev)
        sc->bst = rman_get_bustag(sc->res);
        sc->bsh = rman_get_bushandle(sc->res);
 
+       /* compensate base address difference */
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data
+          == UPSTREAM_DTB)
+               sc->regs_offset = UPSTREAM_DTB_REGS_OFFSET;
+
        bcmwd_lsc = sc;
        mtx_init(&sc->mtx, "BCM2835 Watchdog", "bcmwd", MTX_DEF);
        EVENTHANDLER_REGISTER(watchdog_list, bcmwd_watchdog_fn, sc, 0);

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c
==============================================================================
--- stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c        Tue Oct 18 
16:18:25 2016        (r307574)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c        Tue Oct 18 
19:15:43 2016        (r307575)
@@ -51,6 +51,12 @@ __FBSDID("$FreeBSD$");
 
 #include <arm/broadcom/bcm2835/bcm2835_mbox_prop.h>
 
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-usb",        1},
+       {"brcm,bcm2708-usb",            1},
+       {NULL,                          0}
+};
+
 static device_probe_t bcm283x_dwc_otg_probe;
 static device_attach_t bcm283x_dwc_otg_attach;
 
@@ -61,7 +67,7 @@ bcm283x_dwc_otg_probe(device_t dev)
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
 
-       if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-usb"))
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
                return (ENXIO);
 
        device_set_desc(dev, "DWC OTG 2.0 integrated USB controller (bcm283x)");

Modified: stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c
==============================================================================
--- stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c        Tue Oct 
18 16:18:25 2016        (r307574)
+++ stable/11/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c        Tue Oct 
18 19:15:43 2016        (r307575)
@@ -73,14 +73,25 @@ struct bcm_vchiq_softc {
        void*                   intr_hl;
        bus_space_tag_t         bst;
        bus_space_handle_t      bsh;
+       int                     regs_offset;
 };
 
 static struct bcm_vchiq_softc *bcm_vchiq_sc = NULL;
 
+#define        BSD_DTB                 1
+#define        UPSTREAM_DTB            2
+static struct ofw_compat_data compat_data[] = {
+       {"broadcom,bcm2835-vchiq",      BSD_DTB},
+       {"brcm,bcm2835-vchiq",          UPSTREAM_DTB},
+       {NULL,                          0}
+};
+
 #define        vchiq_read_4(reg)               \
-    bus_space_read_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, reg)
+    bus_space_read_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, (reg) + \
+    bcm_vchiq_sc->regs_offset)
 #define        vchiq_write_4(reg, val)         \
-    bus_space_write_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, reg, val)
+    bus_space_write_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, (reg) + \
+    bcm_vchiq_sc->regs_offset, val)
 
 /* 
  * Extern functions */
@@ -122,12 +133,11 @@ static int
 bcm_vchiq_probe(device_t dev)
 {
 
-       if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-vchiq")) {
-               device_set_desc(dev, "BCM2835 VCHIQ");
-               return(BUS_PROBE_DEFAULT);
-       }
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+               return (ENXIO);
 
-       return (ENXIO);
+       device_set_desc(dev, "BCM2835 VCHIQ");
+       return (BUS_PROBE_DEFAULT);
 }
 
 static int
@@ -157,6 +167,9 @@ bcm_vchiq_attach(device_t dev)
                return (ENXIO);
        }
 
+       if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 
UPSTREAM_DTB)
+               sc->regs_offset = -0x40;
+
        node = ofw_bus_get_node(dev);
        if ((OF_getencprop(node, "cache-line-size", &cell, sizeof(cell))) > 0)
                g_cache_line_size = cell;

Modified: stable/11/sys/dev/usb/controller/dwc_otg_fdt.c
==============================================================================
--- stable/11/sys/dev/usb/controller/dwc_otg_fdt.c      Tue Oct 18 16:18:25 
2016        (r307574)
+++ stable/11/sys/dev/usb/controller/dwc_otg_fdt.c      Tue Oct 18 19:15:43 
2016        (r307575)
@@ -121,7 +121,12 @@ dwc_otg_attach(device_t dev)
        sc->sc_otg.sc_io_hdl = rman_get_bushandle(sc->sc_otg.sc_io_res);
        sc->sc_otg.sc_io_size = rman_get_size(sc->sc_otg.sc_io_res);
 
-       rid = 0;
+
+       /*
+        * brcm,bcm2708-usb FDT provides two interrupts,
+        * we need only second one (VC_USB)
+        */
+       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)
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to