diff options
author | Huang Rui <ray.huang@amd.com> | 2016-08-31 01:23:25 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-08-31 12:11:20 -0400 |
commit | 36b9a952bbf6881eef9e0f1920d6ce354c195553 (patch) | |
tree | 917f9b1913069846942e85e5da10289ef20adbe2 /drivers/gpu/drm/amd/amdgpu/si.c | |
parent | 62a37553414a344491c64e8fd89577dcc1b8bcbb (diff) |
drm/amdgpu: introduce pcie port read/write entry
This patch adds pcie port read/write entry, because it will be also
used on si dpm part.
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/si.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/si.c | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c index 74dbfcadc072..c905470d7e81 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c | |||
@@ -905,6 +905,31 @@ static void si_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | |||
905 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | 905 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); |
906 | } | 906 | } |
907 | 907 | ||
908 | u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg) | ||
909 | { | ||
910 | unsigned long flags; | ||
911 | u32 r; | ||
912 | |||
913 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
914 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | ||
915 | (void)RREG32(PCIE_PORT_INDEX); | ||
916 | r = RREG32(PCIE_PORT_DATA); | ||
917 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
918 | return r; | ||
919 | } | ||
920 | |||
921 | void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
922 | { | ||
923 | unsigned long flags; | ||
924 | |||
925 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
926 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | ||
927 | (void)RREG32(PCIE_PORT_INDEX); | ||
928 | WREG32(PCIE_PORT_DATA, (v)); | ||
929 | (void)RREG32(PCIE_PORT_DATA); | ||
930 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
931 | } | ||
932 | |||
908 | static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg) | 933 | static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg) |
909 | { | 934 | { |
910 | unsigned long flags; | 935 | unsigned long flags; |
@@ -1124,6 +1149,8 @@ static int si_common_early_init(void *handle) | |||
1124 | adev->smc_wreg = &si_smc_wreg; | 1149 | adev->smc_wreg = &si_smc_wreg; |
1125 | adev->pcie_rreg = &si_pcie_rreg; | 1150 | adev->pcie_rreg = &si_pcie_rreg; |
1126 | adev->pcie_wreg = &si_pcie_wreg; | 1151 | adev->pcie_wreg = &si_pcie_wreg; |
1152 | adev->pciep_rreg = &si_pciep_rreg; | ||
1153 | adev->pciep_wreg = &si_pciep_wreg; | ||
1127 | adev->uvd_ctx_rreg = NULL; | 1154 | adev->uvd_ctx_rreg = NULL; |
1128 | adev->uvd_ctx_wreg = NULL; | 1155 | adev->uvd_ctx_wreg = NULL; |
1129 | adev->didt_rreg = NULL; | 1156 | adev->didt_rreg = NULL; |
@@ -1315,31 +1342,6 @@ static void si_init_golden_registers(struct amdgpu_device *adev) | |||
1315 | } | 1342 | } |
1316 | } | 1343 | } |
1317 | 1344 | ||
1318 | u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg) | ||
1319 | { | ||
1320 | unsigned long flags; | ||
1321 | u32 r; | ||
1322 | |||
1323 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
1324 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | ||
1325 | (void)RREG32(PCIE_PORT_INDEX); | ||
1326 | r = RREG32(PCIE_PORT_DATA); | ||
1327 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
1328 | return r; | ||
1329 | } | ||
1330 | |||
1331 | void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
1332 | { | ||
1333 | unsigned long flags; | ||
1334 | |||
1335 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | ||
1336 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); | ||
1337 | (void)RREG32(PCIE_PORT_INDEX); | ||
1338 | WREG32(PCIE_PORT_DATA, (v)); | ||
1339 | (void)RREG32(PCIE_PORT_DATA); | ||
1340 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); | ||
1341 | } | ||
1342 | |||
1343 | static void si_pcie_gen3_enable(struct amdgpu_device *adev) | 1345 | static void si_pcie_gen3_enable(struct amdgpu_device *adev) |
1344 | { | 1346 | { |
1345 | struct pci_dev *root = adev->pdev->bus->self; | 1347 | struct pci_dev *root = adev->pdev->bus->self; |
@@ -1364,7 +1366,7 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1364 | if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) | 1366 | if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) |
1365 | return; | 1367 | return; |
1366 | 1368 | ||
1367 | speed_cntl = si_pciep_rreg(adev,PCIE_LC_SPEED_CNTL); | 1369 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
1368 | current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> | 1370 | current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> |
1369 | LC_CURRENT_DATA_RATE_SHIFT; | 1371 | LC_CURRENT_DATA_RATE_SHIFT; |
1370 | if (mask & DRM_PCIE_SPEED_80) { | 1372 | if (mask & DRM_PCIE_SPEED_80) { |
@@ -1409,12 +1411,12 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1409 | current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; | 1411 | current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; |
1410 | 1412 | ||
1411 | if (current_lw < max_lw) { | 1413 | if (current_lw < max_lw) { |
1412 | tmp = si_pciep_rreg(adev, PCIE_LC_LINK_WIDTH_CNTL); | 1414 | tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
1413 | if (tmp & LC_RENEGOTIATION_SUPPORT) { | 1415 | if (tmp & LC_RENEGOTIATION_SUPPORT) { |
1414 | tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); | 1416 | tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); |
1415 | tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); | 1417 | tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); |
1416 | tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; | 1418 | tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; |
1417 | si_pciep_wreg(adev, PCIE_LC_LINK_WIDTH_CNTL, tmp); | 1419 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); |
1418 | } | 1420 | } |
1419 | } | 1421 | } |
1420 | 1422 | ||
@@ -1429,13 +1431,13 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1429 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2); | 1431 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2); |
1430 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2); | 1432 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2); |
1431 | 1433 | ||
1432 | tmp = si_pciep_rreg(adev, PCIE_LC_CNTL4); | 1434 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
1433 | tmp |= LC_SET_QUIESCE; | 1435 | tmp |= LC_SET_QUIESCE; |
1434 | si_pciep_wreg(adev,PCIE_LC_CNTL4, tmp); | 1436 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
1435 | 1437 | ||
1436 | tmp = si_pciep_rreg(adev, PCIE_LC_CNTL4); | 1438 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
1437 | tmp |= LC_REDO_EQ; | 1439 | tmp |= LC_REDO_EQ; |
1438 | si_pciep_wreg(adev, PCIE_LC_CNTL4, tmp); | 1440 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
1439 | 1441 | ||
1440 | mdelay(100); | 1442 | mdelay(100); |
1441 | 1443 | ||
@@ -1459,16 +1461,16 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1459 | tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9))); | 1461 | tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9))); |
1460 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); | 1462 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); |
1461 | 1463 | ||
1462 | tmp = si_pciep_rreg(adev, PCIE_LC_CNTL4); | 1464 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
1463 | tmp &= ~LC_SET_QUIESCE; | 1465 | tmp &= ~LC_SET_QUIESCE; |
1464 | si_pciep_wreg(adev, PCIE_LC_CNTL4, tmp); | 1466 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
1465 | } | 1467 | } |
1466 | } | 1468 | } |
1467 | } | 1469 | } |
1468 | 1470 | ||
1469 | speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; | 1471 | speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; |
1470 | speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; | 1472 | speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; |
1471 | si_pciep_wreg(adev, PCIE_LC_SPEED_CNTL, speed_cntl); | 1473 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
1472 | 1474 | ||
1473 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); | 1475 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); |
1474 | tmp16 &= ~0xf; | 1476 | tmp16 &= ~0xf; |
@@ -1480,12 +1482,12 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1480 | tmp16 |= 1; | 1482 | tmp16 |= 1; |
1481 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); | 1483 | pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); |
1482 | 1484 | ||
1483 | speed_cntl = si_pciep_rreg(adev, PCIE_LC_SPEED_CNTL); | 1485 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
1484 | speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; | 1486 | speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; |
1485 | si_pciep_wreg(adev, PCIE_LC_SPEED_CNTL, speed_cntl); | 1487 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
1486 | 1488 | ||
1487 | for (i = 0; i < adev->usec_timeout; i++) { | 1489 | for (i = 0; i < adev->usec_timeout; i++) { |
1488 | speed_cntl = si_pciep_rreg(adev, PCIE_LC_SPEED_CNTL); | 1490 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
1489 | if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) | 1491 | if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) |
1490 | break; | 1492 | break; |
1491 | udelay(1); | 1493 | udelay(1); |
@@ -1546,23 +1548,23 @@ static void si_program_aspm(struct amdgpu_device *adev) | |||
1546 | 1548 | ||
1547 | if (adev->flags & AMD_IS_APU) | 1549 | if (adev->flags & AMD_IS_APU) |
1548 | return; | 1550 | return; |
1549 | orig = data = si_pciep_rreg(adev, PCIE_LC_N_FTS_CNTL); | 1551 | orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); |
1550 | data &= ~LC_XMIT_N_FTS_MASK; | 1552 | data &= ~LC_XMIT_N_FTS_MASK; |
1551 | data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; | 1553 | data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; |
1552 | if (orig != data) | 1554 | if (orig != data) |
1553 | si_pciep_wreg(adev, PCIE_LC_N_FTS_CNTL, data); | 1555 | WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); |
1554 | 1556 | ||
1555 | orig = data = si_pciep_rreg(adev, PCIE_LC_CNTL3); | 1557 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); |
1556 | data |= LC_GO_TO_RECOVERY; | 1558 | data |= LC_GO_TO_RECOVERY; |
1557 | if (orig != data) | 1559 | if (orig != data) |
1558 | si_pciep_wreg(adev, PCIE_LC_CNTL3, data); | 1560 | WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); |
1559 | 1561 | ||
1560 | orig = data = RREG32_PCIE(PCIE_P_CNTL); | 1562 | orig = data = RREG32_PCIE(PCIE_P_CNTL); |
1561 | data |= P_IGNORE_EDB_ERR; | 1563 | data |= P_IGNORE_EDB_ERR; |
1562 | if (orig != data) | 1564 | if (orig != data) |
1563 | WREG32_PCIE(PCIE_P_CNTL, data); | 1565 | WREG32_PCIE(PCIE_P_CNTL, data); |
1564 | 1566 | ||
1565 | orig = data = si_pciep_rreg(adev, PCIE_LC_CNTL); | 1567 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); |
1566 | data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); | 1568 | data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); |
1567 | data |= LC_PMI_TO_L1_DIS; | 1569 | data |= LC_PMI_TO_L1_DIS; |
1568 | if (!disable_l0s) | 1570 | if (!disable_l0s) |
@@ -1572,7 +1574,7 @@ static void si_program_aspm(struct amdgpu_device *adev) | |||
1572 | data |= LC_L1_INACTIVITY(7); | 1574 | data |= LC_L1_INACTIVITY(7); |
1573 | data &= ~LC_PMI_TO_L1_DIS; | 1575 | data &= ~LC_PMI_TO_L1_DIS; |
1574 | if (orig != data) | 1576 | if (orig != data) |
1575 | si_pciep_wreg(adev, PCIE_LC_CNTL, data); | 1577 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
1576 | 1578 | ||
1577 | if (!disable_plloff_in_l1) { | 1579 | if (!disable_plloff_in_l1) { |
1578 | bool clk_req_support; | 1580 | bool clk_req_support; |
@@ -1642,11 +1644,11 @@ static void si_program_aspm(struct amdgpu_device *adev) | |||
1642 | if (orig != data) | 1644 | if (orig != data) |
1643 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data); | 1645 | si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data); |
1644 | } | 1646 | } |
1645 | orig = data = si_pciep_rreg(adev, PCIE_LC_LINK_WIDTH_CNTL); | 1647 | orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
1646 | data &= ~LC_DYN_LANES_PWR_STATE_MASK; | 1648 | data &= ~LC_DYN_LANES_PWR_STATE_MASK; |
1647 | data |= LC_DYN_LANES_PWR_STATE(3); | 1649 | data |= LC_DYN_LANES_PWR_STATE(3); |
1648 | if (orig != data) | 1650 | if (orig != data) |
1649 | si_pciep_wreg(adev, PCIE_LC_LINK_WIDTH_CNTL, data); | 1651 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); |
1650 | 1652 | ||
1651 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL); | 1653 | orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL); |
1652 | data &= ~LS2_EXIT_TIME_MASK; | 1654 | data &= ~LS2_EXIT_TIME_MASK; |
@@ -1676,10 +1678,10 @@ static void si_program_aspm(struct amdgpu_device *adev) | |||
1676 | } | 1678 | } |
1677 | 1679 | ||
1678 | if (clk_req_support) { | 1680 | if (clk_req_support) { |
1679 | orig = data = si_pciep_rreg(adev, PCIE_LC_CNTL2); | 1681 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); |
1680 | data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; | 1682 | data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; |
1681 | if (orig != data) | 1683 | if (orig != data) |
1682 | si_pciep_wreg(adev, PCIE_LC_CNTL2, data); | 1684 | WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); |
1683 | 1685 | ||
1684 | orig = data = RREG32(THM_CLK_CNTL); | 1686 | orig = data = RREG32(THM_CLK_CNTL); |
1685 | data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); | 1687 | data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); |
@@ -1717,7 +1719,7 @@ static void si_program_aspm(struct amdgpu_device *adev) | |||
1717 | } | 1719 | } |
1718 | } else { | 1720 | } else { |
1719 | if (orig != data) | 1721 | if (orig != data) |
1720 | si_pciep_wreg(adev, PCIE_LC_CNTL, data); | 1722 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
1721 | } | 1723 | } |
1722 | 1724 | ||
1723 | orig = data = RREG32_PCIE(PCIE_CNTL2); | 1725 | orig = data = RREG32_PCIE(PCIE_CNTL2); |
@@ -1726,14 +1728,14 @@ static void si_program_aspm(struct amdgpu_device *adev) | |||
1726 | WREG32_PCIE(PCIE_CNTL2, data); | 1728 | WREG32_PCIE(PCIE_CNTL2, data); |
1727 | 1729 | ||
1728 | if (!disable_l0s) { | 1730 | if (!disable_l0s) { |
1729 | data = si_pciep_rreg(adev, PCIE_LC_N_FTS_CNTL); | 1731 | data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); |
1730 | if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { | 1732 | if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { |
1731 | data = RREG32_PCIE(PCIE_LC_STATUS1); | 1733 | data = RREG32_PCIE(PCIE_LC_STATUS1); |
1732 | if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { | 1734 | if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { |
1733 | orig = data = si_pciep_rreg(adev, PCIE_LC_CNTL); | 1735 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); |
1734 | data &= ~LC_L0S_INACTIVITY_MASK; | 1736 | data &= ~LC_L0S_INACTIVITY_MASK; |
1735 | if (orig != data) | 1737 | if (orig != data) |
1736 | si_pciep_wreg(adev, PCIE_LC_CNTL, data); | 1738 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
1737 | } | 1739 | } |
1738 | } | 1740 | } |
1739 | } | 1741 | } |