All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sumit Garg <sumit.garg@kernel.org>
To: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Cc: Sumit Garg <sumit.garg@kernel.org>,
	u-boot-qcom@groups.io, u-boot@lists.u-boot-project.org,
	Casey Connolly <casey.connolly@linaro.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Tom Rini <trini@konsulko.com>,
	Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Subject: Re: [PATCH v2] phy: qcom: qmp-combo: honor USB-C orientation for port select
Date: Fri, 16 Oct 2026 17:53:23 +0530	[thread overview]
Message-ID: <atIXO9NJTpxWXmev@sumit-xelite> (raw)
In-Reply-To: <20261013-ss-orientation-v2-1-8daddb44447e@oss.qualcomm.com>

On Tue, 13 Oct 2026 at 22:38:09 +0530, Balaji Selvanathan wrote:
>The TypeC port-select mux was always programmed with SW_PORTSELECT_MUX
>set and SW_PORTSELECT_VAL left clear, regardless of which way the
>USB-C cable was inserted. On a board where the cable goes in reversed,
>the SuperSpeed/DP lanes end up routed to the wrong side of the
>connector, so USB3/DP never comes up correctly.
>
>Cable orientation is reported by a GPIO on the qcom,pmic-glink node
>("orientation-gpios"), and is now sampled each time the PHY is
>enabled to check for the orientation.
>
>Taken from Linux commit 815891eee668 ("phy: qcom-qmp-combo: Introduce
>orientation variable").
>
>Tested on QCS6490 RB3 Gen2 board.
>
>Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>---
>Changes in v2:
>- Instead of reading the orientation at probe, read it only during the PHY init
>- Updated the commit message to better explain why this change is required
>- Link to v1: https://lore.kernel.org/u-boot/20260724-kodiak_ss_orientation-v1-1-d9d8fd271e0c@oss.qualcomm.com/
>---
> drivers/phy/qcom/phy-qcom-qmp-combo.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>

-Sumit

>
>diff --git a/drivers/phy/qcom/phy-qcom-qmp-combo.c b/drivers/phy/qcom/phy-qcom-qmp-combo.c
>index 0d63e482ee4..65141489d51 100644
>--- a/drivers/phy/qcom/phy-qcom-qmp-combo.c
>+++ b/drivers/phy/qcom/phy-qcom-qmp-combo.c
>@@ -7,10 +7,12 @@
> #include <dm.h>
> #include <dm/device_compat.h>
> #include <dm/devres.h>
>+#include <dm/ofnode.h>
> #include <generic-phy.h>
> #include <reset.h>
> #include <power/regulator.h>
> #include <asm/io.h>
>+#include <asm-generic/gpio.h>
> #include <linux/bitops.h>
> #include <linux/compat.h>
> #include <linux/delay.h>
>@@ -39,6 +41,7 @@
> #define DP_MODE                                 BIT(1) /* enables DP mode */
>
> /* QPHY_V3_DP_COM_TYPEC_CTRL register bits */
>+#define SW_PORTSELECT_VAL                       BIT(0)
> #define SW_PORTSELECT_MUX                       BIT(1)
>
> /* PHY slot identifiers for device tree phandle arguments */
>@@ -283,6 +286,27 @@ static int qmp_combo_com_exit(struct qmp_combo *qmp)
> 	return 0;
> }
>
>+static bool qmp_combo_read_orientation(void)
>+{
>+	ofnode node;
>+	struct gpio_desc desc;
>+	int ret, val;
>+
>+	node = ofnode_by_compatible(ofnode_null(), "qcom,pmic-glink");
>+	if (!ofnode_valid(node))
>+		return false;
>+
>+	ret = gpio_request_by_name_nodev(node, "orientation-gpios", 0,
>+					 &desc, GPIOD_IS_IN);
>+	if (ret)
>+		return false;
>+
>+	val = dm_gpio_get_value(&desc);
>+	dm_gpio_free(desc.dev, &desc);
>+
>+	return val > 0;
>+}
>+
> static int qmp_combo_com_init(struct qmp_combo *qmp)
> {
> 	void __iomem *com = qmp->com;
>@@ -333,6 +357,8 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
> 		     SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);
>
> 	val = SW_PORTSELECT_MUX;
>+	if (qmp_combo_read_orientation())
>+		val |= SW_PORTSELECT_VAL;
> 	writel(val, com + QPHY_V3_DP_COM_TYPEC_CTRL);
>
> 	writel(USB3_MODE | DP_MODE, com + QPHY_V3_DP_COM_PHY_MODE_CTRL);
>
>---
>base-commit: fed92546960a92177d67c0b8d7b22385f50fed29
>change-id: 20261013-ss-orientation-d85a156e806a
>
>Best regards,
>-- 
>Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>

      reply	other threads:[~2026-10-16 12:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 17:08 [PATCH v2] phy: qcom: qmp-combo: honor USB-C orientation for port select Balaji Selvanathan
2026-10-16 12:23 ` Sumit Garg [this message]

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=atIXO9NJTpxWXmev@sumit-xelite \
    --to=sumit.garg@kernel.org \
    --cc=balaji.selvanathan@oss.qualcomm.com \
    --cc=casey.connolly@linaro.org \
    --cc=neil.armstrong@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=varadarajan.narayanan@oss.qualcomm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.