public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/4] media: i2c: ds90ub953: Add back channel GPIO support
@ 2026-04-24  1:42 Guoniu Zhou
  2026-04-24  1:42 ` [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source Guoniu Zhou
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Guoniu Zhou @ 2026-04-24  1:42 UTC (permalink / raw)
  To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski
  Cc: linux-media, devicetree, linux-kernel, imx, linux-gpio,
	Guoniu Zhou

Add back channel GPIO support.
  dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source
  media: i2c: ds90ub953: Add back channel GPIO support

Use helper macro to simplify code.
  media: i2c: ds90ub953: use devm_mutex_init() to simplify code
  media: i2c: ds90ub953: use guard() to simplify code

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v6:
- Rebased to latest media/next
- Replaced label "err" with "out"
- Changed approach from extending GPIO range (v5) to using a custom GPIO
  flag (GPIO_DATA_SOURCE_REMOTE) as suggested by the driver maintainer
- Dropped Reviewed-by tag from Rob Herring due to significant binding change
- Added GPIO_DATA_SOURCE_REMOTE flag to dt-bindings/gpio/gpio.h
- Updated dt-bindings documentation accordingly
- Added Reviewed-by tag from Tomi Valkeinen
- Detailed changes can be found in each patch's changelog
- Link to v5: https://lore.kernel.org/r/20260228-ds90ub953-v5-0-056cf07cc8f1@nxp.com

Changes in v5:
- Improve the description for "#gpio-cells" as commented by Conor.
- Detail change see each patches's change log.
- Link to v4: https://lore.kernel.org/r/20260227-ds90ub953-v4-0-dea596205f9e@nxp.com

Changes in v4:
- Rebase to 7.0-rc1
- Use folder block instead of literal block for #gpio-cell property description. 
- Only log GPIO 0-3 stats since remote GPIO 4-7 reuse GPIO 0-3 pins.
- Link to v3: https://lore.kernel.org/r/20250916-ds90ub953-v3-0-bb7bc6545da7@nxp.com

Changes in v3:
- Make GPIO range from 0-3 to 0-7 to support GPIO data from remote
  compatible deserializer suggested by Rob instead of adding third
  cell for GPIO controller.
- Update driver to expand GPIO range.
- Link to v2: https://lore.kernel.org/r/20250911-ds90ub953-v2-0-03ee76eb6b59@nxp.com

Changes in v2:
- Remove new property ti,gpio-data added in patch 1.
- Add third cell for GPIO controller to select GPIO output source.
- Move PTR_ERR() in dev_err_probe();
- Parse gpio third cell to select which GPIO pin the data from remote compatible deserializer.
- Link to v1: https://lore.kernel.org/r/20250910-ds90ub953-v1-0-a7813ffbdf11@nxp.com

---
Guoniu Zhou (4):
      dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source
      media: i2c: ds90ub953: Add back channel GPIO support
      media: i2c: ds90ub953: use devm_mutex_init() to simplify code
      media: i2c: ds90ub953: use guard() to simplify code

 .../bindings/media/i2c/ti,ds90ub953.yaml           |   6 +-
 drivers/media/i2c/ds90ub953.c                      | 118 +++++++++++++--------
 include/dt-bindings/gpio/gpio.h                    |   8 ++
 3 files changed, 83 insertions(+), 49 deletions(-)
---
base-commit: 4fbeef21f5387234111b5d52924e77757626faa5
change-id: 20250901-ds90ub953-168628c53a00

Best regards,
-- 
Guoniu Zhou <guoniu.zhou@oss.nxp.com>


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

* [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source
  2026-04-24  1:42 [PATCH v6 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
@ 2026-04-24  1:42 ` Guoniu Zhou
  2026-04-24 17:09   ` Conor Dooley
  2026-04-26  8:36   ` Linus Walleij
  2026-04-24  1:42 ` [PATCH v6 2/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Guoniu Zhou @ 2026-04-24  1:42 UTC (permalink / raw)
  To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski
  Cc: linux-media, devicetree, linux-kernel, imx, linux-gpio,
	Guoniu Zhou

From: Guoniu Zhou <guoniu.zhou@nxp.com>

The DS90UB953 supports four pins, GPIO0 through GPIO3. When enabled as an
output, it can be programed to output local data or remote data coming
from the remote compatible deserializer.

Add GPIO flag in second cell to select remote GPIO data source.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v6:
- Added GPIO_DATA_SOURCE_REMOTE flag to dt-bindings/gpio/gpio.h
- Updated dt-bindings documentation accordingly
- Dropped Reviewed-by tag from Rob Herring due to significant binding change

Changes in v5:
- Improve the description for "#gpio-cells" as commented by Conor.

Changes in v4:
- Use folder block instead of literal block for #gpio-cell property description.

Changes in v3:
- Make GPIO range from 0-3 to 0-7 to support GPIO data from remote
  compatible deserializer suggested by Rob instead of adding third
  cell for GPIO controller.

Changes in v2:
- Remove new property ti,gpio-data
- Add third cell for GPIO controller to select GPIO output source.
---
 Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml | 6 ++++--
 include/dt-bindings/gpio/gpio.h                               | 8 ++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
index 2e129bf573b7..da63771bc236 100644
--- a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
@@ -21,8 +21,10 @@ properties:
   '#gpio-cells':
     const: 2
     description:
-      First cell is the GPIO pin number, second cell is the flags. The GPIO pin
-      number must be in range of [0, 3].
+      First cell is the GPIO pin number (0-3) and the second cell is used
+      to specify flags. See <dt-bindings/gpio/gpio.h> for available flags
+      including GPIO_DATA_SOURCE_REMOTE for remote GPIO data source.
+      Flags can be OR'd together.
 
   gpio-controller: true
 
diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h
index b5d531237448..d04a494d96ad 100644
--- a/include/dt-bindings/gpio/gpio.h
+++ b/include/dt-bindings/gpio/gpio.h
@@ -42,4 +42,12 @@
 /* Bit 6 express pull disable */
 #define GPIO_PULL_DISABLE 64
 
+/*
+ * Bit 24 indicates the GPIO data source is from a remote device.
+ * This is used in serializer/deserializer setups where the GPIO pin
+ * on the local device (e.g., TI DS90UB953 serializer) reflects the
+ * state of a GPIO on the remote device (e.g., TI DS90UB960 deserializer).
+ */
+#define GPIO_DATA_SOURCE_REMOTE		0x01000000
+
 #endif

-- 
2.34.1


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

* [PATCH v6 2/4] media: i2c: ds90ub953: Add back channel GPIO support
  2026-04-24  1:42 [PATCH v6 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
  2026-04-24  1:42 ` [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source Guoniu Zhou
@ 2026-04-24  1:42 ` Guoniu Zhou
  2026-04-24  1:42 ` [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
  2026-04-24  1:42 ` [PATCH v6 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
  3 siblings, 0 replies; 9+ messages in thread
From: Guoniu Zhou @ 2026-04-24  1:42 UTC (permalink / raw)
  To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski
  Cc: linux-media, devicetree, linux-kernel, imx, linux-gpio,
	Guoniu Zhou

From: Guoniu Zhou <guoniu.zhou@nxp.com>

The ds90ub953 supports GPIO0 through GPIO3. When enabled as an output,
each GPIO pin can be programed to output remote data coming from the
compatible deserializer using the register LOCAL_GPIO_DATA[7:4] field.

Add back channel GPIO support by parsing flags from device tree.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v6:
- Changed approach from extending GPIO range (v5) to using a custom GPIO
  flag (GPIO_DATA_SOURCE_REMOTE) as suggested by the driver maintainer

Changes in v4:
- Only log GPIO 0-3 stats since remote GPIO 4-7 reuse GPIO 0-3 pins.

Changes in v3:
- Update driver to expand GPIO range.

Changes in v2:
- Parse gpio third cell to select which GPIO pin the data from remote
  compatible deserializer.
---
 drivers/media/i2c/ds90ub953.c | 51 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 45 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index a8ab67f4137f..da63dcfbbbc3 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -27,6 +27,8 @@
 #include <media/v4l2-mediabus.h>
 #include <media/v4l2-subdev.h>
 
+#include <dt-bindings/gpio/gpio.h>
+
 #include "ds90ub953.h"
 
 #define UB953_PAD_SINK			0
@@ -71,6 +73,7 @@ struct ub953_data {
 	bool			non_continous_clk;
 
 	struct gpio_chip	gpio_chip;
+	u32			gpio_flags[UB953_NUM_GPIOS];
 
 	struct v4l2_subdev	sd;
 	struct media_pad	pads[2];
@@ -258,6 +261,12 @@ static int ub953_write_ind(struct ub953_data *priv, u8 block, u8 reg, u8 val,
 /*
  * GPIO chip
  */
+
+static inline bool ub953_gpio_is_remote(unsigned int flag)
+{
+	return !!(flag & GPIO_DATA_SOURCE_REMOTE);
+}
+
 static int ub953_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 {
 	struct ub953_data *priv = gpiochip_get_data(gc);
@@ -288,13 +297,23 @@ static int ub953_gpio_direction_out(struct gpio_chip *gc, unsigned int offset,
 				    int value)
 {
 	struct ub953_data *priv = gpiochip_get_data(gc);
+	bool is_remote = ub953_gpio_is_remote(priv->gpio_flags[offset]);
+	unsigned int mask, val;
 	int ret;
 
-	ret = regmap_update_bits(priv->regmap, UB953_REG_LOCAL_GPIO_DATA,
-				 UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset),
-				 value ? UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset) :
-					 0);
+	mask = UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset) |
+	       UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(offset);
 
+	if (is_remote) {
+		/* Enable remote deserializer GPIO data on local GPIO */
+		val = UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(offset);
+	} else {
+		/* Set output value on local GPIO and disable remote mode */
+		val = value ? UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset) : 0;
+	}
+
+	ret = regmap_update_bits(priv->regmap, UB953_REG_LOCAL_GPIO_DATA,
+				 mask, val);
 	if (ret)
 		return ret;
 
@@ -330,10 +349,30 @@ static int ub953_gpio_of_xlate(struct gpio_chip *gc,
 			       const struct of_phandle_args *gpiospec,
 			       u32 *flags)
 {
+	struct ub953_data *priv = gpiochip_get_data(gc);
+	struct device *dev = &priv->client->dev;
+	u32 pin;
+
+	if (WARN_ON(gc->of_gpio_n_cells < 2))
+		return -EINVAL;
+
+	if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
+		return -EINVAL;
+
+	pin = gpiospec->args[0];
+	if (pin >= UB953_NUM_GPIOS) {
+		dev_err(dev, "Invalid GPIO pin number: %u\n", pin);
+		return -EINVAL;
+	}
+
+	/* Store GPIO flags for each pin */
+	priv->gpio_flags[pin] = gpiospec->args[1];
+
+	/* Return standard flags to GPIO core */
 	if (flags)
-		*flags = gpiospec->args[1];
+		*flags = gpiospec->args[1] & ~GPIO_DATA_SOURCE_REMOTE;
 
-	return gpiospec->args[0];
+	return pin;
 }
 
 static int ub953_gpiochip_probe(struct ub953_data *priv)

-- 
2.34.1


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

* [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code
  2026-04-24  1:42 [PATCH v6 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
  2026-04-24  1:42 ` [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source Guoniu Zhou
  2026-04-24  1:42 ` [PATCH v6 2/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
@ 2026-04-24  1:42 ` Guoniu Zhou
  2026-04-24  8:14   ` Bartosz Golaszewski
  2026-04-24  1:42 ` [PATCH v6 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
  3 siblings, 1 reply; 9+ messages in thread
From: Guoniu Zhou @ 2026-04-24  1:42 UTC (permalink / raw)
  To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski
  Cc: linux-media, devicetree, linux-kernel, imx, linux-gpio,
	Guoniu Zhou

From: Guoniu Zhou <guoniu.zhou@nxp.com>

Use devm_mutex_init() to simplify the code. No functional change.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v6:
- Added Reviewed-by tag from Tomi Valkeinen

Changes in v2:
- Move PTR_ERR() in dev_err_probe();
---
 drivers/media/i2c/ds90ub953.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index da63dcfbbbc3..c37d9cbe88b9 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -1299,7 +1299,9 @@ static int ub953_probe(struct i2c_client *client)
 	if (!priv->plat_data)
 		return dev_err_probe(dev, -ENODEV, "Platform data missing\n");
 
-	mutex_init(&priv->reg_lock);
+	ret = devm_mutex_init(dev, &priv->reg_lock);
+	if (ret)
+		return ret;
 
 	/*
 	 * Initialize to invalid values so that the first reg writes will
@@ -1308,32 +1310,26 @@ static int ub953_probe(struct i2c_client *client)
 	priv->current_indirect_target = 0xff;
 
 	priv->regmap = devm_regmap_init_i2c(client, &ub953_regmap_config);
-	if (IS_ERR(priv->regmap)) {
-		ret = PTR_ERR(priv->regmap);
-		dev_err_probe(dev, ret, "Failed to init regmap\n");
-		goto err_mutex_destroy;
-	}
+	if (IS_ERR(priv->regmap))
+		return dev_err_probe(dev, PTR_ERR(priv->regmap),
+				     "Failed to init regmap\n");
 
 	priv->clkin = devm_clk_get_optional(dev, "clkin");
-	if (IS_ERR(priv->clkin)) {
-		ret = PTR_ERR(priv->clkin);
-		dev_err_probe(dev, ret, "failed to parse 'clkin'\n");
-		goto err_mutex_destroy;
-	}
+	if (IS_ERR(priv->clkin))
+		return dev_err_probe(dev, PTR_ERR(priv->clkin),
+				     "Failed to parse 'clkin'\n");
 
 	ret = ub953_parse_dt(priv);
 	if (ret)
-		goto err_mutex_destroy;
+		return ret;
 
 	ret = ub953_hw_init(priv);
 	if (ret)
-		goto err_mutex_destroy;
+		return ret;
 
 	ret = ub953_gpiochip_probe(priv);
-	if (ret) {
-		dev_err_probe(dev, ret, "Failed to init gpiochip\n");
-		goto err_mutex_destroy;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to init gpiochip\n");
 
 	ret = ub953_register_clkout(priv);
 	if (ret) {
@@ -1357,8 +1353,6 @@ static int ub953_probe(struct i2c_client *client)
 	ub953_subdev_uninit(priv);
 err_gpiochip_remove:
 	ub953_gpiochip_remove(priv);
-err_mutex_destroy:
-	mutex_destroy(&priv->reg_lock);
 
 	return ret;
 }
@@ -1373,7 +1367,6 @@ static void ub953_remove(struct i2c_client *client)
 	ub953_subdev_uninit(priv);
 
 	ub953_gpiochip_remove(priv);
-	mutex_destroy(&priv->reg_lock);
 }
 
 static const struct ub953_hw_data ds90ub953_hw = {

-- 
2.34.1


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

* [PATCH v6 4/4] media: i2c: ds90ub953: use guard() to simplify code
  2026-04-24  1:42 [PATCH v6 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
                   ` (2 preceding siblings ...)
  2026-04-24  1:42 ` [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
@ 2026-04-24  1:42 ` Guoniu Zhou
  2026-04-24  8:15   ` Bartosz Golaszewski
  3 siblings, 1 reply; 9+ messages in thread
From: Guoniu Zhou @ 2026-04-24  1:42 UTC (permalink / raw)
  To: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski
  Cc: linux-media, devicetree, linux-kernel, imx, linux-gpio,
	Guoniu Zhou

From: Guoniu Zhou <guoniu.zhou@nxp.com>

Use guard() to simplify mutex locking. No functional change.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v6:
- Replace label "err" with "out"
---
 drivers/media/i2c/ds90ub953.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index c37d9cbe88b9..a351d366cc3e 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -114,20 +114,18 @@ static int ub953_read(struct ub953_data *priv, u8 reg, u8 *val, int *err)
 	if (err && *err)
 		return *err;
 
-	mutex_lock(&priv->reg_lock);
+	guard(mutex)(&priv->reg_lock);
 
 	ret = regmap_read(priv->regmap, reg, &v);
 	if (ret) {
 		dev_err(&priv->client->dev, "Cannot read register 0x%02x: %d\n",
 			reg, ret);
-		goto out_unlock;
+		goto out;
 	}
 
 	*val = v;
 
-out_unlock:
-	mutex_unlock(&priv->reg_lock);
-
+out:
 	if (ret && err)
 		*err = ret;
 
@@ -141,15 +139,13 @@ static int ub953_write(struct ub953_data *priv, u8 reg, u8 val, int *err)
 	if (err && *err)
 		return *err;
 
-	mutex_lock(&priv->reg_lock);
+	guard(mutex)(&priv->reg_lock);
 
 	ret = regmap_write(priv->regmap, reg, val);
 	if (ret)
 		dev_err(&priv->client->dev,
 			"Cannot write register 0x%02x: %d\n", reg, ret);
 
-	mutex_unlock(&priv->reg_lock);
-
 	if (ret && err)
 		*err = ret;
 
@@ -186,18 +182,18 @@ static int ub953_read_ind(struct ub953_data *priv, u8 block, u8 reg, u8 *val,
 	if (err && *err)
 		return *err;
 
-	mutex_lock(&priv->reg_lock);
+	guard(mutex)(&priv->reg_lock);
 
 	ret = ub953_select_ind_reg_block(priv, block);
 	if (ret)
-		goto out_unlock;
+		goto out;
 
 	ret = regmap_write(priv->regmap, UB953_REG_IND_ACC_ADDR, reg);
 	if (ret) {
 		dev_err(&priv->client->dev,
 			"Write to IND_ACC_ADDR failed when reading %u:0x%02x: %d\n",
 			block, reg, ret);
-		goto out_unlock;
+		goto out;
 	}
 
 	ret = regmap_read(priv->regmap, UB953_REG_IND_ACC_DATA, &v);
@@ -205,14 +201,12 @@ static int ub953_read_ind(struct ub953_data *priv, u8 block, u8 reg, u8 *val,
 		dev_err(&priv->client->dev,
 			"Write to IND_ACC_DATA failed when reading %u:0x%02x: %d\n",
 			block, reg, ret);
-		goto out_unlock;
+		goto out;
 	}
 
 	*val = v;
 
-out_unlock:
-	mutex_unlock(&priv->reg_lock);
-
+out:
 	if (ret && err)
 		*err = ret;
 
@@ -228,18 +222,18 @@ static int ub953_write_ind(struct ub953_data *priv, u8 block, u8 reg, u8 val,
 	if (err && *err)
 		return *err;
 
-	mutex_lock(&priv->reg_lock);
+	guard(mutex)(&priv->reg_lock);
 
 	ret = ub953_select_ind_reg_block(priv, block);
 	if (ret)
-		goto out_unlock;
+		goto out;
 
 	ret = regmap_write(priv->regmap, UB953_REG_IND_ACC_ADDR, reg);
 	if (ret) {
 		dev_err(&priv->client->dev,
 			"Write to IND_ACC_ADDR failed when writing %u:0x%02x: %d\n",
 			block, reg, ret);
-		goto out_unlock;
+		goto out;
 	}
 
 	ret = regmap_write(priv->regmap, UB953_REG_IND_ACC_DATA, val);
@@ -249,9 +243,7 @@ static int ub953_write_ind(struct ub953_data *priv, u8 block, u8 reg, u8 val,
 			block, reg, ret);
 	}
 
-out_unlock:
-	mutex_unlock(&priv->reg_lock);
-
+out:
 	if (ret && err)
 		*err = ret;
 

-- 
2.34.1


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

* Re: [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code
  2026-04-24  1:42 ` [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
@ 2026-04-24  8:14   ` Bartosz Golaszewski
  0 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2026-04-24  8:14 UTC (permalink / raw)
  To: Guoniu Zhou
  Cc: linux-media, devicetree, linux-kernel, imx, linux-gpio,
	Guoniu Zhou, Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski

On Fri, 24 Apr 2026 03:42:26 +0200, Guoniu Zhou <guoniu.zhou@oss.nxp.com> said:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
>
> Use devm_mutex_init() to simplify the code. No functional change.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
> Changes in v6:
> - Added Reviewed-by tag from Tomi Valkeinen
>
> Changes in v2:
> - Move PTR_ERR() in dev_err_probe();
> ---

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

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

* Re: [PATCH v6 4/4] media: i2c: ds90ub953: use guard() to simplify code
  2026-04-24  1:42 ` [PATCH v6 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
@ 2026-04-24  8:15   ` Bartosz Golaszewski
  0 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2026-04-24  8:15 UTC (permalink / raw)
  To: Guoniu Zhou
  Cc: linux-media, devicetree, linux-kernel, imx, linux-gpio,
	Guoniu Zhou, Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski

On Fri, 24 Apr 2026 03:42:27 +0200, Guoniu Zhou <guoniu.zhou@oss.nxp.com> said:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
>
> Use guard() to simplify mutex locking. No functional change.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

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

* Re: [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source
  2026-04-24  1:42 ` [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source Guoniu Zhou
@ 2026-04-24 17:09   ` Conor Dooley
  2026-04-26  8:36   ` Linus Walleij
  1 sibling, 0 replies; 9+ messages in thread
From: Conor Dooley @ 2026-04-24 17:09 UTC (permalink / raw)
  To: Guoniu Zhou
  Cc: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Linus Walleij, Bartosz Golaszewski, linux-media, devicetree,
	linux-kernel, imx, linux-gpio, Guoniu Zhou

[-- Attachment #1: Type: text/plain, Size: 3050 bytes --]

On Fri, Apr 24, 2026 at 09:42:24AM +0800, Guoniu Zhou wrote:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
> 
> The DS90UB953 supports four pins, GPIO0 through GPIO3. When enabled as an
> output, it can be programed to output local data or remote data coming
> from the remote compatible deserializer.
> 
> Add GPIO flag in second cell to select remote GPIO data source.
> 
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
> Changes in v6:
> - Added GPIO_DATA_SOURCE_REMOTE flag to dt-bindings/gpio/gpio.h
> - Updated dt-bindings documentation accordingly
> - Dropped Reviewed-by tag from Rob Herring due to significant binding change
> 
> Changes in v5:
> - Improve the description for "#gpio-cells" as commented by Conor.
> 
> Changes in v4:
> - Use folder block instead of literal block for #gpio-cell property description.
> 
> Changes in v3:
> - Make GPIO range from 0-3 to 0-7 to support GPIO data from remote
>   compatible deserializer suggested by Rob instead of adding third
>   cell for GPIO controller.
> 
> Changes in v2:
> - Remove new property ti,gpio-data
> - Add third cell for GPIO controller to select GPIO output source.
> ---
>  Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml | 6 ++++--
>  include/dt-bindings/gpio/gpio.h                               | 8 ++++++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
> index 2e129bf573b7..da63771bc236 100644
> --- a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
> @@ -21,8 +21,10 @@ properties:
>    '#gpio-cells':
>      const: 2
>      description:
> -      First cell is the GPIO pin number, second cell is the flags. The GPIO pin
> -      number must be in range of [0, 3].
> +      First cell is the GPIO pin number (0-3) and the second cell is used
> +      to specify flags. See <dt-bindings/gpio/gpio.h> for available flags
> +      including GPIO_DATA_SOURCE_REMOTE for remote GPIO data source.
> +      Flags can be OR'd together.
>  
>    gpio-controller: true
>  
> diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h
> index b5d531237448..d04a494d96ad 100644
> --- a/include/dt-bindings/gpio/gpio.h
> +++ b/include/dt-bindings/gpio/gpio.h
> @@ -42,4 +42,12 @@
>  /* Bit 6 express pull disable */
>  #define GPIO_PULL_DISABLE 64
>  
> +/*
> + * Bit 24 indicates the GPIO data source is from a remote device.

Why 24, not 7?

> + * This is used in serializer/deserializer setups where the GPIO pin
> + * on the local device (e.g., TI DS90UB953 serializer) reflects the
> + * state of a GPIO on the remote device (e.g., TI DS90UB960 deserializer).
> + */
> +#define GPIO_DATA_SOURCE_REMOTE		0x01000000

And why the divergent formatting compared to other defines in this file?

> +
>  #endif
> 
> -- 
> 2.34.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source
  2026-04-24  1:42 ` [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source Guoniu Zhou
  2026-04-24 17:09   ` Conor Dooley
@ 2026-04-26  8:36   ` Linus Walleij
  1 sibling, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2026-04-26  8:36 UTC (permalink / raw)
  To: Guoniu Zhou
  Cc: Tomi Valkeinen, Mauro Carvalho Chehab, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Frank Li, Vladimir Zapolskiy,
	Bartosz Golaszewski, linux-media, devicetree, linux-kernel, imx,
	linux-gpio, Guoniu Zhou

Hi Guoniu,

thanks for your patch!

n Fri, Apr 24, 2026 at 3:40 AM Guoniu Zhou <guoniu.zhou@oss.nxp.com> wrote:

> The DS90UB953 supports four pins, GPIO0 through GPIO3. When enabled as an
> output, it can be programed to output local data or remote data coming
> from the remote compatible deserializer.
>
> Add GPIO flag in second cell to select remote GPIO data source.
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
(...)
> ---
> Changes in v6:
> - Added GPIO_DATA_SOURCE_REMOTE flag to dt-bindings/gpio/gpio.h

(...)
> +/*
> + * Bit 24 indicates the GPIO data source is from a remote device.
> + * This is used in serializer/deserializer setups where the GPIO pin
> + * on the local device (e.g., TI DS90UB953 serializer) reflects the
> + * state of a GPIO on the remote device (e.g., TI DS90UB960 deserializer).
> + */
> +#define GPIO_DATA_SOURCE_REMOTE                0x01000000

So this is added to all GPIO controllers ever in existance as something
fundamental about GPIO that may need its own flag.

I doubt this.

I understand that the driver needs to deal with this in a per-gpio-line
basis though, have you considered:

1. Just hard-coding this into the driver based on the .compatible
  string, if the remote GPIOs are always the same for this TI thing?

2. If it is just for one particular system, you *could* actually have
  a table/mask inside the driver for this:
  if (of_machine_is_compatible("my-funky-system")) which will
  kick in only on that very machine,

3. If you really want to store the information in the media i2c
  device node, add some custom property like this:
  ti,remote-sources = <0x0000001f>;
  where a bit is set to 1 for each GPIO which is remote.

Putting flags on the GPIO lines themselves seems too complex
and system-specific.

Yours,
Linus Walleij

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

end of thread, other threads:[~2026-04-26  8:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24  1:42 [PATCH v6 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
2026-04-24  1:42 ` [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source Guoniu Zhou
2026-04-24 17:09   ` Conor Dooley
2026-04-26  8:36   ` Linus Walleij
2026-04-24  1:42 ` [PATCH v6 2/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
2026-04-24  1:42 ` [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
2026-04-24  8:14   ` Bartosz Golaszewski
2026-04-24  1:42 ` [PATCH v6 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
2026-04-24  8:15   ` Bartosz Golaszewski

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