[PATCH v4 10/16] phy: rockchip: usbdp: Cleanup DP lane selection function
Neil Armstrong
neil.armstrong at linaro.org
Wed May 6 07:55:54 PDT 2026
On 4/28/26 18:13, Sebastian Reichel wrote:
> Use FIELD_PREP_WM16() helpers to simplify the DP lane selection
> logic.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>
> ---
> drivers/phy/rockchip/phy-rockchip-usbdp.c | 28 +++++++---------------------
> 1 file changed, 7 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index 1bfc365e2b2c..beab20e4c512 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -550,30 +550,16 @@ static void rk_udphy_usb_bvalid_enable(struct rk_udphy *udphy, u8 enable)
> static void rk_udphy_dp_lane_select(struct rk_udphy *udphy)
> {
> const struct rk_udphy_cfg *cfg = udphy->cfgs;
> - u32 value = 0;
> -
> - switch (udphy->dp_lanes) {
> - case 4:
> - value |= 3 << udphy->dp_lane_sel[3] * 2;
> - value |= 2 << udphy->dp_lane_sel[2] * 2;
> - fallthrough;
> -
> - case 2:
> - value |= 1 << udphy->dp_lane_sel[1] * 2;
> - fallthrough;
> + u32 value = FIELD_PREP_WM16(DP_LANE_SEL_ALL, 0);
> + int i;
>
> - case 1:
> - value |= 0 << udphy->dp_lane_sel[0] * 2;
> - break;
> + for (i = 0; i < udphy->dp_lanes; i++)
> + value |= field_prep(DP_LANE_SEL_N(udphy->dp_lane_sel[i]), i);
>
> - default:
> - break;
> - }
> + value |= FIELD_PREP_WM16(DP_AUX_DIN_SEL, udphy->dp_aux_din_sel);
> + value |= FIELD_PREP_WM16(DP_AUX_DOUT_SEL, udphy->dp_aux_dout_sel);
>
> - regmap_write(udphy->vogrf, cfg->vogrfcfg[udphy->id].dp_lane_reg,
> - ((DP_AUX_DIN_SEL | DP_AUX_DOUT_SEL | DP_LANE_SEL_ALL) << 16) |
> - FIELD_PREP(DP_AUX_DIN_SEL, udphy->dp_aux_din_sel) |
> - FIELD_PREP(DP_AUX_DOUT_SEL, udphy->dp_aux_dout_sel) | value);
> + regmap_write(udphy->vogrf, cfg->vogrfcfg[udphy->id].dp_lane_reg, value);
> }
>
> static void rk_udphy_dp_lane_enable(struct rk_udphy *udphy, int dp_lanes)
>
Reviewed-by: Neil Armstrong <neil.armstrong at linaro.org>
Thanks,
Neil
More information about the linux-phy
mailing list