From: Xu Yang <xu.yang_2@nxp.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Li Jun <jun.li@nxp.com>,
Badhri Jagan Sridharan <badhri@google.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: linux-usb@vger.kernel.org, imx@lists.linux.dev,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Xu Yang <xu.yang_2@nxp.com>
Subject: [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO
Date: Tue, 10 Mar 2026 16:13:57 +0800 [thread overview]
Message-ID: <20260310-support-setting-orientation-use-gpio-v1-2-da31dc6cd641@nxp.com> (raw)
In-Reply-To: <20260310-support-setting-orientation-use-gpio-v1-0-da31dc6cd641@nxp.com>
If the chip indicates its "Connection Orientation" standard output control
in STANDARD_OUTPUT_CAPABILITIES register, it can do the thing by
programming CONFIG_STANDARD_OUTPUT register. Due to the optional feature,
the chip which not present this capability currently doesn't have a way to
correctly set the data path. This add the support to set orientation via
a simple GPIO.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/usb/typec/tcpm/tcpci.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index 2a951c585e92..079b7d574253 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -7,6 +7,7 @@
#include <linux/bitfield.h>
#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/i2c.h>
@@ -42,6 +43,7 @@ struct tcpci {
struct tcpc_dev tcpc;
struct tcpci_data *data;
+ struct gpio_desc *orientation_gpio;
};
struct tcpci_chip {
@@ -328,6 +330,10 @@ static int tcpci_set_orientation(struct tcpc_dev *tcpc,
break;
}
+ if (tcpci->orientation_gpio)
+ gpiod_set_value_cansleep(tcpci->orientation_gpio,
+ orientation == TYPEC_ORIENTATION_NORMAL ? 0 : 1);
+
return regmap_update_bits(tcpci->regmap, TCPC_CONFIG_STD_OUTPUT,
TCPC_CONFIG_STD_OUTPUT_ORIENTATION_MASK, reg);
}
@@ -903,6 +909,7 @@ EXPORT_SYMBOL_GPL(tcpci_unregister_port);
static int tcpci_probe(struct i2c_client *client)
{
struct tcpci_chip *chip;
+ struct gpio_desc *orient_gpio = NULL;
int err;
u16 val = 0;
@@ -931,12 +938,23 @@ static int tcpci_probe(struct i2c_client *client)
if (err < 0)
return err;
+ if (err == 0) {
+ orient_gpio = devm_gpiod_get_optional(&client->dev, "orientation",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(orient_gpio))
+ return dev_err_probe(&client->dev, PTR_ERR(orient_gpio),
+ "unable to acquire orientation gpio\n");
+ err = !!orient_gpio;
+ }
+
chip->data.set_orientation = err;
chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
if (IS_ERR(chip->tcpci))
return PTR_ERR(chip->tcpci);
+ chip->tcpci->orientation_gpio = orient_gpio;
+
err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
_tcpci_irq,
IRQF_SHARED | IRQF_ONESHOT,
--
2.34.1
next prev parent reply other threads:[~2026-03-10 8:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 8:13 [PATCH 0/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
2026-03-10 8:13 ` [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property Xu Yang
2026-03-11 12:59 ` Krzysztof Kozlowski
2026-03-11 15:06 ` Xu Yang
2026-03-11 13:00 ` Krzysztof Kozlowski
2026-03-11 15:19 ` Xu Yang
2026-03-11 15:28 ` Krzysztof Kozlowski
2026-03-10 8:13 ` Xu Yang [this message]
2026-03-10 18:34 ` [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO Frank Li
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=20260310-support-setting-orientation-use-gpio-v1-2-da31dc6cd641@nxp.com \
--to=xu.yang_2@nxp.com \
--cc=badhri@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=imx@lists.linux.dev \
--cc=jun.li@nxp.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh@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