mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guoniu Zhou <guoniu.zhou@nxp.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>, Frank Li <Frank.Li@nxp.com>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org, Guoniu Zhou <guoniu.zhou@nxp.com>
Subject: [PATCH 2/4] media: i2c: ds90ub953: Add back channel GPIO support
Date: Wed, 10 Sep 2025 17:44:39 +0800	[thread overview]
Message-ID: <20250910-ds90ub953-v1-2-a7813ffbdf11@nxp.com> (raw)
In-Reply-To: <20250910-ds90ub953-v1-0-a7813ffbdf11@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.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
 drivers/media/i2c/ds90ub953.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index e3fc9d66970a762d284955f14db48d7105b4b8c4..98d6b6fab810a8f65a01a6049238cbf700eb8cd6 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -86,6 +86,7 @@ struct ub953_data {
 	struct mutex		reg_lock;
 
 	u8			current_indirect_target;
+	u8			gpio_rmten;
 
 	struct clk_hw		clkout_clk_hw;
 
@@ -288,13 +289,17 @@ static int ub953_gpio_direction_out(struct gpio_chip *gc, unsigned int offset,
 				    int value)
 {
 	struct ub953_data *priv = gpiochip_get_data(gc);
+	unsigned int 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);
+	val = priv->gpio_rmten & BIT(offset)
+	    ? UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(offset)
+	    : value ? UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset) : 0;
 
+	ret = regmap_update_bits(priv->regmap, UB953_REG_LOCAL_GPIO_DATA,
+				 UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset) |
+					UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(offset),
+				 val);
 	if (ret)
 		return ret;
 
@@ -320,6 +325,12 @@ static int ub953_gpio_get(struct gpio_chip *gc, unsigned int offset)
 static int ub953_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
 {
 	struct ub953_data *priv = gpiochip_get_data(gc);
+	struct device *dev = &priv->client->dev;
+
+	if (priv->gpio_rmten & BIT(offset)) {
+		dev_err(dev, "GPIO%u be programed to output remote data\n", offset);
+		return -EINVAL;
+	}
 
 	return regmap_update_bits(priv->regmap, UB953_REG_LOCAL_GPIO_DATA,
 				  UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(offset),
@@ -1133,6 +1144,17 @@ static int ub953_parse_dt(struct ub953_data *priv)
 	struct fwnode_handle *ep_fwnode;
 	unsigned char nlanes;
 	int ret;
+	u8 val;
+
+	/*
+	 * Config ti,gpio-data to program GPIO pin to output remote data
+	 * coming from the compatible deserializer, it's optional.
+	 */
+	ret = of_property_read_u8(dev->of_node, "ti,gpio-data", &val);
+	if (ret == 0 && val > 15)
+		return dev_err_probe(dev, -EINVAL, "Out of range: %u\n", val);
+
+	priv->gpio_rmten = ret ? 0 : val;
 
 	ep_fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev),
 						    UB953_PAD_SINK, 0, 0);

-- 
2.34.1


  parent reply	other threads:[~2025-09-10  9:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10  9:44 [PATCH 0/4] " Guoniu Zhou
2025-09-10  9:44 ` [PATCH 1/4] dt-bindings: media: ti,ds90ub953: Add new property ti,gpio-data Guoniu Zhou
2025-09-10 12:06   ` Vladimir Zapolskiy
2025-09-10  9:44 ` Guoniu Zhou [this message]
2025-09-10  9:44 ` [PATCH 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Guoniu Zhou
2025-09-10 22:33   ` Frank Li
2025-09-10  9:44 ` [PATCH 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
2025-09-10 22:31   ` Frank Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250910-ds90ub953-v1-2-a7813ffbdf11@nxp.com \
    --to=guoniu.zhou@nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    --cc=tomi.valkeinen@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®