[PATCH v3 3/5] phy: apple: atc: Add initial M3 series support

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Nov 25 13:38:20 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] phy: apple: atc: stale atcphy->mode on
  atcphy_wait_rcal1_done_t8122() failure
--

commit 5502f6b851712985ca558c7a0dd17a0358624746
Author: Sasha Finkelstein <k at chaosmail.tech>

phy: apple: atc: Add initial M3 series support

This commit adds initial support for the Apple t8122 (M3) Type-C PHY,
covering USB and Thunderbolt modes through a per-SoC hardware operations
structure.

> diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c
> index 45f1280a6faa3..68fc93a88f41a 100644
> --- a/drivers/phy/apple/atc.c
> +++ b/drivers/phy/apple/atc.c
[ ... ]
> @@ -1792,18 +1929,93 @@ static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode)
[ ... ]
> +static int atcphy_wait_rcal1_done_t8122(struct apple_atcphy *atcphy, enum atcphy_mode mode)
> +{
> +	int ret = 0;
> +	u32 reg;
> +
> +	if (atcphy_modes[mode].pipehandler_state == ATCPHY_PIPEHANDLER_STATE_USB3) {
> +		ret = readl_poll_timeout(atcphy->regs.core + AUS_COMMON_DIG_RCAL1, reg,
> +					 (reg & AUS_COMMON_DIG_RCAL1_ALL_CODES_DONE), 10, 100000);
> +		if (ret) {
> +			atcphy_power_off(atcphy);
> +			dev_err(atcphy->dev, "Failed to wait for RCAL1 done\n");
> +			return ret;
> +		}
> +	}
> +	return ret;
> +}
> +
> +static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode)
> +{
> +	int ret = 0;
> +
> +	lockdep_assert_held(&atcphy->lock);
> +
> +	if (mode == APPLE_ATCPHY_MODE_OFF) {
> +		ret = atcphy_power_off(atcphy);
> +		atcphy->mode = mode;
> +		return ret;
> +	}
> +
> +	ret = atcphy_power_on(atcphy);
> +	if (ret)
> +		return ret;
> +
> +	atcphy_apply_tunables(atcphy, mode);
> +	atcphy->hw->configure_post_tunable(atcphy, mode);
>  
>  	/* Setup AUX channel if DP altmode is requested */
>  	if (atcphy_modes[mode].enable_dp_aux)
>  		atcphy_enable_dp_aux(atcphy);
>  
>  	/* Enable clocks and configure lanes */
> -	core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_PCLK_EN);
> -	core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_REFCLK_EN);
> +	if (atcphy->hw->enable_cio3pll_clk)
> +		atcphy->hw->enable_cio3pll_clk(atcphy);
> +
>  	atcphy_configure_lanes(atcphy, mode);
>  
>  	/* Take the USB3 PHY out of reset */
>  	core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_PHY_RESET_N);
> +	/*
> +	 * NOTE: Not what macos does, it takes the phy out of reset right before writing to
> +	 * ACIOPHY_CFG0_COMMON_SMALL does lane configuration with phy out of reset, and the poll is
> +	 * right after AUS_COMMON_SHIM_BLK_BIAS_REG write. Does not seem to matter, but if something
> +	 * does not work, consider re-ordering things to macos order.
> +	 */
> +	if (atcphy->hw->wait_rcal1_done) {
> +		ret = atcphy->hw->wait_rcal1_done(atcphy, mode);
> +		if (ret)
> +			return ret;
> +	}
>  
>  	atcphy->mode = mode;

[Severity: Medium]
Does failing in atcphy_wait_rcal1_done_t8122() leave atcphy->mode out of
sync with the hardware state?

When the RCAL1 poll times out, atcphy_wait_rcal1_done_t8122() calls
atcphy_power_off(), and atcphy_configure() returns early without updating
atcphy->mode.  If atcphy->mode was already a non-OFF mode (such as
APPLE_ATCPHY_MODE_USB2) before transitioning to a USB3 mode, atcphy->mode
retains that previous active mode while the PHY hardware is powered off
and held in reset.  A subsequent atcphy_mux_set() back to that previous
mode will then see atcphy->mode == target_mode and return 0 without
powering the PHY back on.  Should atcphy->mode be reset to
APPLE_ATCPHY_MODE_OFF when atcphy_power_off() is called on this error
path?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-t8122-phy-v3-0-196e20b3537e@chaosmail.tech?part=3



More information about the linux-phy mailing list