[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <xbblw4jfte7re2pyroanvzqv4ddwhxbgcui5ubpnw7rwuo4s4d@gkph7jqzf33o>
Date: Sat, 11 Oct 2025 19:57:06 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
To: Chaoyi Chen <kernel@...kyi.com>
Cc: Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>,
Heiko Stuebner <heiko@...ech.de>, Sandy Huang <hjc@...k-chips.com>,
Andy Yan <andy.yan@...k-chips.com>,
Yubing Zhang <yubing.zhang@...k-chips.com>,
Frank Wang <frank.wang@...k-chips.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Amit Sunil Dhamne <amitsd@...gle.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Chaoyi Chen <chaoyi.chen@...k-chips.com>,
Dragan Simic <dsimic@...jaro.org>, Johan Jonker <jbx6244@...il.com>,
Diederik de Haas <didi.debian@...ow.org>,
Peter Robinson <pbrobinson@...il.com>, linux-usb@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-phy@...ts.infradead.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v5 3/8] phy: rockchip: phy-rockchip-typec: Add
typec_mux/typec_switch support
On Sat, Oct 11, 2025 at 11:32:28AM +0800, Chaoyi Chen wrote:
> From: Chaoyi Chen <chaoyi.chen@...k-chips.com>
>
> This patch add support for Type-C Port Controller Manager. Each PHY
> will register typec_mux and typec_switch when external Type-C
> controller is present. Type-C events are handled by TCPM without
> extcon.
>
> The extcon device should still be supported.
>
> Signed-off-by: Chaoyi Chen <chaoyi.chen@...k-chips.com>
> ---
>
> (no changes since v5)
>
> Changes in v4:
> - Remove notify DP HPD state by USB/DP PHY.
>
> (no changes since v3)
>
> Changes in v2:
> - Fix compile error when CONFIG_TYPEC is not enabled.
> - Notify DP HPD state by USB/DP PHY.
>
> drivers/phy/rockchip/phy-rockchip-typec.c | 365 +++++++++++++++++++++-
> 1 file changed, 349 insertions(+), 16 deletions(-)
>
> @@ -850,6 +998,72 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy)
> return mode;
> }
>
> +#if IS_ENABLED(CONFIG_TYPEC)
> +static int tcphy_orien_sw_set(struct typec_switch_dev *sw,
> + enum typec_orientation orien)
> +{
> + struct rockchip_typec_phy *tcphy = typec_switch_get_drvdata(sw);
> +
> + mutex_lock(&tcphy->lock);
> +
> + if (orien == TYPEC_ORIENTATION_NONE) {
> + tcphy->new_mode = MODE_DISCONNECT;
> + goto unlock_ret;
> + }
> +
> + tcphy->flip = (orien == TYPEC_ORIENTATION_REVERSE) ? true : false;
> + tcphy->new_mode = MODE_DFP_USB;
Carrying over unanswered(!) comment from the previous series:
I don't think it is correct. Orientation defines only the cable (plug)
orientation. You should be getting the mux events for the mode
selection.
> +
> +unlock_ret:
> + mutex_unlock(&tcphy->lock);
> + return 0;
> +}
> +
> +static void udphy_orien_switch_unregister(void *data)
> +{
> + struct rockchip_typec_phy *tcphy = data;
> +
> + typec_switch_unregister(tcphy->sw);
> +}
> +
> @@ -1037,6 +1251,89 @@ static const struct phy_ops rockchip_dp_phy_ops = {
> .owner = THIS_MODULE,
> };
>
> +#if IS_ENABLED(CONFIG_TYPEC)
> +static int tcphy_typec_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state)
> +{
> + struct rockchip_typec_phy *tcphy = typec_mux_get_drvdata(mux);
> + struct typec_displayport_data *data;
> + int hpd = 0;
> +
> + mutex_lock(&tcphy->lock);
> +
> + switch (state->mode) {
> + case TYPEC_STATE_SAFE:
> + fallthrough;
> + case TYPEC_STATE_USB:
> + tcphy->new_mode = MODE_DFP_USB;
> + phy_set_bus_width(tcphy->phys[TYPEC_PHY_DP], 0);
> + break;
> + case TYPEC_DP_STATE_C:
> + case TYPEC_DP_STATE_E:
You need to check that altmode->svid is DP before checking for these
modes.
> + tcphy->new_mode = MODE_DFP_DP;
> + data = state->data;
> + hpd = !!(data->status & DP_STATUS_HPD_STATE);
> + phy_set_bus_width(tcphy->phys[TYPEC_PHY_DP], hpd ? 4 : 0);
> + break;
> + case TYPEC_DP_STATE_D:
> + tcphy->new_mode = MODE_DFP_DP | MODE_DFP_USB;
> + data = state->data;
> + hpd = !!(data->status & DP_STATUS_HPD_STATE);
> + phy_set_bus_width(tcphy->phys[TYPEC_PHY_DP], hpd ? 2 : 0);
> + break;
> + default:
> + break;
> + }
> +
> + mutex_unlock(&tcphy->lock);
> +
> + return 0;
> +}
> +
--
With best wishes
Dmitry
Powered by blists - more mailing lists