From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: linux-phy@lists.infradead.org, vkoul@kernel.org,
neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v18 6/7] phy: rockchip: usbdp: Add USB-C state without DP enabled
Date: Thu, 19 Nov 2026 20:02:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-224003@kernel.org> (raw)
In-Reply-To: <20261119-b4-rockchip-usbdp-cleanup-part3-v18-6-fb325e336494@collabora.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] phy: rockchip: usbdp: missing power state update in
rk_udphy_orien_sw_set()
--
commit 8cfb31a083620f391bf963a14254a3d4d3b77ee1
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
phy: rockchip: usbdp: Add USB-C state without DP enabled
This commit adds a dedicated USB-only hardware mode for TYPEC_STATE_SAFE
and TYPEC_STATE_USB so that the DisplayPort side of the PHY is not kept
enabled when a USB-C device without DP AltMode is connected.
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index e4bbcb4edeae6..e72752ed49689 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -583,32 +583,14 @@ static void rk_udphy_dp_lane_enable(struct rk_udphy *udphy, int dp_lanes)
> CMN_DP_CMN_RSTN, FIELD_PREP(CMN_DP_CMN_RSTN, 0x0));
> }
>
> -static void rk_udphy_mode_set(struct rk_udphy *udphy, u8 hw_mode)
> +static void rk_udphy_set_lane_mux(struct rk_udphy *udphy)
> {
> - if (udphy->hw_mode == hw_mode)
> - return;
> -
> - udphy->phy_needs_reinit = true;
> - udphy->hw_mode = hw_mode;
> -}
> -
> -static void rk_udphy_set_typec_state(struct rk_udphy *udphy, unsigned long state)
> -{
> - u8 hw_mode;
> -
> - switch (state) {
> - case TYPEC_DP_STATE_C:
> - case TYPEC_DP_STATE_E:
> + if (udphy->dp_lanes == 4) {
> udphy->lane_mux_sel[0] = PHY_LANE_MUX_DP;
> udphy->lane_mux_sel[1] = PHY_LANE_MUX_DP;
> udphy->lane_mux_sel[2] = PHY_LANE_MUX_DP;
> udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP;
> - hw_mode = UDPHY_MODE_DP;
> - udphy->dp_lanes = 4;
> - break;
> -
> - case TYPEC_DP_STATE_D:
> - default:
> + } else {
> if (udphy->flip) {
> udphy->lane_mux_sel[0] = PHY_LANE_MUX_DP;
> udphy->lane_mux_sel[1] = PHY_LANE_MUX_DP;
> @@ -620,12 +602,39 @@ static void rk_udphy_set_typec_state(struct rk_udphy *udphy, unsigned long state
> udphy->lane_mux_sel[2] = PHY_LANE_MUX_DP;
> udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP;
> }
> - hw_mode = UDPHY_MODE_DP_USB;
> - udphy->dp_lanes = 2;
> + }
> +}
> +
> +static void rk_udphy_mode_set(struct rk_udphy *udphy, u8 hw_mode, u8 dp_lanes)
> +{
> + if (udphy->hw_mode == hw_mode && udphy->dp_lanes == dp_lanes)
> + return;
> +
> + udphy->phy_needs_reinit = true;
> + udphy->hw_mode = hw_mode;
> + udphy->dp_lanes = dp_lanes;
> +}
> +
> +static void rk_udphy_set_typec_state(struct rk_udphy *udphy, unsigned long state)
> +{
> + switch (state) {
> + case TYPEC_DP_STATE_C:
> + case TYPEC_DP_STATE_E:
> + rk_udphy_mode_set(udphy, UDPHY_MODE_DP, 4);
> + break;
> +
> + case TYPEC_DP_STATE_D:
> + rk_udphy_mode_set(udphy, UDPHY_MODE_DP_USB, 2);
> + break;
> +
> + case TYPEC_STATE_SAFE:
> + case TYPEC_STATE_USB:
> + default:
> + rk_udphy_mode_set(udphy, UDPHY_MODE_USB, 0);
> break;
> }
>
> - rk_udphy_mode_set(udphy, hw_mode);
> + rk_udphy_set_lane_mux(udphy);
> }
>
> static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)
> @@ -650,8 +659,15 @@ static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)
> gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 1);
> }
>
> - /* default to USB3 + DP as 4 lane USB is not supported */
> - rk_udphy_set_typec_state(udphy, TYPEC_DP_STATE_D);
> + /*
> + * default to safe mode (USB only) when mux is available to
> + * avoid unnecessary mode changes; otherwise default to 2+2
> + * mode, considering HW can effectively only do 2+2 or DP-only
> + */
> + if (udphy->mux)
> + rk_udphy_set_typec_state(udphy, TYPEC_STATE_SAFE);
> + else
> + rk_udphy_set_typec_state(udphy, TYPEC_DP_STATE_D);
> }
[Severity: Medium]
Does rk_udphy_orien_sw_set() need to call rk_udphy_update_power_state()
after rk_udphy_set_typec_default_mapping()?
When udphy->mux is NULL (the else branch above, on boards with an
orientation-switch but no mode-switch), rk_udphy_typec_mux_set() is never
called after rk_udphy_orien_sw_set():
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_orien_sw_set() {
...
if (udphy->flip != flipped) {
dev_dbg(udphy->dev, "cable orientation changed, PHY re-init required.\n");
udphy->phy_needs_reinit = true;
}
udphy->flip = flipped;
rk_udphy_set_typec_default_mapping(udphy);
rk_udphy_usb_bvalid_enable(udphy, true);
return 0;
}
Because dwc3 initializes phy_u3 at probe time and keeps it powered across
cable plug events, setting udphy->flip, udphy->hw_mode, udphy->dp_lanes
and udphy->phy_needs_reinit without calling rk_udphy_update_power_state()
leaves the PHY hardware unprogrammed for the new orientation and
TYPEC_DP_STATE_D mode, breaking USB3 on flipped cables and leaving DP
disabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-b4-rockchip-usbdp-cleanup-part3-v18-0-fb325e336494@collabora.com?part=6
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-11-19 20:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:40 [PATCH v18 0/7] phy: rockchip: usbdp: Fix runtime muxing between USB3 and DP Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 1/7] phy: rockchip: usbdp: Disable USB3 port during normal power-on Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 2/7] phy: rockchip: usbdp: Drop -EPROBE_DEFER hack Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 3/7] phy: rockchip: usbdp: Rename mode to hw_mode Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 4/7] phy: rockchip: usbdp: Fix power state handling Sebastian Reichel
2026-11-19 20:02 ` sashiko-bot
2026-11-19 19:40 ` [PATCH v18 5/7] phy: rockchip: usbdp: Re-init PHY on mux change Sebastian Reichel
2026-11-19 19:54 ` sashiko-bot
2026-11-19 19:40 ` [PATCH v18 6/7] phy: rockchip: usbdp: Add USB-C state without DP enabled Sebastian Reichel
2026-11-19 20:02 ` sashiko-bot [this message]
2026-11-19 19:40 ` [PATCH v18 7/7] phy: rockchip: usbdp: Add DP lane setup to power state update Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-224003@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sebastian.reichel@collabora.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox