From: Heiko Stuebner <heiko@sntech.de>
To: vkoul@kernel.org, kishon@kernel.org
Cc: heiko@sntech.de, linux-phy@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
quentin.schulz@cherry.de, sebastian.reichel@collabora.com,
Heiko Stuebner <heiko.stuebner@cherry.de>
Subject: [PATCH 1/2] phy: rockchip: usbdp: move type-orientation-switch further down
Date: Tue, 25 Feb 2025 19:45:18 +0100 [thread overview]
Message-ID: <20250225184519.3586926-2-heiko@sntech.de> (raw)
In-Reply-To: <20250225184519.3586926-1-heiko@sntech.de>
From: Heiko Stuebner <heiko.stuebner@cherry.de>
Move the typec-orientation-switch functionality further down, next to
the typec-mux code. Not only brings this the typec-related functionality
closer together, but also the following change needs access to other
driver functions, that are below the current position.
No functional change.
Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>
---
drivers/phy/rockchip/phy-rockchip-usbdp.c | 166 +++++++++++-----------
1 file changed, 83 insertions(+), 83 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
index 5b1e8a3806ed..7b17c82ebcfc 100644
--- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
+++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
@@ -616,89 +616,6 @@ static void rk_udphy_dp_hpd_event_trigger(struct rk_udphy *udphy, bool hpd)
rk_udphy_grfreg_write(udphy->vogrf, &cfg->vogrfcfg[udphy->id].hpd_trigger, hpd);
}
-static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)
-{
- if (udphy->flip) {
- udphy->dp_lane_sel[0] = 0;
- udphy->dp_lane_sel[1] = 1;
- udphy->dp_lane_sel[2] = 3;
- udphy->dp_lane_sel[3] = 2;
- 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_USB;
- udphy->lane_mux_sel[3] = PHY_LANE_MUX_USB;
- udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_INVERT;
- udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_INVERT;
- gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 1);
- gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0);
- } else {
- udphy->dp_lane_sel[0] = 2;
- udphy->dp_lane_sel[1] = 3;
- udphy->dp_lane_sel[2] = 1;
- udphy->dp_lane_sel[3] = 0;
- udphy->lane_mux_sel[0] = PHY_LANE_MUX_USB;
- udphy->lane_mux_sel[1] = PHY_LANE_MUX_USB;
- udphy->lane_mux_sel[2] = PHY_LANE_MUX_DP;
- udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP;
- udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_NORMAL;
- udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_NORMAL;
- gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0);
- gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 1);
- }
-
- udphy->mode = UDPHY_MODE_DP_USB;
-}
-
-static int rk_udphy_orien_sw_set(struct typec_switch_dev *sw,
- enum typec_orientation orien)
-{
- struct rk_udphy *udphy = typec_switch_get_drvdata(sw);
-
- mutex_lock(&udphy->mutex);
-
- if (orien == TYPEC_ORIENTATION_NONE) {
- gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0);
- gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0);
- /* unattached */
- rk_udphy_usb_bvalid_enable(udphy, false);
- goto unlock_ret;
- }
-
- udphy->flip = (orien == TYPEC_ORIENTATION_REVERSE) ? true : false;
- rk_udphy_set_typec_default_mapping(udphy);
- rk_udphy_usb_bvalid_enable(udphy, true);
-
-unlock_ret:
- mutex_unlock(&udphy->mutex);
- return 0;
-}
-
-static void rk_udphy_orien_switch_unregister(void *data)
-{
- struct rk_udphy *udphy = data;
-
- typec_switch_unregister(udphy->sw);
-}
-
-static int rk_udphy_setup_orien_switch(struct rk_udphy *udphy)
-{
- struct typec_switch_desc sw_desc = { };
-
- sw_desc.drvdata = udphy;
- sw_desc.fwnode = dev_fwnode(udphy->dev);
- sw_desc.set = rk_udphy_orien_sw_set;
-
- udphy->sw = typec_switch_register(udphy->dev, &sw_desc);
- if (IS_ERR(udphy->sw)) {
- dev_err(udphy->dev, "Error register typec orientation switch: %ld\n",
- PTR_ERR(udphy->sw));
- return PTR_ERR(udphy->sw);
- }
-
- return devm_add_action_or_reset(udphy->dev,
- rk_udphy_orien_switch_unregister, udphy);
-}
-
static int rk_udphy_refclk_set(struct rk_udphy *udphy)
{
unsigned long rate;
@@ -1323,6 +1240,89 @@ static const struct phy_ops rk_udphy_usb3_phy_ops = {
.owner = THIS_MODULE,
};
+static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)
+{
+ if (udphy->flip) {
+ udphy->dp_lane_sel[0] = 0;
+ udphy->dp_lane_sel[1] = 1;
+ udphy->dp_lane_sel[2] = 3;
+ udphy->dp_lane_sel[3] = 2;
+ 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_USB;
+ udphy->lane_mux_sel[3] = PHY_LANE_MUX_USB;
+ udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_INVERT;
+ udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_INVERT;
+ gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 1);
+ gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0);
+ } else {
+ udphy->dp_lane_sel[0] = 2;
+ udphy->dp_lane_sel[1] = 3;
+ udphy->dp_lane_sel[2] = 1;
+ udphy->dp_lane_sel[3] = 0;
+ udphy->lane_mux_sel[0] = PHY_LANE_MUX_USB;
+ udphy->lane_mux_sel[1] = PHY_LANE_MUX_USB;
+ udphy->lane_mux_sel[2] = PHY_LANE_MUX_DP;
+ udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP;
+ udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_NORMAL;
+ udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_NORMAL;
+ gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0);
+ gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 1);
+ }
+
+ udphy->mode = UDPHY_MODE_DP_USB;
+}
+
+static int rk_udphy_orien_sw_set(struct typec_switch_dev *sw,
+ enum typec_orientation orien)
+{
+ struct rk_udphy *udphy = typec_switch_get_drvdata(sw);
+
+ mutex_lock(&udphy->mutex);
+
+ if (orien == TYPEC_ORIENTATION_NONE) {
+ gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0);
+ gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0);
+ /* unattached */
+ rk_udphy_usb_bvalid_enable(udphy, false);
+ goto unlock_ret;
+ }
+
+ udphy->flip = (orien == TYPEC_ORIENTATION_REVERSE) ? true : false;
+ rk_udphy_set_typec_default_mapping(udphy);
+ rk_udphy_usb_bvalid_enable(udphy, true);
+
+unlock_ret:
+ mutex_unlock(&udphy->mutex);
+ return ret;
+}
+
+static void rk_udphy_orien_switch_unregister(void *data)
+{
+ struct rk_udphy *udphy = data;
+
+ typec_switch_unregister(udphy->sw);
+}
+
+static int rk_udphy_setup_orien_switch(struct rk_udphy *udphy)
+{
+ struct typec_switch_desc sw_desc = { };
+
+ sw_desc.drvdata = udphy;
+ sw_desc.fwnode = dev_fwnode(udphy->dev);
+ sw_desc.set = rk_udphy_orien_sw_set;
+
+ udphy->sw = typec_switch_register(udphy->dev, &sw_desc);
+ if (IS_ERR(udphy->sw)) {
+ dev_err(udphy->dev, "Error register typec orientation switch: %ld\n",
+ PTR_ERR(udphy->sw));
+ return PTR_ERR(udphy->sw);
+ }
+
+ return devm_add_action_or_reset(udphy->dev,
+ rk_udphy_orien_switch_unregister, udphy);
+}
+
static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux,
struct typec_mux_state *state)
{
--
2.47.2
next prev parent reply other threads:[~2025-02-25 18:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 18:45 [PATCH 0/2] phy: rockchip: usbdp: improve typec orientation handling Heiko Stuebner
2025-02-25 18:45 ` Heiko Stuebner [this message]
2025-02-25 22:16 ` [PATCH 1/2] phy: rockchip: usbdp: move type-orientation-switch further down Christophe JAILLET
2025-02-25 22:22 ` Heiko Stübner
2025-02-25 18:45 ` [PATCH 2/2] phy: rockchip: usbdp: re-init the phy on orientation-change Heiko Stuebner
2025-02-25 22:07 ` Heiko Stübner
2025-02-26 14:46 ` Ondřej Jirman
2025-02-26 15:53 ` Heiko Stübner
2025-02-26 17:03 ` Ondřej Jirman
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=20250225184519.3586926-2-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=heiko.stuebner@cherry.de \
--cc=kishon@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=quentin.schulz@cherry.de \
--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
all inboxes | Powered by JetHome®