| 1439 | } |
| 1440 | |
| 1441 | static int |
| 1442 | tegra_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 |
nothing calls this directly
no test coverage detected