Changeset View
Changeset View
Standalone View
Standalone View
sys/arm/mv/mv_pci.c
Show First 20 Lines • Show All 910 Lines • ▼ Show 20 Lines | mv_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, | ||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct mv_pcib_softc *sc = device_get_softc(dev); | struct mv_pcib_softc *sc = device_get_softc(dev); | ||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
break; | break; | ||||
#ifdef PCI_RES_BUS | |||||
case PCI_RES_BUS: | case PCI_RES_BUS: | ||||
return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, | return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, | ||||
end, count, flags)); | end, count, flags)); | ||||
#endif | |||||
default: | default: | ||||
return (BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, | return (BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, | ||||
type, rid, start, end, count, flags)); | type, rid, start, end, count, flags)); | ||||
} | } | ||||
if (RMAN_IS_DEFAULT_RANGE(start, end)) { | if (RMAN_IS_DEFAULT_RANGE(start, end)) { | ||||
start = sc->sc_mem_base; | start = sc->sc_mem_base; | ||||
end = sc->sc_mem_base + sc->sc_mem_size - 1; | end = sc->sc_mem_base + sc->sc_mem_size - 1; | ||||
count = sc->sc_mem_size; | count = sc->sc_mem_size; | ||||
} | } | ||||
if ((start < sc->sc_mem_base) || (start + count - 1 != end) || | if ((start < sc->sc_mem_base) || (start + count - 1 != end) || | ||||
(end > sc->sc_mem_base + sc->sc_mem_size - 1)) | (end > sc->sc_mem_base + sc->sc_mem_size - 1)) | ||||
return (NULL); | return (NULL); | ||||
return (bus_generic_rman_alloc_resource(dev, child, type, rid, | return (bus_generic_rman_alloc_resource(dev, child, type, rid, | ||||
start, end, count, flags)); | start, end, count, flags)); | ||||
} | } | ||||
static int | static int | ||||
mv_pcib_adjust_resource(device_t dev, device_t child, int type, | mv_pcib_adjust_resource(device_t dev, device_t child, int type, | ||||
struct resource *r, rman_res_t start, rman_res_t end) | struct resource *r, rman_res_t start, rman_res_t end) | ||||
{ | { | ||||
#ifdef PCI_RES_BUS | |||||
struct mv_pcib_softc *sc = device_get_softc(dev); | struct mv_pcib_softc *sc = device_get_softc(dev); | ||||
#endif | |||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
return (bus_generic_rman_adjust_resource(dev, child, type, r, | return (bus_generic_rman_adjust_resource(dev, child, type, r, | ||||
start, end)); | start, end)); | ||||
#ifdef PCI_RES_BUS | |||||
case PCI_RES_BUS: | case PCI_RES_BUS: | ||||
return (pci_domain_adjust_bus(sc->ap_segment, child, r, start, | return (pci_domain_adjust_bus(sc->ap_segment, child, r, start, | ||||
end)); | end)); | ||||
#endif | |||||
default: | default: | ||||
return (bus_generic_adjust_resource(dev, child, type, r, | return (bus_generic_adjust_resource(dev, child, type, r, | ||||
start, end)); | start, end)); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
mv_pcib_release_resource(device_t dev, device_t child, int type, int rid, | mv_pcib_release_resource(device_t dev, device_t child, int type, int rid, | ||||
struct resource *res) | struct resource *res) | ||||
{ | { | ||||
#ifdef PCI_RES_BUS | |||||
struct mv_pcib_softc *sc = device_get_softc(dev); | struct mv_pcib_softc *sc = device_get_softc(dev); | ||||
#endif | |||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
return (bus_generic_rman_release_resource(dev, child, type, | return (bus_generic_rman_release_resource(dev, child, type, | ||||
rid, res)); | rid, res)); | ||||
#ifdef PCI_RES_BUS | |||||
case PCI_RES_BUS: | case PCI_RES_BUS: | ||||
return (pci_domain_release_bus(sc->ap_segment, child, rid, res)); | return (pci_domain_release_bus(sc->ap_segment, child, rid, res)); | ||||
#endif | |||||
default: | default: | ||||
return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, | return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, | ||||
type, rid, res)); | type, rid, res)); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
mv_pcib_activate_resource(device_t dev, device_t child, int type, int rid, | mv_pcib_activate_resource(device_t dev, device_t child, int type, int rid, | ||||
struct resource *r) | struct resource *r) | ||||
{ | { | ||||
#ifdef PCI_RES_BUS | |||||
struct mv_pcib_softc *sc = device_get_softc(dev); | struct mv_pcib_softc *sc = device_get_softc(dev); | ||||
#endif | |||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
return (bus_generic_rman_activate_resource(dev, child, type, | return (bus_generic_rman_activate_resource(dev, child, type, | ||||
rid, r)); | rid, r)); | ||||
#ifdef PCI_RES_BUS | |||||
case PCI_RES_BUS: | case PCI_RES_BUS: | ||||
return (pci_domain_activate_bus(sc->ap_segment, child, rid, r)); | return (pci_domain_activate_bus(sc->ap_segment, child, rid, r)); | ||||
#endif | |||||
default: | default: | ||||
return (bus_generic_activate_resource(dev, child, type, rid, | return (bus_generic_activate_resource(dev, child, type, rid, | ||||
r)); | r)); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
mv_pcib_deactivate_resource(device_t dev, device_t child, int type, int rid, | mv_pcib_deactivate_resource(device_t dev, device_t child, int type, int rid, | ||||
struct resource *r) | struct resource *r) | ||||
{ | { | ||||
#ifdef PCI_RES_BUS | |||||
struct mv_pcib_softc *sc = device_get_softc(dev); | struct mv_pcib_softc *sc = device_get_softc(dev); | ||||
#endif | |||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
return (bus_generic_rman_deactivate_resource(dev, child, type, | return (bus_generic_rman_deactivate_resource(dev, child, type, | ||||
rid, r)); | rid, r)); | ||||
#ifdef PCI_RES_BUS | |||||
case PCI_RES_BUS: | case PCI_RES_BUS: | ||||
return (pci_domain_deactivate_bus(sc->ap_segment, child, rid, | return (pci_domain_deactivate_bus(sc->ap_segment, child, rid, | ||||
r)); | r)); | ||||
#endif | |||||
default: | default: | ||||
return (bus_generic_deactivate_resource(dev, child, type, rid, | return (bus_generic_deactivate_resource(dev, child, type, rid, | ||||
r)); | r)); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
mv_pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, | mv_pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, | ||||
▲ Show 20 Lines • Show All 375 Lines • Show Last 20 Lines |