diff mbox series

[5/5] media/i2c: max96717: allow user to override operation mode from DT

Message ID 20250207112958.2571600-6-laurentiu.palcu@oss.nxp.com
State New
Headers show
Series media/i2c: max96717: a few changes | expand

Commit Message

Laurentiu Palcu Feb. 7, 2025, 11:29 a.m. UTC
There are situations when the CFG pins set the chip up for a certain
mode of operation (ie: pixel mode or tunneling mode), because the HW
designers decided this way, and we, the users, want to change that. For
that, add an optional DT property that would allow toggling the
operation mode from the configured one to the other one.

The driver still only supports tunneling mode, that didn't change.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
---
 drivers/media/i2c/max96717.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
index 47a3be195a971..a591ca5d5f44f 100644
--- a/drivers/media/i2c/max96717.c
+++ b/drivers/media/i2c/max96717.c
@@ -161,6 +161,7 @@  struct max96717_priv {
 	struct clk_hw                     clk_hw;
 	struct gpio_chip                  gpio_chip;
 	enum max96717_vpg_mode            pattern;
+	bool				  mode_override;
 	struct max96717_fsync_desc	  fsync;
 };
 
@@ -1066,6 +1067,14 @@  static int max96717_hw_init(struct max96717_priv *priv)
 		return dev_err_probe(dev, ret,
 				     "Fail to read mipi rx extension");
 
+	if (priv->mode_override) {
+		val ^= MAX96717_TUN_MODE;
+
+		ret = cci_write(priv->regmap, MAX96717_MIPI_RX_EXT11, val, NULL);
+		if (ret)
+			return dev_err_probe(dev, ret, "Unable to update operation mode\n");
+	}
+
 	if (!(val & MAX96717_TUN_MODE))
 		return dev_err_probe(dev, -EOPNOTSUPP,
 				     "Only supporting tunnel mode");
@@ -1101,6 +1110,9 @@  static int max96717_parse_dt(struct max96717_priv *priv)
 
 	priv->mipi_csi2 = vep.bus.mipi_csi2;
 
+	if (fwnode_property_present(dev_fwnode(dev), "maxim,cfg-mode-override"))
+		priv->mode_override = true;
+
 	priv->fsync.pin = -1;
 	count = fwnode_property_present(dev_fwnode(dev), "maxim,fsync-config");
 	if (count > 0) {