* [PATCH 0/2] usb: typec: tcpci: support setting orientation via GPIO
@ 2026-03-10 8:13 Xu Yang
2026-03-10 8:13 ` [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property Xu Yang
2026-03-10 8:13 ` [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
0 siblings, 2 replies; 9+ messages in thread
From: Xu Yang @ 2026-03-10 8:13 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.
---
Xu Yang (2):
dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property
usb: typec: tcpci: support setting orientation via GPIO
Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 5 +++++
drivers/usb/typec/tcpm/tcpci.c | 18 ++++++++++++++++++
2 files changed, 23 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] 9+ messages in thread
* [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property
2026-03-10 8:13 [PATCH 0/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
@ 2026-03-10 8:13 ` Xu Yang
2026-03-11 12:59 ` Krzysztof Kozlowski
2026-03-11 13:00 ` Krzysztof Kozlowski
2026-03-10 8:13 ` [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
1 sibling, 2 replies; 9+ messages in thread
From: Xu Yang @ 2026-03-10 8:13 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 other chips which don't present this
capability currently there are no way to achieve the orientation setting.
Add an optional "orientation-gpio" property to achieve the same purpose.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
index 65a8632b4d9e..866b5d033f4e 100644
--- a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
+++ b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
@@ -26,6 +26,11 @@ properties:
$ref: /schemas/connector/usb-connector.yaml#
unevaluatedProperties: false
+ orientation-gpio:
+ description: Optional orientation select control if the chip doesn't
+ present "Connector Orientation" bit[0] in STANDARD_OUTPUT_CAPABILITIES
+ register.
+
required:
- compatible
- reg
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO
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-10 8:13 ` Xu Yang
2026-03-10 18:34 ` Frank Li
1 sibling, 1 reply; 9+ messages in thread
From: Xu Yang @ 2026-03-10 8:13 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>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO
2026-03-10 8:13 ` [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
@ 2026-03-10 18:34 ` Frank Li
0 siblings, 0 replies; 9+ messages in thread
From: Frank Li @ 2026-03-10 18:34 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>
> + 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;
> + }
AI: The logic here is confusing. You're converting a pointer to a boolean with
`!!orient_gpio`, then assigning it to `err`. This overwrites the error code
and makes the intent unclear. Consider using a separate flag variable or
restructuring to keep error handling explicit.
> + chip->tcpci->orientation_gpio = orient_gpio;
> +
> + err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
AI: This assignment happens after `tcpci_register_port()` returns. If that
function or any subsequent code path fails before this line, the GPIO
pointer is never stored in the chip structure. Consider moving the
assignment immediately after the GPIO acquisition, or ensure the pointer
is initialized in the struct at declaration time.
Frank
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property
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
1 sibling, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-11 12:59 UTC (permalink / raw)
To: Xu Yang
Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus,
linux-usb, imx, devicetree, linux-kernel
On Tue, Mar 10, 2026 at 04:13:56PM +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 other chips which don't present this
> capability currently there are no way to achieve the orientation setting.
> Add an optional "orientation-gpio" property to achieve the same purpose.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> index 65a8632b4d9e..866b5d033f4e 100644
> --- a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> +++ b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> @@ -26,6 +26,11 @@ properties:
> $ref: /schemas/connector/usb-connector.yaml#
> unevaluatedProperties: false
>
> + orientation-gpio:
> + description: Optional orientation select control if the chip doesn't
> + present "Connector Orientation" bit[0] in STANDARD_OUTPUT_CAPABILITIES
What do you mean by "if the chip"? There is only one chip, so its
registers are fixed. Why would this device sometimes report it and
sometimes not?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property
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 13:00 ` Krzysztof Kozlowski
2026-03-11 15:19 ` Xu Yang
1 sibling, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-11 13:00 UTC (permalink / raw)
To: Xu Yang
Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus,
linux-usb, imx, devicetree, linux-kernel
On Tue, Mar 10, 2026 at 04:13:56PM +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 other chips which don't present this
> capability currently there are no way to achieve the orientation setting.
> Add an optional "orientation-gpio" property to achieve the same purpose.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> index 65a8632b4d9e..866b5d033f4e 100644
> --- a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> +++ b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> @@ -26,6 +26,11 @@ properties:
> $ref: /schemas/connector/usb-connector.yaml#
> unevaluatedProperties: false
>
> + orientation-gpio:
Ah, and you cannot have "gpio" property. It's also typeless and
constrain-less, so looks like you create some random code here. :/
From where did you take such syntax?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property
2026-03-11 12:59 ` Krzysztof Kozlowski
@ 2026-03-11 15:06 ` Xu Yang
0 siblings, 0 replies; 9+ messages in thread
From: Xu Yang @ 2026-03-11 15:06 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus,
linux-usb, imx, devicetree, linux-kernel
On Wed, Mar 11, 2026 at 01:59:10PM +0100, Krzysztof Kozlowski wrote:
> On Tue, Mar 10, 2026 at 04:13:56PM +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 other chips which don't present this
> > capability currently there are no way to achieve the orientation setting.
> > Add an optional "orientation-gpio" property to achieve the same purpose.
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > ---
> > Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> > index 65a8632b4d9e..866b5d033f4e 100644
> > --- a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> > +++ b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> > @@ -26,6 +26,11 @@ properties:
> > $ref: /schemas/connector/usb-connector.yaml#
> > unevaluatedProperties: false
> >
> > + orientation-gpio:
> > + description: Optional orientation select control if the chip doesn't
> > + present "Connector Orientation" bit[0] in STANDARD_OUTPUT_CAPABILITIES
>
> What do you mean by "if the chip"? There is only one chip, so its
> registers are fixed. Why would this device sometimes report it and
> sometimes not?
Yes, you are right. PTN5110 is the only TCPCI compatible chip in this
binding, so its registers are fixed. I forgot this truth and thought it's
for all TCPCI compatible chip. I will remove the confused words.
Thanks,
Xu Yang
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property
2026-03-11 13:00 ` Krzysztof Kozlowski
@ 2026-03-11 15:19 ` Xu Yang
2026-03-11 15:28 ` Krzysztof Kozlowski
0 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2026-03-11 15:19 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus,
linux-usb, imx, devicetree, linux-kernel
On Wed, Mar 11, 2026 at 02:00:21PM +0100, Krzysztof Kozlowski wrote:
> On Tue, Mar 10, 2026 at 04:13:56PM +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 other chips which don't present this
> > capability currently there are no way to achieve the orientation setting.
> > Add an optional "orientation-gpio" property to achieve the same purpose.
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > ---
> > Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> > index 65a8632b4d9e..866b5d033f4e 100644
> > --- a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> > +++ b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
> > @@ -26,6 +26,11 @@ properties:
> > $ref: /schemas/connector/usb-connector.yaml#
> > unevaluatedProperties: false
> >
> > + orientation-gpio:
>
> Ah, and you cannot have "gpio" property. It's also typeless and
> constrain-less, so looks like you create some random code here. :/
Thanks for your correction.
After carefully reading the doc I think it should be:
orientation-gpios:
maxItems: 1
description: ...
>
> >From where did you take such syntax?
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/tree/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml?h=usb-next#n61
It may also need improvement.
Thanks,
Xu Yang
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] dt-bindings: usb: nxp,ptn5110: add optional orientation-gpio property
2026-03-11 15:19 ` Xu Yang
@ 2026-03-11 15:28 ` Krzysztof Kozlowski
0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-11 15:28 UTC (permalink / raw)
To: Xu Yang
Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Li Jun, Badhri Jagan Sridharan, Heikki Krogerus,
linux-usb, imx, devicetree, linux-kernel
On 11/03/2026 16:19, Xu Yang wrote:
> On Wed, Mar 11, 2026 at 02:00:21PM +0100, Krzysztof Kozlowski wrote:
>> On Tue, Mar 10, 2026 at 04:13:56PM +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 other chips which don't present this
>>> capability currently there are no way to achieve the orientation setting.
>>> Add an optional "orientation-gpio" property to achieve the same purpose.
>>>
>>> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>>> ---
>>> Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml | 5 +++++
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
>>> index 65a8632b4d9e..866b5d033f4e 100644
>>> --- a/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
>>> +++ b/Documentation/devicetree/bindings/usb/nxp,ptn5110.yaml
>>> @@ -26,6 +26,11 @@ properties:
>>> $ref: /schemas/connector/usb-connector.yaml#
>>> unevaluatedProperties: false
>>>
>>> + orientation-gpio:
>>
>> Ah, and you cannot have "gpio" property. It's also typeless and
>> constrain-less, so looks like you create some random code here. :/
>
> Thanks for your correction.
> After carefully reading the doc I think it should be:
>
> orientation-gpios:
> maxItems: 1
> description: ...
>
>>
>> >From where did you take such syntax?
>
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/tree/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml?h=usb-next#n61
> It may also need improvement.
And what is written in referenced schema - that's deprecated.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-03-11 15:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO Xu Yang
2026-03-10 18:34 ` Frank Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox