Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/cavium/thunder_pcie.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
* interface represents separate virtual function. | * interface represents separate virtual function. | ||||
*/ | */ | ||||
static int thunder_pcie_max_vfs = 4; | static int thunder_pcie_max_vfs = 4; | ||||
SYSCTL_INT(_hw, OID_AUTO, thunder_pcie_max_vfs, CTLFLAG_RWTUN, | SYSCTL_INT(_hw, OID_AUTO, thunder_pcie_max_vfs, CTLFLAG_RWTUN, | ||||
&thunder_pcie_max_vfs, 0, "Max VFs supported by ThunderX internal PCIe"); | &thunder_pcie_max_vfs, 0, "Max VFs supported by ThunderX internal PCIe"); | ||||
/* Forward prototypes */ | /* Forward prototypes */ | ||||
static struct resource *thunder_pcie_alloc_resource(device_t, | static struct resource *thunder_pcie_alloc_resource(device_t, | ||||
device_t, int, int *, u_long, u_long, u_long, u_int); | device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); | ||||
static int thunder_pcie_attach(device_t); | static int thunder_pcie_attach(device_t); | ||||
static int thunder_pcie_identify_pcib(device_t); | static int thunder_pcie_identify_pcib(device_t); | ||||
static int thunder_pcie_maxslots(device_t); | static int thunder_pcie_maxslots(device_t); | ||||
static int parse_pci_mem_ranges(struct thunder_pcie_softc *); | static int parse_pci_mem_ranges(struct thunder_pcie_softc *); | ||||
static int thunder_pcie_probe(device_t); | static int thunder_pcie_probe(device_t); | ||||
static uint32_t thunder_pcie_read_config(device_t, u_int, u_int, u_int, u_int, | static uint32_t thunder_pcie_read_config(device_t, u_int, u_int, u_int, u_int, | ||||
int); | int); | ||||
static int thunder_pcie_read_ivar(device_t, device_t, int, uintptr_t *); | static int thunder_pcie_read_ivar(device_t, device_t, int, uintptr_t *); | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, | return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, | ||||
type, rid, res)); | type, rid, res)); | ||||
return (rman_release_resource(res)); | return (rman_release_resource(res)); | ||||
} | } | ||||
static struct resource * | static struct resource * | ||||
thunder_pcie_alloc_resource(device_t dev, device_t child, int type, int *rid, | thunder_pcie_alloc_resource(device_t dev, device_t child, int type, int *rid, | ||||
u_long start, u_long end, u_long count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct thunder_pcie_softc *sc = device_get_softc(dev); | struct thunder_pcie_softc *sc = device_get_softc(dev); | ||||
struct rman *rm = NULL; | struct rman *rm = NULL; | ||||
struct resource *res; | struct resource *res; | ||||
pci_addr_t map, testval; | pci_addr_t map, testval; | ||||
switch (type) { | switch (type) { | ||||
case SYS_RES_IOPORT: | case SYS_RES_IOPORT: | ||||
goto fail; | goto fail; | ||||
break; | break; | ||||
case SYS_RES_MEMORY: | case SYS_RES_MEMORY: | ||||
rm = &sc->mem_rman; | rm = &sc->mem_rman; | ||||
break; | break; | ||||
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 ((start == 0UL) && (end == ~0UL)) { | if ((start == 0) && (end == ~0)) { | ||||
/* Read BAR manually to get resource address and size */ | /* Read BAR manually to get resource address and size */ | ||||
pci_read_bar(child, *rid, &map, &testval, NULL); | pci_read_bar(child, *rid, &map, &testval, NULL); | ||||
/* Mask the information bits */ | /* Mask the information bits */ | ||||
if (PCI_BAR_MEM(map)) | if (PCI_BAR_MEM(map)) | ||||
map &= PCIM_BAR_MEM_BASE; | map &= PCIM_BAR_MEM_BASE; | ||||
else | else | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static int | static int | ||||
thunder_pcie_identify_pcib(device_t dev) | thunder_pcie_identify_pcib(device_t dev) | ||||
{ | { | ||||
struct thunder_pcie_softc *sc; | struct thunder_pcie_softc *sc; | ||||
u_long start; | rman_res_t start; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
start = bus_get_resource_start(dev, SYS_RES_MEMORY, 0); | start = bus_get_resource_start(dev, SYS_RES_MEMORY, 0); | ||||
switch(start) { | switch(start) { | ||||
case THUNDER_ECAM0_CFG_BASE: | case THUNDER_ECAM0_CFG_BASE: | ||||
sc->ecam = 0; | sc->ecam = 0; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |