From: Guoniu Zhou <guoniu.zhou@oss.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>,
Vladimir Zapolskiy <vz@mleia.com>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
linux-gpio@vger.kernel.org, Guoniu Zhou <guoniu.zhou@nxp.com>
Subject: [PATCH v6 2/4] media: i2c: ds90ub953: Add back channel GPIO support
Date: Fri, 24 Apr 2026 09:42:25 +0800 [thread overview]
Message-ID: <20260424-ds90ub953-v6-2-7a84efbab316@oss.nxp.com> (raw)
In-Reply-To: <20260424-ds90ub953-v6-0-7a84efbab316@oss.nxp.com>
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
next prev parent reply other threads:[~2026-04-24 1:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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-27 8:12 ` G.N. Zhou (OSS)
2026-04-27 19:22 ` Conor Dooley
2026-04-26 8:36 ` Linus Walleij
2026-04-27 9:12 ` G.N. Zhou (OSS)
2026-04-27 20:50 ` Linus Walleij
2026-04-28 6:17 ` G.N. Zhou (OSS)
2026-04-28 6:54 ` Tomi Valkeinen
2026-04-29 18:59 ` Linus Walleij
2026-04-24 1:42 ` Guoniu Zhou [this message]
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
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=20260424-ds90ub953-v6-2-7a84efbab316@oss.nxp.com \
--to=guoniu.zhou@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=guoniu.zhou@nxp.com \
--cc=imx@lists.linux.dev \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.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 \
--cc=vz@mleia.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