-/* $OpenBSD: bcm2711_pcie.c,v 1.12 2024/02/03 10:37:26 kettenis Exp $ */
+/* $OpenBSD: bcm2711_pcie.c,v 1.13 2024/03/27 15:15:00 patrick Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
#include <machine/intr.h>
#include <machine/bus.h>
#include <machine/fdt.h>
+#include <machine/simplebusvar.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pcireg.h>
};
struct bcmpcie_softc {
- struct device sc_dev;
+ struct simplebus_softc sc_sbus;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_dma_tag_t sc_dmat;
{
struct fdt_attach_args *faa = aux;
- return OF_is_compatible(faa->fa_node, "brcm,bcm2711-pcie");
+ return OF_is_compatible(faa->fa_node, "brcm,bcm2711-pcie") ||
+ OF_is_compatible(faa->fa_node, "brcm,bcm2712-pcie");
}
+int bcmpcie_submatch(struct device *, void *, void *);
void bcmpcie_attach_hook(struct device *, struct device *,
struct pcibus_attach_args *);
int bcmpcie_bus_maxdevs(void *, int);
}
}
- printf("\n");
-
memcpy(&sc->sc_bus_iot, sc->sc_iot, sizeof(sc->sc_bus_iot));
sc->sc_bus_iot.bus_private = sc;
sc->sc_bus_iot._space_map = bcmpcie_bs_iomap;
pba.pba_domain = pci_ndomains++;
pba.pba_bus = 0;
- config_found(self, &pba, NULL);
+ /* Attach device tree nodes enumerating PCIe bus */
+ simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa);
+
+ config_found_sm(self, &pba, NULL, bcmpcie_submatch);
+}
+
+int
+bcmpcie_submatch(struct device *self, void *match, void *aux)
+{
+ struct cfdata *cf = match;
+ struct pcibus_attach_args *pba = aux;
+
+ if (strcmp(pba->pba_busname, cf->cf_driver->cd_name) != 0)
+ return 0;
+
+ return (*cf->cf_attach->ca_match)(self, match, aux);
}
void
-# $OpenBSD: files.fdt,v 1.201 2024/03/02 19:52:41 kettenis Exp $
+# $OpenBSD: files.fdt,v 1.202 2024/03/27 15:15:00 patrick Exp $
#
# Config file and device description for machine-independent FDT code.
# Included by ports that need it.
attach bcmmbox at fdt
file dev/fdt/bcm2835_mbox.c bcmmbox
-device bcmpcie: pcibus
+device bcmpcie: pcibus, fdt
attach bcmpcie at fdt
file dev/fdt/bcm2711_pcie.c bcmpcie