aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/pcie/aspm.c34
-rw-r--r--include/uapi/linux/pci_regs.h6
2 files changed, 26 insertions, 14 deletions
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index a378dd9d2473..d240ffab24c1 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -450,24 +450,25 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link,
450 if (!(link->aspm_support & ASPM_STATE_L1_2_MASK)) 450 if (!(link->aspm_support & ASPM_STATE_L1_2_MASK))
451 return; 451 return;
452 452
453 /* Choose the greater of the two T_cmn_mode_rstr_time */ 453 /* Choose the greater of the two Port Common_Mode_Restore_Times */
454 val1 = (upreg->l1ss_cap >> 8) & 0xFF; 454 val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8;
455 val2 = (dwreg->l1ss_cap >> 8) & 0xFF; 455 val2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8;
456 if (val1 > val2) 456 if (val1 > val2)
457 link->l1ss.ctl1 |= val1 << 8; 457 link->l1ss.ctl1 |= val1 << 8;
458 else 458 else
459 link->l1ss.ctl1 |= val2 << 8; 459 link->l1ss.ctl1 |= val2 << 8;
460
460 /* 461 /*
461 * We currently use LTR L1.2 threshold to be fixed constant picked from 462 * We currently use LTR L1.2 threshold to be fixed constant picked from
462 * Intel's coreboot. 463 * Intel's coreboot.
463 */ 464 */
464 link->l1ss.ctl1 |= LTR_L1_2_THRESHOLD_BITS; 465 link->l1ss.ctl1 |= LTR_L1_2_THRESHOLD_BITS;
465 466
466 /* Choose the greater of the two T_pwr_on */ 467 /* Choose the greater of the two Port T_POWER_ON times */
467 val1 = (upreg->l1ss_cap >> 19) & 0x1F; 468 val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_VALUE) >> 19;
468 scale1 = (upreg->l1ss_cap >> 16) & 0x03; 469 scale1 = (upreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_SCALE) >> 16;
469 val2 = (dwreg->l1ss_cap >> 19) & 0x1F; 470 val2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_VALUE) >> 19;
470 scale2 = (dwreg->l1ss_cap >> 16) & 0x03; 471 scale2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_SCALE) >> 16;
471 472
472 if (calc_l1ss_pwron(link->pdev, scale1, val1) > 473 if (calc_l1ss_pwron(link->pdev, scale1, val1) >
473 calc_l1ss_pwron(link->downstream, scale2, val2)) 474 calc_l1ss_pwron(link->downstream, scale2, val2))
@@ -646,21 +647,26 @@ static void pcie_config_aspm_l1ss(struct pcie_link_state *link, u32 state)
646 647
647 if (enable_req & ASPM_STATE_L1_2_MASK) { 648 if (enable_req & ASPM_STATE_L1_2_MASK) {
648 649
649 /* Program T_pwr_on in both ports */ 650 /* Program T_POWER_ON times in both ports */
650 pci_write_config_dword(parent, up_cap_ptr + PCI_L1SS_CTL2, 651 pci_write_config_dword(parent, up_cap_ptr + PCI_L1SS_CTL2,
651 link->l1ss.ctl2); 652 link->l1ss.ctl2);
652 pci_write_config_dword(child, dw_cap_ptr + PCI_L1SS_CTL2, 653 pci_write_config_dword(child, dw_cap_ptr + PCI_L1SS_CTL2,
653 link->l1ss.ctl2); 654 link->l1ss.ctl2);
654 655
655 /* Program T_cmn_mode in parent */ 656 /* Program Common_Mode_Restore_Time in upstream device */
656 pci_clear_and_set_dword(parent, up_cap_ptr + PCI_L1SS_CTL1, 657 pci_clear_and_set_dword(parent, up_cap_ptr + PCI_L1SS_CTL1,
657 0xFF00, link->l1ss.ctl1); 658 PCI_L1SS_CTL1_CM_RESTORE_TIME,
659 link->l1ss.ctl1);
658 660
659 /* Program LTR L1.2 threshold in both ports */ 661 /* Program LTR_L1.2_THRESHOLD time in both ports */
660 pci_clear_and_set_dword(parent, up_cap_ptr + PCI_L1SS_CTL1, 662 pci_clear_and_set_dword(parent, up_cap_ptr + PCI_L1SS_CTL1,
661 0xE3FF0000, link->l1ss.ctl1); 663 PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
664 PCI_L1SS_CTL1_LTR_L12_TH_SCALE,
665 link->l1ss.ctl1);
662 pci_clear_and_set_dword(child, dw_cap_ptr + PCI_L1SS_CTL1, 666 pci_clear_and_set_dword(child, dw_cap_ptr + PCI_L1SS_CTL1,
663 0xE3FF0000, link->l1ss.ctl1); 667 PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
668 PCI_L1SS_CTL1_LTR_L12_TH_SCALE,
669 link->l1ss.ctl1);
664 } 670 }
665 671
666 val = 0; 672 val = 0;
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index 4150acb4cccb..85a4014de42e 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -1002,12 +1002,18 @@
1002#define PCI_L1SS_CAP_ASPM_L1_2 0x00000004 /* ASPM L1.2 Supported */ 1002#define PCI_L1SS_CAP_ASPM_L1_2 0x00000004 /* ASPM L1.2 Supported */
1003#define PCI_L1SS_CAP_ASPM_L1_1 0x00000008 /* ASPM L1.1 Supported */ 1003#define PCI_L1SS_CAP_ASPM_L1_1 0x00000008 /* ASPM L1.1 Supported */
1004#define PCI_L1SS_CAP_L1_PM_SS 0x00000010 /* L1 PM Substates Supported */ 1004#define PCI_L1SS_CAP_L1_PM_SS 0x00000010 /* L1 PM Substates Supported */
1005#define PCI_L1SS_CAP_CM_RESTORE_TIME 0x0000ff00 /* Port Common_Mode_Restore_Time */
1006#define PCI_L1SS_CAP_P_PWR_ON_SCALE 0x00030000 /* Port T_POWER_ON scale */
1007#define PCI_L1SS_CAP_P_PWR_ON_VALUE 0x00f80000 /* Port T_POWER_ON value */
1005#define PCI_L1SS_CTL1 0x08 /* Control 1 Register */ 1008#define PCI_L1SS_CTL1 0x08 /* Control 1 Register */
1006#define PCI_L1SS_CTL1_PCIPM_L1_2 0x00000001 /* PCI-PM L1.2 Enable */ 1009#define PCI_L1SS_CTL1_PCIPM_L1_2 0x00000001 /* PCI-PM L1.2 Enable */
1007#define PCI_L1SS_CTL1_PCIPM_L1_1 0x00000002 /* PCI-PM L1.1 Enable */ 1010#define PCI_L1SS_CTL1_PCIPM_L1_1 0x00000002 /* PCI-PM L1.1 Enable */
1008#define PCI_L1SS_CTL1_ASPM_L1_2 0x00000004 /* ASPM L1.2 Enable */ 1011#define PCI_L1SS_CTL1_ASPM_L1_2 0x00000004 /* ASPM L1.2 Enable */
1009#define PCI_L1SS_CTL1_ASPM_L1_1 0x00000008 /* ASPM L1.1 Enable */ 1012#define PCI_L1SS_CTL1_ASPM_L1_1 0x00000008 /* ASPM L1.1 Enable */
1010#define PCI_L1SS_CTL1_L1SS_MASK 0x0000000f 1013#define PCI_L1SS_CTL1_L1SS_MASK 0x0000000f
1014#define PCI_L1SS_CTL1_CM_RESTORE_TIME 0x0000ff00 /* Common_Mode_Restore_Time */
1015#define PCI_L1SS_CTL1_LTR_L12_TH_VALUE 0x03ff0000 /* LTR_L1.2_THRESHOLD_Value */
1016#define PCI_L1SS_CTL1_LTR_L12_TH_SCALE 0xe0000000 /* LTR_L1.2_THRESHOLD_Scale */
1011#define PCI_L1SS_CTL2 0x0c /* Control 2 Register */ 1017#define PCI_L1SS_CTL2 0x0c /* Control 2 Register */
1012 1018
1013#endif /* LINUX_PCI_REGS_H */ 1019#endif /* LINUX_PCI_REGS_H */