MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tegra_pcib_attach

Function tegra_pcib_attach

freebsd/arm/nvidia/tegra_pcie.c:1441–1579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1439}
1440
1441static int
1442tegra_pcib_attach(device_t dev)
1443{
1444 struct tegra_pcib_softc *sc;
1445 phandle_t node;
1446 int rv;
1447 int rid;
1448 struct tegra_pcib_port *port;
1449 int i;
1450
1451 sc = device_get_softc(dev);
1452 sc->dev = dev;
1453 mtx_init(&sc->mtx, "msi_mtx", NULL, MTX_DEF);
1454
1455 node = ofw_bus_get_node(dev);
1456 sc->soc = (struct pcie_soc *)ofw_bus_search_compatible(dev,
1457 compat_data)->ocd_data;
1458
1459 rv = tegra_pcib_parse_fdt_resources(sc, node);
1460 if (rv != 0) {
1461 device_printf(dev, "Cannot get FDT resources\n");
1462 return (rv);
1463 }
1464
1465 /* Allocate bus_space resources. */
1466 rid = 0;
1467 sc->pads_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
1468 RF_ACTIVE);
1469 if (sc->pads_mem_res == NULL) {
1470 device_printf(dev, "Cannot allocate PADS register\n");
1471 rv = ENXIO;
1472 goto out;
1473 }
1474 /*
1475 * XXX - FIXME
1476 * tag for config space is not filled when RF_ALLOCATED flag is used.
1477 */
1478 sc->bus_tag = rman_get_bustag(sc->pads_mem_res);
1479
1480 rid = 1;
1481 sc->afi_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
1482 RF_ACTIVE);
1483 if (sc->afi_mem_res == NULL) {
1484 device_printf(dev, "Cannot allocate AFI register\n");
1485 rv = ENXIO;
1486 goto out;
1487 }
1488
1489 rid = 2;
1490 sc->cfg_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
1491 RF_ALLOCATED);
1492 if (sc->cfg_mem_res == NULL) {
1493 device_printf(dev, "Cannot allocate config space memory\n");
1494 rv = ENXIO;
1495 goto out;
1496 }
1497 sc->cfg_base_addr = rman_get_start(sc->cfg_mem_res);
1498

Callers

nothing calls this directly

Calls 15

device_get_softcFunction · 0.85
mtx_initFunction · 0.85
device_printfFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
rman_get_bustagFunction · 0.85
rman_get_startFunction · 0.85
bus_space_mapFunction · 0.85
tegra_pcib_decode_rangesFunction · 0.85
bus_setup_intrFunction · 0.85
tegra_pcib_enableFunction · 0.85
tegra_pcib_port_enableFunction · 0.85

Tested by

no test coverage detected