Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions drivers/pci/controller/pcie-apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,41 @@ static int apple_pcie_neo_enumerate(struct pci_host_bridge *bridge)
return ret;
}

/*
* Machines whose internal links may enter the ASPM and PCI-PM L1.1 and L1.2
* substates. Both ends of these links support them, but the boot loader
* leaves them off and the default ASPM policy keeps what it found. On a J514S
* (T6030) turning them on for the Wi-Fi/Bluetooth and SD reader links lowered
* display-off idle power by about 0.3 W, with no change in Wi-Fi latency or
* throughput. Only measured machines are listed; tunneled ports never are.
* The J516S has the same T6030 links but has not been measured.
*/
static const char *const apple_pcie_l1ss_machines[] = {
"apple,j514s", NULL
};

static int apple_pcie_enable_l1ss(struct pci_dev *pdev, void *data)
{
int state = PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 |
PCIE_LINK_STATE_L1_1 | PCIE_LINK_STATE_L1_2 |
PCIE_LINK_STATE_L1_1_PCIPM | PCIE_LINK_STATE_L1_2_PCIPM;
u16 lnkctl;

/*
* pci_enable_link_state_locked() replaces the link's defaults. L0s is
* masked by what the link supports, so keep it. Clock PM is not forced
* on DT platforms: keep it only where the ASPM core left CLKREQ# on.
*/
if (!pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnkctl) &&
(lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN))
state |= PCIE_LINK_STATE_CLKPM;

/* PCI-PM L1 substates need the device in D0 (PCIe r6.0, sec 5.5.4). */
pci_set_power_state_locked(pdev, PCI_D0);
pci_enable_link_state_locked(pdev, state);
return 0;
}

static int apple_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
Expand Down Expand Up @@ -2875,6 +2910,8 @@ static int apple_pcie_probe(struct platform_device *pdev)

if (pcie->hw->tunneled)
pci_walk_bus(bridge->bus, apple_pcie_tunnel_keep_d0, NULL);
else if (of_machine_compatible_match(apple_pcie_l1ss_machines))
pci_walk_bus(bridge->bus, apple_pcie_enable_l1ss, NULL);

return 0;
}
Expand Down