Skip to content
Open
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions drivers/phy/apple/atc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7567,6 +7567,32 @@ static int atcphy_probe_sleep_power(struct apple_atcphy *atcphy)
return 0;
}

/*
* The AXI2AF bridge in front of the PHY keeps its reset values until its
* tunables are written, and until then the fabric branch behind it does not
* clock gate. atcphy_apply_tunables() only writes them on the first mode
* change, so a port that never sees a cable keeps the reset values for good.
* On the T8103 generation, write them as soon as the PHY is reset at probe,
* and again on resume in case the bridge lost them in system sleep. A port
* behind a fixed hub keeps them for its first SuperSpeed mode change, as in
* atcphy_apply_tunables().
*
* The T8103 check has no hardware reason behind it. The early write was
* measured only on a T6000 (M1 Pro), one of the PHYs that fall back to
* T8103, and has not run on a later generation. On two of those it would
* not simply be the same write made sooner: T8132 keeps separate USB3 and
* CIO AXI2AF tunables, and T8152 writes them only after its lanes are up.
*/
static void atcphy_apply_axi2af_tunables(struct apple_atcphy *atcphy)
{
lockdep_assert_held(&atcphy->lock);

if (atcphy->hw->gen != ATCPHY_GENERATION_T8103 || atcphy->fixed_usb2)
return;

apple_tunable_apply(atcphy->regs.axi2af, atcphy->tunables.axi2af);
}

/*
* A DisplayPort-only instance has no USB controller to reset and no PIPE: put
* the PHY in its off state and register the mux, switch and DP PHY.
Expand Down Expand Up @@ -7701,6 +7727,7 @@ static int atcphy_probe_finalize(struct apple_atcphy *atcphy)
if (!atcphy->hw->usb2_only)
atcphy_power_off(atcphy);
atcphy_setup_pipehandler(atcphy);
atcphy_apply_axi2af_tunables(atcphy);

/*
* Powering only the USB2 PHY when the controller initialises its PHYs is
Expand Down Expand Up @@ -8865,6 +8892,7 @@ static int atcphy_resume(struct device *dev)
if (atcphy->idle_rpm && pm_runtime_status_suspended(dev))
return 0;
atcphy_restore_after_pd_off(atcphy);
atcphy_apply_axi2af_tunables(atcphy);

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions tools/testing/selftests/drivers/apple/atc-t8132-usb3.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def main():
atcphy_get_mode_config(struct apple_atcphy *a, enum atcphy_mode m) { (void)a; (void)m; assert(0); return 0; }
static inline bool pm_runtime_status_suspended(struct device *d) { (void)d; return rpm_suspended; }
static inline void atcphy_restore_after_pd_off(struct apple_atcphy *a) { (void)a; }
static inline void atcphy_apply_axi2af_tunables(struct apple_atcphy *a) { (void)a; }
static void apple_tunable_apply(void *regs, struct apple_tunable *t)
{
(void)regs;
Expand Down