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

Function tegra_pcib_enable

freebsd/arm/nvidia/tegra_pcie.c:1248–1380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1246}
1247
1248static int
1249tegra_pcib_enable(struct tegra_pcib_softc *sc)
1250{
1251 int rv;
1252 int i;
1253 uint32_t reg;
1254
1255 rv = tegra_pcib_enable_fdt_resources(sc);
1256 if (rv != 0) {
1257 device_printf(sc->dev, "Cannot enable FDT resources\n");
1258 return (rv);
1259 }
1260
1261 /* Enable PLLE control. */
1262 reg = AFI_RD4(sc, AFI_PLLE_CONTROL);
1263 reg &= ~AFI_PLLE_CONTROL_BYPASS_PADS2PLLE_CONTROL;
1264 reg |= AFI_PLLE_CONTROL_PADS2PLLE_CONTROL_EN;
1265 AFI_WR4(sc, AFI_PLLE_CONTROL, reg);
1266
1267 /* Set bias pad. */
1268 AFI_WR4(sc, AFI_PEXBIAS_CTRL, 0);
1269
1270 /* Configure mode and ports. */
1271 reg = AFI_RD4(sc, AFI_PCIE_CONFIG);
1272 reg &= ~AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK;
1273 if (sc->lanes_cfg == 0x14) {
1274 if (bootverbose)
1275 device_printf(sc->dev,
1276 "Using x1,x4 configuration\n");
1277 reg |= AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_XBAR4_1;
1278 } else if (sc->lanes_cfg == 0x12) {
1279 if (bootverbose)
1280 device_printf(sc->dev,
1281 "Using x1,x2 configuration\n");
1282 reg |= AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_XBAR2_1;
1283 } else {
1284 device_printf(sc->dev,
1285 "Unsupported lanes configuration: 0x%X\n", sc->lanes_cfg);
1286 }
1287 reg |= AFI_PCIE_CONFIG_PCIE_DISABLE_ALL;
1288 for (i = 0; i < TEGRA_PCIB_MAX_PORTS; i++) {
1289 if ((sc->ports[i] != NULL))
1290 reg &=
1291 ~AFI_PCIE_CONFIG_PCIE_DISABLE(sc->ports[i]->port_idx);
1292 }
1293 AFI_WR4(sc, AFI_PCIE_CONFIG, reg);
1294
1295 /* Enable Gen2 support. */
1296 reg = AFI_RD4(sc, AFI_FUSE);
1297 reg &= ~AFI_FUSE_PCIE_T0_GEN2_DIS;
1298 AFI_WR4(sc, AFI_FUSE, reg);
1299
1300 for (i = 0; i < TEGRA_PCIB_MAX_PORTS; i++) {
1301 if (sc->ports[i] != NULL) {
1302 rv = phy_enable(sc->ports[i]->phy);
1303 if (rv != 0) {
1304 device_printf(sc->dev,
1305 "Cannot enable phy for port %d\n",

Callers 1

tegra_pcib_attachFunction · 0.85

Calls 5

device_printfFunction · 0.85
tegra_pcib_set_barFunction · 0.85
rman_get_startFunction · 0.85
rman_get_sizeFunction · 0.85

Tested by

no test coverage detected