phy: apple: atc: Implement the USB4 pipehandler state

USB3 tunneled via USB4 requires dwc3's PIPE interface to be switched to
the USB4 NHI which will take care of the tunneling. Add the required
bringup sequence such that USB3 tunnels work once the USB4 NHI is
upstream.

Signed-off-by: Sven Peter <sven@kernel.org>
Reviewed-by: Janne Grunau <j@jannau.net>
Link: https://patch.msgid.link/20260821-b4-atcphy-usb4-v1-3-45c0b741e0c0@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
Sven Peter 2026-08-21 15:50:29 +02:00 committed by Vinod Koul
parent 8ca2e11111
commit c319906aa4

View File

@ -1082,6 +1082,41 @@ static int atcphy_configure_pipehandler_usb3(struct apple_atcphy *atcphy, bool h
return 0;
}
static int atcphy_configure_pipehandler_usb4(struct apple_atcphy *atcphy)
{
int ret;
ret = atcphy_pipehandler_check(atcphy);
if (ret)
return ret;
/* Force disable link detection */
clear32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE_VALUES,
PIPEHANDLER_OVERRIDE_VAL_RXDETECT0 | PIPEHANDLER_OVERRIDE_VAL_RXDETECT1);
set32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXVALID);
set32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXDETECT);
ret = atcphy_pipehandler_lock(atcphy);
if (ret) {
dev_err(atcphy->dev, "Failed to lock pipehandler\n");
return ret;
}
/* Configure PIPE mux to the USB4/Thunderbolt controller */
atcphy_pipehandler_set_mux(atcphy, PIPEHANDLER_MUX_CTRL_DATA_USB4,
PIPEHANDLER_MUX_CTRL_CLK_USB4);
/* Remove link detection override */
clear32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXVALID);
clear32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXDETECT);
ret = atcphy_pipehandler_unlock(atcphy);
if (ret)
dev_warn(atcphy->dev, "Failed to unlock pipehandler\n");
return 0;
}
static int atcphy_configure_pipehandler_dummy(struct apple_atcphy *atcphy)
{
int ret;
@ -1128,10 +1163,8 @@ static int atcphy_configure_pipehandler(struct apple_atcphy *atcphy, bool host)
atcphy->pipehandler_up = true;
break;
case ATCPHY_PIPEHANDLER_STATE_USB4:
dev_warn(atcphy->dev,
"ATCPHY_PIPEHANDLER_STATE_USB4 not implemented; falling back to USB2\n");
ret = atcphy_configure_pipehandler_dummy(atcphy);
atcphy->pipehandler_up = false;
ret = atcphy_configure_pipehandler_usb4(atcphy);
atcphy->pipehandler_up = true;
break;
case ATCPHY_PIPEHANDLER_STATE_DUMMY:
ret = atcphy_configure_pipehandler_dummy(atcphy);