diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index b875afe892aae..033bf05832fdb 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -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. @@ -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 @@ -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; } diff --git a/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py b/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py index a8784387f1d8f..8dd1aaeefdc64 100755 --- a/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py +++ b/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py @@ -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;