* [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present
@ 2025-04-16 10:59 Xu Yang
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Xu Yang @ 2025-04-16 10:59 UTC (permalink / raw)
To: krzk, myungjoo.ham, cw00.choi, robh, conor+dt; +Cc: devicetree, imx, jun.li
PTN5150 Type-C chip normally binds to a Type-C connector, so allow
"connector" node to present under it.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
index 072b3c0c5fd0..79f88b5f4e5c 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
+++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
@@ -42,6 +42,9 @@ properties:
description:
A port node to link the usb controller for the dual role switch.
+ connector:
+ $ref: /schemas/connector/usb-connector.yaml#
+
required:
- compatible
- interrupts
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
2025-04-16 10:59 [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Xu Yang
@ 2025-04-16 10:59 ` Xu Yang
2025-04-16 14:33 ` Frank Li
` (2 more replies)
2025-04-16 10:59 ` [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode Xu Yang
` (2 subsequent siblings)
3 siblings, 3 replies; 13+ messages in thread
From: Xu Yang @ 2025-04-16 10:59 UTC (permalink / raw)
To: krzk, myungjoo.ham, cw00.choi, robh, conor+dt; +Cc: devicetree, imx, jun.li
PTN5150 is able to detect CC polarity. The field[1:0] of CC status
register (04H) will keep the result.
00: Cable Not Attached
01: CC1 is connected (normal orientation)
10: CC2 is connected (reversed orientation)
11: Reserved
Sometimes this information is necessary, so add orientation switch
support to correctly set orientation of multiplexer.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/extcon/Kconfig | 1 +
drivers/extcon/extcon-ptn5150.c | 40 +++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index a6f6d467aacf..fd4ec5dda0b7 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -145,6 +145,7 @@ config EXTCON_PTN5150
tristate "NXP PTN5150 CC LOGIC USB EXTCON support"
depends on I2C && (GPIOLIB || COMPILE_TEST)
depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
+ depends on TYPEC || !TYPEC
select REGMAP_I2C
help
Say Y here to enable support for USB peripheral and USB host
diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
index 78ad86c4a3be..b7e05d921c79 100644
--- a/drivers/extcon/extcon-ptn5150.c
+++ b/drivers/extcon/extcon-ptn5150.c
@@ -18,6 +18,7 @@
#include <linux/extcon-provider.h>
#include <linux/gpio/consumer.h>
#include <linux/usb/role.h>
+#include <linux/usb/typec_mux.h>
/* PTN5150 registers */
#define PTN5150_REG_DEVICE_ID 0x01
@@ -38,7 +39,11 @@
#define PTN5150_REG_DEVICE_ID_VERSION GENMASK(7, 3)
#define PTN5150_REG_DEVICE_ID_VENDOR GENMASK(2, 0)
+#define PTN5150_POLARITY_CC1 0x1
+#define PTN5150_POLARITY_CC2 0x2
+
#define PTN5150_REG_CC_PORT_ATTACHMENT GENMASK(4, 2)
+#define PTN5150_REG_CC_POLARITY GENMASK(1, 0)
#define PTN5150_REG_CC_VBUS_DETECTION BIT(7)
#define PTN5150_REG_INT_CABLE_ATTACH_MASK BIT(0)
#define PTN5150_REG_INT_CABLE_DETACH_MASK BIT(1)
@@ -53,6 +58,7 @@ struct ptn5150_info {
int irq;
struct work_struct irq_work;
struct mutex mutex;
+ struct typec_switch *orient_sw;
struct usb_role_switch *role_sw;
};
@@ -72,6 +78,7 @@ static const struct regmap_config ptn5150_regmap_config = {
static void ptn5150_check_state(struct ptn5150_info *info)
{
unsigned int port_status, reg_data, vbus;
+ enum typec_orientation orient = TYPEC_ORIENTATION_NONE;
enum usb_role usb_role = USB_ROLE_NONE;
int ret;
@@ -81,6 +88,23 @@ static void ptn5150_check_state(struct ptn5150_info *info)
return;
}
+ orient = FIELD_GET(PTN5150_REG_CC_POLARITY, reg_data);
+ switch (orient) {
+ case PTN5150_POLARITY_CC1:
+ orient = TYPEC_ORIENTATION_NORMAL;
+ break;
+ case PTN5150_POLARITY_CC2:
+ orient = TYPEC_ORIENTATION_REVERSE;
+ break;
+ default:
+ orient = TYPEC_ORIENTATION_NONE;
+ break;
+ }
+
+ ret = typec_switch_set(info->orient_sw, orient);
+ if (ret)
+ dev_err(info->dev, "failed to set orientation: %d\n", ret);
+
port_status = FIELD_GET(PTN5150_REG_CC_PORT_ATTACHMENT, reg_data);
switch (port_status) {
@@ -152,6 +176,12 @@ static void ptn5150_irq_work(struct work_struct *work)
dev_err(info->dev,
"failed to set none role: %d\n",
ret);
+
+ ret = typec_switch_set(info->orient_sw,
+ TYPEC_ORIENTATION_NONE);
+ if (ret)
+ dev_err(info->dev,
+ "failed to set orientation: %d\n", ret);
}
}
@@ -219,12 +249,14 @@ static void ptn5150_work_sync_and_put(void *data)
cancel_work_sync(&info->irq_work);
usb_role_switch_put(info->role_sw);
+ typec_switch_put(info->orient_sw);
}
static int ptn5150_i2c_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
struct device_node *np = i2c->dev.of_node;
+ struct fwnode_handle *connector;
struct ptn5150_info *info;
int ret;
@@ -311,6 +343,14 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
if (ret)
return -EINVAL;
+ connector = device_get_named_child_node(dev, "connector");
+ if (connector) {
+ info->orient_sw = fwnode_typec_switch_get(connector);
+ if (IS_ERR(info->orient_sw))
+ return dev_err_probe(info->dev, PTR_ERR(info->orient_sw),
+ "failed to get orientation switch\n");
+ }
+
info->role_sw = usb_role_switch_get(info->dev);
if (IS_ERR(info->role_sw))
return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode
2025-04-16 10:59 [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Xu Yang
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
@ 2025-04-16 10:59 ` Xu Yang
2025-04-16 14:37 ` Frank Li
2025-04-16 14:23 ` [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Frank Li
2025-04-22 12:19 ` Rob Herring (Arm)
3 siblings, 1 reply; 13+ messages in thread
From: Xu Yang @ 2025-04-16 10:59 UTC (permalink / raw)
To: krzk, myungjoo.ham, cw00.choi, robh, conor+dt; +Cc: devicetree, imx, jun.li
Since PTN5150 is a Type-C chip, we normally need to describe some
properties under connector node. Due to this, the port node will
locate at connector node in the future. To support it, we need to
get usb role switch via connector fwnode. For compatibility, this
will not remove usb_role_switch_get() function.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/extcon/extcon-ptn5150.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
index b7e05d921c79..160998e163f0 100644
--- a/drivers/extcon/extcon-ptn5150.c
+++ b/drivers/extcon/extcon-ptn5150.c
@@ -352,6 +352,8 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
}
info->role_sw = usb_role_switch_get(info->dev);
+ if (!info->role_sw && connector)
+ info->role_sw = fwnode_usb_role_switch_get(connector);
if (IS_ERR(info->role_sw))
return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
"failed to get role switch\n");
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present
2025-04-16 10:59 [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Xu Yang
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
2025-04-16 10:59 ` [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode Xu Yang
@ 2025-04-16 14:23 ` Frank Li
2025-04-17 1:53 ` Xu Yang
2025-04-22 12:19 ` Rob Herring (Arm)
3 siblings, 1 reply; 13+ messages in thread
From: Frank Li @ 2025-04-16 14:23 UTC (permalink / raw)
To: Xu Yang
Cc: krzk, myungjoo.ham, cw00.choi, robh, conor+dt, devicetree, imx,
jun.li
On Wed, Apr 16, 2025 at 06:59:38PM +0800, Xu Yang wrote:
> PTN5150 Type-C chip normally binds to a Type-C connector, so allow
> "connector" node to present under it.
Suggest commit message:
PTN5150 is usually used with a Type-C connector, so allow a "connector"
node to be defined under it.
Frank
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
> index 072b3c0c5fd0..79f88b5f4e5c 100644
> --- a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
> +++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
> @@ -42,6 +42,9 @@ properties:
> description:
> A port node to link the usb controller for the dual role switch.
>
> + connector:
> + $ref: /schemas/connector/usb-connector.yaml#
> +
> required:
> - compatible
> - interrupts
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
@ 2025-04-16 14:33 ` Frank Li
2025-04-17 2:16 ` Xu Yang
2025-04-17 12:38 ` kernel test robot
2025-04-17 13:20 ` kernel test robot
2 siblings, 1 reply; 13+ messages in thread
From: Frank Li @ 2025-04-16 14:33 UTC (permalink / raw)
To: Xu Yang
Cc: krzk, myungjoo.ham, cw00.choi, robh, conor+dt, devicetree, imx,
jun.li
On Wed, Apr 16, 2025 at 06:59:39PM +0800, Xu Yang wrote:
> PTN5150 is able to detect CC polarity. The field[1:0] of CC status
> register (04H) will keep the result.
>
> 00: Cable Not Attached
> 01: CC1 is connected (normal orientation)
> 10: CC2 is connected (reversed orientation)
> 11: Reserved
>
> Sometimes this information is necessary, so add orientation switch
> support to correctly set orientation of multiplexer.
Add orientation switch support to correctly set orientation of
multiplexer according to CC status.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> drivers/extcon/Kconfig | 1 +
> drivers/extcon/extcon-ptn5150.c | 40 +++++++++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> index a6f6d467aacf..fd4ec5dda0b7 100644
> --- a/drivers/extcon/Kconfig
> +++ b/drivers/extcon/Kconfig
> @@ -145,6 +145,7 @@ config EXTCON_PTN5150
> tristate "NXP PTN5150 CC LOGIC USB EXTCON support"
> depends on I2C && (GPIOLIB || COMPILE_TEST)
> depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
> + depends on TYPEC || !TYPEC
> select REGMAP_I2C
> help
> Say Y here to enable support for USB peripheral and USB host
> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> index 78ad86c4a3be..b7e05d921c79 100644
> --- a/drivers/extcon/extcon-ptn5150.c
> +++ b/drivers/extcon/extcon-ptn5150.c
> @@ -18,6 +18,7 @@
> #include <linux/extcon-provider.h>
> #include <linux/gpio/consumer.h>
> #include <linux/usb/role.h>
> +#include <linux/usb/typec_mux.h>
>
> /* PTN5150 registers */
> #define PTN5150_REG_DEVICE_ID 0x01
> @@ -38,7 +39,11 @@
> #define PTN5150_REG_DEVICE_ID_VERSION GENMASK(7, 3)
> #define PTN5150_REG_DEVICE_ID_VENDOR GENMASK(2, 0)
>
> +#define PTN5150_POLARITY_CC1 0x1
> +#define PTN5150_POLARITY_CC2 0x2
> +
> #define PTN5150_REG_CC_PORT_ATTACHMENT GENMASK(4, 2)
> +#define PTN5150_REG_CC_POLARITY GENMASK(1, 0)
> #define PTN5150_REG_CC_VBUS_DETECTION BIT(7)
> #define PTN5150_REG_INT_CABLE_ATTACH_MASK BIT(0)
> #define PTN5150_REG_INT_CABLE_DETACH_MASK BIT(1)
> @@ -53,6 +58,7 @@ struct ptn5150_info {
> int irq;
> struct work_struct irq_work;
> struct mutex mutex;
> + struct typec_switch *orient_sw;
> struct usb_role_switch *role_sw;
> };
>
> @@ -72,6 +78,7 @@ static const struct regmap_config ptn5150_regmap_config = {
> static void ptn5150_check_state(struct ptn5150_info *info)
> {
> unsigned int port_status, reg_data, vbus;
> + enum typec_orientation orient = TYPEC_ORIENTATION_NONE;
Move to first variable to keep reverse christmas order
> enum usb_role usb_role = USB_ROLE_NONE;
> int ret;
>
> @@ -81,6 +88,23 @@ static void ptn5150_check_state(struct ptn5150_info *info)
> return;
> }
>
> + orient = FIELD_GET(PTN5150_REG_CC_POLARITY, reg_data);
> + switch (orient) {
> + case PTN5150_POLARITY_CC1:
> + orient = TYPEC_ORIENTATION_NORMAL;
> + break;
> + case PTN5150_POLARITY_CC2:
> + orient = TYPEC_ORIENTATION_REVERSE;
> + break;
> + default:
> + orient = TYPEC_ORIENTATION_NONE;
> + break;
> + }
> +
> + ret = typec_switch_set(info->orient_sw, orient);
> + if (ret)
> + dev_err(info->dev, "failed to set orientation: %d\n", ret);
> +
Does it need return error here?
Frank
> port_status = FIELD_GET(PTN5150_REG_CC_PORT_ATTACHMENT, reg_data);
>
> switch (port_status) {
> @@ -152,6 +176,12 @@ static void ptn5150_irq_work(struct work_struct *work)
> dev_err(info->dev,
> "failed to set none role: %d\n",
> ret);
> +
> + ret = typec_switch_set(info->orient_sw,
> + TYPEC_ORIENTATION_NONE);
> + if (ret)
> + dev_err(info->dev,
> + "failed to set orientation: %d\n", ret);
> }
> }
>
> @@ -219,12 +249,14 @@ static void ptn5150_work_sync_and_put(void *data)
>
> cancel_work_sync(&info->irq_work);
> usb_role_switch_put(info->role_sw);
> + typec_switch_put(info->orient_sw);
> }
>
> static int ptn5150_i2c_probe(struct i2c_client *i2c)
> {
> struct device *dev = &i2c->dev;
> struct device_node *np = i2c->dev.of_node;
> + struct fwnode_handle *connector;
> struct ptn5150_info *info;
> int ret;
>
> @@ -311,6 +343,14 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
> if (ret)
> return -EINVAL;
>
> + connector = device_get_named_child_node(dev, "connector");
> + if (connector) {
> + info->orient_sw = fwnode_typec_switch_get(connector);
> + if (IS_ERR(info->orient_sw))
> + return dev_err_probe(info->dev, PTR_ERR(info->orient_sw),
> + "failed to get orientation switch\n");
> + }
> +
> info->role_sw = usb_role_switch_get(info->dev);
> if (IS_ERR(info->role_sw))
> return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode
2025-04-16 10:59 ` [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode Xu Yang
@ 2025-04-16 14:37 ` Frank Li
2025-04-17 2:24 ` Xu Yang
0 siblings, 1 reply; 13+ messages in thread
From: Frank Li @ 2025-04-16 14:37 UTC (permalink / raw)
To: Xu Yang
Cc: krzk, myungjoo.ham, cw00.choi, robh, conor+dt, devicetree, imx,
jun.li
On Wed, Apr 16, 2025 at 06:59:40PM +0800, Xu Yang wrote:
> Since PTN5150 is a Type-C chip, we normally need to describe some
> properties under connector node. Due to this, the port node will
> locate at connector node in the future. To support it, we need to
> get usb role switch via connector fwnode. For compatibility, this
> will not remove usb_role_switch_get() function.
Your patch 2 already return error if there not connector, which already
broken compatibility.
You should handle compatibility in patch 2 or before patch 2.
Frank
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> drivers/extcon/extcon-ptn5150.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> index b7e05d921c79..160998e163f0 100644
> --- a/drivers/extcon/extcon-ptn5150.c
> +++ b/drivers/extcon/extcon-ptn5150.c
> @@ -352,6 +352,8 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
> }
>
> info->role_sw = usb_role_switch_get(info->dev);
> + if (!info->role_sw && connector)
> + info->role_sw = fwnode_usb_role_switch_get(connector);
> if (IS_ERR(info->role_sw))
> return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
> "failed to get role switch\n");
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present
2025-04-16 14:23 ` [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Frank Li
@ 2025-04-17 1:53 ` Xu Yang
0 siblings, 0 replies; 13+ messages in thread
From: Xu Yang @ 2025-04-17 1:53 UTC (permalink / raw)
To: Frank Li
Cc: krzk, myungjoo.ham, cw00.choi, robh, conor+dt, devicetree, imx,
jun.li
On Wed, Apr 16, 2025 at 10:23:08AM -0400, Frank Li wrote:
> On Wed, Apr 16, 2025 at 06:59:38PM +0800, Xu Yang wrote:
> > PTN5150 Type-C chip normally binds to a Type-C connector, so allow
> > "connector" node to present under it.
>
> Suggest commit message:
>
> PTN5150 is usually used with a Type-C connector, so allow a "connector"
> node to be defined under it.
Okay.
Thanks,
Xu Yang
>
> Frank
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > ---
> > Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
> > index 072b3c0c5fd0..79f88b5f4e5c 100644
> > --- a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
> > +++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
> > @@ -42,6 +42,9 @@ properties:
> > description:
> > A port node to link the usb controller for the dual role switch.
> >
> > + connector:
> > + $ref: /schemas/connector/usb-connector.yaml#
> > +
> > required:
> > - compatible
> > - interrupts
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
2025-04-16 14:33 ` Frank Li
@ 2025-04-17 2:16 ` Xu Yang
0 siblings, 0 replies; 13+ messages in thread
From: Xu Yang @ 2025-04-17 2:16 UTC (permalink / raw)
To: Frank Li
Cc: krzk, myungjoo.ham, cw00.choi, robh, conor+dt, devicetree, imx,
jun.li
On Wed, Apr 16, 2025 at 10:33:10AM -0400, Frank Li wrote:
> On Wed, Apr 16, 2025 at 06:59:39PM +0800, Xu Yang wrote:
> > PTN5150 is able to detect CC polarity. The field[1:0] of CC status
> > register (04H) will keep the result.
> >
> > 00: Cable Not Attached
> > 01: CC1 is connected (normal orientation)
> > 10: CC2 is connected (reversed orientation)
> > 11: Reserved
> >
> > Sometimes this information is necessary, so add orientation switch
> > support to correctly set orientation of multiplexer.
>
> Add orientation switch support to correctly set orientation of
> multiplexer according to CC status.
OKay.
>
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > ---
> > drivers/extcon/Kconfig | 1 +
> > drivers/extcon/extcon-ptn5150.c | 40 +++++++++++++++++++++++++++++++++
> > 2 files changed, 41 insertions(+)
> >
> > diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
> > index a6f6d467aacf..fd4ec5dda0b7 100644
> > --- a/drivers/extcon/Kconfig
> > +++ b/drivers/extcon/Kconfig
> > @@ -145,6 +145,7 @@ config EXTCON_PTN5150
> > tristate "NXP PTN5150 CC LOGIC USB EXTCON support"
> > depends on I2C && (GPIOLIB || COMPILE_TEST)
> > depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
> > + depends on TYPEC || !TYPEC
> > select REGMAP_I2C
> > help
> > Say Y here to enable support for USB peripheral and USB host
> > diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> > index 78ad86c4a3be..b7e05d921c79 100644
> > --- a/drivers/extcon/extcon-ptn5150.c
> > +++ b/drivers/extcon/extcon-ptn5150.c
> > @@ -18,6 +18,7 @@
> > #include <linux/extcon-provider.h>
> > #include <linux/gpio/consumer.h>
> > #include <linux/usb/role.h>
> > +#include <linux/usb/typec_mux.h>
> >
> > /* PTN5150 registers */
> > #define PTN5150_REG_DEVICE_ID 0x01
> > @@ -38,7 +39,11 @@
> > #define PTN5150_REG_DEVICE_ID_VERSION GENMASK(7, 3)
> > #define PTN5150_REG_DEVICE_ID_VENDOR GENMASK(2, 0)
> >
> > +#define PTN5150_POLARITY_CC1 0x1
> > +#define PTN5150_POLARITY_CC2 0x2
> > +
> > #define PTN5150_REG_CC_PORT_ATTACHMENT GENMASK(4, 2)
> > +#define PTN5150_REG_CC_POLARITY GENMASK(1, 0)
> > #define PTN5150_REG_CC_VBUS_DETECTION BIT(7)
> > #define PTN5150_REG_INT_CABLE_ATTACH_MASK BIT(0)
> > #define PTN5150_REG_INT_CABLE_DETACH_MASK BIT(1)
> > @@ -53,6 +58,7 @@ struct ptn5150_info {
> > int irq;
> > struct work_struct irq_work;
> > struct mutex mutex;
> > + struct typec_switch *orient_sw;
> > struct usb_role_switch *role_sw;
> > };
> >
> > @@ -72,6 +78,7 @@ static const struct regmap_config ptn5150_regmap_config = {
> > static void ptn5150_check_state(struct ptn5150_info *info)
> > {
> > unsigned int port_status, reg_data, vbus;
> > + enum typec_orientation orient = TYPEC_ORIENTATION_NONE;
>
> Move to first variable to keep reverse christmas order
Okay.
>
> > enum usb_role usb_role = USB_ROLE_NONE;
> > int ret;
> >
> > @@ -81,6 +88,23 @@ static void ptn5150_check_state(struct ptn5150_info *info)
> > return;
> > }
> >
> > + orient = FIELD_GET(PTN5150_REG_CC_POLARITY, reg_data);
> > + switch (orient) {
> > + case PTN5150_POLARITY_CC1:
> > + orient = TYPEC_ORIENTATION_NORMAL;
> > + break;
> > + case PTN5150_POLARITY_CC2:
> > + orient = TYPEC_ORIENTATION_REVERSE;
> > + break;
> > + default:
> > + orient = TYPEC_ORIENTATION_NONE;
> > + break;
> > + }
> > +
> > + ret = typec_switch_set(info->orient_sw, orient);
> > + if (ret)
> > + dev_err(info->dev, "failed to set orientation: %d\n", ret);
> > +
>
> Does it need return error here?
The context is a void function. So it'll not return error here.
Thanks,
Xu Yang
>
> Frank
>
> > port_status = FIELD_GET(PTN5150_REG_CC_PORT_ATTACHMENT, reg_data);
> >
> > switch (port_status) {
> > @@ -152,6 +176,12 @@ static void ptn5150_irq_work(struct work_struct *work)
> > dev_err(info->dev,
> > "failed to set none role: %d\n",
> > ret);
> > +
> > + ret = typec_switch_set(info->orient_sw,
> > + TYPEC_ORIENTATION_NONE);
> > + if (ret)
> > + dev_err(info->dev,
> > + "failed to set orientation: %d\n", ret);
> > }
> > }
> >
> > @@ -219,12 +249,14 @@ static void ptn5150_work_sync_and_put(void *data)
> >
> > cancel_work_sync(&info->irq_work);
> > usb_role_switch_put(info->role_sw);
> > + typec_switch_put(info->orient_sw);
> > }
> >
> > static int ptn5150_i2c_probe(struct i2c_client *i2c)
> > {
> > struct device *dev = &i2c->dev;
> > struct device_node *np = i2c->dev.of_node;
> > + struct fwnode_handle *connector;
> > struct ptn5150_info *info;
> > int ret;
> >
> > @@ -311,6 +343,14 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
> > if (ret)
> > return -EINVAL;
> >
> > + connector = device_get_named_child_node(dev, "connector");
> > + if (connector) {
> > + info->orient_sw = fwnode_typec_switch_get(connector);
> > + if (IS_ERR(info->orient_sw))
> > + return dev_err_probe(info->dev, PTR_ERR(info->orient_sw),
> > + "failed to get orientation switch\n");
> > + }
> > +
> > info->role_sw = usb_role_switch_get(info->dev);
> > if (IS_ERR(info->role_sw))
> > return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode
2025-04-16 14:37 ` Frank Li
@ 2025-04-17 2:24 ` Xu Yang
2025-04-17 14:34 ` Frank Li
0 siblings, 1 reply; 13+ messages in thread
From: Xu Yang @ 2025-04-17 2:24 UTC (permalink / raw)
To: Frank Li
Cc: krzk, myungjoo.ham, cw00.choi, robh, conor+dt, devicetree, imx,
jun.li
On Wed, Apr 16, 2025 at 10:37:41AM -0400, Frank Li wrote:
> On Wed, Apr 16, 2025 at 06:59:40PM +0800, Xu Yang wrote:
> > Since PTN5150 is a Type-C chip, we normally need to describe some
> > properties under connector node. Due to this, the port node will
> > locate at connector node in the future. To support it, we need to
> > get usb role switch via connector fwnode. For compatibility, this
> > will not remove usb_role_switch_get() function.
>
> Your patch 2 already return error if there not connector, which already
> broken compatibility.
>
> You should handle compatibility in patch 2 or before patch 2.
Since connector is not a required node, so patch2 doesn't return error if
connector node doesn't exist. It only handle orientation switch thing. This
will not break compatibility of usb role switch (eg: port node is outside of
connector node).
Thanks,
Xu Yang
>
> Frank
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > ---
> > drivers/extcon/extcon-ptn5150.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> > index b7e05d921c79..160998e163f0 100644
> > --- a/drivers/extcon/extcon-ptn5150.c
> > +++ b/drivers/extcon/extcon-ptn5150.c
> > @@ -352,6 +352,8 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
> > }
> >
> > info->role_sw = usb_role_switch_get(info->dev);
> > + if (!info->role_sw && connector)
> > + info->role_sw = fwnode_usb_role_switch_get(connector);
> > if (IS_ERR(info->role_sw))
> > return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
> > "failed to get role switch\n");
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
2025-04-16 14:33 ` Frank Li
@ 2025-04-17 12:38 ` kernel test robot
2025-04-17 13:20 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-04-17 12:38 UTC (permalink / raw)
To: Xu Yang, krzk, myungjoo.ham, cw00.choi, robh, conor+dt
Cc: oe-kbuild-all, devicetree, imx, jun.li
Hi Xu,
kernel test robot noticed the following build errors:
[auto build test ERROR on krzk-dt/for-next]
[also build test ERROR on chanwoo-extcon/extcon-next linus/master v6.15-rc2 next-20250417]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Xu-Yang/extcon-ptn5150-Add-Type-C-orientation-switch-support/20250416-185917
base: https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-dt.git for-next
patch link: https://lore.kernel.org/r/20250416105940.1572672-2-xu.yang_2%40nxp.com
patch subject: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
config: csky-randconfig-001-20250417 (https://download.01.org/0day-ci/archive/20250417/202504172041.B86u6VMO-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250417/202504172041.B86u6VMO-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504172041.B86u6VMO-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "typec_switch_set" [drivers/extcon/extcon-ptn5150.ko] undefined!
>> ERROR: modpost: "fwnode_typec_switch_get" [drivers/extcon/extcon-ptn5150.ko] undefined!
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
2025-04-16 14:33 ` Frank Li
2025-04-17 12:38 ` kernel test robot
@ 2025-04-17 13:20 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-04-17 13:20 UTC (permalink / raw)
To: Xu Yang, krzk, myungjoo.ham, cw00.choi, robh, conor+dt
Cc: oe-kbuild-all, devicetree, imx, jun.li
Hi Xu,
kernel test robot noticed the following build errors:
[auto build test ERROR on krzk-dt/for-next]
[also build test ERROR on linus/master v6.15-rc2 next-20250417]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Xu-Yang/extcon-ptn5150-Add-Type-C-orientation-switch-support/20250416-185917
base: https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-dt.git for-next
patch link: https://lore.kernel.org/r/20250416105940.1572672-2-xu.yang_2%40nxp.com
patch subject: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
config: parisc-randconfig-001-20250417 (https://download.01.org/0day-ci/archive/20250417/202504172148.DEw1gGPg-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250417/202504172148.DEw1gGPg-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504172148.DEw1gGPg-lkp@intel.com/
All errors (new ones prefixed by >>):
hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_work_sync_and_put':
>> drivers/extcon/extcon-ptn5150.c:252:(.text+0x20): undefined reference to `typec_switch_put'
hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_check_state':
>> drivers/extcon/extcon-ptn5150.c:104:(.text+0x94): undefined reference to `typec_switch_set'
hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_irq_work':
drivers/extcon/extcon-ptn5150.c:180:(.text+0x29c): undefined reference to `typec_switch_set'
hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_i2c_probe':
>> drivers/extcon/extcon-ptn5150.c:348:(.text+0x618): undefined reference to `fwnode_typec_switch_get'
vim +252 drivers/extcon/extcon-ptn5150.c
77
78 static void ptn5150_check_state(struct ptn5150_info *info)
79 {
80 unsigned int port_status, reg_data, vbus;
81 enum typec_orientation orient = TYPEC_ORIENTATION_NONE;
82 enum usb_role usb_role = USB_ROLE_NONE;
83 int ret;
84
85 ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, ®_data);
86 if (ret) {
87 dev_err(info->dev, "failed to read CC STATUS %d\n", ret);
88 return;
89 }
90
91 orient = FIELD_GET(PTN5150_REG_CC_POLARITY, reg_data);
92 switch (orient) {
93 case PTN5150_POLARITY_CC1:
94 orient = TYPEC_ORIENTATION_NORMAL;
95 break;
96 case PTN5150_POLARITY_CC2:
97 orient = TYPEC_ORIENTATION_REVERSE;
98 break;
99 default:
100 orient = TYPEC_ORIENTATION_NONE;
101 break;
102 }
103
> 104 ret = typec_switch_set(info->orient_sw, orient);
105 if (ret)
106 dev_err(info->dev, "failed to set orientation: %d\n", ret);
107
108 port_status = FIELD_GET(PTN5150_REG_CC_PORT_ATTACHMENT, reg_data);
109
110 switch (port_status) {
111 case PTN5150_DFP_ATTACHED:
112 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false);
113 gpiod_set_value_cansleep(info->vbus_gpiod, 0);
114 extcon_set_state_sync(info->edev, EXTCON_USB, true);
115 usb_role = USB_ROLE_DEVICE;
116 break;
117 case PTN5150_UFP_ATTACHED:
118 extcon_set_state_sync(info->edev, EXTCON_USB, false);
119 vbus = FIELD_GET(PTN5150_REG_CC_VBUS_DETECTION, reg_data);
120 if (vbus)
121 gpiod_set_value_cansleep(info->vbus_gpiod, 0);
122 else
123 gpiod_set_value_cansleep(info->vbus_gpiod, 1);
124
125 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true);
126 usb_role = USB_ROLE_HOST;
127 break;
128 default:
129 break;
130 }
131
132 if (usb_role) {
133 ret = usb_role_switch_set_role(info->role_sw, usb_role);
134 if (ret)
135 dev_err(info->dev, "failed to set %s role: %d\n",
136 usb_role_string(usb_role), ret);
137 }
138 }
139
140 static void ptn5150_irq_work(struct work_struct *work)
141 {
142 struct ptn5150_info *info = container_of(work,
143 struct ptn5150_info, irq_work);
144 int ret = 0;
145 unsigned int int_status;
146
147 if (!info->edev)
148 return;
149
150 mutex_lock(&info->mutex);
151
152 /* Clear interrupt. Read would clear the register */
153 ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, &int_status);
154 if (ret) {
155 dev_err(info->dev, "failed to read INT STATUS %d\n", ret);
156 mutex_unlock(&info->mutex);
157 return;
158 }
159
160 if (int_status) {
161 unsigned int cable_attach;
162
163 cable_attach = int_status & PTN5150_REG_INT_CABLE_ATTACH_MASK;
164 if (cable_attach) {
165 ptn5150_check_state(info);
166 } else {
167 extcon_set_state_sync(info->edev,
168 EXTCON_USB_HOST, false);
169 extcon_set_state_sync(info->edev,
170 EXTCON_USB, false);
171 gpiod_set_value_cansleep(info->vbus_gpiod, 0);
172
173 ret = usb_role_switch_set_role(info->role_sw,
174 USB_ROLE_NONE);
175 if (ret)
176 dev_err(info->dev,
177 "failed to set none role: %d\n",
178 ret);
179
180 ret = typec_switch_set(info->orient_sw,
181 TYPEC_ORIENTATION_NONE);
182 if (ret)
183 dev_err(info->dev,
184 "failed to set orientation: %d\n", ret);
185 }
186 }
187
188 /* Clear interrupt. Read would clear the register */
189 ret = regmap_read(info->regmap, PTN5150_REG_INT_REG_STATUS,
190 &int_status);
191 if (ret) {
192 dev_err(info->dev,
193 "failed to read INT REG STATUS %d\n", ret);
194 mutex_unlock(&info->mutex);
195 return;
196 }
197
198 mutex_unlock(&info->mutex);
199 }
200
201
202 static irqreturn_t ptn5150_irq_handler(int irq, void *data)
203 {
204 struct ptn5150_info *info = data;
205
206 schedule_work(&info->irq_work);
207
208 return IRQ_HANDLED;
209 }
210
211 static int ptn5150_init_dev_type(struct ptn5150_info *info)
212 {
213 unsigned int reg_data, vendor_id, version_id;
214 int ret;
215
216 ret = regmap_read(info->regmap, PTN5150_REG_DEVICE_ID, ®_data);
217 if (ret) {
218 dev_err(info->dev, "failed to read DEVICE_ID %d\n", ret);
219 return -EINVAL;
220 }
221
222 vendor_id = FIELD_GET(PTN5150_REG_DEVICE_ID_VENDOR, reg_data);
223 version_id = FIELD_GET(PTN5150_REG_DEVICE_ID_VERSION, reg_data);
224 dev_dbg(info->dev, "Device type: version: 0x%x, vendor: 0x%x\n",
225 version_id, vendor_id);
226
227 /* Clear any existing interrupts */
228 ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, ®_data);
229 if (ret) {
230 dev_err(info->dev,
231 "failed to read PTN5150_REG_INT_STATUS %d\n",
232 ret);
233 return -EINVAL;
234 }
235
236 ret = regmap_read(info->regmap, PTN5150_REG_INT_REG_STATUS, ®_data);
237 if (ret) {
238 dev_err(info->dev,
239 "failed to read PTN5150_REG_INT_REG_STATUS %d\n", ret);
240 return -EINVAL;
241 }
242
243 return 0;
244 }
245
246 static void ptn5150_work_sync_and_put(void *data)
247 {
248 struct ptn5150_info *info = data;
249
250 cancel_work_sync(&info->irq_work);
251 usb_role_switch_put(info->role_sw);
> 252 typec_switch_put(info->orient_sw);
253 }
254
255 static int ptn5150_i2c_probe(struct i2c_client *i2c)
256 {
257 struct device *dev = &i2c->dev;
258 struct device_node *np = i2c->dev.of_node;
259 struct fwnode_handle *connector;
260 struct ptn5150_info *info;
261 int ret;
262
263 if (!np)
264 return -EINVAL;
265
266 info = devm_kzalloc(&i2c->dev, sizeof(*info), GFP_KERNEL);
267 if (!info)
268 return -ENOMEM;
269 i2c_set_clientdata(i2c, info);
270
271 info->dev = &i2c->dev;
272 info->i2c = i2c;
273 info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_OUT_LOW);
274 if (IS_ERR(info->vbus_gpiod)) {
275 ret = PTR_ERR(info->vbus_gpiod);
276 if (ret == -ENOENT) {
277 dev_info(dev, "No VBUS GPIO, ignoring VBUS control\n");
278 info->vbus_gpiod = NULL;
279 } else {
280 return dev_err_probe(dev, ret, "failed to get VBUS GPIO\n");
281 }
282 }
283
284 mutex_init(&info->mutex);
285
286 INIT_WORK(&info->irq_work, ptn5150_irq_work);
287
288 info->regmap = devm_regmap_init_i2c(i2c, &ptn5150_regmap_config);
289 if (IS_ERR(info->regmap)) {
290 return dev_err_probe(info->dev, PTR_ERR(info->regmap),
291 "failed to allocate register map\n");
292 }
293
294 if (i2c->irq > 0) {
295 info->irq = i2c->irq;
296 } else {
297 info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN);
298 if (IS_ERR(info->int_gpiod)) {
299 return dev_err_probe(dev, PTR_ERR(info->int_gpiod),
300 "failed to get INT GPIO\n");
301 }
302
303 info->irq = gpiod_to_irq(info->int_gpiod);
304 if (info->irq < 0) {
305 dev_err(dev, "failed to get INTB IRQ\n");
306 return info->irq;
307 }
308 }
309
310 ret = devm_request_threaded_irq(dev, info->irq, NULL,
311 ptn5150_irq_handler,
312 IRQF_TRIGGER_FALLING |
313 IRQF_ONESHOT,
314 i2c->name, info);
315 if (ret < 0) {
316 dev_err(dev, "failed to request handler for INTB IRQ\n");
317 return ret;
318 }
319
320 /* Allocate extcon device */
321 info->edev = devm_extcon_dev_allocate(info->dev, ptn5150_extcon_cable);
322 if (IS_ERR(info->edev)) {
323 dev_err(info->dev, "failed to allocate memory for extcon\n");
324 return -ENOMEM;
325 }
326
327 /* Register extcon device */
328 ret = devm_extcon_dev_register(info->dev, info->edev);
329 if (ret) {
330 dev_err(info->dev, "failed to register extcon device\n");
331 return ret;
332 }
333
334 extcon_set_property_capability(info->edev, EXTCON_USB,
335 EXTCON_PROP_USB_VBUS);
336 extcon_set_property_capability(info->edev, EXTCON_USB_HOST,
337 EXTCON_PROP_USB_VBUS);
338 extcon_set_property_capability(info->edev, EXTCON_USB_HOST,
339 EXTCON_PROP_USB_TYPEC_POLARITY);
340
341 /* Initialize PTN5150 device and print vendor id and version id */
342 ret = ptn5150_init_dev_type(info);
343 if (ret)
344 return -EINVAL;
345
346 connector = device_get_named_child_node(dev, "connector");
347 if (connector) {
> 348 info->orient_sw = fwnode_typec_switch_get(connector);
349 if (IS_ERR(info->orient_sw))
350 return dev_err_probe(info->dev, PTR_ERR(info->orient_sw),
351 "failed to get orientation switch\n");
352 }
353
354 info->role_sw = usb_role_switch_get(info->dev);
355 if (IS_ERR(info->role_sw))
356 return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
357 "failed to get role switch\n");
358
359 ret = devm_add_action_or_reset(dev, ptn5150_work_sync_and_put, info);
360 if (ret)
361 return ret;
362
363 /*
364 * Update current extcon state if for example OTG connection was there
365 * before the probe
366 */
367 mutex_lock(&info->mutex);
368 ptn5150_check_state(info);
369 mutex_unlock(&info->mutex);
370
371 return 0;
372 }
373
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode
2025-04-17 2:24 ` Xu Yang
@ 2025-04-17 14:34 ` Frank Li
0 siblings, 0 replies; 13+ messages in thread
From: Frank Li @ 2025-04-17 14:34 UTC (permalink / raw)
To: Xu Yang
Cc: krzk, myungjoo.ham, cw00.choi, robh, conor+dt, devicetree, imx,
jun.li
On Thu, Apr 17, 2025 at 10:24:36AM +0800, Xu Yang wrote:
> On Wed, Apr 16, 2025 at 10:37:41AM -0400, Frank Li wrote:
> > On Wed, Apr 16, 2025 at 06:59:40PM +0800, Xu Yang wrote:
> > > Since PTN5150 is a Type-C chip, we normally need to describe some
> > > properties under connector node. Due to this, the port node will
> > > locate at connector node in the future. To support it, we need to
> > > get usb role switch via connector fwnode. For compatibility, this
> > > will not remove usb_role_switch_get() function.
> >
> > Your patch 2 already return error if there not connector, which already
> > broken compatibility.
> >
> > You should handle compatibility in patch 2 or before patch 2.
>
> Since connector is not a required node, so patch2 doesn't return error if
> connector node doesn't exist. It only handle orientation switch thing. This
> will not break compatibility of usb role switch (eg: port node is outside of
> connector node).
You are right.
suggest commit message:
usb: typec: ptn5150: Support USB role switch via connector fwnode
Since the PTN5150 is a Type-C chip, it's common to describe related
properties under the connector node. To align with this, the port
node will be located under the connector node in the future.
To support this layout, retrieve the USB role switch using the
connector's fwnode. For compatibility with existing device trees,
keep the usb_role_switch_get() function.
Frank
>
> Thanks,
> Xu Yang
>
> >
> > Frank
> > >
> > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > > ---
> > > drivers/extcon/extcon-ptn5150.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> > > index b7e05d921c79..160998e163f0 100644
> > > --- a/drivers/extcon/extcon-ptn5150.c
> > > +++ b/drivers/extcon/extcon-ptn5150.c
> > > @@ -352,6 +352,8 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
> > > }
> > >
> > > info->role_sw = usb_role_switch_get(info->dev);
> > > + if (!info->role_sw && connector)
> > > + info->role_sw = fwnode_usb_role_switch_get(connector);
> > > if (IS_ERR(info->role_sw))
> > > return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
> > > "failed to get role switch\n");
> > > --
> > > 2.34.1
> > >
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present
2025-04-16 10:59 [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Xu Yang
` (2 preceding siblings ...)
2025-04-16 14:23 ` [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Frank Li
@ 2025-04-22 12:19 ` Rob Herring (Arm)
3 siblings, 0 replies; 13+ messages in thread
From: Rob Herring (Arm) @ 2025-04-22 12:19 UTC (permalink / raw)
To: Xu Yang; +Cc: imx, jun.li, devicetree, conor+dt, cw00.choi, krzk, myungjoo.ham
On Wed, 16 Apr 2025 18:59:38 +0800, Xu Yang wrote:
> PTN5150 Type-C chip normally binds to a Type-C connector, so allow
> "connector" node to present under it.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-04-22 12:19 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 10:59 [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Xu Yang
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
2025-04-16 14:33 ` Frank Li
2025-04-17 2:16 ` Xu Yang
2025-04-17 12:38 ` kernel test robot
2025-04-17 13:20 ` kernel test robot
2025-04-16 10:59 ` [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode Xu Yang
2025-04-16 14:37 ` Frank Li
2025-04-17 2:24 ` Xu Yang
2025-04-17 14:34 ` Frank Li
2025-04-16 14:23 ` [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Frank Li
2025-04-17 1:53 ` Xu Yang
2025-04-22 12:19 ` Rob Herring (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).