Changeset View
Changeset View
Standalone View
Standalone View
sys/arm/mv/mv_pci.c
Show First 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | mv_pcib_probe(device_t self) | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
} | } | ||||
static int | static int | ||||
mv_pcib_attach(device_t self) | mv_pcib_attach(device_t self) | ||||
{ | { | ||||
struct mv_pcib_softc *sc; | struct mv_pcib_softc *sc; | ||||
phandle_t node, parnode; | phandle_t node, parnode; | ||||
uint32_t val, unit, reg0; | uint32_t val, reg0; | ||||
int err, bus, devfn; | int err, bus, devfn, port_id; | ||||
sc = device_get_softc(self); | sc = device_get_softc(self); | ||||
sc->sc_dev = self; | sc->sc_dev = self; | ||||
unit = fdt_get_unit(self); | |||||
node = ofw_bus_get_node(self); | node = ofw_bus_get_node(self); | ||||
parnode = OF_parent(node); | parnode = OF_parent(node); | ||||
if (OF_getencprop(node, "port-id", &(port_id), | |||||
sizeof(port_id)) <= 0) { | |||||
/* If port-id does not exist in FDT set value to 0 */ | |||||
andrew: Is it ever the case this will return < 0 when the property exists? You could use this to check… | |||||
if (!OF_hasprop(node, "port-id")) | |||||
port_id = 0; | |||||
else | |||||
return(ENXIO); | |||||
} | |||||
if (fdt_is_compatible(node, "mrvl,pcie")) { | if (fdt_is_compatible(node, "mrvl,pcie")) { | ||||
sc->sc_type = MV_TYPE_PCIE; | sc->sc_type = MV_TYPE_PCIE; | ||||
sc->sc_win_target = MV_WIN_PCIE_TARGET(unit); | sc->sc_win_target = MV_WIN_PCIE_TARGET(port_id); | ||||
sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR(unit); | sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR(port_id); | ||||
sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR(unit); | sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR(port_id); | ||||
} else if (fdt_is_compatible(node, "mrvl,pci")) { | } else if (fdt_is_compatible(node, "mrvl,pci")) { | ||||
sc->sc_type = MV_TYPE_PCI; | sc->sc_type = MV_TYPE_PCI; | ||||
sc->sc_win_target = MV_WIN_PCI_TARGET; | sc->sc_win_target = MV_WIN_PCI_TARGET; | ||||
sc->sc_mem_win_attr = MV_WIN_PCI_MEM_ATTR; | sc->sc_mem_win_attr = MV_WIN_PCI_MEM_ATTR; | ||||
sc->sc_io_win_attr = MV_WIN_PCI_IO_ATTR; | sc->sc_io_win_attr = MV_WIN_PCI_IO_ATTR; | ||||
} else | } else | ||||
return (ENXIO); | return (ENXIO); | ||||
Show All 26 Lines | mv_pcib_attach(device_t self) | ||||
if (mv_pcib_decode_win(node, sc) != 0) | if (mv_pcib_decode_win(node, sc) != 0) | ||||
return (ENXIO); | return (ENXIO); | ||||
mv_pcib_hw_cfginit(); | mv_pcib_hw_cfginit(); | ||||
/* | /* | ||||
* Enable PCIE device. | * Enable PCIE device. | ||||
*/ | */ | ||||
mv_pcib_enable(sc, unit); | mv_pcib_enable(sc, port_id); | ||||
/* | /* | ||||
* Memory management. | * Memory management. | ||||
*/ | */ | ||||
err = mv_pcib_mem_init(sc); | err = mv_pcib_mem_init(sc); | ||||
if (err) | if (err) | ||||
return (err); | return (err); | ||||
▲ Show 20 Lines • Show All 741 Lines • Show Last 20 Lines |
Is it ever the case this will return < 0 when the property exists? You could use this to check if it exists, but is empty.