Allow pci_host_generic attachments to manage registers
To allow for attachments that don't use memory mapped registers add a flag they can set when the base driver shouldn't map them. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D39227
This commit is contained in:
parent
fb421e96c0
commit
7029f2c887
@ -106,27 +106,30 @@ pci_host_generic_core_attach(device_t dev)
|
|||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
rid = 0;
|
if ((sc->quirks & PCIE_CUSTOM_CONFIG_SPACE_QUIRK) == 0) {
|
||||||
sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
|
rid = 0;
|
||||||
PCI_RF_FLAGS | RF_ACTIVE);
|
sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
|
||||||
if (sc->res == NULL) {
|
PCI_RF_FLAGS | RF_ACTIVE);
|
||||||
device_printf(dev, "could not allocate memory.\n");
|
if (sc->res == NULL) {
|
||||||
error = ENXIO;
|
device_printf(dev, "could not allocate memory.\n");
|
||||||
goto err_resource;
|
error = ENXIO;
|
||||||
}
|
goto err_resource;
|
||||||
|
}
|
||||||
#ifdef PCI_UNMAPPED
|
#ifdef PCI_UNMAPPED
|
||||||
resource_init_map_request(&req);
|
resource_init_map_request(&req);
|
||||||
req.memattr = VM_MEMATTR_DEVICE_NP;
|
req.memattr = VM_MEMATTR_DEVICE_NP;
|
||||||
error = bus_map_resource(dev, SYS_RES_MEMORY, sc->res, &req, &map);
|
error = bus_map_resource(dev, SYS_RES_MEMORY, sc->res, &req,
|
||||||
if (error != 0) {
|
&map);
|
||||||
device_printf(dev, "could not map memory.\n");
|
if (error != 0) {
|
||||||
return (error);
|
device_printf(dev, "could not map memory.\n");
|
||||||
}
|
return (error);
|
||||||
rman_set_mapping(sc->res, &map);
|
}
|
||||||
|
rman_set_mapping(sc->res, &map);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sc->bst = rman_get_bustag(sc->res);
|
sc->bst = rman_get_bustag(sc->res);
|
||||||
sc->bsh = rman_get_bushandle(sc->res);
|
sc->bsh = rman_get_bushandle(sc->res);
|
||||||
|
}
|
||||||
|
|
||||||
sc->has_pmem = false;
|
sc->has_pmem = false;
|
||||||
sc->pmem_rman.rm_type = RMAN_ARRAY;
|
sc->pmem_rman.rm_type = RMAN_ARRAY;
|
||||||
@ -196,7 +199,8 @@ pci_host_generic_core_attach(device_t dev)
|
|||||||
err_mem_rman:
|
err_mem_rman:
|
||||||
rman_fini(&sc->pmem_rman);
|
rman_fini(&sc->pmem_rman);
|
||||||
err_pmem_rman:
|
err_pmem_rman:
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res);
|
if (sc->res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res);
|
||||||
err_resource:
|
err_resource:
|
||||||
bus_dma_tag_destroy(sc->dmat);
|
bus_dma_tag_destroy(sc->dmat);
|
||||||
return (error);
|
return (error);
|
||||||
@ -217,7 +221,8 @@ pci_host_generic_core_detach(device_t dev)
|
|||||||
rman_fini(&sc->io_rman);
|
rman_fini(&sc->io_rman);
|
||||||
rman_fini(&sc->mem_rman);
|
rman_fini(&sc->mem_rman);
|
||||||
rman_fini(&sc->pmem_rman);
|
rman_fini(&sc->pmem_rman);
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res);
|
if (sc->res != NULL)
|
||||||
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res);
|
||||||
bus_dma_tag_destroy(sc->dmat);
|
bus_dma_tag_destroy(sc->dmat);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -90,6 +90,8 @@ struct generic_pcie_core_softc {
|
|||||||
|
|
||||||
/* Quirks */
|
/* Quirks */
|
||||||
#define PCIE_ECAM_DESIGNWARE_QUIRK (1 << 0)
|
#define PCIE_ECAM_DESIGNWARE_QUIRK (1 << 0)
|
||||||
|
/* Child will map resources to access config registers */
|
||||||
|
#define PCIE_CUSTOM_CONFIG_SPACE_QUIRK (1 << 1)
|
||||||
|
|
||||||
DECLARE_CLASS(generic_pcie_core_driver);
|
DECLARE_CLASS(generic_pcie_core_driver);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user