* [PATCH v2 0/2] usb: typec: tcpci: support setting orientation via GPIO
@ 2026-03-12 8:07 Xu Yang
2026-03-12 8:07 ` [PATCH v2 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpios property Xu Yang
2026-03-12 8:07 ` [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
0 siblings, 2 replies; 8+ messages in thread
From: Xu Yang @ 2026-03-12 8:07 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus
Cc: linux-usb, imx, devicetree, linux-kernel, Xu Yang
This patchset will add support to set orientation via a simple GPIO in
case the tcpci compatible chip doesn't present "Connection Orientation"
standard output capability.
---
Changes in v2:
- rename the property as orientation-gpios
- add maxItems to the property and modify description
- improve tcpci_set_orientation()
- Link to v1: https://lore.kernel.org/r/20260310-support-setting-orientation-use-gpio-v1-0-da31dc6cd641@nxp.com
---
Xu Yang (2):
dt-bindings: usb: nxp,ptn5110: add optional orientation-gpios property
usb: typec: tcpci: support setting orientation via GPIO
Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 4 ++++
drivers/usb/typec/tcpm/tcpci.c | 18 ++++++++++++++++++
2 files changed, 22 insertions(+)
---
base-commit: bb375c251ab40bdbc5272008fcf2bc6cd5266610
change-id: 20260310-support-setting-orientation-use-gpio-5942d9a0b22e
Best regards,
--
Xu Yang <xu.yang_2@nxp.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpios property
2026-03-12 8:07 [PATCH v2 0/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
@ 2026-03-12 8:07 ` Xu Yang
2026-03-14 0:21 ` Rob Herring (Arm)
2026-03-12 8:07 ` [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
1 sibling, 1 reply; 8+ messages in thread
From: Xu Yang @ 2026-03-12 8:07 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus
Cc: linux-usb, imx, devicetree, linux-kernel, Xu Yang
The Type-C chip know the cable orientation and then normally will set the
switch channel to correctly configure the data path. Some chips itself
support to output the control signal by indicating the capability in
bit[0] of STANDARD_OUTPUT_CAPABILITIES register and do it in
CONFIG_STANDARD_OUTPUT register. For PTN5110 which doesn't present this
capability currently there is no way to achieve the orientation setting.
Add an optional "orientation-gpios" property to achieve the same purpose.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes in v2:
- use property name "orientation-gpios"
- remove the "if" condition and modify commit message
---
Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
index 65a8632b4d9e..581e5916eadd 100644
--- a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
+++ b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
@@ -26,6 +26,10 @@ properties:
$ref: /schemas/connector/usb-connector.yaml#
unevaluatedProperties: false
+ orientation-gpios:
+ maxItems: 1
+ description: Optional orientation select control
+
required:
- compatible
- reg
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO
2026-03-12 8:07 [PATCH v2 0/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
2026-03-12 8:07 ` [PATCH v2 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpios property Xu Yang
@ 2026-03-12 8:07 ` Xu Yang
2026-03-12 19:12 ` Frank Li
1 sibling, 1 reply; 8+ messages in thread
From: Xu Yang @ 2026-03-12 8:07 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus
Cc: linux-usb, imx, devicetree, linux-kernel, Xu Yang
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>
---
Changes in v2:
- return early in tcpci_set_orientation() if using gpio method
---
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..b930c8b1d2f7 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 {
@@ -316,6 +318,10 @@ static int tcpci_set_orientation(struct tcpc_dev *tcpc,
struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
unsigned int reg;
+ if (tcpci->orientation_gpio)
+ return gpiod_set_value_cansleep(tcpci->orientation_gpio,
+ orientation == TYPEC_ORIENTATION_NORMAL ? 0 : 1);
+
switch (orientation) {
case TYPEC_ORIENTATION_NONE:
/* We can't put a single output into high impedance */
@@ -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 ? 1 : 0;
+ }
+
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO
2026-03-12 8:07 ` [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
@ 2026-03-12 19:12 ` Frank Li
2026-03-12 20:27 ` Greg Kroah-Hartman
2026-03-13 2:03 ` Xu Yang
0 siblings, 2 replies; 8+ messages in thread
From: Frank Li @ 2026-03-12 19:12 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus
Cc: Frank Li, linux-usb, imx, devicetree, linux-kernel, Xu Yang
From: Frank Li (AI-BOT) <frank.li@nxp.com>
> + err = orient_gpio ? 1 : 0;
AI: Redundant ternary. Use `err = !!orient_gpio;` or `err = orient_gpio != NULL;`
for clarity.
Frank
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO
2026-03-12 19:12 ` Frank Li
@ 2026-03-12 20:27 ` Greg Kroah-Hartman
2026-03-12 20:50 ` Frank Li
2026-03-13 2:03 ` Xu Yang
1 sibling, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2026-03-12 20:27 UTC (permalink / raw)
To: Frank Li
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Li Jun,
Badhri Jagan Sridharan, Heikki Krogerus, linux-usb, imx,
devicetree, linux-kernel, Xu Yang
On Thu, Mar 12, 2026 at 03:12:41PM -0400, Frank Li wrote:
> From: Frank Li (AI-BOT) <frank.li@nxp.com>
>
>
> > + err = orient_gpio ? 1 : 0;
>
> AI: Redundant ternary. Use `err = !!orient_gpio;` or `err = orient_gpio != NULL;`
> for clarity.
Better yet, never use ? :, just spell it out with a real if statement.
And ick, do NOT do that last option, go kick your AI bot, that's horrid.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO
2026-03-12 20:27 ` Greg Kroah-Hartman
@ 2026-03-12 20:50 ` Frank Li
0 siblings, 0 replies; 8+ messages in thread
From: Frank Li @ 2026-03-12 20:50 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Li Jun,
Badhri Jagan Sridharan, Heikki Krogerus, linux-usb, imx,
devicetree, linux-kernel, Xu Yang
On Thu, Mar 12, 2026 at 09:27:09PM +0100, Greg Kroah-Hartman wrote:
> On Thu, Mar 12, 2026 at 03:12:41PM -0400, Frank Li wrote:
> > From: Frank Li (AI-BOT) <frank.li@nxp.com>
> >
> >
> > > + err = orient_gpio ? 1 : 0;
> >
> > AI: Redundant ternary. Use `err = !!orient_gpio;` or `err = orient_gpio != NULL;`
> > for clarity.
>
> Better yet, never use ? :, just spell it out with a real if statement.
> And ick, do NOT do that last option, go kick your AI bot, that's horrid.
last option is bad, I have not remove it when I review AI's result because
I think first one look good. I generally just remove whole sentense from AI.
Frank
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO
2026-03-12 19:12 ` Frank Li
2026-03-12 20:27 ` Greg Kroah-Hartman
@ 2026-03-13 2:03 ` Xu Yang
1 sibling, 0 replies; 8+ messages in thread
From: Xu Yang @ 2026-03-13 2:03 UTC (permalink / raw)
To: Frank Li
Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus,
linux-usb, imx, devicetree, linux-kernel
On Thu, Mar 12, 2026 at 03:12:41PM -0400, Frank Li wrote:
> From: Frank Li (AI-BOT) <frank.li@nxp.com>
>
>
> > + err = orient_gpio ? 1 : 0;
>
> AI: Redundant ternary. Use `err = !!orient_gpio;` or `err = orient_gpio != NULL;`
> for clarity.
It was "err = !!orient_gpio;" in V1. But the AI-BOT complained about it.
I will return it back in V3.
Thanks,
Xu Yang
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpios property
2026-03-12 8:07 ` [PATCH v2 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpios property Xu Yang
@ 2026-03-14 0:21 ` Rob Herring (Arm)
0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring (Arm) @ 2026-03-14 0:21 UTC (permalink / raw)
To: Xu Yang
Cc: Conor Dooley, linux-kernel, Heikki Krogerus, linux-usb,
Badhri Jagan Sridharan, Greg Kroah-Hartman, devicetree, Li Jun,
Krzysztof Kozlowski, imx
On Thu, 12 Mar 2026 16:07:24 +0800, Xu Yang wrote:
> The Type-C chip know the cable orientation and then normally will set the
> switch channel to correctly configure the data path. Some chips itself
> support to output the control signal by indicating the capability in
> bit[0] of STANDARD_OUTPUT_CAPABILITIES register and do it in
> CONFIG_STANDARD_OUTPUT register. For PTN5110 which doesn't present this
> capability currently there is no way to achieve the orientation setting.
> Add an optional "orientation-gpios" property to achieve the same purpose.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>
> ---
> Changes in v2:
> - use property name "orientation-gpios"
> - remove the "if" condition and modify commit message
> ---
> Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 4 ++++
> 1 file changed, 4 insertions(+)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-03-14 0:21 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 8:07 [PATCH v2 0/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
2026-03-12 8:07 ` [PATCH v2 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpios property Xu Yang
2026-03-14 0:21 ` Rob Herring (Arm)
2026-03-12 8:07 ` [PATCH v2 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
2026-03-12 19:12 ` Frank Li
2026-03-12 20:27 ` Greg Kroah-Hartman
2026-03-12 20:50 ` Frank Li
2026-03-13 2:03 ` Xu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox