Devicetree
 help / color / mirror / Atom feed
* [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO
  2026-11-17 14:09 [PATCH v2 0/2] usb: typec: ucsi_ccg: Add CC orientation-gpios support Akash Kumar
@ 2026-11-17 14:09 ` Akash Kumar
  2026-11-20 14:51   ` Heikki Krogerus
  0 siblings, 1 reply; 7+ messages in thread
From: Akash Kumar @ 2026-11-17 14:09 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Wayne Chang, Akash Kumar, Heikki Krogerus
  Cc: linux-usb, devicetree, linux-kernel

The CCGx chip has no HPI register exposing CC polarity, so there is
no way for the driver to report typec_cap.orientation_aware or call
typec_set_orientation() from UCSI status alone. On boards that wire
a sense line to the connector, pick it up via the orientation-gpios
property and use it to report orientation.

Acquire an optional "orientation" GPIO for each connector child node
in ucsi_ccg_probe(), indexed by the connector's reg property. Add
update_connector and connector_status ops that mark the connector
orientation_aware when a GPIO is present, and drive
typec_set_orientation() from the GPIO value while connected.

Signed-off-by: Akash Kumar <akash.kumar@oss.qualcomm.com>
---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 76 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 34fde72fe0a6..c6cae20d8602 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -10,6 +10,7 @@
 #include <linux/acpi.h>
 #include <linux/delay.h>
 #include <linux/firmware.h>
+#include <linux/gpio/consumer.h>
 #include <linux/hex.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
@@ -17,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/usb/typec_dp.h>
 
 #include <linux/unaligned.h>
@@ -201,6 +203,9 @@ struct op_region {
 	__le32 message_in[CCGX_MESSAGE_IN_MAX];
 };
 
+/* CCGx can expose at most 2 PD ports per chip */
+#define CCG_MAX_PORTS 2
+
 struct ucsi_ccg {
 	struct device *dev;
 	struct ucsi *ucsi;
@@ -235,6 +240,15 @@ struct ucsi_ccg {
 	 */
 	spinlock_t op_lock;
 	struct op_region op_data;
+
+	/*
+	 * Optional per-connector CC-orientation GPIO ("orientation-gpios"
+	 * on the controller node). Not part of the UCSI spec's connector
+	 * status - the CCGx chip has no HPI register exposing CC polarity,
+	 * so orientation must come from a board-level sense line if one
+	 * exists. Left NULL (orientation_aware stays false) when absent.
+	 */
+	struct gpio_desc *orientation_gpio[CCG_MAX_PORTS];
 };
 
 static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len)
@@ -694,6 +708,36 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
 	return ret;
 }
 
+static void ucsi_ccg_update_connector(struct ucsi_connector *con)
+{
+	struct ucsi_ccg *uc = ucsi_get_drvdata(con->ucsi);
+
+	if (con->num > CCG_MAX_PORTS || !uc->orientation_gpio[con->num - 1])
+		return;
+
+	con->typec_cap.orientation_aware = true;
+}
+
+static void ucsi_ccg_connector_status(struct ucsi_connector *con)
+{
+	struct ucsi_ccg *uc = ucsi_get_drvdata(con->ucsi);
+	int orientation;
+
+	if (!UCSI_CONSTAT(con, CONNECTED)) {
+		typec_set_orientation(con->port, TYPEC_ORIENTATION_NONE);
+		return;
+	}
+
+	if (con->num > CCG_MAX_PORTS || !uc->orientation_gpio[con->num - 1])
+		return;
+
+	orientation = gpiod_get_value_cansleep(uc->orientation_gpio[con->num - 1]);
+	if (orientation >= 0)
+		typec_set_orientation(con->port,
+				       orientation ? TYPEC_ORIENTATION_REVERSE :
+						     TYPEC_ORIENTATION_NORMAL);
+}
+
 static const struct ucsi_operations ucsi_ccg_ops = {
 	.read_version = ucsi_ccg_read_version,
 	.read_cci = ucsi_ccg_read_cci,
@@ -701,7 +745,9 @@ static const struct ucsi_operations ucsi_ccg_ops = {
 	.read_message_in = ucsi_ccg_read_message_in,
 	.sync_control = ucsi_ccg_sync_control,
 	.async_control = ucsi_ccg_async_control,
-	.update_altmodes = ucsi_ccg_update_altmodes
+	.update_altmodes = ucsi_ccg_update_altmodes,
+	.update_connector = ucsi_ccg_update_connector,
+	.connector_status = ucsi_ccg_connector_status,
 };
 
 static irqreturn_t ccg_irq_handler(int irq, void *data)
@@ -1506,6 +1552,34 @@ static int ucsi_ccg_probe(struct i2c_client *client)
 	if (uc->info.mode & CCG_DEVINFO_PDPORTS_MASK)
 		uc->port_num++;
 
+	device_for_each_child_node_scoped(dev, fwnode) {
+		struct gpio_desc *desc;
+		u32 port;
+
+		status = fwnode_property_read_u32(fwnode, "reg", &port);
+		if (status < 0) {
+			dev_err(dev, "missing reg property of %pOFn\n", fwnode);
+			return status;
+		}
+
+		if (port >= CCG_MAX_PORTS) {
+			dev_warn(dev, "invalid connector number, ignoring\n");
+			continue;
+		}
+
+		desc = devm_gpiod_get_index_optional(dev, "orientation", port, GPIOD_IN);
+
+		/* If GPIO isn't found, continue */
+		if (!desc)
+			continue;
+
+		if (IS_ERR(desc))
+			return dev_err_probe(dev, PTR_ERR(desc),
+					      "unable to acquire orientation gpio\n");
+
+		uc->orientation_gpio[port] = desc;
+	}
+
 	uc->ucsi = ucsi_create(dev, &ucsi_ccg_ops);
 	if (IS_ERR(uc->ucsi))
 		return PTR_ERR(uc->ucsi);

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO
  2026-11-17 14:09 ` [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
@ 2026-11-20 14:51   ` Heikki Krogerus
  0 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2026-11-20 14:51 UTC (permalink / raw)
  To: Akash Kumar
  Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Wayne Chang, linux-usb, devicetree, linux-kernel

Hi,

> +static void ucsi_ccg_connector_status(struct ucsi_connector *con)
> +{
> +	struct ucsi_ccg *uc = ucsi_get_drvdata(con->ucsi);
> +	int orientation;
> +
> +	if (!UCSI_CONSTAT(con, CONNECTED)) {
> +		typec_set_orientation(con->port, TYPEC_ORIENTATION_NONE);
> +		return;
> +	}
> +
> +	if (con->num > CCG_MAX_PORTS || !uc->orientation_gpio[con->num - 1])
> +		return;
> +
> +	orientation = gpiod_get_value_cansleep(uc->orientation_gpio[con->num - 1]);
> +	if (orientation >= 0)
> +		typec_set_orientation(con->port,
> +				       orientation ? TYPEC_ORIENTATION_REVERSE :
> +						     TYPEC_ORIENTATION_NORMAL);
> +}

Looks like you have a small allignment issue here.

Maybe it would be more clear to return if the orientation is < 0.

	orientation = gpiod_get_value_cansleep(uc->orientation_gpio[con->num - 1]);
	if (orientation < 0)
                return;

	typec_set_orientation(con->port, orientation ? TYPEC_ORIENTATION_REVERSE :
                                                       TYPEC_ORIENTATION_NORMAL);

Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 0/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO
@ 2026-11-23  9:10 Akash Kumar
  2026-11-23  9:10 ` [PATCH v2 1/2] dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property Akash Kumar
  2026-11-23  9:10 ` [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
  0 siblings, 2 replies; 7+ messages in thread
From: Akash Kumar @ 2026-11-23  9:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Dmitry Baryshkov, Krzysztof Kozlowski, Conor Dooley,
	Heikki Krogerus
  Cc: linux-usb, linux-kernel, linux-arm-msm, devicetree

From: Akash Kumar <akakum@qti.qualcomm.com>

The CCGx chip has no HPI register exposing CC polarity, so on boards
that wire a sense line to the connector, pick it up via an optional
orientation-gpios property and report it through typec_set_orientation().

Patch 1 adds the dt-binding property, patch 2 wires it up in the
ucsi_ccg driver.

Changes in v2:
- Reworked ucsi_ccg_connector_status() to return early when the GPIO
  read fails instead of wrapping the call in typec_set_orientation()
  in a positive-case conditional (Heikki Krogerus).

Akash Kumar (2):
  dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property
  usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO

 .../bindings/usb/cypress,cypd4226.yaml        | 10 +++
 drivers/usb/typec/ucsi/ucsi_ccg.c             | 77 ++++++++++++++++++-
 2 files changed, 86 insertions(+), 1 deletion(-)


base-commit: 8e31dedb9ad496ea7dd7064d77d6f7d459c1c90f
prerequisite-patch-id: 0ffa67d7d9ce66074ffa2e070249ee5b0cbedb2e
prerequisite-patch-id: 65ba14bc52b50cdf47ecdce1f4b3fe678704955e
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property
  2026-11-23  9:10 [PATCH v2 0/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
@ 2026-11-23  9:10 ` Akash Kumar
  2026-11-23  9:18   ` sashiko-bot
  2026-11-23  9:10 ` [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
  1 sibling, 1 reply; 7+ messages in thread
From: Akash Kumar @ 2026-11-23  9:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Dmitry Baryshkov, Krzysztof Kozlowski, Conor Dooley,
	Heikki Krogerus
  Cc: linux-usb, linux-kernel, linux-arm-msm, devicetree

Add the optional orientation-gpios property, used to sense the CC
orientation of each Type-C connector on boards where the CCGx chip
has no HPI register exposing CC polarity. Entries are ordered by
connector number; an entry may be left as <0> for connectors with no
sense line.

Signed-off-by: Akash Kumar <akash.kumar@oss.qualcomm.com>
---
 .../devicetree/bindings/usb/cypress,cypd4226.yaml      | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
index d923ef82ecfa..5716c045d87e 100644
--- a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
+++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
@@ -59,6 +59,14 @@ properties:
     description: enable IRQ remote wakeup, see power/wakeup-source.txt
     type: boolean
 
+  orientation-gpios:
+    description:
+      GPIOs used to sense the CC orientation of each Type-C connector.
+      Entries are ordered by connector number, i.e. the first entry
+      corresponds to connector@0 and the second to connector@1.
+    minItems: 1
+    maxItems: 2
+
 patternProperties:
   '^connector@[01]$':
     $ref: /schemas/connector/usb-connector.yaml#
@@ -129,6 +137,7 @@ examples:
       };
     };
   - |
+    #include <dt-bindings/gpio/gpio.h>
     #include <dt-bindings/interrupt-controller/irq.h>
     i2c {
         #address-cells = <1>;
@@ -141,6 +150,7 @@ examples:
             pinctrl-0 = <&usb0_intr_state>;
             pinctrl-names = "default";
             wakeup-source;
+            orientation-gpios = <0>, <&tlmm XX GPIO_ACTIVE_HIGH>;
 
             #address-cells = <1>;
             #size-cells = <0>;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO
  2026-11-23  9:10 [PATCH v2 0/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
  2026-11-23  9:10 ` [PATCH v2 1/2] dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property Akash Kumar
@ 2026-11-23  9:10 ` Akash Kumar
  2026-11-23  9:22   ` sashiko-bot
  1 sibling, 1 reply; 7+ messages in thread
From: Akash Kumar @ 2026-11-23  9:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Dmitry Baryshkov, Krzysztof Kozlowski, Conor Dooley,
	Heikki Krogerus
  Cc: linux-usb, linux-kernel, linux-arm-msm, devicetree

The CCGx chip has no HPI register exposing CC polarity, so there is
no way for the driver to report typec_cap.orientation_aware or call
typec_set_orientation() from UCSI status alone. On boards that wire
a sense line to the connector, pick it up via the orientation-gpios
property and use it to report orientation.

Acquire an optional "orientation" GPIO for each connector child node
in ucsi_ccg_probe(), indexed by the connector's reg property. Add
update_connector and connector_status ops that mark the connector
orientation_aware when a GPIO is present, and drive
typec_set_orientation() from the GPIO value while connected.

Signed-off-by: Akash Kumar <akash.kumar@oss.qualcomm.com>
---
Changes in v2:
- Return early when the GPIO read fails instead of wrapping
  typec_set_orientation() in a positive-case conditional, avoiding the
  wrapped ternary continuation lines entirely (Heikki Krogerus).

 drivers/usb/typec/ucsi/ucsi_ccg.c | 77 ++++++++++++++++++++++++++++++-
 1 file changed, 76 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index c560d4539302..06c536d87694 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -10,6 +10,7 @@
 #include <linux/acpi.h>
 #include <linux/delay.h>
 #include <linux/firmware.h>
+#include <linux/gpio/consumer.h>
 #include <linux/hex.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
@@ -17,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/usb/typec_dp.h>
 
 #include <linux/unaligned.h>
@@ -201,6 +203,9 @@ struct op_region {
 	__le32 message_in[CCGX_MESSAGE_IN_MAX];
 };
 
+/* CCGx can expose at most 2 PD ports per chip */
+#define CCG_MAX_PORTS 2
+
 struct ucsi_ccg {
 	struct device *dev;
 	struct ucsi *ucsi;
@@ -235,6 +240,15 @@ struct ucsi_ccg {
 	 */
 	spinlock_t op_lock;
 	struct op_region op_data;
+
+	/*
+	 * Optional per-connector CC-orientation GPIO ("orientation-gpios"
+	 * on the controller node). Not part of the UCSI spec's connector
+	 * status - the CCGx chip has no HPI register exposing CC polarity,
+	 * so orientation must come from a board-level sense line if one
+	 * exists. Left NULL (orientation_aware stays false) when absent.
+	 */
+	struct gpio_desc *orientation_gpio[CCG_MAX_PORTS];
 };
 
 static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len)
@@ -694,6 +708,37 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
 	return ret;
 }
 
+static void ucsi_ccg_update_connector(struct ucsi_connector *con)
+{
+	struct ucsi_ccg *uc = ucsi_get_drvdata(con->ucsi);
+
+	if (con->num > CCG_MAX_PORTS || !uc->orientation_gpio[con->num - 1])
+		return;
+
+	con->typec_cap.orientation_aware = true;
+}
+
+static void ucsi_ccg_connector_status(struct ucsi_connector *con)
+{
+	struct ucsi_ccg *uc = ucsi_get_drvdata(con->ucsi);
+	int orientation;
+
+	if (!UCSI_CONSTAT(con, CONNECTED)) {
+		typec_set_orientation(con->port, TYPEC_ORIENTATION_NONE);
+		return;
+	}
+
+	if (con->num > CCG_MAX_PORTS || !uc->orientation_gpio[con->num - 1])
+		return;
+
+	orientation = gpiod_get_value_cansleep(uc->orientation_gpio[con->num - 1]);
+	if (orientation < 0)
+		return;
+
+	typec_set_orientation(con->port, orientation ? TYPEC_ORIENTATION_REVERSE :
+							TYPEC_ORIENTATION_NORMAL);
+}
+
 static const struct ucsi_operations ucsi_ccg_ops = {
 	.read_version = ucsi_ccg_read_version,
 	.read_cci = ucsi_ccg_read_cci,
@@ -701,7 +746,9 @@ static const struct ucsi_operations ucsi_ccg_ops = {
 	.read_message_in = ucsi_ccg_read_message_in,
 	.sync_control = ucsi_ccg_sync_control,
 	.async_control = ucsi_ccg_async_control,
-	.update_altmodes = ucsi_ccg_update_altmodes
+	.update_altmodes = ucsi_ccg_update_altmodes,
+	.update_connector = ucsi_ccg_update_connector,
+	.connector_status = ucsi_ccg_connector_status,
 };
 
 static irqreturn_t ccg_irq_handler(int irq, void *data)
@@ -1506,6 +1553,34 @@ static int ucsi_ccg_probe(struct i2c_client *client)
 	if (uc->info.mode & CCG_DEVINFO_PDPORTS_MASK)
 		uc->port_num++;
 
+	device_for_each_child_node_scoped(dev, fwnode) {
+		struct gpio_desc *desc;
+		u32 port;
+
+		status = fwnode_property_read_u32(fwnode, "reg", &port);
+		if (status < 0) {
+			dev_err(dev, "missing reg property of %pOFn\n", fwnode);
+			return status;
+		}
+
+		if (port >= CCG_MAX_PORTS) {
+			dev_warn(dev, "invalid connector number, ignoring\n");
+			continue;
+		}
+
+		desc = devm_gpiod_get_index_optional(dev, "orientation", port, GPIOD_IN);
+
+		/* If GPIO isn't found, continue */
+		if (!desc)
+			continue;
+
+		if (IS_ERR(desc))
+			return dev_err_probe(dev, PTR_ERR(desc),
+					      "unable to acquire orientation gpio\n");
+
+		uc->orientation_gpio[port] = desc;
+	}
+
 	uc->ucsi = ucsi_create(dev, &ucsi_ccg_ops);
 	if (IS_ERR(uc->ucsi))
 		return PTR_ERR(uc->ucsi);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property
  2026-11-23  9:10 ` [PATCH v2 1/2] dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property Akash Kumar
@ 2026-11-23  9:18   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-23  9:18 UTC (permalink / raw)
  To: Akash Kumar; +Cc: linux-usb, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] dt-bindings: usb: cypress,cypd4226: undefined XX token in
  orientation-gpios
- [Low] dt-bindings: usb: cypress,cypd4226: use items list for
  orientation-gpios
--

commit 68e05d99b098ac78032aa1e2d387de700ee8bf5b
Author: Akash Kumar <akash.kumar@oss.qualcomm.com>

dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property

This commit adds the optional orientation-gpios property to the
cypress,cypd4226 binding schema and illustrates it in the example.

> diff --git a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> index d923ef82ecfaa..5716c045d87ec 100644
> --- a/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> +++ b/Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml
> @@ -59,6 +59,14 @@ properties:
>      description: enable IRQ remote wakeup, see power/wakeup-source.txt
>      type: boolean
>  
> +  orientation-gpios:
> +    description:
> +      GPIOs used to sense the CC orientation of each Type-C connector.
> +      Entries are ordered by connector number, i.e. the first entry
> +      corresponds to connector@0 and the second to connector@1.
> +    minItems: 1
> +    maxItems: 2
> +
>  patternProperties:
>    '^connector@[01]$':
>      $ref: /schemas/connector/usb-connector.yaml#

[Severity: Low]
This isn't a bug, but since orientation-gpios has a fixed maximum of two
ordered entries corresponding to connector@0 and connector@1, should this use
an items list with a per-entry description (along with minItems: 1) instead
of maxItems: 2 and enumerating the entries in the description text?

> @@ -129,6 +137,7 @@ examples:
>        };
>      };
>    - |
> +    #include <dt-bindings/gpio/gpio.h>
>      #include <dt-bindings/interrupt-controller/irq.h>
>      i2c {
>          #address-cells = <1>;
> @@ -141,6 +150,7 @@ examples:
>              pinctrl-0 = <&usb0_intr_state>;
>              pinctrl-names = "default";
>              wakeup-source;
> +            orientation-gpios = <0>, <&tlmm XX GPIO_ACTIVE_HIGH>;

[Severity: Medium]
Does the undefined placeholder pin number in orientation-gpios cause dtc to
fail with a lexical error when compiling this example?  In addition, this
example node only defines child node connector@0, whereas placing <0> first
and the specifier second assigns the sense line to connector@1.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123091024.2214918-1-akash.kumar@oss.qualcomm.com?part=1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO
  2026-11-23  9:10 ` [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
@ 2026-11-23  9:22   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-23  9:22 UTC (permalink / raw)
  To: Akash Kumar; +Cc: linux-usb, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: typec: ucsi_ccg: invalid %pOFn format for fwnode in
  ucsi_ccg_probe()
--

commit 0ee9b6d78660aaf0655e001e14913cd7b0e55e8e
Author: Akash Kumar <akash.kumar@oss.qualcomm.com>

usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO

This commit adds optional per-connector CC orientation sensing via the
orientation-gpios property in ucsi_ccg_probe() and reports connector
orientation through update_connector and connector_status callbacks.

> diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
> index c560d45393024..06c536d876940 100644
> --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c

[ ... ]

> @@ -1506,6 +1553,34 @@ static int ucsi_ccg_probe(struct i2c_client *client)
>  	if (uc->info.mode & CCG_DEVINFO_PDPORTS_MASK)
>  		uc->port_num++;
>  
> +	device_for_each_child_node_scoped(dev, fwnode) {
> +		struct gpio_desc *desc;
> +		u32 port;
> +
> +		status = fwnode_property_read_u32(fwnode, "reg", &port);
> +		if (status < 0) {
> +			dev_err(dev, "missing reg property of %pOFn\n", fwnode);
> +			return status;
> +		}

[Severity: Medium]
Should this format string use %pfwP instead of %pOFn for fwnode?

device_for_each_child_node_scoped() yields a struct fwnode_handle *, whereas
%pOFn expects a struct device_node * and applies of_fwnode_handle() to the
argument in device_node_string(), shifting the pointer by
offsetof(struct device_node, fwnode) and causing an invalid pointer
dereference if a child node lacks a reg property.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123091024.2214918-1-akash.kumar@oss.qualcomm.com?part=2

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-23  9:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  9:10 [PATCH v2 0/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
2026-11-23  9:10 ` [PATCH v2 1/2] dt-bindings: usb: cypress,cypd4226: Add orientation-gpios property Akash Kumar
2026-11-23  9:18   ` sashiko-bot
2026-11-23  9:10 ` [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
2026-11-23  9:22   ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-11-17 14:09 [PATCH v2 0/2] usb: typec: ucsi_ccg: Add CC orientation-gpios support Akash Kumar
2026-11-17 14:09 ` [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO Akash Kumar
2026-11-20 14:51   ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox