linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 00/16]  media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
@ 2025-03-09  8:47 Cosmin Tanislav
  2025-03-09  8:47 ` [RFC PATCH v2 01/16] dt-bindings: media: i2c: max96717: add myself as maintainer Cosmin Tanislav
                   ` (15 more replies)
  0 siblings, 16 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

This series adds new drivers for multiple Maxim GMSL2 and GMSL3 devices,
replacing the few GMSL2 drivers already in upstream, and introducing a
common framework that can be used to implement such GMSL chips, which
avoids code duplication while also adding support for previously
unsupported features.

While the normally acceptable and polite way would be to extend the
current mainline drivers, the choice was made here to add a totally new
set of drivers. The current drivers support only a small subset of the
possible features, and only a few devices, so the end result after
extending them would in any case be essentially fully rewritten, new
drivers.

This series depends on these two series:
 * https://lore.kernel.org/lkml/20250306-fpc202-v9-0-2779af6780f6@bootlin.com
 * https://lore.kernel.org/lkml/20250228151730.1874916-1-demonsingur@gmail.com

The following deserializers are supported:
 * MAX96712 (already exists in staging)
 * MAX96714 (already exists)
 * MAX96716 (GMSL2)
 * MAX96724 (part of existing MAX96712 driver)
 * MAX9296A (GMSL2)
 * MAX96792A (GMSL3)

The following serializers are supported:
 * MAX96717 (already exists)
 * MAX9295A (GMSL2)
 * MAX96793 (GMSL3)

Missing features:
 * The current TPG implementation makes use of the V4L2_CID_TEST_PATTERN
   V4L2 control. With V4L2 streams support added, we would like to hook
   up TPG using the internal pad feature which has not been accepted
   upstream yet. We decided to leave TPG out for the moment and add it
   back after internal pads have been accepted.

Known backward compatibility breakages:
 * No default routing. Default routing has been intentionally ommitted
   as the devices support quite complex routing and it would be
   unfeasible to provide sane defaults for multi-link deserialziers.
   It is expected that userspace programs would set appropritate
   routing. 

The following list enumerates new features that are supported by the
common framework and their respective chip-specific drivers:
 * Full Streams API support. Most deserializers have support for more
   than one link, and more than one PHY. Streams support allows
   configuration of routing between these links and PHYs.

 * .get_frame_desc() support. Both the serializers and deserializers
   implement this to query and provide frame descriptor data. This is
   used in features explained in-depth below.

 * .get_mbus_config() support. The deserializers implement this to allow
   upstream devices to query the link frequency of its pads.

 * Address translation with I2C ATR for the serializers.

 * I2C MUX where supported by the hardware for deserializers, otherwise
   I2C ATR translation - some deserializers cannot do muxing since I2C
   communication channel masking is not available per-link, and the only
   other way to select links is to turn them off, causing link resets.
   For such cases, I2C ATR is used to change the address of
   the serializers at probe time.

 * Automatic VC remapping on the deserializers. VCs are picked so that
   if they were unique on the sink pad, they will end up as unique on
   the source pad they are routed to too, prioritizing using the same
   VC ID as the sink pad, to facilitate the possibility of using tunnel
   mode.

 * Automatic pixel mode / tunnel mode selection. Tunnel mode is used
   when VC IDs do not need to be changed and all hardware supports
   tunnel mode, otherwise, pixel mode is used. The serializers are
   automatically switched between the two by using a private API.

 * Automatic double mode selection. In pixel mode, double mode can be
   used to pack two pixels into a single data unit, optimizing bandwidth
   usage. The serializers are automatically set up to support the double
   modes determined by the deserializers using a private API.

 * Automatic data padding. In pixel mode, if the data being transferred
   uses two different BPPs, data needs to be padded. The serializers
   automatically set this up depending on the configured double mode
   settings and incoming data types.

 * Logging. Both the deserializers and serializers implement the V4L2
   .log_status() ops to allow debugging of the internal state and
   important chip status registers.

 * PHY modes. Deserializer chips commonly have more than a single PHY.
   The firmware ports are parsed to determine the modes in which to
   configure the PHYs (2x4, 4x2, 1x4+2x2, 2x2+1x4, and variations using
   fewer lanes).

 * Serializer pinctrl. Serializers implement pinctrl to allow setting
   configs which would otherwise be inaccessible through GPIO: TX/RX via
   GMSL link, pull-up & pull-down (with strength), open-drain &
   push-pull, slew rate, RCLK pin selection.

The drivers have been tested on the following hardware combinations, but
further testing is welcome to ensure no / minimal breakage:
 * Raspberry Pi 5 + MAX96724 + 4xMAX96717 + 4xIMX219
 * Raspberry Pi 5 + MAX96792A + 1xMAX96793 + 1xMAX96717 + 2xIMX219
 * Raspberry Pi 5 + MAX96792A + 2xMAX96717 + 2xIMX219
 * Renesas V4H + MAX96712 + 2xMAX96717 + 2xIMX219 

Analog Devices is taking responsibility for the maintenance of these
drivers and common framework, and plans to add support for new
broad-market chips on top of them.

Special thanks go to Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
for testing the drivers, helping debug and coming up with ideas /
implementations for various features.

V2:
 * add missing compatible for MAX96717F
 * fix embarrassing dt-bindings mistakes
 * move MAX9296A/MAX96716/MAX96792A to a separate file as they have two
   links / PHYs, and adding those conditionally seems impossible

Cosmin Tanislav (16):
  dt-bindings: media: i2c: max96717: add myself as maintainer
  dt-bindings: media: i2c: max96717: reflow text
  dt-bindings: media: i2c: max96717: add support for I2C ATR
  dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf
  dt-bindings: media: i2c: max96717: add support for MAX9295A
  dt-bindings: media: i2c: max96717: add support for MAX96793
  dt-bindings: media: i2c: max96712: add myself as maintainer
  dt-bindings: media: i2c: max96712: use pattern properties for ports
  dt-bindings: media: i2c: max96712: add support for I2C MUX
  dt-bindings: media: i2c: max96712: add support for POC supplies
  dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A
  media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  arm64: defconfig: disable deprecated MAX96712 driver
  staging: media: remove MAX96712 driver
  media: i2c: remove MAX96717 driver
  media: i2c: remove MAX96714 driver

 .../bindings/media/i2c/maxim,max9296a.yaml    |  281 ++
 .../bindings/media/i2c/maxim,max96712.yaml    |   47 +-
 .../media/i2c/maxim,max96717-pinctrl.yaml     |   71 +
 .../bindings/media/i2c/maxim,max96717.yaml    |   80 +-
 MAINTAINERS                                   |   13 +-
 arch/arm64/configs/defconfig                  |    1 -
 drivers/media/i2c/Kconfig                     |   34 +-
 drivers/media/i2c/Makefile                    |    3 +-
 drivers/media/i2c/max96714.c                  | 1024 --------
 drivers/media/i2c/max96717.c                  | 1103 --------
 drivers/media/i2c/maxim-serdes/Kconfig        |   53 +
 drivers/media/i2c/maxim-serdes/Makefile       |    6 +
 drivers/media/i2c/maxim-serdes/max9296a.c     | 1146 ++++++++
 drivers/media/i2c/maxim-serdes/max96717.c     | 1501 +++++++++++
 drivers/media/i2c/maxim-serdes/max96724.c     |  905 +++++++
 drivers/media/i2c/maxim-serdes/max_des.c      | 2321 +++++++++++++++++
 drivers/media/i2c/maxim-serdes/max_des.h      |  135 +
 drivers/media/i2c/maxim-serdes/max_ser.c      | 1584 +++++++++++
 drivers/media/i2c/maxim-serdes/max_ser.h      |  132 +
 drivers/media/i2c/maxim-serdes/max_serdes.c   |  302 +++
 drivers/media/i2c/maxim-serdes/max_serdes.h   |   88 +
 drivers/staging/media/Kconfig                 |    2 -
 drivers/staging/media/Makefile                |    1 -
 drivers/staging/media/max96712/Kconfig        |   14 -
 drivers/staging/media/max96712/Makefile       |    2 -
 drivers/staging/media/max96712/max96712.c     |  487 ----
 26 files changed, 8634 insertions(+), 2702 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
 create mode 100644 Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
 delete mode 100644 drivers/media/i2c/max96714.c
 delete mode 100644 drivers/media/i2c/max96717.c
 create mode 100644 drivers/media/i2c/maxim-serdes/Kconfig
 create mode 100644 drivers/media/i2c/maxim-serdes/Makefile
 create mode 100644 drivers/media/i2c/maxim-serdes/max9296a.c
 create mode 100644 drivers/media/i2c/maxim-serdes/max96717.c
 create mode 100644 drivers/media/i2c/maxim-serdes/max96724.c
 create mode 100644 drivers/media/i2c/maxim-serdes/max_des.c
 create mode 100644 drivers/media/i2c/maxim-serdes/max_des.h
 create mode 100644 drivers/media/i2c/maxim-serdes/max_ser.c
 create mode 100644 drivers/media/i2c/maxim-serdes/max_ser.h
 create mode 100644 drivers/media/i2c/maxim-serdes/max_serdes.c
 create mode 100644 drivers/media/i2c/maxim-serdes/max_serdes.h
 delete mode 100644 drivers/staging/media/max96712/Kconfig
 delete mode 100644 drivers/staging/media/max96712/Makefile
 delete mode 100644 drivers/staging/media/max96712/max96712.c

-- 
2.48.1



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

* [RFC PATCH v2 01/16] dt-bindings: media: i2c: max96717: add myself as maintainer
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
@ 2025-03-09  8:47 ` Cosmin Tanislav
  2025-03-11 18:06   ` Rob Herring (Arm)
  2025-03-09  8:47 ` [RFC PATCH v2 02/16] dt-bindings: media: i2c: max96717: reflow text Cosmin Tanislav
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

Analog Devices is taking responsability for the maintenance of the Maxim
GMSL2/3 devices.
Add myself to the maintainers list and to the device tree bindings.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml | 1 +
 MAINTAINERS                                                     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
index d1e8ba6e368e..15ab37702a92 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
@@ -9,6 +9,7 @@ title: MAX96717 CSI-2 to GMSL2 Serializer
 
 maintainers:
   - Julien Massot <julien.massot@collabora.com>
+  - Cosmin Tanislav <cosmin.tanislav@analog.com>
 
 description:
   The MAX96717 serializer converts MIPI CSI-2 D-PHY formatted input
diff --git a/MAINTAINERS b/MAINTAINERS
index 1916d0636408..8f463ebca056 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14198,6 +14198,7 @@ F:	drivers/media/i2c/max96714.c
 
 MAX96717 GMSL2 SERIALIZER DRIVER
 M:	Julien Massot <julien.massot@collabora.com>
+M:	Cosmin Tanislav <cosmin.tanislav@analog.com>
 L:	linux-media@vger.kernel.org
 S:	Maintained
 F:	Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
-- 
2.48.1



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

* [RFC PATCH v2 02/16] dt-bindings: media: i2c: max96717: reflow text
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
  2025-03-09  8:47 ` [RFC PATCH v2 01/16] dt-bindings: media: i2c: max96717: add myself as maintainer Cosmin Tanislav
@ 2025-03-09  8:47 ` Cosmin Tanislav
  2025-03-11 18:09   ` Rob Herring
  2025-03-09  8:47 ` [RFC PATCH v2 03/16] dt-bindings: media: i2c: max96717: add support for I2C ATR Cosmin Tanislav
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

This text is using weird line lengths. Fix it.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../bindings/media/i2c/maxim,max96717.yaml    | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
index 15ab37702a92..1026678a17a7 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
@@ -12,16 +12,15 @@ maintainers:
   - Cosmin Tanislav <cosmin.tanislav@analog.com>
 
 description:
-  The MAX96717 serializer converts MIPI CSI-2 D-PHY formatted input
-  into GMSL2 serial outputs. The device allows the GMSL2 link to
-  simultaneously transmit bidirectional control-channel data while forward
-  video transmissions are in progress. The MAX96717 can connect to one
-  remotely located deserializer using industry-standard coax or STP
-  interconnects. The device cans operate in pixel or tunnel mode. In pixel mode
-  the MAX96717 can select the MIPI datatype, while the tunnel mode forward all the MIPI
-  data received by the serializer.
-  The MAX96717 supports Reference Over Reverse (channel),
-  to generate a clock output for the sensor from the GMSL reverse channel.
+  The MAX96717 serializer converts MIPI CSI-2 D-PHY formatted input into GMSL2
+  serial outputs. The device allows the GMSL2 link to simultaneously transmit
+  bidirectional control-channel data while forward video transmissions are in
+  progress. The MAX96717 can connect to one remotely located deserializer using
+  industry-standard coax or STP interconnects. The device cans operate in pixel
+  or tunnel mode. In pixel mode the MAX96717 can select the MIPI datatype, while
+  the tunnel mode forward all the MIPI data received by the serializer.
+  The MAX96717 supports Reference Over Reverse (channel), to generate a clock
+  output for the sensor from the GMSL reverse channel.
 
   The GMSL2 serial link operates at a fixed rate of 3Gbps or 6Gbps in the
   forward direction and 187.5Mbps in the reverse direction.
-- 
2.48.1



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

* [RFC PATCH v2 03/16] dt-bindings: media: i2c: max96717: add support for I2C ATR
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
  2025-03-09  8:47 ` [RFC PATCH v2 01/16] dt-bindings: media: i2c: max96717: add myself as maintainer Cosmin Tanislav
  2025-03-09  8:47 ` [RFC PATCH v2 02/16] dt-bindings: media: i2c: max96717: reflow text Cosmin Tanislav
@ 2025-03-09  8:47 ` Cosmin Tanislav
  2025-03-11 18:15   ` Rob Herring
  2025-03-09  8:47 ` [RFC PATCH v2 04/16] dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf Cosmin Tanislav
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

MAX96717 is capable of address translation for the connected I2C slaves.

Add support for I2C ATR while keeping I2C gate for compatibility to
support this usecase.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../bindings/media/i2c/maxim,max96717.yaml    | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
index 1026678a17a7..dd28cc397674 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
@@ -91,6 +91,30 @@ properties:
       incoming GMSL2 link. Therefore, it supports an i2c-gate
       subnode to configure a sensor.
 
+  i2c-alias-pool:
+    maxItems: 2
+
+  i2c-atr:
+    type: object
+    additionalProperties: false
+
+    properties:
+      '#address-cells':
+        const: 1
+
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      '^i2c@0':
+        $ref: /schemas/i2c/i2c-controller.yaml#
+        unevaluatedProperties: false
+        properties:
+          reg:
+            items:
+              minimum: 0
+              maximum: 1
+
 required:
   - compatible
   - reg
@@ -98,6 +122,21 @@ required:
 
 additionalProperties: false
 
+allOf:
+  - $ref: /schemas/i2c/i2c-atr.yaml#
+
+  - anyOf:
+      - oneOf:
+          - required: [i2c-atr]
+          - required: [i2c-gate]
+
+      - not:
+          required: [i2c-atr, i2c-gate]
+
+dependentRequired:
+  i2c-atr: [i2c-alias-pool]
+  i2c-alias-pool: [i2c-atr]
+
 examples:
   - |
     #include <dt-bindings/gpio/gpio.h>
-- 
2.48.1



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

* [RFC PATCH v2 04/16] dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (2 preceding siblings ...)
  2025-03-09  8:47 ` [RFC PATCH v2 03/16] dt-bindings: media: i2c: max96717: add support for I2C ATR Cosmin Tanislav
@ 2025-03-09  8:47 ` Cosmin Tanislav
  2025-03-11 18:23   ` Rob Herring
  2025-03-09  8:47 ` [RFC PATCH v2 05/16] dt-bindings: media: i2c: max96717: add support for MAX9295A Cosmin Tanislav
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

MAX96717 is capable of configuring various pin properties.

Add pinctrl/pinconf properties to support this usecase.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../media/i2c/maxim,max96717-pinctrl.yaml     | 71 +++++++++++++++++++
 .../bindings/media/i2c/maxim,max96717.yaml    | 16 ++++-
 MAINTAINERS                                   |  1 +
 3 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
new file mode 100644
index 000000000000..347e66a5320c
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2025 Analog Devices Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/maxim,max96717-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim GMSL2 Serializer Pinctrl
+
+maintainers:
+  - Cosmin Tanislav <cosmin.tanislav@analog.com>
+
+allOf:
+  - $ref: /schemas/pinctrl/pincfg-node.yaml#
+  - $ref: /schemas/pinctrl/pinmux-node.yaml#
+
+unevaluatedProperties: false
+
+properties:
+  function: true
+  pins: true
+  drive-open-drain: true
+  drive-push-pull: true
+  bias-disable: true
+  bias-pull-up: true
+  bias-pull-down: true
+  output-disable: true
+  output-enable: true
+  output-low: true
+  output-high: true
+  slew-rate: true
+  input-enable: true
+
+  maxim,jitter-compensation:
+    type: boolean
+    description: Enables jitter compensation.
+
+  maxim,gmsl-tx:
+    type: boolean
+    description: Enable transmitting pin value to GMSL link.
+
+  maxim,gmsl-rx:
+    type: boolean
+    description: Enable receiving pin value from GMSL link.
+
+  maxim,gmsl-tx-id:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Identifier used while transmitting value to GMSL link.
+      Default value matches the pin number.
+    minimum: 0
+    maximum: 31
+
+  maxim,gmsl-rx-id:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Identifier used while receiving value from GMSL link.
+      Default value matches the pin number.
+    minimum: 0
+    maximum: 31
+
+  maxim,rclkout-clock:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Clock value.
+      0 - XTAL / 1 = 25MHz
+      1 - XTAL / 2 = 12.5MHz
+      2 - XTAL / 4 = 6.25MHz
+      3 - Reference PLL output
+    minimum: 0
+    maximum: 3
diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
index dd28cc397674..0a43582168a8 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
@@ -120,7 +120,21 @@ required:
   - reg
   - ports
 
-additionalProperties: false
+additionalProperties:
+  anyOf:
+    - type: object
+      allOf:
+        - $ref: /schemas/media/i2c/maxim,max96717-pinctrl.yaml#
+
+      unevaluatedProperties: false
+
+    - type: object
+      additionalProperties:
+        type: object
+        allOf:
+          - $ref: /schemas/media/i2c/maxim,max96717-pinctrl.yaml#
+
+        unevaluatedProperties: false
 
 allOf:
   - $ref: /schemas/i2c/i2c-atr.yaml#
diff --git a/MAINTAINERS b/MAINTAINERS
index 8f463ebca056..f8ffb7cff9c5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14201,6 +14201,7 @@ M:	Julien Massot <julien.massot@collabora.com>
 M:	Cosmin Tanislav <cosmin.tanislav@analog.com>
 L:	linux-media@vger.kernel.org
 S:	Maintained
+F:	Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
 F:	Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
 F:	drivers/media/i2c/max96717.c
 
-- 
2.48.1



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

* [RFC PATCH v2 05/16] dt-bindings: media: i2c: max96717: add support for MAX9295A
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (3 preceding siblings ...)
  2025-03-09  8:47 ` [RFC PATCH v2 04/16] dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf Cosmin Tanislav
@ 2025-03-09  8:47 ` Cosmin Tanislav
  2025-03-11 18:28   ` Rob Herring
  2025-03-09  8:47 ` [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793 Cosmin Tanislav
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

MAX9295A is an older variant of the MAX96717 which does not support
tunnel mode.

Document the compatibility.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../devicetree/bindings/media/i2c/maxim,max96717.yaml          | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
index 0a43582168a8..31fb62debdc7 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
@@ -24,11 +24,14 @@ description:
 
   The GMSL2 serial link operates at a fixed rate of 3Gbps or 6Gbps in the
   forward direction and 187.5Mbps in the reverse direction.
+
   MAX96717F only supports a fixed rate of 3Gbps in the forward direction.
+  MAX9295A only supports pixel mode.
 
 properties:
   compatible:
     oneOf:
+      - const: maxim,max9295a
       - const: maxim,max96717f
       - items:
           - enum:
-- 
2.48.1



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

* [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (4 preceding siblings ...)
  2025-03-09  8:47 ` [RFC PATCH v2 05/16] dt-bindings: media: i2c: max96717: add support for MAX9295A Cosmin Tanislav
@ 2025-03-09  8:47 ` Cosmin Tanislav
  2025-03-11 18:30   ` Rob Herring (Arm)
  2025-03-13 12:25   ` Sakari Ailus
  2025-03-09  8:47 ` [RFC PATCH v2 07/16] dt-bindings: media: i2c: max96712: add myself as maintainer Cosmin Tanislav
                   ` (9 subsequent siblings)
  15 siblings, 2 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

MAX96793 is a newer variant of the MAX96717 which also supports GMSL3
links.

Document this compatibility.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
index 31fb62debdc7..02857f0364c4 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
@@ -27,6 +27,7 @@ description:
 
   MAX96717F only supports a fixed rate of 3Gbps in the forward direction.
   MAX9295A only supports pixel mode.
+  MAX96793 also supports GMSL3 mode.
 
 properties:
   compatible:
@@ -36,6 +37,7 @@ properties:
       - items:
           - enum:
               - maxim,max96717
+              - maxim,max96793
           - const: maxim,max96717f
 
   '#gpio-cells':
-- 
2.48.1



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

* [RFC PATCH v2 07/16] dt-bindings: media: i2c: max96712: add myself as maintainer
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (5 preceding siblings ...)
  2025-03-09  8:47 ` [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793 Cosmin Tanislav
@ 2025-03-09  8:47 ` Cosmin Tanislav
  2025-03-11 18:54   ` Rob Herring (Arm)
  2025-03-09  8:48 ` [RFC PATCH v2 08/16] dt-bindings: media: i2c: max96712: use pattern properties for ports Cosmin Tanislav
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:47 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

Analog Devices is taking responsability for the maintenance of the Maxim
GMSL2/3 devices.
Add myself to the maintainers list and to the device tree bindings.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml | 1 +
 MAINTAINERS                                                     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
index 26f85151afbd..efdece2b33b9 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
@@ -9,6 +9,7 @@ title: Quad GMSL2 to CSI-2 Deserializer with GMSL1 Compatibility
 
 maintainers:
   - Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
+  - Cosmin Tanislav <cosmin.tanislav@analog.com>
 
 description: |
   The MAX96712 deserializer converts GMSL2 or GMSL1 serial inputs into MIPI
diff --git a/MAINTAINERS b/MAINTAINERS
index f8ffb7cff9c5..abf3afc95fc9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14184,6 +14184,7 @@ F:	drivers/media/i2c/max9286.c
 
 MAX96712 QUAD GMSL2 DESERIALIZER DRIVER
 M:	Niklas Söderlund <niklas.soderlund@ragnatech.se>
+M:	Cosmin Tanislav <cosmin.tanislav@analog.com>
 L:	linux-media@vger.kernel.org
 S:	Maintained
 F:	Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
-- 
2.48.1



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

* [RFC PATCH v2 08/16] dt-bindings: media: i2c: max96712: use pattern properties for ports
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (6 preceding siblings ...)
  2025-03-09  8:47 ` [RFC PATCH v2 07/16] dt-bindings: media: i2c: max96712: add myself as maintainer Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
  2025-03-11 19:00   ` Rob Herring
  2025-03-09  8:48 ` [RFC PATCH v2 09/16] dt-bindings: media: i2c: max96712: add support for I2C MUX Cosmin Tanislav
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

The MAX96712 and MAX96724 support up to 4 separate PHYs, depending on
the selected PHY configuration. Use patternProperties to document this.

The input ports are all the same, use patternProperties for them.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../bindings/media/i2c/maxim,max96712.yaml    | 29 +++++++------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
index efdece2b33b9..bf8c861c836b 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
@@ -40,27 +40,15 @@ properties:
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
 
-    properties:
-      port@0:
+    patternProperties:
+      '^port@[0-3]$':
         $ref: /schemas/graph.yaml#/properties/port
-        description: GMSL Input 0
+        description: GMSL Input port
 
-      port@1:
-        $ref: /schemas/graph.yaml#/properties/port
-        description: GMSL Input 1
-
-      port@2:
-        $ref: /schemas/graph.yaml#/properties/port
-        description: GMSL Input 2
-
-      port@3:
-        $ref: /schemas/graph.yaml#/properties/port
-        description: GMSL Input 3
-
-      port@4:
+      '^port@[4-7]$':
         $ref: /schemas/graph.yaml#/$defs/port-base
         unevaluatedProperties: false
-        description: CSI-2 Output
+        description: CSI-2 Output port
 
         properties:
           endpoint:
@@ -78,8 +66,11 @@ properties:
               - data-lanes
               - bus-type
 
-    required:
-      - port@4
+    anyOf:
+      - required: [port@4]
+      - required: [port@5]
+      - required: [port@6]
+      - required: [port@7]
 
 required:
   - compatible
-- 
2.48.1



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

* [RFC PATCH v2 09/16] dt-bindings: media: i2c: max96712: add support for I2C MUX
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (7 preceding siblings ...)
  2025-03-09  8:48 ` [RFC PATCH v2 08/16] dt-bindings: media: i2c: max96712: use pattern properties for ports Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
  2025-03-11 19:01   ` Rob Herring (Arm)
  2025-03-09  8:48 ` [RFC PATCH v2 10/16] dt-bindings: media: i2c: max96712: add support for POC supplies Cosmin Tanislav
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

MAX96712 and MAX96724 have more than one GMSL2 link, and each link is
capable of connecting to a separate serializer. If these serializers
have the same CFG pins configuration, they will also have the same I2C
address, causing conflicts unless the deserializer muxes the I2C
channels. Moreover, the serializers can have the same hardware attached
to their respective I2C bus.

The MAX96712 and MAX96724 suppot I2C channel muxing via the GMSL2 link
to facilitate communication to each of the connected serializers.

Document this capability.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../bindings/media/i2c/maxim,max96712.yaml          | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
index bf8c861c836b..9e27568e0105 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
@@ -37,6 +37,19 @@ properties:
 
   enable-gpios: true
 
+  i2c-mux:
+    $ref: /schemas/i2c/i2c-mux.yaml#
+    unevaluatedProperties: false
+    patternProperties:
+      '^i2c@[0-3]$':
+        $ref: /schemas/i2c/i2c-controller.yaml#
+        unevaluatedProperties: false
+        properties:
+          reg:
+            items:
+              minimum: 0
+              maximum: 3
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
 
-- 
2.48.1



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

* [RFC PATCH v2 10/16] dt-bindings: media: i2c: max96712: add support for POC supplies
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (8 preceding siblings ...)
  2025-03-09  8:48 ` [RFC PATCH v2 09/16] dt-bindings: media: i2c: max96712: add support for I2C MUX Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
  2025-03-11 19:02   ` Rob Herring (Arm)
  2025-03-09  8:48 ` [RFC PATCH v2 11/16] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A Cosmin Tanislav
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

The GMSL links can carry power to the serializer when using coaxial
cables.

Document this capability.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../devicetree/bindings/media/i2c/maxim,max96712.yaml         | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
index 9e27568e0105..a497c7af645e 100644
--- a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
@@ -85,6 +85,10 @@ properties:
       - required: [port@6]
       - required: [port@7]
 
+patternProperties:
+  '^port[0-3]-poc-supply$':
+    description: Regulator providing Power over Coax for GMSL ports
+
 required:
   - compatible
   - reg
-- 
2.48.1



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

* [RFC PATCH v2 11/16] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (9 preceding siblings ...)
  2025-03-09  8:48 ` [RFC PATCH v2 10/16] dt-bindings: media: i2c: max96712: add support for POC supplies Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
  2025-03-11 19:07   ` Rob Herring
  2025-03-09  8:48 ` [RFC PATCH v2 13/16] arm64: defconfig: disable deprecated MAX96712 driver Cosmin Tanislav
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

The MAX9296A deserializer converts single or dual serial inputs to MIPI
CSI-2 outputs. The GMSL2 links operate at a fixed rate of 3Gbps or 6Gbps
in the forward direction and 187.5Mbps in the reverse direction.
In GMSL1 mode, each serial link can be paired with 3.12Gbps or 1.5Gbps
GMSL1 serializers or operate up to 4.5Gbps with GMSL2 serializers with
GMSL1 backward compatibility. The MAX9296A supports mixed GMSL2 and
GMSL1 links. The serial inputs operate independently, allowing videos
with different timings and resolutions to be received on each input.

MAX96716A supports both tunnel and pixel mode.
MAX96792A supports both tunnel and pixel mode, and has two GMSL3 links.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 .../bindings/media/i2c/maxim,max9296a.yaml    | 281 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 2 files changed, 287 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml

diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
new file mode 100644
index 000000000000..97731549d161
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
@@ -0,0 +1,281 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2024 Collabora Ltd.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/maxim,max9296a.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX9296A GMSL2 to CSI-2 Deserializer
+
+maintainers:
+  - Cosmin Tanislav <cosmin.tanislav@analog.com>
+
+description:
+  The MAX9296A deserializer converts single or dual serial inputs to
+  MIPI CSI-2 outputs. The GMSL2 links operate at a fixed rate of 3Gbps
+  or 6Gbps in the forward direction and 187.5Mbps in the reverse
+  direction. In GMSL1 mode, each serial link can be paired with 3.12Gbps
+  or 1.5Gbps GMSL1 serializers or operate up to 4.5Gbps with GMSL2
+  serializers with GMSL1 backward compatibility. The MAX9296A supports
+  mixed GMSL2 and GMSL1 links. The serial inputs operate independently,
+  allowing videos with different timings and resolutions to be received
+  on each input.
+
+  MAX96716A supports both tunnel and pixel mode.
+  MAX96792A supports both tunnel and pixel mode, and has two GMSL3 links.
+
+properties:
+  compatible:
+    enum:
+      - maxim,max9296a
+      - maxim,max96716a
+      - maxim,max96792a
+
+  reg:
+    maxItems: 1
+
+  powerdown-gpios:
+    maxItems: 1
+    description: Specifier for the GPIO connected to the PWDNB pin.
+
+  port0-poc-supply:
+    description: Regulator providing Power over Coax for GMSL port 0
+
+  port1-poc-supply:
+    description: Regulator providing Power over Coax for GMSL port 1
+
+  i2c-mux:
+    $ref: /schemas/i2c/i2c-mux.yaml#
+    unevaluatedProperties: false
+    patternProperties:
+      '^i2c@[0-1]$':
+        $ref: /schemas/i2c/i2c-controller.yaml#
+        unevaluatedProperties: false
+        properties:
+          reg:
+            items:
+              minimum: 0
+              maximum: 1
+
+  i2c-alias-pool:
+    maxItems: 2
+
+  i2c-atr:
+    type: object
+    additionalProperties: false
+
+    properties:
+      '#address-cells':
+        const: 1
+
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      '^i2c@[0-1]$':
+        $ref: /schemas/i2c/i2c-controller.yaml#
+        unevaluatedProperties: false
+        properties:
+          reg:
+            items:
+              minimum: 0
+              maximum: 1
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    patternProperties:
+      '^port@[0-1]$':
+        $ref: /schemas/graph.yaml#/properties/port
+        unevaluatedProperties: false
+        description: GMSL Input
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
+            unevaluatedProperties: false
+            description: Endpoint for GMSL2-Link port.
+
+      '^port@[2-3]$':
+        $ref: /schemas/graph.yaml#/$defs/port-base
+        unevaluatedProperties: false
+        description: CSI-2 Output port
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
+            unevaluatedProperties: false
+
+            properties:
+              data-lanes:
+                minItems: 1
+                maxItems: 4
+
+              lane-polarities:
+                minItems: 1
+                maxItems: 5
+
+              link-frequencies:
+                maxItems: 1
+
+            required:
+              - data-lanes
+
+    anyOf:
+      - required:
+          - port@2
+      - required:
+          - port@3
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+allOf:
+  - $ref: /schemas/i2c/i2c-atr.yaml#
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - maxim,max9296a
+              - maxim,max96792a
+    then:
+      not:
+        required: [i2c-mux]
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - maxim,max96716a
+    then:
+      not:
+        required: [i2c-atr]
+
+dependentRequired:
+  i2c-atr: [i2c-alias-pool]
+  i2c-alias-pool: [i2c-atr]
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/media/video-interfaces.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        deserializer@28 {
+            compatible = "maxim,max9296a";
+            reg = <0x28>;
+            powerdown-gpios = <&main_gpio0 37 GPIO_ACTIVE_LOW>;
+
+            i2c-alias-pool = <0x40 0x41>;
+
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                port@0 {
+                    reg = <0>;
+                    des_gmsl_in_0: endpoint {
+                        remote-endpoint = <&ser_0_gmsl_out>;
+                    };
+                };
+
+                port@1 {
+                    reg = <1>;
+                    des_gmsl_in_1: endpoint {
+                        remote-endpoint = <&ser_1_gmsl_out>;
+                    };
+                };
+
+                port@2 {
+                    reg = <2>;
+                    des_csi_out: endpoint {
+                        data-lanes = <1 2 3 4>;
+                        link-frequencies = /bits/ 64 <400000000>;
+                        remote-endpoint = <&csi_in>;
+                    };
+                };
+            };
+
+            i2c-atr {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                i2c@0 {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <0>;
+
+                    serializer@40 {
+                        compatible = "maxim,max96717";
+                        reg = <0x40>;
+                        gpio-controller;
+                        #gpio-cells = <2>;
+                        #clock-cells = <0>;
+
+                        ports {
+                            #address-cells = <1>;
+                            #size-cells = <0>;
+
+                            port@0 {
+                                reg = <0>;
+                                ser_0_csi_in: endpoint {
+                                    data-lanes = <1 2>;
+                                    remote-endpoint = <&sensor_0_out>;
+                                };
+                            };
+
+                            port@1 {
+                                reg = <1>;
+                                ser_0_gmsl_out: endpoint {
+                                    remote-endpoint = <&des_gmsl_in_0>;
+                                };
+                            };
+                        };
+                    };
+                };
+
+                i2c@1 {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+                    reg = <1>;
+
+                    serializer@40 {
+                        compatible = "maxim,max96717";
+                        reg = <0x40>;
+                        gpio-controller;
+                        #gpio-cells = <2>;
+                        #clock-cells = <0>;
+
+                        ports {
+                            #address-cells = <1>;
+                            #size-cells = <0>;
+
+                            port@0 {
+                                reg = <0>;
+                                ser_1_csi_in: endpoint {
+                                    data-lanes = <1 2>;
+                                    remote-endpoint = <&sensor_1_out>;
+                                };
+                            };
+
+                            port@1 {
+                                reg = <1>;
+                                ser_1_gmsl_out: endpoint {
+                                    remote-endpoint = <&des_gmsl_in_1>;
+                                };
+                            };
+                        };
+                    };
+                };
+            };
+        };
+    };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index abf3afc95fc9..c1e01668e81a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14220,6 +14220,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.yaml
 F:	drivers/iio/proximity/mb1232.c
 
+MAXIM GMSL2 SERIALIZERS AND DESERIALIZERS
+M:	Cosmin Tanislav <cosmin.tanislav@analog.com>
+L:	linux-media@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
+
 MAXIM MAX11205 DRIVER
 M:	Ramona Bolboaca <ramona.bolboaca@analog.com>
 L:	linux-iio@vger.kernel.org
-- 
2.48.1



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

* [RFC PATCH v2 13/16] arm64: defconfig: disable deprecated MAX96712 driver
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (10 preceding siblings ...)
  2025-03-09  8:48 ` [RFC PATCH v2 11/16] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
  2025-03-09  8:48 ` [RFC PATCH v2 14/16] staging: media: remove " Cosmin Tanislav
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

The staging MAX96712 driver will be removed as its functionality has
been moved to the MAX96724 driver which makes use of the Maxim
GMSL2/3 deserializer framework.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 arch/arm64/configs/defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index cb7da4415599..6e9bd9072d11 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1272,7 +1272,6 @@ CONFIG_XEN_GNTDEV=y
 CONFIG_XEN_GRANT_DEV_ALLOC=y
 CONFIG_STAGING=y
 CONFIG_STAGING_MEDIA=y
-CONFIG_VIDEO_MAX96712=m
 CONFIG_VIDEO_MESON_VDEC=m
 CONFIG_SND_BCM2835=m
 CONFIG_CHROME_PLATFORMS=y
-- 
2.48.1



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

* [RFC PATCH v2 14/16] staging: media: remove MAX96712 driver
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (11 preceding siblings ...)
  2025-03-09  8:48 ` [RFC PATCH v2 13/16] arm64: defconfig: disable deprecated MAX96712 driver Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
  2025-03-09  8:48 ` [RFC PATCH v2 15/16] media: i2c: remove MAX96717 driver Cosmin Tanislav
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

Remove the staging MAX96712 driver.
Its functionality has been moved to the MAX96724 driver which makes use
of the Maxim GMSL2/3 deserializer framework.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 MAINTAINERS                               |   1 -
 drivers/staging/media/Kconfig             |   2 -
 drivers/staging/media/Makefile            |   1 -
 drivers/staging/media/max96712/Kconfig    |  14 -
 drivers/staging/media/max96712/Makefile   |   2 -
 drivers/staging/media/max96712/max96712.c | 487 ----------------------
 6 files changed, 507 deletions(-)
 delete mode 100644 drivers/staging/media/max96712/Kconfig
 delete mode 100644 drivers/staging/media/max96712/Makefile
 delete mode 100644 drivers/staging/media/max96712/max96712.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e97c4f55bc2f..4d1ff8cf537b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14188,7 +14188,6 @@ M:	Cosmin Tanislav <cosmin.tanislav@analog.com>
 L:	linux-media@vger.kernel.org
 S:	Maintained
 F:	Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
-F:	drivers/staging/media/max96712/max96712.c
 
 MAX96714 GMSL2 DESERIALIZER DRIVER
 M:	Julien Massot <julien.massot@collabora.com>
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index b44214854399..fe29821f64a3 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -28,8 +28,6 @@ source "drivers/staging/media/imx/Kconfig"
 
 source "drivers/staging/media/ipu3/Kconfig"
 
-source "drivers/staging/media/max96712/Kconfig"
-
 source "drivers/staging/media/meson/vdec/Kconfig"
 
 source "drivers/staging/media/rkvdec/Kconfig"
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index ad4e9619a9e0..1a562b3b6881 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -2,7 +2,6 @@
 obj-$(CONFIG_VIDEO_ATMEL_ISC_BASE)	+= deprecated/atmel/
 obj-$(CONFIG_INTEL_ATOMISP)     += atomisp/
 obj-$(CONFIG_VIDEO_IMX_MEDIA)	+= imx/
-obj-$(CONFIG_VIDEO_MAX96712)	+= max96712/
 obj-$(CONFIG_VIDEO_MESON_VDEC)	+= meson/vdec/
 obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC)	+= rkvdec/
 obj-$(CONFIG_VIDEO_STARFIVE_CAMSS)	+= starfive/
diff --git a/drivers/staging/media/max96712/Kconfig b/drivers/staging/media/max96712/Kconfig
deleted file mode 100644
index 117fadf81bd0..000000000000
--- a/drivers/staging/media/max96712/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config VIDEO_MAX96712
-	tristate "Maxim MAX96712 Quad GMSL2 Deserializer support"
-	depends on I2C
-	depends on OF_GPIO
-	depends on VIDEO_DEV
-	select V4L2_FWNODE
-	select VIDEO_V4L2_SUBDEV_API
-	select MEDIA_CONTROLLER
-	help
-	  This driver supports the Maxim MAX96712 Quad GMSL2 Deserializer.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called max96712.
diff --git a/drivers/staging/media/max96712/Makefile b/drivers/staging/media/max96712/Makefile
deleted file mode 100644
index 70c1974ce3f0..000000000000
--- a/drivers/staging/media/max96712/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_VIDEO_MAX96712) += max96712.o
diff --git a/drivers/staging/media/max96712/max96712.c b/drivers/staging/media/max96712/max96712.c
deleted file mode 100644
index 0751b2e04895..000000000000
--- a/drivers/staging/media/max96712/max96712.c
+++ /dev/null
@@ -1,487 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Maxim MAX96712 Quad GMSL2 Deserializer Driver
- *
- * Copyright (C) 2021 Renesas Electronics Corporation
- * Copyright (C) 2021 Niklas Söderlund
- */
-
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/of_graph.h>
-#include <linux/regmap.h>
-
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-fwnode.h>
-#include <media/v4l2-subdev.h>
-
-#define DEBUG_EXTRA_REG			0x09
-#define DEBUG_EXTRA_PCLK_25MHZ		0x00
-#define DEBUG_EXTRA_PCLK_75MHZ		0x01
-
-enum max96712_pattern {
-	MAX96712_PATTERN_CHECKERBOARD = 0,
-	MAX96712_PATTERN_GRADIENT,
-};
-
-struct max96712_info {
-	unsigned int dpllfreq;
-	bool have_debug_extra;
-};
-
-struct max96712_priv {
-	struct i2c_client *client;
-	struct regmap *regmap;
-	struct gpio_desc *gpiod_pwdn;
-
-	const struct max96712_info *info;
-
-	bool cphy;
-	struct v4l2_mbus_config_mipi_csi2 mipi;
-
-	struct v4l2_subdev sd;
-	struct v4l2_ctrl_handler ctrl_handler;
-	struct media_pad pads[1];
-
-	enum max96712_pattern pattern;
-};
-
-static int max96712_write(struct max96712_priv *priv, unsigned int reg, u8 val)
-{
-	int ret;
-
-	ret = regmap_write(priv->regmap, reg, val);
-	if (ret)
-		dev_err(&priv->client->dev, "write 0x%04x failed\n", reg);
-
-	return ret;
-}
-
-static int max96712_update_bits(struct max96712_priv *priv, unsigned int reg,
-				u8 mask, u8 val)
-{
-	int ret;
-
-	ret = regmap_update_bits(priv->regmap, reg, mask, val);
-	if (ret)
-		dev_err(&priv->client->dev, "update 0x%04x failed\n", reg);
-
-	return ret;
-}
-
-static int max96712_write_bulk(struct max96712_priv *priv, unsigned int reg,
-			       const void *val, size_t val_count)
-{
-	int ret;
-
-	ret = regmap_bulk_write(priv->regmap, reg, val, val_count);
-	if (ret)
-		dev_err(&priv->client->dev, "bulk write 0x%04x failed\n", reg);
-
-	return ret;
-}
-
-static int max96712_write_bulk_value(struct max96712_priv *priv,
-				     unsigned int reg, unsigned int val,
-				     size_t val_count)
-{
-	unsigned int i;
-	u8 values[4];
-
-	for (i = 1; i <= val_count; i++)
-		values[i - 1] = (val >> ((val_count - i) * 8)) & 0xff;
-
-	return max96712_write_bulk(priv, reg, &values, val_count);
-}
-
-static void max96712_reset(struct max96712_priv *priv)
-{
-	max96712_update_bits(priv, 0x13, 0x40, 0x40);
-	msleep(20);
-}
-
-static void max96712_mipi_enable(struct max96712_priv *priv, bool enable)
-{
-	if (enable) {
-		max96712_update_bits(priv, 0x40b, 0x02, 0x02);
-		max96712_update_bits(priv, 0x8a0, 0x80, 0x80);
-	} else {
-		max96712_update_bits(priv, 0x8a0, 0x80, 0x00);
-		max96712_update_bits(priv, 0x40b, 0x02, 0x00);
-	}
-}
-
-static void max96712_mipi_configure(struct max96712_priv *priv)
-{
-	unsigned int i;
-	u8 phy5 = 0;
-
-	max96712_mipi_enable(priv, false);
-
-	/* Select 2x4 mode. */
-	max96712_write(priv, 0x8a0, 0x04);
-
-	/* TODO: Add support for 2-lane and 1-lane configurations. */
-	if (priv->cphy) {
-		/* Configure a 3-lane C-PHY using PHY0 and PHY1. */
-		max96712_write(priv, 0x94a, 0xa0);
-
-		/* Configure C-PHY timings. */
-		max96712_write(priv, 0x8ad, 0x3f);
-		max96712_write(priv, 0x8ae, 0x7d);
-	} else {
-		/* Configure a 4-lane D-PHY using PHY0 and PHY1. */
-		max96712_write(priv, 0x94a, 0xc0);
-	}
-
-	/* Configure lane mapping for PHY0 and PHY1. */
-	/* TODO: Add support for lane swapping. */
-	max96712_write(priv, 0x8a3, 0xe4);
-
-	/* Configure lane polarity for PHY0 and PHY1. */
-	for (i = 0; i < priv->mipi.num_data_lanes + 1; i++)
-		if (priv->mipi.lane_polarities[i])
-			phy5 |= BIT(i == 0 ? 5 : i < 3 ? i - 1 : i);
-	max96712_write(priv, 0x8a5, phy5);
-
-	/* Set link frequency for PHY0 and PHY1. */
-	max96712_update_bits(priv, 0x415, 0x3f,
-			     ((priv->info->dpllfreq / 100) & 0x1f) | BIT(5));
-	max96712_update_bits(priv, 0x418, 0x3f,
-			     ((priv->info->dpllfreq / 100) & 0x1f) | BIT(5));
-
-	/* Enable PHY0 and PHY1 */
-	max96712_update_bits(priv, 0x8a2, 0xf0, 0x30);
-}
-
-static void max96712_pattern_enable(struct max96712_priv *priv, bool enable)
-{
-	const u32 h_active = 1920;
-	const u32 h_fp = 88;
-	const u32 h_sw = 44;
-	const u32 h_bp = 148;
-	const u32 h_tot = h_active + h_fp + h_sw + h_bp;
-
-	const u32 v_active = 1080;
-	const u32 v_fp = 4;
-	const u32 v_sw = 5;
-	const u32 v_bp = 36;
-	const u32 v_tot = v_active + v_fp + v_sw + v_bp;
-
-	if (!enable) {
-		max96712_write(priv, 0x1051, 0x00);
-		return;
-	}
-
-	/* Set PCLK to 75MHz if device have DEBUG_EXTRA register. */
-	if (priv->info->have_debug_extra)
-		max96712_write(priv, DEBUG_EXTRA_REG, DEBUG_EXTRA_PCLK_75MHZ);
-
-	/* Configure Video Timing Generator for 1920x1080 @ 30 fps. */
-	max96712_write_bulk_value(priv, 0x1052, 0, 3);
-	max96712_write_bulk_value(priv, 0x1055, v_sw * h_tot, 3);
-	max96712_write_bulk_value(priv, 0x1058,
-				  (v_active + v_fp + + v_bp) * h_tot, 3);
-	max96712_write_bulk_value(priv, 0x105b, 0, 3);
-	max96712_write_bulk_value(priv, 0x105e, h_sw, 2);
-	max96712_write_bulk_value(priv, 0x1060, h_active + h_fp + h_bp, 2);
-	max96712_write_bulk_value(priv, 0x1062, v_tot, 2);
-	max96712_write_bulk_value(priv, 0x1064,
-				  h_tot * (v_sw + v_bp) + (h_sw + h_bp), 3);
-	max96712_write_bulk_value(priv, 0x1067, h_active, 2);
-	max96712_write_bulk_value(priv, 0x1069, h_fp + h_sw + h_bp, 2);
-	max96712_write_bulk_value(priv, 0x106b, v_active, 2);
-
-	/* Generate VS, HS and DE in free-running mode. */
-	max96712_write(priv, 0x1050, 0xfb);
-
-	/* Configure Video Pattern Generator. */
-	if (priv->pattern == MAX96712_PATTERN_CHECKERBOARD) {
-		/* Set checkerboard pattern size. */
-		max96712_write(priv, 0x1074, 0x3c);
-		max96712_write(priv, 0x1075, 0x3c);
-		max96712_write(priv, 0x1076, 0x3c);
-
-		/* Set checkerboard pattern colors. */
-		max96712_write_bulk_value(priv, 0x106e, 0xfecc00, 3);
-		max96712_write_bulk_value(priv, 0x1071, 0x006aa7, 3);
-
-		/* Generate checkerboard pattern. */
-		max96712_write(priv, 0x1051, 0x10);
-	} else {
-		/* Set gradient increment. */
-		max96712_write(priv, 0x106d, 0x10);
-
-		/* Generate gradient pattern. */
-		max96712_write(priv, 0x1051, 0x20);
-	}
-}
-
-static int max96712_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	struct max96712_priv *priv = v4l2_get_subdevdata(sd);
-
-	if (enable) {
-		max96712_pattern_enable(priv, true);
-		max96712_mipi_enable(priv, true);
-	} else {
-		max96712_mipi_enable(priv, false);
-		max96712_pattern_enable(priv, false);
-	}
-
-	return 0;
-}
-
-static const struct v4l2_subdev_video_ops max96712_video_ops = {
-	.s_stream = max96712_s_stream,
-};
-
-static int max96712_init_state(struct v4l2_subdev *sd,
-			       struct v4l2_subdev_state *state)
-{
-	static const struct v4l2_mbus_framefmt default_fmt = {
-		.width          = 1920,
-		.height         = 1080,
-		.code           = MEDIA_BUS_FMT_RGB888_1X24,
-		.colorspace     = V4L2_COLORSPACE_SRGB,
-		.field          = V4L2_FIELD_NONE,
-		.ycbcr_enc      = V4L2_YCBCR_ENC_DEFAULT,
-		.quantization   = V4L2_QUANTIZATION_DEFAULT,
-		.xfer_func      = V4L2_XFER_FUNC_DEFAULT,
-	};
-	struct v4l2_mbus_framefmt *fmt;
-
-	fmt = v4l2_subdev_state_get_format(state, 0);
-	*fmt = default_fmt;
-
-	return 0;
-}
-
-static const struct v4l2_subdev_internal_ops max96712_internal_ops = {
-	.init_state = max96712_init_state,
-};
-
-static const struct v4l2_subdev_pad_ops max96712_pad_ops = {
-	.get_fmt = v4l2_subdev_get_fmt,
-	.set_fmt = v4l2_subdev_get_fmt,
-};
-
-static const struct v4l2_subdev_ops max96712_subdev_ops = {
-	.video = &max96712_video_ops,
-	.pad = &max96712_pad_ops,
-};
-
-static const char * const max96712_test_pattern[] = {
-	"Checkerboard",
-	"Gradient",
-};
-
-static int max96712_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct max96712_priv *priv =
-		container_of(ctrl->handler, struct max96712_priv, ctrl_handler);
-
-	switch (ctrl->id) {
-	case V4L2_CID_TEST_PATTERN:
-		priv->pattern = ctrl->val ?
-			MAX96712_PATTERN_GRADIENT :
-			MAX96712_PATTERN_CHECKERBOARD;
-		break;
-	}
-	return 0;
-}
-
-static const struct v4l2_ctrl_ops max96712_ctrl_ops = {
-	.s_ctrl = max96712_s_ctrl,
-};
-
-static int max96712_v4l2_register(struct max96712_priv *priv)
-{
-	long pixel_rate;
-	int ret;
-
-	priv->sd.internal_ops = &max96712_internal_ops;
-	v4l2_i2c_subdev_init(&priv->sd, priv->client, &max96712_subdev_ops);
-	priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
-
-	v4l2_ctrl_handler_init(&priv->ctrl_handler, 2);
-
-	/*
-	 * TODO: Once V4L2_CID_LINK_FREQ is changed from a menu control to an
-	 * INT64 control it should be used here instead of V4L2_CID_PIXEL_RATE.
-	 */
-	pixel_rate = priv->info->dpllfreq / priv->mipi.num_data_lanes * 1000000;
-	v4l2_ctrl_new_std(&priv->ctrl_handler, NULL, V4L2_CID_PIXEL_RATE,
-			  pixel_rate, pixel_rate, 1, pixel_rate);
-
-	v4l2_ctrl_new_std_menu_items(&priv->ctrl_handler, &max96712_ctrl_ops,
-				     V4L2_CID_TEST_PATTERN,
-				     ARRAY_SIZE(max96712_test_pattern) - 1,
-				     0, 0, max96712_test_pattern);
-
-	priv->sd.ctrl_handler = &priv->ctrl_handler;
-	ret = priv->ctrl_handler.error;
-	if (ret)
-		goto error;
-
-	priv->pads[0].flags = MEDIA_PAD_FL_SOURCE;
-	ret = media_entity_pads_init(&priv->sd.entity, 1, priv->pads);
-	if (ret)
-		goto error;
-
-	v4l2_set_subdevdata(&priv->sd, priv);
-
-	priv->sd.state_lock = priv->ctrl_handler.lock;
-	ret = v4l2_subdev_init_finalize(&priv->sd);
-	if (ret)
-		goto error;
-
-	ret = v4l2_async_register_subdev(&priv->sd);
-	if (ret < 0) {
-		dev_err(&priv->client->dev, "Unable to register subdevice\n");
-		goto error;
-	}
-
-	return 0;
-error:
-	v4l2_ctrl_handler_free(&priv->ctrl_handler);
-
-	return ret;
-}
-
-static int max96712_parse_dt(struct max96712_priv *priv)
-{
-	struct fwnode_handle *ep;
-	struct v4l2_fwnode_endpoint v4l2_ep = {
-		.bus_type = V4L2_MBUS_UNKNOWN,
-	};
-	unsigned int supported_lanes;
-	int ret;
-
-	ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(&priv->client->dev), 4,
-					     0, 0);
-	if (!ep) {
-		dev_err(&priv->client->dev, "Not connected to subdevice\n");
-		return -EINVAL;
-	}
-
-	ret = v4l2_fwnode_endpoint_parse(ep, &v4l2_ep);
-	fwnode_handle_put(ep);
-	if (ret) {
-		dev_err(&priv->client->dev, "Could not parse v4l2 endpoint\n");
-		return -EINVAL;
-	}
-
-	switch (v4l2_ep.bus_type) {
-	case V4L2_MBUS_CSI2_DPHY:
-		supported_lanes = 4;
-		priv->cphy = false;
-		break;
-	case V4L2_MBUS_CSI2_CPHY:
-		supported_lanes = 3;
-		priv->cphy = true;
-		break;
-	default:
-		dev_err(&priv->client->dev, "Unsupported bus-type %u\n",
-			v4l2_ep.bus_type);
-		return -EINVAL;
-	}
-
-	if (v4l2_ep.bus.mipi_csi2.num_data_lanes != supported_lanes) {
-		dev_err(&priv->client->dev, "Only %u data lanes supported\n",
-			supported_lanes);
-		return -EINVAL;
-	}
-
-	priv->mipi = v4l2_ep.bus.mipi_csi2;
-
-	return 0;
-}
-
-static const struct regmap_config max96712_i2c_regmap = {
-	.reg_bits = 16,
-	.val_bits = 8,
-	.max_register = 0x1f00,
-};
-
-static int max96712_probe(struct i2c_client *client)
-{
-	struct max96712_priv *priv;
-	int ret;
-
-	priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	priv->info = of_device_get_match_data(&client->dev);
-
-	priv->client = client;
-
-	priv->regmap = devm_regmap_init_i2c(client, &max96712_i2c_regmap);
-	if (IS_ERR(priv->regmap))
-		return PTR_ERR(priv->regmap);
-
-	priv->gpiod_pwdn = devm_gpiod_get_optional(&client->dev, "enable",
-						   GPIOD_OUT_HIGH);
-	if (IS_ERR(priv->gpiod_pwdn))
-		return PTR_ERR(priv->gpiod_pwdn);
-
-	gpiod_set_consumer_name(priv->gpiod_pwdn, "max96712-pwdn");
-	gpiod_set_value_cansleep(priv->gpiod_pwdn, 1);
-
-	if (priv->gpiod_pwdn)
-		usleep_range(4000, 5000);
-
-	max96712_reset(priv);
-
-	ret = max96712_parse_dt(priv);
-	if (ret)
-		return ret;
-
-	max96712_mipi_configure(priv);
-
-	return max96712_v4l2_register(priv);
-}
-
-static void max96712_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct max96712_priv *priv = container_of(sd, struct max96712_priv, sd);
-
-	v4l2_async_unregister_subdev(&priv->sd);
-
-	gpiod_set_value_cansleep(priv->gpiod_pwdn, 0);
-}
-
-static const struct max96712_info max96712_info_max96712 = {
-	.dpllfreq = 1000,
-	.have_debug_extra = true,
-};
-
-static const struct max96712_info max96712_info_max96724 = {
-	.dpllfreq = 1200,
-};
-
-static const struct of_device_id max96712_of_table[] = {
-	{ .compatible = "maxim,max96712", .data = &max96712_info_max96712 },
-	{ .compatible = "maxim,max96724", .data = &max96712_info_max96724 },
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, max96712_of_table);
-
-static struct i2c_driver max96712_i2c_driver = {
-	.driver	= {
-		.name = "max96712",
-		.of_match_table	= of_match_ptr(max96712_of_table),
-	},
-	.probe = max96712_probe,
-	.remove = max96712_remove,
-};
-
-module_i2c_driver(max96712_i2c_driver);
-
-MODULE_DESCRIPTION("Maxim MAX96712 Quad GMSL2 Deserializer Driver");
-MODULE_AUTHOR("Niklas Söderlund <niklas.soderlund@ragnatech.se>");
-MODULE_LICENSE("GPL");
-- 
2.48.1



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

* [RFC PATCH v2 15/16] media: i2c: remove MAX96717 driver
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (12 preceding siblings ...)
  2025-03-09  8:48 ` [RFC PATCH v2 14/16] staging: media: remove " Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
  2025-03-09  8:48 ` [RFC PATCH v2 16/16] media: i2c: remove MAX96714 driver Cosmin Tanislav
       [not found] ` <20250309084814.3114794-13-demonsingur@gmail.com>
  15 siblings, 0 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

The previous MAX96717 driver has been removed and its functionality has
been moved to a MAX96717 driver which makes use of the Maxim GMSL2/3
serializer framework.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 MAINTAINERS                  |    1 -
 drivers/media/i2c/Kconfig    |   17 -
 drivers/media/i2c/Makefile   |    1 -
 drivers/media/i2c/max96717.c | 1103 ----------------------------------
 4 files changed, 1122 deletions(-)
 delete mode 100644 drivers/media/i2c/max96717.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 4d1ff8cf537b..e9fe6e9856d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14203,7 +14203,6 @@ L:	linux-media@vger.kernel.org
 S:	Maintained
 F:	Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
 F:	Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
-F:	drivers/media/i2c/max96717.c
 
 MAX9860 MONO AUDIO VOICE CODEC DRIVER
 M:	Peter Rosin <peda@axentia.se>
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index e24c84962c92..6c595dffb280 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -1636,23 +1636,6 @@ config VIDEO_MAX96714
 	  To compile this driver as a module, choose M here: the
 	  module will be called max96714.
 
-config VIDEO_MAX96717
-	tristate "Maxim MAX96717 GMSL2 Serializer support"
-	depends on OF && I2C && VIDEO_DEV && COMMON_CLK
-	select I2C_MUX
-	select MEDIA_CONTROLLER
-	select GPIOLIB
-	select V4L2_CCI_I2C
-	select V4L2_FWNODE
-	select VIDEO_V4L2_SUBDEV_API
-	help
-	  Device driver for the Maxim MAX96717 GMSL2 Serializer.
-	  MAX96717 serializers convert video on a MIPI CSI-2
-	  input to a GMSL2 output.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called max96717.
-
 source "drivers/media/i2c/maxim-serdes/Kconfig"
 
 endmenu
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index b24e7cf7bb2f..de0680ebf190 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -69,7 +69,6 @@ obj-$(CONFIG_VIDEO_M52790) += m52790.o
 obj-$(CONFIG_VIDEO_MAX9271_LIB) += max9271.o
 obj-$(CONFIG_VIDEO_MAX9286) += max9286.o
 obj-$(CONFIG_VIDEO_MAX96714) += max96714.o
-obj-$(CONFIG_VIDEO_MAX96717) += max96717.o
 obj-$(CONFIG_VIDEO_MAXIM_SERDES) += maxim-serdes/
 obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o
 obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
deleted file mode 100644
index 9259d58ba734..000000000000
--- a/drivers/media/i2c/max96717.c
+++ /dev/null
@@ -1,1103 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Maxim GMSL2 Serializer Driver
- *
- * Copyright (C) 2024 Collabora Ltd.
- */
-
-#include <linux/bitfield.h>
-#include <linux/clk.h>
-#include <linux/clk-provider.h>
-#include <linux/delay.h>
-#include <linux/fwnode.h>
-#include <linux/gpio/driver.h>
-#include <linux/i2c-mux.h>
-#include <linux/i2c.h>
-#include <linux/regmap.h>
-
-#include <media/v4l2-cci.h>
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-fwnode.h>
-#include <media/v4l2-subdev.h>
-
-#define MAX96717_DEVICE_ID  0xbf
-#define MAX96717F_DEVICE_ID 0xc8
-#define MAX96717_PORTS      2
-#define MAX96717_PAD_SINK   0
-#define MAX96717_PAD_SOURCE 1
-#define MAX96717_CSI_NLANES 4
-
-#define MAX96717_DEFAULT_CLKOUT_RATE	24000000UL
-
-/* DEV */
-#define MAX96717_REG3    CCI_REG8(0x3)
-#define MAX96717_RCLKSEL GENMASK(1, 0)
-#define RCLKSEL_REF_PLL  CCI_REG8(0x3)
-#define MAX96717_REG6    CCI_REG8(0x6)
-#define RCLKEN           BIT(5)
-#define MAX96717_DEV_ID  CCI_REG8(0xd)
-#define MAX96717_DEV_REV CCI_REG8(0xe)
-#define MAX96717_DEV_REV_MASK GENMASK(3, 0)
-
-/* VID_TX Z */
-#define MAX96717_VIDEO_TX0 CCI_REG8(0x110)
-#define MAX96717_VIDEO_AUTO_BPP BIT(3)
-#define MAX96717_VIDEO_TX2 CCI_REG8(0x112)
-#define MAX96717_VIDEO_PCLKDET BIT(7)
-
-/* VTX_Z */
-#define MAX96717_VTX0                  CCI_REG8(0x24e)
-#define MAX96717_VTX1                  CCI_REG8(0x24f)
-#define MAX96717_PATTERN_CLK_FREQ      GENMASK(3, 1)
-#define MAX96717_VTX_VS_DLY            CCI_REG24(0x250)
-#define MAX96717_VTX_VS_HIGH           CCI_REG24(0x253)
-#define MAX96717_VTX_VS_LOW            CCI_REG24(0x256)
-#define MAX96717_VTX_V2H               CCI_REG24(0x259)
-#define MAX96717_VTX_HS_HIGH           CCI_REG16(0x25c)
-#define MAX96717_VTX_HS_LOW            CCI_REG16(0x25e)
-#define MAX96717_VTX_HS_CNT            CCI_REG16(0x260)
-#define MAX96717_VTX_V2D               CCI_REG24(0x262)
-#define MAX96717_VTX_DE_HIGH           CCI_REG16(0x265)
-#define MAX96717_VTX_DE_LOW            CCI_REG16(0x267)
-#define MAX96717_VTX_DE_CNT            CCI_REG16(0x269)
-#define MAX96717_VTX29                 CCI_REG8(0x26b)
-#define MAX96717_VTX_MODE              GENMASK(1, 0)
-#define MAX96717_VTX_GRAD_INC          CCI_REG8(0x26c)
-#define MAX96717_VTX_CHKB_COLOR_A      CCI_REG24(0x26d)
-#define MAX96717_VTX_CHKB_COLOR_B      CCI_REG24(0x270)
-#define MAX96717_VTX_CHKB_RPT_CNT_A    CCI_REG8(0x273)
-#define MAX96717_VTX_CHKB_RPT_CNT_B    CCI_REG8(0x274)
-#define MAX96717_VTX_CHKB_ALT          CCI_REG8(0x275)
-
-/* GPIO */
-#define MAX96717_NUM_GPIO         11
-#define MAX96717_GPIO_REG_A(gpio) CCI_REG8(0x2be + (gpio) * 3)
-#define MAX96717_GPIO_OUT         BIT(4)
-#define MAX96717_GPIO_IN          BIT(3)
-#define MAX96717_GPIO_RX_EN       BIT(2)
-#define MAX96717_GPIO_TX_EN       BIT(1)
-#define MAX96717_GPIO_OUT_DIS     BIT(0)
-
-/* FRONTTOP */
-/* MAX96717 only have CSI port 'B' */
-#define MAX96717_FRONTOP0     CCI_REG8(0x308)
-#define MAX96717_START_PORT_B BIT(5)
-
-/* MIPI_RX */
-#define MAX96717_MIPI_RX1       CCI_REG8(0x331)
-#define MAX96717_MIPI_LANES_CNT GENMASK(5, 4)
-#define MAX96717_MIPI_RX2       CCI_REG8(0x332) /* phy1 Lanes map */
-#define MAX96717_PHY2_LANES_MAP GENMASK(7, 4)
-#define MAX96717_MIPI_RX3       CCI_REG8(0x333) /* phy2 Lanes map */
-#define MAX96717_PHY1_LANES_MAP GENMASK(3, 0)
-#define MAX96717_MIPI_RX4       CCI_REG8(0x334) /* phy1 lane polarities */
-#define MAX96717_PHY1_LANES_POL GENMASK(6, 4)
-#define MAX96717_MIPI_RX5       CCI_REG8(0x335) /* phy2 lane polarities */
-#define MAX96717_PHY2_LANES_POL GENMASK(2, 0)
-
-/* MIPI_RX_EXT */
-#define MAX96717_MIPI_RX_EXT11 CCI_REG8(0x383)
-#define MAX96717_TUN_MODE      BIT(7)
-
-/* REF_VTG */
-#define REF_VTG0                CCI_REG8(0x3f0)
-#define REFGEN_PREDEF_EN        BIT(6)
-#define REFGEN_PREDEF_FREQ_MASK GENMASK(5, 4)
-#define REFGEN_PREDEF_FREQ_ALT  BIT(3)
-#define REFGEN_RST              BIT(1)
-#define REFGEN_EN               BIT(0)
-
-/* MISC */
-#define PIO_SLEW_1 CCI_REG8(0x570)
-
-enum max96717_vpg_mode {
-	MAX96717_VPG_DISABLED = 0,
-	MAX96717_VPG_CHECKERBOARD = 1,
-	MAX96717_VPG_GRADIENT = 2,
-};
-
-struct max96717_priv {
-	struct i2c_client		  *client;
-	struct regmap			  *regmap;
-	struct i2c_mux_core		  *mux;
-	struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
-	struct v4l2_subdev                sd;
-	struct media_pad                  pads[MAX96717_PORTS];
-	struct v4l2_ctrl_handler          ctrl_handler;
-	struct v4l2_async_notifier        notifier;
-	struct v4l2_subdev                *source_sd;
-	u16                               source_sd_pad;
-	u64			          enabled_source_streams;
-	u8                                pll_predef_index;
-	struct clk_hw                     clk_hw;
-	struct gpio_chip                  gpio_chip;
-	enum max96717_vpg_mode            pattern;
-};
-
-static inline struct max96717_priv *sd_to_max96717(struct v4l2_subdev *sd)
-{
-	return container_of(sd, struct max96717_priv, sd);
-}
-
-static inline struct max96717_priv *clk_hw_to_max96717(struct clk_hw *hw)
-{
-	return container_of(hw, struct max96717_priv, clk_hw);
-}
-
-static int max96717_i2c_mux_select(struct i2c_mux_core *mux, u32 chan)
-{
-	return 0;
-}
-
-static int max96717_i2c_mux_init(struct max96717_priv *priv)
-{
-	priv->mux = i2c_mux_alloc(priv->client->adapter, &priv->client->dev,
-				  1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE,
-				  max96717_i2c_mux_select, NULL);
-	if (!priv->mux)
-		return -ENOMEM;
-
-	return i2c_mux_add_adapter(priv->mux, 0, 0);
-}
-
-static inline int max96717_start_csi(struct max96717_priv *priv, bool start)
-{
-	return cci_update_bits(priv->regmap, MAX96717_FRONTOP0,
-			       MAX96717_START_PORT_B,
-			       start ? MAX96717_START_PORT_B : 0, NULL);
-}
-
-static int max96717_apply_patgen_timing(struct max96717_priv *priv,
-					struct v4l2_subdev_state *state)
-{
-	struct v4l2_mbus_framefmt *fmt =
-		v4l2_subdev_state_get_format(state, MAX96717_PAD_SOURCE);
-	const u32 h_active = fmt->width;
-	const u32 h_fp = 88;
-	const u32 h_sw = 44;
-	const u32 h_bp = 148;
-	u32 h_tot;
-	const u32 v_active = fmt->height;
-	const u32 v_fp = 4;
-	const u32 v_sw = 5;
-	const u32 v_bp = 36;
-	u32 v_tot;
-	int ret = 0;
-
-	h_tot = h_active + h_fp + h_sw + h_bp;
-	v_tot = v_active + v_fp + v_sw + v_bp;
-
-	/* 75 Mhz pixel clock */
-	cci_update_bits(priv->regmap, MAX96717_VTX1,
-			MAX96717_PATTERN_CLK_FREQ, 0xa, &ret);
-
-	dev_info(&priv->client->dev, "height: %d width: %d\n", fmt->height,
-		 fmt->width);
-
-	cci_write(priv->regmap, MAX96717_VTX_VS_DLY, 0, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_VS_HIGH, v_sw * h_tot, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_VS_LOW,
-		  (v_active + v_fp + v_bp) * h_tot, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_HS_HIGH, h_sw, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_HS_LOW, h_active + h_fp + h_bp,
-		  &ret);
-	cci_write(priv->regmap, MAX96717_VTX_V2D,
-		  h_tot * (v_sw + v_bp) + (h_sw + h_bp), &ret);
-	cci_write(priv->regmap, MAX96717_VTX_HS_CNT, v_tot, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_DE_HIGH, h_active, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_DE_LOW, h_fp + h_sw + h_bp,
-		  &ret);
-	cci_write(priv->regmap, MAX96717_VTX_DE_CNT, v_active, &ret);
-	/* B G R */
-	cci_write(priv->regmap, MAX96717_VTX_CHKB_COLOR_A, 0xfecc00, &ret);
-	/* B G R */
-	cci_write(priv->regmap, MAX96717_VTX_CHKB_COLOR_B, 0x006aa7, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_CHKB_RPT_CNT_A, 0x3c, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_CHKB_RPT_CNT_B, 0x3c, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_CHKB_ALT, 0x3c, &ret);
-	cci_write(priv->regmap, MAX96717_VTX_GRAD_INC, 0x10, &ret);
-
-	return ret;
-}
-
-static int max96717_apply_patgen(struct max96717_priv *priv,
-				 struct v4l2_subdev_state *state)
-{
-	unsigned int val;
-	int ret = 0;
-
-	if (priv->pattern)
-		ret = max96717_apply_patgen_timing(priv, state);
-
-	cci_write(priv->regmap, MAX96717_VTX0, priv->pattern ? 0xfb : 0,
-		  &ret);
-
-	val = FIELD_PREP(MAX96717_VTX_MODE, priv->pattern);
-	cci_update_bits(priv->regmap, MAX96717_VTX29, MAX96717_VTX_MODE,
-			val, &ret);
-	return ret;
-}
-
-static int max96717_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct max96717_priv *priv =
-		container_of(ctrl->handler, struct max96717_priv, ctrl_handler);
-	int ret;
-
-	switch (ctrl->id) {
-	case V4L2_CID_TEST_PATTERN:
-		if (priv->enabled_source_streams)
-			return -EBUSY;
-		priv->pattern = ctrl->val;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* Use bpp from bpp register */
-	ret = cci_update_bits(priv->regmap, MAX96717_VIDEO_TX0,
-			      MAX96717_VIDEO_AUTO_BPP,
-			      priv->pattern ? 0 : MAX96717_VIDEO_AUTO_BPP,
-			      NULL);
-
-	/*
-	 * Pattern generator doesn't work with tunnel mode.
-	 * Needs RGB color format and deserializer tunnel mode must be disabled.
-	 */
-	return cci_update_bits(priv->regmap, MAX96717_MIPI_RX_EXT11,
-			       MAX96717_TUN_MODE,
-			       priv->pattern ? 0 : MAX96717_TUN_MODE, &ret);
-}
-
-static const char * const max96717_test_pattern[] = {
-	"Disabled",
-	"Checkerboard",
-	"Gradient"
-};
-
-static const struct v4l2_ctrl_ops max96717_ctrl_ops = {
-	.s_ctrl = max96717_s_ctrl,
-};
-
-static int max96717_gpiochip_get(struct gpio_chip *gpiochip,
-				 unsigned int offset)
-{
-	struct max96717_priv *priv = gpiochip_get_data(gpiochip);
-	u64 val;
-	int ret;
-
-	ret = cci_read(priv->regmap, MAX96717_GPIO_REG_A(offset),
-		       &val, NULL);
-	if (ret)
-		return ret;
-
-	if (val & MAX96717_GPIO_OUT_DIS)
-		return !!(val & MAX96717_GPIO_IN);
-	else
-		return !!(val & MAX96717_GPIO_OUT);
-}
-
-static void max96717_gpiochip_set(struct gpio_chip *gpiochip,
-				  unsigned int offset, int value)
-{
-	struct max96717_priv *priv = gpiochip_get_data(gpiochip);
-
-	cci_update_bits(priv->regmap, MAX96717_GPIO_REG_A(offset),
-			MAX96717_GPIO_OUT, MAX96717_GPIO_OUT, NULL);
-}
-
-static int max96717_gpio_get_direction(struct gpio_chip *gpiochip,
-				       unsigned int offset)
-{
-	struct max96717_priv *priv = gpiochip_get_data(gpiochip);
-	u64 val;
-	int ret;
-
-	ret = cci_read(priv->regmap, MAX96717_GPIO_REG_A(offset), &val, NULL);
-	if (ret < 0)
-		return ret;
-
-	return !!(val & MAX96717_GPIO_OUT_DIS);
-}
-
-static int max96717_gpio_direction_out(struct gpio_chip *gpiochip,
-				       unsigned int offset, int value)
-{
-	struct max96717_priv *priv = gpiochip_get_data(gpiochip);
-
-	return cci_update_bits(priv->regmap, MAX96717_GPIO_REG_A(offset),
-			       MAX96717_GPIO_OUT_DIS | MAX96717_GPIO_OUT,
-			       value ? MAX96717_GPIO_OUT : 0, NULL);
-}
-
-static int max96717_gpio_direction_in(struct gpio_chip *gpiochip,
-				      unsigned int offset)
-{
-	struct max96717_priv *priv = gpiochip_get_data(gpiochip);
-
-	return cci_update_bits(priv->regmap, MAX96717_GPIO_REG_A(offset),
-			       MAX96717_GPIO_OUT_DIS, MAX96717_GPIO_OUT_DIS,
-			       NULL);
-}
-
-static int max96717_gpiochip_probe(struct max96717_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	struct gpio_chip *gc = &priv->gpio_chip;
-	int i, ret = 0;
-
-	gc->label = dev_name(dev);
-	gc->parent = dev;
-	gc->owner = THIS_MODULE;
-	gc->ngpio = MAX96717_NUM_GPIO;
-	gc->base = -1;
-	gc->can_sleep = true;
-	gc->get_direction = max96717_gpio_get_direction;
-	gc->direction_input = max96717_gpio_direction_in;
-	gc->direction_output = max96717_gpio_direction_out;
-	gc->set = max96717_gpiochip_set;
-	gc->get = max96717_gpiochip_get;
-	gc->of_gpio_n_cells = 2;
-
-	/* Disable GPIO forwarding */
-	for (i = 0; i < gc->ngpio; i++)
-		cci_update_bits(priv->regmap, MAX96717_GPIO_REG_A(i),
-				MAX96717_GPIO_RX_EN | MAX96717_GPIO_TX_EN,
-				0, &ret);
-
-	if (ret)
-		return ret;
-
-	ret = devm_gpiochip_add_data(dev, gc, priv);
-	if (ret) {
-		dev_err(dev, "Unable to create gpio_chip\n");
-		return ret;
-	}
-
-	return 0;
-}
-
-static int _max96717_set_routing(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_state *state,
-				 struct v4l2_subdev_krouting *routing)
-{
-	static const struct v4l2_mbus_framefmt format = {
-		.width = 1280,
-		.height = 1080,
-		.code = MEDIA_BUS_FMT_Y8_1X8,
-		.field = V4L2_FIELD_NONE,
-	};
-	int ret;
-
-	ret = v4l2_subdev_routing_validate(sd, routing,
-					   V4L2_SUBDEV_ROUTING_ONLY_1_TO_1);
-	if (ret)
-		return ret;
-
-	ret = v4l2_subdev_set_routing_with_fmt(sd, state, routing, &format);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static int max96717_set_routing(struct v4l2_subdev *sd,
-				struct v4l2_subdev_state *state,
-				enum v4l2_subdev_format_whence which,
-				struct v4l2_subdev_krouting *routing)
-{
-	struct max96717_priv *priv = sd_to_max96717(sd);
-
-	if (which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->enabled_source_streams)
-		return -EBUSY;
-
-	return _max96717_set_routing(sd, state, routing);
-}
-
-static int max96717_set_fmt(struct v4l2_subdev *sd,
-			    struct v4l2_subdev_state *state,
-			    struct v4l2_subdev_format *format)
-{
-	struct max96717_priv *priv = sd_to_max96717(sd);
-	struct v4l2_mbus_framefmt *fmt;
-	u64 stream_source_mask;
-
-	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE &&
-	    priv->enabled_source_streams)
-		return -EBUSY;
-
-	/* No transcoding, source and sink formats must match. */
-	if (format->pad == MAX96717_PAD_SOURCE)
-		return v4l2_subdev_get_fmt(sd, state, format);
-
-	/* Set sink format */
-	fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream);
-	if (!fmt)
-		return -EINVAL;
-
-	*fmt = format->format;
-
-	/* Propagate to source format */
-	fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad,
-							   format->stream);
-	if (!fmt)
-		return -EINVAL;
-	*fmt = format->format;
-
-	stream_source_mask = BIT(format->stream);
-
-	return v4l2_subdev_state_xlate_streams(state, MAX96717_PAD_SOURCE,
-					       MAX96717_PAD_SINK,
-					       &stream_source_mask);
-}
-
-static int max96717_init_state(struct v4l2_subdev *sd,
-			       struct v4l2_subdev_state *state)
-{
-	struct v4l2_subdev_route routes[] = {
-		{
-			.sink_pad = MAX96717_PAD_SINK,
-			.sink_stream = 0,
-			.source_pad = MAX96717_PAD_SOURCE,
-			.source_stream = 0,
-			.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
-		},
-	};
-	struct v4l2_subdev_krouting routing = {
-		.num_routes = ARRAY_SIZE(routes),
-		.routes = routes,
-	};
-
-	return _max96717_set_routing(sd, state, &routing);
-}
-
-static bool max96717_pipe_pclkdet(struct max96717_priv *priv)
-{
-	u64 val = 0;
-
-	cci_read(priv->regmap, MAX96717_VIDEO_TX2, &val, NULL);
-
-	return val & MAX96717_VIDEO_PCLKDET;
-}
-
-static int max96717_log_status(struct v4l2_subdev *sd)
-{
-	struct max96717_priv *priv = sd_to_max96717(sd);
-	struct device *dev = &priv->client->dev;
-
-	dev_info(dev, "Serializer: max96717\n");
-	dev_info(dev, "Pipe: pclkdet:%d\n", max96717_pipe_pclkdet(priv));
-
-	return 0;
-}
-
-static int max96717_enable_streams(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_state *state, u32 pad,
-				   u64 streams_mask)
-{
-	struct max96717_priv *priv = sd_to_max96717(sd);
-	u64 sink_streams;
-	int ret;
-
-	if (!priv->enabled_source_streams)
-		max96717_start_csi(priv, true);
-
-	ret = max96717_apply_patgen(priv, state);
-	if (ret)
-		goto stop_csi;
-
-	if (!priv->pattern) {
-		sink_streams =
-			v4l2_subdev_state_xlate_streams(state,
-							MAX96717_PAD_SOURCE,
-							MAX96717_PAD_SINK,
-							&streams_mask);
-
-		ret = v4l2_subdev_enable_streams(priv->source_sd,
-						 priv->source_sd_pad,
-						 sink_streams);
-		if (ret)
-			goto stop_csi;
-	}
-
-	priv->enabled_source_streams |= streams_mask;
-
-	return 0;
-
-stop_csi:
-	if (!priv->enabled_source_streams)
-		max96717_start_csi(priv, false);
-
-	return ret;
-}
-
-static int max96717_disable_streams(struct v4l2_subdev *sd,
-				    struct v4l2_subdev_state *state, u32 pad,
-				    u64 streams_mask)
-{
-	struct max96717_priv *priv = sd_to_max96717(sd);
-	u64 sink_streams;
-
-	/*
-	 * Stop the CSI receiver first then the source,
-	 * otherwise the device may become unresponsive
-	 * while holding the I2C bus low.
-	 */
-	priv->enabled_source_streams &= ~streams_mask;
-	if (!priv->enabled_source_streams)
-		max96717_start_csi(priv, false);
-
-	if (!priv->pattern) {
-		int ret;
-
-		sink_streams =
-			v4l2_subdev_state_xlate_streams(state,
-							MAX96717_PAD_SOURCE,
-							MAX96717_PAD_SINK,
-							&streams_mask);
-
-		ret = v4l2_subdev_disable_streams(priv->source_sd,
-						  priv->source_sd_pad,
-						  sink_streams);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-
-static const struct v4l2_subdev_pad_ops max96717_pad_ops = {
-	.enable_streams = max96717_enable_streams,
-	.disable_streams = max96717_disable_streams,
-	.set_routing = max96717_set_routing,
-	.get_fmt = v4l2_subdev_get_fmt,
-	.set_fmt = max96717_set_fmt,
-};
-
-static const struct v4l2_subdev_core_ops max96717_subdev_core_ops = {
-	.log_status = max96717_log_status,
-};
-
-static const struct v4l2_subdev_internal_ops max96717_internal_ops = {
-	.init_state = max96717_init_state,
-};
-
-static const struct v4l2_subdev_ops max96717_subdev_ops = {
-	.core = &max96717_subdev_core_ops,
-	.pad = &max96717_pad_ops,
-};
-
-static const struct media_entity_operations max96717_entity_ops = {
-	.link_validate = v4l2_subdev_link_validate,
-};
-
-static int max96717_notify_bound(struct v4l2_async_notifier *notifier,
-				 struct v4l2_subdev *source_subdev,
-				 struct v4l2_async_connection *asd)
-{
-	struct max96717_priv *priv = sd_to_max96717(notifier->sd);
-	struct device *dev = &priv->client->dev;
-	int ret;
-
-	ret = media_entity_get_fwnode_pad(&source_subdev->entity,
-					  source_subdev->fwnode,
-					  MEDIA_PAD_FL_SOURCE);
-	if (ret < 0) {
-		dev_err(dev, "Failed to find pad for %s\n",
-			source_subdev->name);
-		return ret;
-	}
-
-	priv->source_sd = source_subdev;
-	priv->source_sd_pad = ret;
-
-	ret = media_create_pad_link(&source_subdev->entity, priv->source_sd_pad,
-				    &priv->sd.entity, 0,
-				    MEDIA_LNK_FL_ENABLED |
-				    MEDIA_LNK_FL_IMMUTABLE);
-	if (ret) {
-		dev_err(dev, "Unable to link %s:%u -> %s:0\n",
-			source_subdev->name, priv->source_sd_pad,
-			priv->sd.name);
-		return ret;
-	}
-
-	return 0;
-}
-
-static const struct v4l2_async_notifier_operations max96717_notify_ops = {
-	.bound = max96717_notify_bound,
-};
-
-static int max96717_v4l2_notifier_register(struct max96717_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	struct v4l2_async_connection *asd;
-	struct fwnode_handle *ep_fwnode;
-	int ret;
-
-	ep_fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev),
-						    MAX96717_PAD_SINK, 0, 0);
-	if (!ep_fwnode) {
-		dev_err(dev, "No graph endpoint\n");
-		return -ENODEV;
-	}
-
-	v4l2_async_subdev_nf_init(&priv->notifier, &priv->sd);
-
-	asd = v4l2_async_nf_add_fwnode_remote(&priv->notifier, ep_fwnode,
-					      struct v4l2_async_connection);
-
-	fwnode_handle_put(ep_fwnode);
-
-	if (IS_ERR(asd)) {
-		dev_err(dev, "Failed to add subdev: %ld", PTR_ERR(asd));
-		v4l2_async_nf_cleanup(&priv->notifier);
-		return PTR_ERR(asd);
-	}
-
-	priv->notifier.ops = &max96717_notify_ops;
-
-	ret = v4l2_async_nf_register(&priv->notifier);
-	if (ret) {
-		dev_err(dev, "Failed to register subdev_notifier");
-		v4l2_async_nf_cleanup(&priv->notifier);
-		return ret;
-	}
-
-	return 0;
-}
-
-static int max96717_subdev_init(struct max96717_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	int ret;
-
-	v4l2_i2c_subdev_init(&priv->sd, priv->client, &max96717_subdev_ops);
-	priv->sd.internal_ops = &max96717_internal_ops;
-
-	v4l2_ctrl_handler_init(&priv->ctrl_handler, 1);
-	priv->sd.ctrl_handler = &priv->ctrl_handler;
-
-	v4l2_ctrl_new_std_menu_items(&priv->ctrl_handler,
-				     &max96717_ctrl_ops,
-				     V4L2_CID_TEST_PATTERN,
-				     ARRAY_SIZE(max96717_test_pattern) - 1,
-				     0, 0, max96717_test_pattern);
-	if (priv->ctrl_handler.error) {
-		ret = priv->ctrl_handler.error;
-		goto err_free_ctrl;
-	}
-
-	priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_STREAMS;
-	priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
-	priv->sd.entity.ops = &max96717_entity_ops;
-
-	priv->pads[MAX96717_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-	priv->pads[MAX96717_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-
-	ret = media_entity_pads_init(&priv->sd.entity, 2, priv->pads);
-	if (ret) {
-		dev_err_probe(dev, ret, "Failed to init pads\n");
-		goto err_free_ctrl;
-	}
-
-	ret = v4l2_subdev_init_finalize(&priv->sd);
-	if (ret) {
-		dev_err_probe(dev, ret,
-			      "v4l2 subdev init finalized failed\n");
-		goto err_entity_cleanup;
-	}
-	ret = max96717_v4l2_notifier_register(priv);
-	if (ret) {
-		dev_err_probe(dev, ret,
-			      "v4l2 subdev notifier register failed\n");
-		goto err_free_state;
-	}
-
-	ret = v4l2_async_register_subdev(&priv->sd);
-	if (ret) {
-		dev_err_probe(dev, ret, "v4l2_async_register_subdev error\n");
-		goto err_unreg_notif;
-	}
-
-	return 0;
-
-err_unreg_notif:
-	v4l2_async_nf_unregister(&priv->notifier);
-	v4l2_async_nf_cleanup(&priv->notifier);
-err_free_state:
-	v4l2_subdev_cleanup(&priv->sd);
-err_entity_cleanup:
-	media_entity_cleanup(&priv->sd.entity);
-err_free_ctrl:
-	v4l2_ctrl_handler_free(&priv->ctrl_handler);
-
-	return ret;
-}
-
-static void max96717_subdev_uninit(struct max96717_priv *priv)
-{
-	v4l2_async_unregister_subdev(&priv->sd);
-	v4l2_async_nf_unregister(&priv->notifier);
-	v4l2_async_nf_cleanup(&priv->notifier);
-	v4l2_subdev_cleanup(&priv->sd);
-	media_entity_cleanup(&priv->sd.entity);
-	v4l2_ctrl_handler_free(&priv->ctrl_handler);
-}
-
-struct max96717_pll_predef_freq {
-	unsigned long freq;
-	bool is_alt;
-	u8 val;
-};
-
-static const struct max96717_pll_predef_freq max96717_predef_freqs[] = {
-	{ 13500000, true,  0 }, { 19200000, false, 0 },
-	{ 24000000, true,  1 }, { 27000000, false, 1 },
-	{ 37125000, false, 2 }, { 74250000, false, 3 },
-};
-
-static unsigned long
-max96717_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
-{
-	struct max96717_priv *priv = clk_hw_to_max96717(hw);
-
-	return max96717_predef_freqs[priv->pll_predef_index].freq;
-}
-
-static unsigned int max96717_clk_find_best_index(struct max96717_priv *priv,
-						 unsigned long rate)
-{
-	unsigned int i, idx = 0;
-	unsigned long diff_new, diff_old = U32_MAX;
-
-	for (i = 0; i < ARRAY_SIZE(max96717_predef_freqs); i++) {
-		diff_new = abs(rate - max96717_predef_freqs[i].freq);
-		if (diff_new < diff_old) {
-			diff_old = diff_new;
-			idx = i;
-		}
-	}
-
-	return idx;
-}
-
-static long max96717_clk_round_rate(struct clk_hw *hw, unsigned long rate,
-				    unsigned long *parent_rate)
-{
-	struct max96717_priv *priv = clk_hw_to_max96717(hw);
-	struct device *dev = &priv->client->dev;
-	unsigned int idx;
-
-	idx = max96717_clk_find_best_index(priv, rate);
-
-	if (rate != max96717_predef_freqs[idx].freq) {
-		dev_warn(dev, "Request CLK freq:%lu, found CLK freq:%lu\n",
-			 rate, max96717_predef_freqs[idx].freq);
-	}
-
-	return max96717_predef_freqs[idx].freq;
-}
-
-static int max96717_clk_set_rate(struct clk_hw *hw, unsigned long rate,
-				 unsigned long parent_rate)
-{
-	struct max96717_priv *priv = clk_hw_to_max96717(hw);
-	unsigned int val, idx;
-	int ret = 0;
-
-	idx = max96717_clk_find_best_index(priv, rate);
-
-	val = FIELD_PREP(REFGEN_PREDEF_FREQ_MASK,
-			 max96717_predef_freqs[idx].val);
-
-	if (max96717_predef_freqs[idx].is_alt)
-		val |= REFGEN_PREDEF_FREQ_ALT;
-
-	val |= REFGEN_RST | REFGEN_PREDEF_EN;
-
-	cci_write(priv->regmap, REF_VTG0, val, &ret);
-	cci_update_bits(priv->regmap, REF_VTG0, REFGEN_RST | REFGEN_EN,
-			REFGEN_EN, &ret);
-	if (ret)
-		return ret;
-
-	priv->pll_predef_index = idx;
-
-	return 0;
-}
-
-static int max96717_clk_prepare(struct clk_hw *hw)
-{
-	struct max96717_priv *priv = clk_hw_to_max96717(hw);
-
-	return cci_update_bits(priv->regmap, MAX96717_REG6, RCLKEN,
-			       RCLKEN, NULL);
-}
-
-static void max96717_clk_unprepare(struct clk_hw *hw)
-{
-	struct max96717_priv *priv = clk_hw_to_max96717(hw);
-
-	cci_update_bits(priv->regmap, MAX96717_REG6, RCLKEN, 0, NULL);
-}
-
-static const struct clk_ops max96717_clk_ops = {
-	.prepare     = max96717_clk_prepare,
-	.unprepare   = max96717_clk_unprepare,
-	.set_rate    = max96717_clk_set_rate,
-	.recalc_rate = max96717_clk_recalc_rate,
-	.round_rate  = max96717_clk_round_rate,
-};
-
-static int max96717_register_clkout(struct max96717_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	struct clk_init_data init = { .ops = &max96717_clk_ops };
-	int ret;
-
-	init.name = kasprintf(GFP_KERNEL, "max96717.%s.clk_out", dev_name(dev));
-	if (!init.name)
-		return -ENOMEM;
-
-	/* RCLKSEL Reference PLL output */
-	ret = cci_update_bits(priv->regmap, MAX96717_REG3, MAX96717_RCLKSEL,
-			      MAX96717_RCLKSEL, NULL);
-	/* MFP4 fastest slew rate */
-	cci_update_bits(priv->regmap, PIO_SLEW_1, BIT(5) | BIT(4), 0, &ret);
-	if (ret)
-		goto free_init_name;
-
-	priv->clk_hw.init = &init;
-
-	/* Initialize to 24 MHz */
-	ret = max96717_clk_set_rate(&priv->clk_hw,
-				    MAX96717_DEFAULT_CLKOUT_RATE, 0);
-	if (ret < 0)
-		goto free_init_name;
-
-	ret = devm_clk_hw_register(dev, &priv->clk_hw);
-	kfree(init.name);
-	if (ret)
-		return dev_err_probe(dev, ret, "Cannot register clock HW\n");
-
-	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
-					  &priv->clk_hw);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Cannot add OF clock provider\n");
-
-	return 0;
-
-free_init_name:
-	kfree(init.name);
-	return ret;
-}
-
-static int max96717_init_csi_lanes(struct max96717_priv *priv)
-{
-	struct v4l2_mbus_config_mipi_csi2 *mipi = &priv->mipi_csi2;
-	unsigned long lanes_used = 0;
-	unsigned int nlanes, lane, val = 0;
-	int ret;
-
-	nlanes = mipi->num_data_lanes;
-
-	ret = cci_update_bits(priv->regmap, MAX96717_MIPI_RX1,
-			      MAX96717_MIPI_LANES_CNT,
-			      FIELD_PREP(MAX96717_MIPI_LANES_CNT,
-					 nlanes - 1), NULL);
-
-	/* lanes polarity */
-	for (lane = 0; lane < nlanes + 1; lane++) {
-		if (!mipi->lane_polarities[lane])
-			continue;
-		/* Clock lane */
-		if (lane == 0)
-			val |= BIT(2);
-		else if (lane < 3)
-			val |= BIT(lane - 1);
-		else
-			val |= BIT(lane);
-	}
-
-	cci_update_bits(priv->regmap, MAX96717_MIPI_RX5,
-			MAX96717_PHY2_LANES_POL,
-			FIELD_PREP(MAX96717_PHY2_LANES_POL, val), &ret);
-
-	cci_update_bits(priv->regmap, MAX96717_MIPI_RX4,
-			MAX96717_PHY1_LANES_POL,
-			FIELD_PREP(MAX96717_PHY1_LANES_POL,
-				   val >> 3), &ret);
-	/* lanes mapping */
-	for (lane = 0, val = 0; lane < nlanes; lane++) {
-		val |= (mipi->data_lanes[lane] - 1) << (lane * 2);
-		lanes_used |= BIT(mipi->data_lanes[lane] - 1);
-	}
-
-	/*
-	 * Unused lanes need to be mapped as well to not have
-	 * the same lanes mapped twice.
-	 */
-	for (; lane < MAX96717_CSI_NLANES; lane++) {
-		unsigned int idx = find_first_zero_bit(&lanes_used,
-						       MAX96717_CSI_NLANES);
-
-		val |= idx << (lane * 2);
-		lanes_used |= BIT(idx);
-	}
-
-	cci_update_bits(priv->regmap, MAX96717_MIPI_RX3,
-			MAX96717_PHY1_LANES_MAP,
-			FIELD_PREP(MAX96717_PHY1_LANES_MAP, val), &ret);
-
-	return cci_update_bits(priv->regmap, MAX96717_MIPI_RX2,
-			       MAX96717_PHY2_LANES_MAP,
-			       FIELD_PREP(MAX96717_PHY2_LANES_MAP, val >> 4),
-			       &ret);
-}
-
-static int max96717_hw_init(struct max96717_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	u64 dev_id, val;
-	int ret;
-
-	ret = cci_read(priv->regmap, MAX96717_DEV_ID, &dev_id, NULL);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Fail to read the device id\n");
-
-	if (dev_id != MAX96717_DEVICE_ID && dev_id != MAX96717F_DEVICE_ID)
-		return dev_err_probe(dev, -EOPNOTSUPP,
-				     "Unsupported device id got %x\n", (u8)dev_id);
-
-	ret = cci_read(priv->regmap, MAX96717_DEV_REV, &val, NULL);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Fail to read device revision");
-
-	dev_dbg(dev, "Found %x (rev %lx)\n", (u8)dev_id,
-		(u8)val & MAX96717_DEV_REV_MASK);
-
-	ret = cci_read(priv->regmap, MAX96717_MIPI_RX_EXT11, &val, NULL);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Fail to read mipi rx extension");
-
-	if (!(val & MAX96717_TUN_MODE))
-		return dev_err_probe(dev, -EOPNOTSUPP,
-				     "Only supporting tunnel mode");
-
-	return max96717_init_csi_lanes(priv);
-}
-
-static int max96717_parse_dt(struct max96717_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_CSI2_DPHY };
-	struct fwnode_handle *ep_fwnode;
-	unsigned char num_data_lanes;
-	int ret;
-
-	ep_fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev),
-						    MAX96717_PAD_SINK, 0, 0);
-	if (!ep_fwnode)
-		return dev_err_probe(dev, -ENOENT, "no endpoint found\n");
-
-	ret = v4l2_fwnode_endpoint_parse(ep_fwnode, &vep);
-
-	fwnode_handle_put(ep_fwnode);
-
-	if (ret < 0)
-		return dev_err_probe(dev, ret, "Failed to parse sink endpoint");
-
-	num_data_lanes = vep.bus.mipi_csi2.num_data_lanes;
-	if (num_data_lanes < 1 || num_data_lanes > MAX96717_CSI_NLANES)
-		return dev_err_probe(dev, -EINVAL,
-				     "Invalid data lanes must be 1 to 4\n");
-
-	priv->mipi_csi2 = vep.bus.mipi_csi2;
-
-	return 0;
-}
-
-static int max96717_probe(struct i2c_client *client)
-{
-	struct device *dev = &client->dev;
-	struct max96717_priv *priv;
-	int ret;
-
-	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	priv->client = client;
-	priv->regmap = devm_cci_regmap_init_i2c(client, 16);
-	if (IS_ERR(priv->regmap)) {
-		ret = PTR_ERR(priv->regmap);
-		return dev_err_probe(dev, ret, "Failed to init regmap\n");
-	}
-
-	ret = max96717_parse_dt(priv);
-	if (ret)
-		return dev_err_probe(dev, ret, "Failed to parse the dt\n");
-
-	ret = max96717_hw_init(priv);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Failed to initialize the hardware\n");
-
-	ret = max96717_gpiochip_probe(priv);
-	if (ret)
-		return dev_err_probe(&client->dev, ret,
-				     "Failed to init gpiochip\n");
-
-	ret = max96717_register_clkout(priv);
-	if (ret)
-		return dev_err_probe(dev, ret, "Failed to register clkout\n");
-
-	ret = max96717_subdev_init(priv);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Failed to initialize v4l2 subdev\n");
-
-	ret = max96717_i2c_mux_init(priv);
-	if (ret) {
-		dev_err_probe(dev, ret, "failed to add remote i2c adapter\n");
-		max96717_subdev_uninit(priv);
-	}
-
-	return ret;
-}
-
-static void max96717_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct max96717_priv *priv = sd_to_max96717(sd);
-
-	max96717_subdev_uninit(priv);
-	i2c_mux_del_adapters(priv->mux);
-}
-
-static const struct of_device_id max96717_of_ids[] = {
-	{ .compatible = "maxim,max96717f" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, max96717_of_ids);
-
-static struct i2c_driver max96717_i2c_driver = {
-	.driver	= {
-		.name		= "max96717",
-		.of_match_table	= max96717_of_ids,
-	},
-	.probe		= max96717_probe,
-	.remove		= max96717_remove,
-};
-
-module_i2c_driver(max96717_i2c_driver);
-
-MODULE_DESCRIPTION("Maxim GMSL2 MAX96717 Serializer Driver");
-MODULE_AUTHOR("Julien Massot <julien.massot@collabora.com>");
-MODULE_LICENSE("GPL");
-- 
2.48.1



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

* [RFC PATCH v2 16/16] media: i2c: remove MAX96714 driver
  2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
                   ` (13 preceding siblings ...)
  2025-03-09  8:48 ` [RFC PATCH v2 15/16] media: i2c: remove MAX96717 driver Cosmin Tanislav
@ 2025-03-09  8:48 ` Cosmin Tanislav
       [not found] ` <20250309084814.3114794-13-demonsingur@gmail.com>
  15 siblings, 0 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-09  8:48 UTC (permalink / raw)
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio, Cosmin Tanislav

The previous MAX96714 driver has been removed and its functionality has
been moved to the MAX9296A driver which makes use of the Maxim GMSL2/3
serializer framework.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
 MAINTAINERS                  |    1 -
 drivers/media/i2c/Kconfig    |   17 -
 drivers/media/i2c/Makefile   |    1 -
 drivers/media/i2c/max96714.c | 1024 ----------------------------------
 4 files changed, 1043 deletions(-)
 delete mode 100644 drivers/media/i2c/max96714.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e9fe6e9856d8..395de7a7da92 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14194,7 +14194,6 @@ M:	Julien Massot <julien.massot@collabora.com>
 L:	linux-media@vger.kernel.org
 S:	Maintained
 F:	Documentation/devicetree/bindings/media/i2c/maxim,max96714.yaml
-F:	drivers/media/i2c/max96714.c
 
 MAX96717 GMSL2 SERIALIZER DRIVER
 M:	Julien Massot <julien.massot@collabora.com>
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 6c595dffb280..aa0a67b7da47 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -1619,23 +1619,6 @@ config VIDEO_DS90UB960
 	  Device driver for the Texas Instruments DS90UB960
 	  FPD-Link III Deserializer and DS90UB9702 FPD-Link IV Deserializer.
 
-config VIDEO_MAX96714
-	tristate "Maxim MAX96714 GMSL2 deserializer"
-	depends on OF && I2C && VIDEO_DEV
-	select I2C_MUX
-	select MEDIA_CONTROLLER
-	select GPIOLIB
-	select V4L2_CCI_I2C
-	select V4L2_FWNODE
-	select VIDEO_V4L2_SUBDEV_API
-	help
-	  Device driver for the Maxim MAX96714 GMSL2 Deserializer.
-	  MAX96714 deserializers convert a GMSL2 input to MIPI CSI-2
-	  output.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called max96714.
-
 source "drivers/media/i2c/maxim-serdes/Kconfig"
 
 endmenu
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index de0680ebf190..065e728f54ce 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -68,7 +68,6 @@ obj-$(CONFIG_VIDEO_LT6911UXE) += lt6911uxe.o
 obj-$(CONFIG_VIDEO_M52790) += m52790.o
 obj-$(CONFIG_VIDEO_MAX9271_LIB) += max9271.o
 obj-$(CONFIG_VIDEO_MAX9286) += max9286.o
-obj-$(CONFIG_VIDEO_MAX96714) += max96714.o
 obj-$(CONFIG_VIDEO_MAXIM_SERDES) += maxim-serdes/
 obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o
 obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
diff --git a/drivers/media/i2c/max96714.c b/drivers/media/i2c/max96714.c
deleted file mode 100644
index 159753b13777..000000000000
--- a/drivers/media/i2c/max96714.c
+++ /dev/null
@@ -1,1024 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Maxim GMSL2 Deserializer Driver
- *
- * Copyright (C) 2024 Collabora Ltd.
- */
-
-#include <linux/bitfield.h>
-#include <linux/bitops.h>
-#include <linux/fwnode.h>
-#include <linux/gpio/consumer.h>
-#include <linux/i2c.h>
-#include <linux/i2c-mux.h>
-#include <linux/module.h>
-#include <linux/regmap.h>
-#include <linux/regulator/consumer.h>
-
-#include <media/v4l2-cci.h>
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-fwnode.h>
-#include <media/v4l2-subdev.h>
-
-#define MAX96714_DEVICE_ID  0xc9
-#define MAX96714F_DEVICE_ID 0xca
-#define MAX96714_NPORTS     2
-#define MAX96714_PAD_SINK   0
-#define MAX96714_PAD_SOURCE 1
-#define MAX96714_CSI_NLANES 4
-
-/* DEV */
-#define MAX96714_REG13                 CCI_REG8(0x0d)
-#define MAX96714_DEV_REV               CCI_REG8(0x0e)
-#define MAX96714_DEV_REV_MASK          GENMASK(3, 0)
-#define MAX96714_LINK_LOCK             CCI_REG8(0x13)
-#define MAX96714_LINK_LOCK_BIT         BIT(3)
-#define MAX96714_IO_CHK0               CCI_REG8(0x38)
-#define MAX96714_PATTERN_CLK_FREQ      GENMASK(1, 0)
-/* VID_RX */
-#define MAX96714_VIDEO_RX8             CCI_REG8(0x11a)
-#define MAX96714_VID_LOCK              BIT(6)
-
-/* VRX_PATGEN_0 */
-#define MAX96714_PATGEN_0              CCI_REG8(0x240)
-#define MAX96714_PATGEN_1              CCI_REG8(0x241)
-#define MAX96714_PATGEN_MODE           GENMASK(5, 4)
-#define MAX96714_PATGEN_VS_DLY         CCI_REG24(0x242)
-#define MAX96714_PATGEN_VS_HIGH        CCI_REG24(0x245)
-#define MAX96714_PATGEN_VS_LOW         CCI_REG24(0x248)
-#define MAX96714_PATGEN_V2H            CCI_REG24(0x24b)
-#define MAX96714_PATGEN_HS_HIGH        CCI_REG16(0x24e)
-#define MAX96714_PATGEN_HS_LOW         CCI_REG16(0x250)
-#define MAX96714_PATGEN_HS_CNT         CCI_REG16(0x252)
-#define MAX96714_PATGEN_V2D            CCI_REG24(0x254)
-#define MAX96714_PATGEN_DE_HIGH        CCI_REG16(0x257)
-#define MAX96714_PATGEN_DE_LOW         CCI_REG16(0x259)
-#define MAX96714_PATGEN_DE_CNT         CCI_REG16(0x25b)
-#define MAX96714_PATGEN_GRAD_INC       CCI_REG8(0x25d)
-#define MAX96714_PATGEN_CHKB_COLOR_A   CCI_REG24(0x25e)
-#define MAX96714_PATGEN_CHKB_COLOR_B   CCI_REG24(0x261)
-#define MAX96714_PATGEN_CHKB_RPT_CNT_A CCI_REG8(0x264)
-#define MAX96714_PATGEN_CHKB_RPT_CNT_B CCI_REG8(0x265)
-#define MAX96714_PATGEN_CHKB_ALT       CCI_REG8(0x266)
-/* BACKTOP */
-#define MAX96714_BACKTOP25             CCI_REG8(0x320)
-#define CSI_DPLL_FREQ_MASK             GENMASK(4, 0)
-
-/* MIPI_PHY */
-#define MAX96714_MIPI_PHY0             CCI_REG8(0x330)
-#define MAX96714_FORCE_CSI_OUT         BIT(7)
-#define MAX96714_MIPI_STDBY_N          CCI_REG8(0x332)
-#define MAX96714_MIPI_STDBY_MASK       GENMASK(5, 4)
-#define MAX96714_MIPI_LANE_MAP         CCI_REG8(0x333)
-#define MAX96714_MIPI_POLARITY         CCI_REG8(0x335)
-#define MAX96714_MIPI_POLARITY_MASK    GENMASK(5, 0)
-
-/* MIPI_TX */
-#define MAX96714_MIPI_LANE_CNT         CCI_REG8(0x44a)
-#define MAX96714_CSI2_LANE_CNT_MASK    GENMASK(7, 6)
-#define MAX96714_MIPI_TX52             CCI_REG8(0x474)
-#define MAX96714_TUN_EN                BIT(0)
-
-#define MHZ(v) ((u32)((v)  * 1000000U))
-
-enum max96714_vpg_mode {
-	MAX96714_VPG_DISABLED = 0,
-	MAX96714_VPG_CHECKERBOARD = 1,
-	MAX96714_VPG_GRADIENT = 2,
-};
-
-struct max96714_rxport {
-	struct {
-		struct v4l2_subdev   *sd;
-		u16                  pad;
-		struct fwnode_handle *ep_fwnode;
-	} source;
-	struct regulator	     *poc;
-};
-
-struct max96714_txport {
-	struct v4l2_fwnode_endpoint vep;
-};
-
-struct max96714_priv {
-	struct i2c_client                 *client;
-	struct regmap                     *regmap;
-	struct gpio_desc                  *pd_gpio;
-	struct max96714_rxport            rxport;
-	struct i2c_mux_core               *mux;
-	u64                               enabled_source_streams;
-	struct v4l2_subdev		  sd;
-	struct media_pad		  pads[MAX96714_NPORTS];
-	struct v4l2_mbus_config_mipi_csi2 mipi_csi2;
-	struct v4l2_ctrl_handler          ctrl_handler;
-	struct v4l2_async_notifier        notifier;
-	s64                               tx_link_freq;
-	enum max96714_vpg_mode            pattern;
-};
-
-static inline struct max96714_priv *sd_to_max96714(struct v4l2_subdev *sd)
-{
-	return container_of(sd, struct max96714_priv, sd);
-}
-
-static int max96714_enable_tx_port(struct max96714_priv *priv)
-{
-	return cci_update_bits(priv->regmap, MAX96714_MIPI_STDBY_N,
-			       MAX96714_MIPI_STDBY_MASK,
-			       MAX96714_MIPI_STDBY_MASK, NULL);
-}
-
-static int max96714_disable_tx_port(struct max96714_priv *priv)
-{
-	return cci_update_bits(priv->regmap, MAX96714_MIPI_STDBY_N,
-			       MAX96714_MIPI_STDBY_MASK, 0, NULL);
-}
-
-static bool max96714_tx_port_enabled(struct max96714_priv *priv)
-{
-	u64 val;
-
-	cci_read(priv->regmap, MAX96714_MIPI_STDBY_N, &val, NULL);
-
-	return val & MAX96714_MIPI_STDBY_MASK;
-}
-
-static int max96714_apply_patgen_timing(struct max96714_priv *priv,
-					struct v4l2_subdev_state *state)
-{
-	struct v4l2_mbus_framefmt *fmt =
-		v4l2_subdev_state_get_format(state, MAX96714_PAD_SOURCE);
-	const u32 h_active = fmt->width;
-	const u32 h_fp = 88;
-	const u32 h_sw = 44;
-	const u32 h_bp = 148;
-	u32 h_tot;
-	const u32 v_active = fmt->height;
-	const u32 v_fp = 4;
-	const u32 v_sw = 5;
-	const u32 v_bp = 36;
-	u32 v_tot;
-	int ret = 0;
-
-	h_tot = h_active + h_fp + h_sw + h_bp;
-	v_tot = v_active + v_fp + v_sw + v_bp;
-
-	/* 75 Mhz pixel clock */
-	cci_update_bits(priv->regmap, MAX96714_IO_CHK0,
-			MAX96714_PATTERN_CLK_FREQ, 1, &ret);
-
-	dev_info(&priv->client->dev, "height: %d width: %d\n", fmt->height,
-		 fmt->width);
-
-	cci_write(priv->regmap, MAX96714_PATGEN_VS_DLY, 0, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_VS_HIGH, v_sw * h_tot, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_VS_LOW,
-		  (v_active + v_fp + v_bp) * h_tot, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_HS_HIGH, h_sw, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_HS_LOW, h_active + h_fp + h_bp,
-		  &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_V2D,
-		  h_tot * (v_sw + v_bp) + (h_sw + h_bp), &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_HS_CNT, v_tot, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_DE_HIGH, h_active, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_DE_LOW, h_fp + h_sw + h_bp,
-		  &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_DE_CNT, v_active, &ret);
-	/* B G R */
-	cci_write(priv->regmap, MAX96714_PATGEN_CHKB_COLOR_A, 0xfecc00, &ret);
-	/* B G R */
-	cci_write(priv->regmap, MAX96714_PATGEN_CHKB_COLOR_B, 0x006aa7, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_CHKB_RPT_CNT_A, 0x3c, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_CHKB_RPT_CNT_B, 0x3c, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_CHKB_ALT, 0x3c, &ret);
-	cci_write(priv->regmap, MAX96714_PATGEN_GRAD_INC, 0x10, &ret);
-
-	return ret;
-}
-
-static int max96714_apply_patgen(struct max96714_priv *priv,
-				 struct v4l2_subdev_state *state)
-{
-	unsigned int val;
-	int ret = 0;
-
-	if (priv->pattern)
-		ret = max96714_apply_patgen_timing(priv, state);
-
-	cci_write(priv->regmap, MAX96714_PATGEN_0, priv->pattern ? 0xfb : 0,
-		  &ret);
-
-	val = FIELD_PREP(MAX96714_PATGEN_MODE, priv->pattern);
-	cci_update_bits(priv->regmap, MAX96714_PATGEN_1, MAX96714_PATGEN_MODE,
-			val, &ret);
-	return ret;
-}
-
-static int max96714_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct max96714_priv *priv =
-		container_of(ctrl->handler, struct max96714_priv, ctrl_handler);
-	int ret;
-
-	switch (ctrl->id) {
-	case V4L2_CID_TEST_PATTERN:
-		if (priv->enabled_source_streams)
-			return -EBUSY;
-		priv->pattern = ctrl->val;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	ret = cci_update_bits(priv->regmap, MAX96714_MIPI_PHY0,
-			      MAX96714_FORCE_CSI_OUT,
-			      priv->pattern ? MAX96714_FORCE_CSI_OUT : 0, NULL);
-
-	/* Pattern generator doesn't work with tunnel mode */
-	return cci_update_bits(priv->regmap, MAX96714_MIPI_TX52,
-			       MAX96714_TUN_EN,
-			       priv->pattern ? 0 : MAX96714_TUN_EN, &ret);
-}
-
-static const char * const max96714_test_pattern[] = {
-	"Disabled",
-	"Checkerboard",
-	"Gradient"
-};
-
-static const struct v4l2_ctrl_ops max96714_ctrl_ops = {
-	.s_ctrl = max96714_s_ctrl,
-};
-
-static int max96714_enable_streams(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_state *state,
-				   u32 source_pad, u64 streams_mask)
-{
-	struct max96714_priv *priv = sd_to_max96714(sd);
-	u64 sink_streams;
-	int ret;
-
-	if (!priv->enabled_source_streams)
-		max96714_enable_tx_port(priv);
-
-	ret = max96714_apply_patgen(priv, state);
-	if (ret)
-		goto err;
-
-	if (!priv->pattern) {
-		if (!priv->rxport.source.sd) {
-			ret = -ENODEV;
-			goto err;
-		}
-
-		sink_streams =
-			v4l2_subdev_state_xlate_streams(state,
-							MAX96714_PAD_SOURCE,
-							MAX96714_PAD_SINK,
-							&streams_mask);
-
-		ret = v4l2_subdev_enable_streams(priv->rxport.source.sd,
-						 priv->rxport.source.pad,
-						 sink_streams);
-		if (ret)
-			goto err;
-	}
-
-	priv->enabled_source_streams |= streams_mask;
-
-	return 0;
-
-err:
-	if (!priv->enabled_source_streams)
-		max96714_disable_tx_port(priv);
-
-	return ret;
-}
-
-static int max96714_disable_streams(struct v4l2_subdev *sd,
-				    struct v4l2_subdev_state *state,
-				    u32 source_pad, u64 streams_mask)
-{
-	struct max96714_priv *priv = sd_to_max96714(sd);
-	u64 sink_streams;
-
-	if (!priv->pattern) {
-		int ret;
-
-		sink_streams =
-			v4l2_subdev_state_xlate_streams(state,
-							MAX96714_PAD_SOURCE,
-							MAX96714_PAD_SINK,
-							&streams_mask);
-
-		ret = v4l2_subdev_disable_streams(priv->rxport.source.sd,
-						  priv->rxport.source.pad,
-						  sink_streams);
-		if (ret)
-			return ret;
-	}
-
-	priv->enabled_source_streams &= ~streams_mask;
-
-	if (!priv->enabled_source_streams)
-		max96714_disable_tx_port(priv);
-
-	return 0;
-}
-
-static int max96714_set_fmt(struct v4l2_subdev *sd,
-			    struct v4l2_subdev_state *state,
-			    struct v4l2_subdev_format *format)
-{
-	struct max96714_priv *priv = sd_to_max96714(sd);
-	struct v4l2_mbus_framefmt *fmt;
-
-	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE &&
-	    priv->enabled_source_streams)
-		return -EBUSY;
-
-	/* No transcoding, source and sink formats must match. */
-	if (format->pad == MAX96714_PAD_SOURCE)
-		return v4l2_subdev_get_fmt(sd, state, format);
-
-	fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream);
-	if (!fmt)
-		return -EINVAL;
-
-	*fmt = format->format;
-
-	fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad,
-							   format->stream);
-	if (!fmt)
-		return -EINVAL;
-
-	*fmt = format->format;
-
-	return 0;
-}
-
-static int _max96714_set_routing(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_state *state,
-				 enum v4l2_subdev_format_whence which,
-				 struct v4l2_subdev_krouting *routing)
-{
-	static const struct v4l2_mbus_framefmt format = {
-		.width = 1280,
-		.height = 1080,
-		.code = MEDIA_BUS_FMT_Y8_1X8,
-		.field = V4L2_FIELD_NONE,
-	};
-	int ret;
-
-	/*
-	 * Note: we can only support up to V4L2_FRAME_DESC_ENTRY_MAX, until
-	 * frame desc is made dynamically allocated.
-	 */
-	if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX)
-		return -EINVAL;
-
-	ret = v4l2_subdev_routing_validate(sd, routing,
-					   V4L2_SUBDEV_ROUTING_ONLY_1_TO_1);
-	if (ret)
-		return ret;
-
-	return v4l2_subdev_set_routing_with_fmt(sd, state, routing, &format);
-}
-
-static int max96714_set_routing(struct v4l2_subdev *sd,
-				struct v4l2_subdev_state *state,
-				enum v4l2_subdev_format_whence which,
-				struct v4l2_subdev_krouting *routing)
-{
-	struct max96714_priv *priv = sd_to_max96714(sd);
-
-	if (which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->enabled_source_streams)
-		return -EBUSY;
-
-	return _max96714_set_routing(sd, state, which, routing);
-}
-
-static int max96714_init_state(struct v4l2_subdev *sd,
-			       struct v4l2_subdev_state *state)
-{
-	struct v4l2_subdev_route routes[] = {
-		{
-			.sink_pad = MAX96714_PAD_SINK,
-			.sink_stream = 0,
-			.source_pad = MAX96714_PAD_SOURCE,
-			.source_stream = 0,
-			.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
-		}
-	};
-	struct v4l2_subdev_krouting routing = {
-		.num_routes = ARRAY_SIZE(routes),
-		.routes = routes,
-	};
-
-	return _max96714_set_routing(sd, state, V4L2_SUBDEV_FORMAT_ACTIVE,
-				     &routing);
-}
-
-static const struct v4l2_subdev_pad_ops max96714_pad_ops = {
-	.enable_streams = max96714_enable_streams,
-	.disable_streams = max96714_disable_streams,
-
-	.set_routing = max96714_set_routing,
-	.get_fmt = v4l2_subdev_get_fmt,
-	.set_fmt = max96714_set_fmt,
-};
-
-static bool max96714_link_locked(struct max96714_priv *priv)
-{
-	u64 val = 0;
-
-	cci_read(priv->regmap, MAX96714_LINK_LOCK, &val, NULL);
-
-	return val & MAX96714_LINK_LOCK_BIT;
-}
-
-static void max96714_link_status(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-
-	dev_info(dev, "Link locked:%d\n", max96714_link_locked(priv));
-}
-
-static bool max96714_pipe_locked(struct max96714_priv *priv)
-{
-	u64 val;
-
-	cci_read(priv->regmap, MAX96714_VIDEO_RX8, &val, NULL);
-
-	return val & MAX96714_VID_LOCK;
-}
-
-static void max96714_pipe_status(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-
-	dev_info(dev, "Pipe vidlock:%d\n", max96714_pipe_locked(priv));
-}
-
-static void max96714_csi_status(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	u64 freq = 0;
-
-	cci_read(priv->regmap, MAX96714_BACKTOP25, &freq, NULL);
-	freq = FIELD_GET(CSI_DPLL_FREQ_MASK, freq);
-
-	dev_info(dev, "CSI controller DPLL freq:%u00MHz CSIPHY enabled:%d\n",
-		 (u8)freq, max96714_tx_port_enabled(priv));
-}
-
-static int max96714_log_status(struct v4l2_subdev *sd)
-{
-	struct max96714_priv *priv = sd_to_max96714(sd);
-	struct device *dev = &priv->client->dev;
-
-	dev_info(dev, "Deserializer: max96714\n");
-
-	max96714_link_status(priv);
-	max96714_pipe_status(priv);
-	max96714_csi_status(priv);
-
-	return 0;
-}
-
-static const struct v4l2_subdev_core_ops max96714_subdev_core_ops = {
-	.log_status = max96714_log_status,
-};
-
-static const struct v4l2_subdev_video_ops max96714_video_ops = {
-	.s_stream	= v4l2_subdev_s_stream_helper,
-};
-
-static const struct v4l2_subdev_internal_ops max96714_internal_ops = {
-	.init_state = max96714_init_state,
-};
-
-static const struct v4l2_subdev_ops max96714_subdev_ops = {
-	.video = &max96714_video_ops,
-	.core = &max96714_subdev_core_ops,
-	.pad = &max96714_pad_ops,
-};
-
-static const struct media_entity_operations max96714_entity_ops = {
-	.link_validate = v4l2_subdev_link_validate,
-};
-
-static int max96714_notify_bound(struct v4l2_async_notifier *notifier,
-				 struct v4l2_subdev *subdev,
-				 struct v4l2_async_connection *asd)
-{
-	struct max96714_priv *priv = sd_to_max96714(notifier->sd);
-	struct device *dev = &priv->client->dev;
-	int ret;
-
-	ret = media_entity_get_fwnode_pad(&subdev->entity,
-					  priv->rxport.source.ep_fwnode,
-					  MEDIA_PAD_FL_SOURCE);
-	if (ret < 0) {
-		dev_err(dev, "Failed to find pad for %s\n", subdev->name);
-		return ret;
-	}
-
-	priv->rxport.source.sd = subdev;
-	priv->rxport.source.pad = ret;
-
-	ret = media_create_pad_link(&priv->rxport.source.sd->entity,
-				    priv->rxport.source.pad, &priv->sd.entity,
-				    MAX96714_PAD_SINK,
-				    MEDIA_LNK_FL_ENABLED |
-				    MEDIA_LNK_FL_IMMUTABLE);
-	if (ret) {
-		dev_err(dev, "Unable to link %s:%u -> %s:%u\n",
-			priv->rxport.source.sd->name, priv->rxport.source.pad,
-			priv->sd.name, MAX96714_PAD_SINK);
-		return ret;
-	}
-
-	return 0;
-}
-
-static const struct v4l2_async_notifier_operations max96714_notify_ops = {
-	.bound = max96714_notify_bound,
-};
-
-static int max96714_v4l2_notifier_register(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	struct max96714_rxport *rxport = &priv->rxport;
-	struct v4l2_async_connection *asd;
-	int ret;
-
-	if (!rxport->source.ep_fwnode)
-		return 0;
-
-	v4l2_async_subdev_nf_init(&priv->notifier, &priv->sd);
-
-	asd = v4l2_async_nf_add_fwnode(&priv->notifier,
-				       rxport->source.ep_fwnode,
-				       struct v4l2_async_connection);
-	if (IS_ERR(asd)) {
-		dev_err(dev, "Failed to add subdev: %pe", asd);
-		v4l2_async_nf_cleanup(&priv->notifier);
-		return PTR_ERR(asd);
-	}
-
-	priv->notifier.ops = &max96714_notify_ops;
-
-	ret = v4l2_async_nf_register(&priv->notifier);
-	if (ret) {
-		dev_err(dev, "Failed to register subdev_notifier");
-		v4l2_async_nf_cleanup(&priv->notifier);
-		return ret;
-	}
-
-	return 0;
-}
-
-static int max96714_create_subdev(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	int ret;
-
-	v4l2_i2c_subdev_init(&priv->sd, priv->client, &max96714_subdev_ops);
-	priv->sd.internal_ops = &max96714_internal_ops;
-
-	v4l2_ctrl_handler_init(&priv->ctrl_handler, 1);
-	priv->sd.ctrl_handler = &priv->ctrl_handler;
-
-	v4l2_ctrl_new_int_menu(&priv->ctrl_handler, NULL, V4L2_CID_LINK_FREQ,
-			       0, 0, &priv->tx_link_freq);
-	v4l2_ctrl_new_std_menu_items(&priv->ctrl_handler,
-				     &max96714_ctrl_ops,
-				     V4L2_CID_TEST_PATTERN,
-				     ARRAY_SIZE(max96714_test_pattern) - 1,
-				     0, 0, max96714_test_pattern);
-	if (priv->ctrl_handler.error) {
-		ret = priv->ctrl_handler.error;
-		goto err_free_ctrl;
-	}
-
-	priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_STREAMS;
-	priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
-	priv->sd.entity.ops = &max96714_entity_ops;
-
-	priv->pads[MAX96714_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-	priv->pads[MAX96714_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-
-	ret = media_entity_pads_init(&priv->sd.entity,
-				     MAX96714_NPORTS,
-				     priv->pads);
-	if (ret)
-		goto err_free_ctrl;
-
-	priv->sd.state_lock = priv->sd.ctrl_handler->lock;
-
-	ret = v4l2_subdev_init_finalize(&priv->sd);
-	if (ret)
-		goto err_entity_cleanup;
-
-	ret = max96714_v4l2_notifier_register(priv);
-	if (ret) {
-		dev_err(dev, "v4l2 subdev notifier register failed: %d\n", ret);
-		goto err_subdev_cleanup;
-	}
-
-	ret = v4l2_async_register_subdev(&priv->sd);
-	if (ret) {
-		dev_err(dev, "v4l2_async_register_subdev error: %d\n", ret);
-		goto err_unreg_notif;
-	}
-
-	return 0;
-
-err_unreg_notif:
-	v4l2_async_nf_unregister(&priv->notifier);
-	v4l2_async_nf_cleanup(&priv->notifier);
-err_subdev_cleanup:
-	v4l2_subdev_cleanup(&priv->sd);
-err_entity_cleanup:
-	media_entity_cleanup(&priv->sd.entity);
-err_free_ctrl:
-	v4l2_ctrl_handler_free(&priv->ctrl_handler);
-
-	return ret;
-};
-
-static void max96714_destroy_subdev(struct max96714_priv *priv)
-{
-	v4l2_async_nf_unregister(&priv->notifier);
-	v4l2_async_nf_cleanup(&priv->notifier);
-	v4l2_async_unregister_subdev(&priv->sd);
-
-	v4l2_subdev_cleanup(&priv->sd);
-
-	media_entity_cleanup(&priv->sd.entity);
-	v4l2_ctrl_handler_free(&priv->ctrl_handler);
-}
-
-static int max96714_i2c_mux_select(struct i2c_mux_core *mux, u32 chan)
-{
-	return 0;
-}
-
-static int max96714_i2c_mux_init(struct max96714_priv *priv)
-{
-	priv->mux = i2c_mux_alloc(priv->client->adapter, &priv->client->dev,
-				  1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE,
-				  max96714_i2c_mux_select, NULL);
-	if (!priv->mux)
-		return -ENOMEM;
-
-	return i2c_mux_add_adapter(priv->mux, 0, 0);
-}
-
-static int max96714_init_tx_port(struct max96714_priv *priv)
-{
-	struct v4l2_mbus_config_mipi_csi2 *mipi;
-	unsigned long lanes_used = 0;
-	unsigned int val, lane;
-	int ret;
-
-	ret = max96714_disable_tx_port(priv);
-
-	mipi = &priv->mipi_csi2;
-	val = div_u64(priv->tx_link_freq * 2, MHZ(100));
-
-	cci_update_bits(priv->regmap, MAX96714_BACKTOP25,
-			CSI_DPLL_FREQ_MASK, val, &ret);
-
-	val = FIELD_PREP(MAX96714_CSI2_LANE_CNT_MASK, mipi->num_data_lanes - 1);
-	cci_update_bits(priv->regmap, MAX96714_MIPI_LANE_CNT,
-			MAX96714_CSI2_LANE_CNT_MASK, val, &ret);
-
-	/* lanes polarity */
-	val = 0;
-	for (lane = 0; lane < mipi->num_data_lanes + 1; lane++) {
-		if (!mipi->lane_polarities[lane])
-			continue;
-		if (lane == 0)
-			/* clock lane */
-			val |= BIT(5);
-		else if (lane < 3)
-			/* Lane D0 and D1 */
-			val |= BIT(lane - 1);
-		else
-			/* D2 and D3 */
-			val |= BIT(lane);
-	}
-
-	cci_update_bits(priv->regmap, MAX96714_MIPI_POLARITY,
-			MAX96714_MIPI_POLARITY_MASK, val, &ret);
-
-	/* lanes mapping */
-	val = 0;
-	for (lane = 0; lane < mipi->num_data_lanes; lane++) {
-		val |= (mipi->data_lanes[lane] - 1) << (lane * 2);
-		lanes_used |= BIT(mipi->data_lanes[lane] - 1);
-	}
-
-	/*
-	 * Unused lanes need to be mapped as well to not have
-	 * the same lanes mapped twice.
-	 */
-	for (; lane < MAX96714_CSI_NLANES; lane++) {
-		unsigned int idx = find_first_zero_bit(&lanes_used,
-						       MAX96714_CSI_NLANES);
-
-		val |= idx << (lane * 2);
-		lanes_used |= BIT(idx);
-	}
-
-	return cci_write(priv->regmap, MAX96714_MIPI_LANE_MAP, val, &ret);
-}
-
-static int max96714_rxport_enable_poc(struct max96714_priv *priv)
-{
-	struct max96714_rxport *rxport = &priv->rxport;
-
-	if (!rxport->poc)
-		return 0;
-
-	return regulator_enable(rxport->poc);
-}
-
-static int max96714_rxport_disable_poc(struct max96714_priv *priv)
-{
-	struct max96714_rxport *rxport = &priv->rxport;
-
-	if (!rxport->poc)
-		return 0;
-
-	return regulator_disable(rxport->poc);
-}
-
-static int max96714_parse_dt_txport(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_CSI2_DPHY };
-	struct fwnode_handle *ep_fwnode;
-	u32 num_data_lanes;
-	int ret;
-
-	ep_fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev),
-						    MAX96714_PAD_SOURCE, 0, 0);
-	if (!ep_fwnode)
-		return -EINVAL;
-
-	ret = v4l2_fwnode_endpoint_alloc_parse(ep_fwnode, &vep);
-	fwnode_handle_put(ep_fwnode);
-	if (ret) {
-		dev_err(dev, "tx: failed to parse endpoint data\n");
-		return -EINVAL;
-	}
-
-	if (vep.nr_of_link_frequencies != 1) {
-		ret = -EINVAL;
-		goto err_free_vep;
-	}
-
-	priv->tx_link_freq = vep.link_frequencies[0];
-	/* Min 50MHz, Max 1250MHz, 50MHz step */
-	if (priv->tx_link_freq < MHZ(50) || priv->tx_link_freq > MHZ(1250) ||
-	    (u32)priv->tx_link_freq % MHZ(50)) {
-		dev_err(dev, "tx: invalid link frequency\n");
-		ret = -EINVAL;
-		goto err_free_vep;
-	}
-
-	num_data_lanes = vep.bus.mipi_csi2.num_data_lanes;
-	if (num_data_lanes < 1 || num_data_lanes > MAX96714_CSI_NLANES) {
-		dev_err(dev,
-			"tx: invalid number of data lanes must be 1 to 4\n");
-		ret = -EINVAL;
-		goto err_free_vep;
-	}
-
-	priv->mipi_csi2 = vep.bus.mipi_csi2;
-
-err_free_vep:
-	v4l2_fwnode_endpoint_free(&vep);
-
-	return ret;
-}
-
-static int max96714_parse_dt_rxport(struct max96714_priv *priv)
-{
-	static const char *poc_name = "port0-poc";
-	struct max96714_rxport *rxport = &priv->rxport;
-	struct device *dev = &priv->client->dev;
-	struct fwnode_handle *ep_fwnode;
-	int ret;
-
-	ep_fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev),
-						    MAX96714_PAD_SINK, 0, 0);
-	if (!ep_fwnode)
-		return -ENOENT;
-
-	rxport->source.ep_fwnode = fwnode_graph_get_remote_endpoint(ep_fwnode);
-	fwnode_handle_put(ep_fwnode);
-
-	if (!rxport->source.ep_fwnode) {
-		dev_err(dev, "rx: no remote endpoint\n");
-		return -EINVAL;
-	}
-
-	rxport->poc = devm_regulator_get_optional(dev, poc_name);
-	if (IS_ERR(rxport->poc)) {
-		ret = PTR_ERR(rxport->poc);
-		if (ret == -ENODEV) {
-			rxport->poc = NULL;
-		} else {
-			dev_err(dev, "rx: failed to get POC supply: %d\n", ret);
-			goto err_put_source_ep_fwnode;
-		}
-	}
-
-	return 0;
-
-err_put_source_ep_fwnode:
-	fwnode_handle_put(rxport->source.ep_fwnode);
-	return ret;
-}
-
-static int max96714_parse_dt(struct max96714_priv *priv)
-{
-	int ret;
-
-	ret = max96714_parse_dt_txport(priv);
-	if (ret)
-		return ret;
-
-	ret = max96714_parse_dt_rxport(priv);
-	/*
-	 * The deserializer can create a test pattern even if the
-	 * rx port is not connected to a serializer.
-	 */
-	if (ret && ret == -ENOENT)
-		ret = 0;
-
-	return ret;
-}
-
-static int max96714_enable_core_hw(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-	u64 val;
-	int ret;
-
-	if (priv->pd_gpio) {
-		/* wait min 2 ms for reset to complete */
-		gpiod_set_value_cansleep(priv->pd_gpio, 1);
-		fsleep(2000);
-		gpiod_set_value_cansleep(priv->pd_gpio, 0);
-		/* wait min 2 ms for power up to finish */
-		fsleep(2000);
-	}
-
-	ret = cci_read(priv->regmap, MAX96714_REG13, &val, NULL);
-	if (ret) {
-		dev_err_probe(dev, ret, "Cannot read first register, abort\n");
-		goto err_pd_gpio;
-	}
-
-	if (val != MAX96714_DEVICE_ID && val != MAX96714F_DEVICE_ID) {
-		dev_err(dev, "Unsupported device id expected %x got %x\n",
-			MAX96714F_DEVICE_ID, (u8)val);
-		ret = -EOPNOTSUPP;
-		goto err_pd_gpio;
-	}
-
-	ret = cci_read(priv->regmap, MAX96714_DEV_REV, &val, NULL);
-	if (ret)
-		goto err_pd_gpio;
-
-	dev_dbg(dev, "Found %x (rev %lx)\n", MAX96714F_DEVICE_ID,
-		(u8)val & MAX96714_DEV_REV_MASK);
-
-	ret = cci_read(priv->regmap, MAX96714_MIPI_TX52, &val, NULL);
-	if (ret)
-		goto err_pd_gpio;
-
-	if (!(val & MAX96714_TUN_EN)) {
-		dev_err(dev, "Only supporting tunnel mode");
-		ret = -EOPNOTSUPP;
-		goto err_pd_gpio;
-	}
-
-	return 0;
-
-err_pd_gpio:
-	gpiod_set_value_cansleep(priv->pd_gpio, 1);
-	return ret;
-}
-
-static void max96714_disable_core_hw(struct max96714_priv *priv)
-{
-	gpiod_set_value_cansleep(priv->pd_gpio, 1);
-}
-
-static int max96714_get_hw_resources(struct max96714_priv *priv)
-{
-	struct device *dev = &priv->client->dev;
-
-	priv->regmap = devm_cci_regmap_init_i2c(priv->client, 16);
-	if (IS_ERR(priv->regmap))
-		return PTR_ERR(priv->regmap);
-
-	priv->pd_gpio =
-		devm_gpiod_get_optional(dev, "powerdown", GPIOD_OUT_HIGH);
-	if (IS_ERR(priv->pd_gpio))
-		return dev_err_probe(dev, PTR_ERR(priv->pd_gpio),
-				     "Cannot get powerdown GPIO\n");
-	return 0;
-}
-
-static int max96714_probe(struct i2c_client *client)
-{
-	struct device *dev = &client->dev;
-	struct max96714_priv *priv;
-	int ret;
-
-	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	priv->client = client;
-
-	ret = max96714_get_hw_resources(priv);
-	if (ret)
-		return ret;
-
-	ret = max96714_enable_core_hw(priv);
-	if (ret)
-		return ret;
-
-	ret = max96714_parse_dt(priv);
-	if (ret)
-		goto err_disable_core_hw;
-
-	max96714_init_tx_port(priv);
-
-	ret = max96714_rxport_enable_poc(priv);
-	if (ret)
-		goto err_free_ports;
-
-	ret = max96714_i2c_mux_init(priv);
-	if (ret)
-		goto err_disable_poc;
-
-	ret = max96714_create_subdev(priv);
-	if (ret)
-		goto err_del_mux;
-
-	return 0;
-
-err_del_mux:
-	i2c_mux_del_adapters(priv->mux);
-err_disable_poc:
-	max96714_rxport_disable_poc(priv);
-err_free_ports:
-	fwnode_handle_put(priv->rxport.source.ep_fwnode);
-err_disable_core_hw:
-	max96714_disable_core_hw(priv);
-
-	return ret;
-}
-
-static void max96714_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct max96714_priv *priv = sd_to_max96714(sd);
-
-	max96714_destroy_subdev(priv);
-	i2c_mux_del_adapters(priv->mux);
-	max96714_rxport_disable_poc(priv);
-	fwnode_handle_put(priv->rxport.source.ep_fwnode);
-	max96714_disable_core_hw(priv);
-	gpiod_set_value_cansleep(priv->pd_gpio, 1);
-}
-
-static const struct of_device_id max96714_of_ids[] = {
-	{ .compatible = "maxim,max96714f" },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, max96714_of_ids);
-
-static struct i2c_driver max96714_i2c_driver = {
-	.driver	= {
-		.name		= "max96714",
-		.of_match_table	= max96714_of_ids,
-	},
-	.probe		= max96714_probe,
-	.remove		= max96714_remove,
-};
-
-module_i2c_driver(max96714_i2c_driver);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Maxim Integrated GMSL2 Deserializers Driver");
-MODULE_AUTHOR("Julien Massot <julien.massot@collabora.com>");
-- 
2.48.1



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

* Re: [RFC PATCH v2 01/16] dt-bindings: media: i2c: max96717: add myself as maintainer
  2025-03-09  8:47 ` [RFC PATCH v2 01/16] dt-bindings: media: i2c: max96717: add myself as maintainer Cosmin Tanislav
@ 2025-03-11 18:06   ` Rob Herring (Arm)
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring (Arm) @ 2025-03-11 18:06 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Ross Burton, Tomi Valkeinen, Kieran Bingham,
	Mauro Carvalho Chehab, Dmitry Baryshkov, Eric Biggers,
	Sakari Ailus, Javier Carrasco, linux-kernel, Mark Brown,
	Laurent Pinchart, linux-arm-kernel, Zhi Mao, Hans Verkuil,
	Conor Dooley, Greg Kroah-Hartman, Dongcheng Yan, Will Deacon,
	Krzysztof Kozlowski, linux-media, Catalin Marinas,
	Niklas Söderlund, Bjorn Andersson, Arnd Bergmann,
	Dan Carpenter, Laurentiu Palcu, Benjamin Mugnier, Taniya Das,
	Ihor Matushchak, Linus Walleij, Geert Uytterhoeven, linux-staging,
	Bartosz Golaszewski, devicetree, Nícolas F . R . A . Prado,
	Julien Massot, Liam Girdwood, Tommaso Merciai,
	AngeloGioacchino Del Regno, Biju Das, linux-gpio, Cosmin Tanislav


On Sun, 09 Mar 2025 10:47:53 +0200, Cosmin Tanislav wrote:
> Analog Devices is taking responsability for the maintenance of the Maxim
> GMSL2/3 devices.
> Add myself to the maintainers list and to the device tree bindings.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml | 1 +
>  MAINTAINERS                                                     | 1 +
>  2 files changed, 2 insertions(+)
> 

Acked-by: Rob Herring (Arm) <robh@kernel.org>



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

* Re: [RFC PATCH v2 02/16] dt-bindings: media: i2c: max96717: reflow text
  2025-03-09  8:47 ` [RFC PATCH v2 02/16] dt-bindings: media: i2c: max96717: reflow text Cosmin Tanislav
@ 2025-03-11 18:09   ` Rob Herring
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring @ 2025-03-11 18:09 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Conor Dooley, Niklas Söderlund,
	Julien Massot, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Liam Girdwood, Mark Brown, Linus Walleij, Bartosz Golaszewski,
	Bjorn Andersson, Geert Uytterhoeven, Dmitry Baryshkov,
	Arnd Bergmann, Taniya Das, Biju Das,
	Nícolas F . R . A . Prado, Eric Biggers, Javier Carrasco,
	Ross Burton, Hans Verkuil, Sakari Ailus, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

On Sun, Mar 09, 2025 at 10:47:54AM +0200, Cosmin Tanislav wrote:
> This text is using weird line lengths. Fix it.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../bindings/media/i2c/maxim,max96717.yaml    | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> index 15ab37702a92..1026678a17a7 100644
> --- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> @@ -12,16 +12,15 @@ maintainers:
>    - Cosmin Tanislav <cosmin.tanislav@analog.com>
>  
>  description:

Use '>' token for multiple paragraphs.

> -  The MAX96717 serializer converts MIPI CSI-2 D-PHY formatted input
> -  into GMSL2 serial outputs. The device allows the GMSL2 link to
> -  simultaneously transmit bidirectional control-channel data while forward
> -  video transmissions are in progress. The MAX96717 can connect to one
> -  remotely located deserializer using industry-standard coax or STP
> -  interconnects. The device cans operate in pixel or tunnel mode. In pixel mode
> -  the MAX96717 can select the MIPI datatype, while the tunnel mode forward all the MIPI
> -  data received by the serializer.
> -  The MAX96717 supports Reference Over Reverse (channel),
> -  to generate a clock output for the sensor from the GMSL reverse channel.
> +  The MAX96717 serializer converts MIPI CSI-2 D-PHY formatted input into GMSL2
> +  serial outputs. The device allows the GMSL2 link to simultaneously transmit
> +  bidirectional control-channel data while forward video transmissions are in
> +  progress. The MAX96717 can connect to one remotely located deserializer using
> +  industry-standard coax or STP interconnects. The device cans operate in pixel
> +  or tunnel mode. In pixel mode the MAX96717 can select the MIPI datatype, while
> +  the tunnel mode forward all the MIPI data received by the serializer.

> +  The MAX96717 supports Reference Over Reverse (channel), to generate a clock
> +  output for the sensor from the GMSL reverse channel.

Is this a separate paragraph? If not, the wrapping is not right. If so, 
then needs a blank line in between.

>  
>    The GMSL2 serial link operates at a fixed rate of 3Gbps or 6Gbps in the
>    forward direction and 187.5Mbps in the reverse direction.
> -- 
> 2.48.1
> 


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

* Re: [RFC PATCH v2 03/16] dt-bindings: media: i2c: max96717: add support for I2C ATR
  2025-03-09  8:47 ` [RFC PATCH v2 03/16] dt-bindings: media: i2c: max96717: add support for I2C ATR Cosmin Tanislav
@ 2025-03-11 18:15   ` Rob Herring
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring @ 2025-03-11 18:15 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Conor Dooley, Niklas Söderlund,
	Julien Massot, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Liam Girdwood, Mark Brown, Linus Walleij, Bartosz Golaszewski,
	Bjorn Andersson, Geert Uytterhoeven, Dmitry Baryshkov,
	Arnd Bergmann, Taniya Das, Biju Das,
	Nícolas F . R . A . Prado, Eric Biggers, Javier Carrasco,
	Ross Burton, Hans Verkuil, Sakari Ailus, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

On Sun, Mar 09, 2025 at 10:47:55AM +0200, Cosmin Tanislav wrote:
> MAX96717 is capable of address translation for the connected I2C slaves.
> 
> Add support for I2C ATR while keeping I2C gate for compatibility to
> support this usecase.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../bindings/media/i2c/maxim,max96717.yaml    | 39 +++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> index 1026678a17a7..dd28cc397674 100644
> --- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> @@ -91,6 +91,30 @@ properties:
>        incoming GMSL2 link. Therefore, it supports an i2c-gate
>        subnode to configure a sensor.
>  
> +  i2c-alias-pool:
> +    maxItems: 2
> +
> +  i2c-atr:
> +    type: object
> +    additionalProperties: false
> +
> +    properties:
> +      '#address-cells':
> +        const: 1
> +
> +      '#size-cells':
> +        const: 0
> +
> +    patternProperties:
> +      '^i2c@0':

This allows "i2c@0anything-you-want". Based on reg, you want 
'^i2c@[01]$'.

 
> +        $ref: /schemas/i2c/i2c-controller.yaml#
> +        unevaluatedProperties: false
> +        properties:
> +          reg:
> +            items:
> +              minimum: 0
> +              maximum: 1
> +
>  required:
>    - compatible
>    - reg
> @@ -98,6 +122,21 @@ required:
>  
>  additionalProperties: false
>  
> +allOf:
> +  - $ref: /schemas/i2c/i2c-atr.yaml#
> +
> +  - anyOf:
> +      - oneOf:
> +          - required: [i2c-atr]
> +          - required: [i2c-gate]
> +
> +      - not:
> +          required: [i2c-atr, i2c-gate]
> +
> +dependentRequired:
> +  i2c-atr: [i2c-alias-pool]
> +  i2c-alias-pool: [i2c-atr]
> +
>  examples:
>    - |
>      #include <dt-bindings/gpio/gpio.h>
> -- 
> 2.48.1
> 



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

* Re: [RFC PATCH v2 04/16] dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf
  2025-03-09  8:47 ` [RFC PATCH v2 04/16] dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf Cosmin Tanislav
@ 2025-03-11 18:23   ` Rob Herring
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring @ 2025-03-11 18:23 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Conor Dooley, Niklas Söderlund,
	Julien Massot, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Liam Girdwood, Mark Brown, Linus Walleij, Bartosz Golaszewski,
	Bjorn Andersson, Geert Uytterhoeven, Dmitry Baryshkov,
	Arnd Bergmann, Taniya Das, Biju Das,
	Nícolas F . R . A . Prado, Eric Biggers, Javier Carrasco,
	Ross Burton, Hans Verkuil, Sakari Ailus, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

On Sun, Mar 09, 2025 at 10:47:56AM +0200, Cosmin Tanislav wrote:
> MAX96717 is capable of configuring various pin properties.
> 
> Add pinctrl/pinconf properties to support this usecase.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../media/i2c/maxim,max96717-pinctrl.yaml     | 71 +++++++++++++++++++
>  .../bindings/media/i2c/maxim,max96717.yaml    | 16 ++++-
>  MAINTAINERS                                   |  1 +
>  3 files changed, 87 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
> new file mode 100644
> index 000000000000..347e66a5320c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717-pinctrl.yaml
> @@ -0,0 +1,71 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +# Copyright (C) 2025 Analog Devices Inc.
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/media/i2c/maxim,max96717-pinctrl.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim GMSL2 Serializer Pinctrl
> +
> +maintainers:
> +  - Cosmin Tanislav <cosmin.tanislav@analog.com>
> +
> +allOf:
> +  - $ref: /schemas/pinctrl/pincfg-node.yaml#
> +  - $ref: /schemas/pinctrl/pinmux-node.yaml#
> +
> +unevaluatedProperties: false
> +
> +properties:
> +  function: true
> +  pins: true
> +  drive-open-drain: true
> +  drive-push-pull: true
> +  bias-disable: true
> +  bias-pull-up: true
> +  bias-pull-down: true
> +  output-disable: true
> +  output-enable: true
> +  output-low: true
> +  output-high: true
> +  slew-rate: true
> +  input-enable: true
> +
> +  maxim,jitter-compensation:
> +    type: boolean
> +    description: Enables jitter compensation.
> +
> +  maxim,gmsl-tx:
> +    type: boolean
> +    description: Enable transmitting pin value to GMSL link.
> +
> +  maxim,gmsl-rx:
> +    type: boolean
> +    description: Enable receiving pin value from GMSL link.
> +
> +  maxim,gmsl-tx-id:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      Identifier used while transmitting value to GMSL link.
> +      Default value matches the pin number.

Use normally wrapping or blank line between paragraphs.

> +    minimum: 0
> +    maximum: 31
> +
> +  maxim,gmsl-rx-id:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      Identifier used while receiving value from GMSL link.
> +      Default value matches the pin number.
> +    minimum: 0
> +    maximum: 31
> +
> +  maxim,rclkout-clock:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      Clock value.
> +      0 - XTAL / 1 = 25MHz
> +      1 - XTAL / 2 = 12.5MHz
> +      2 - XTAL / 4 = 6.25MHz
> +      3 - Reference PLL output
> +    minimum: 0
> +    maximum: 3
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> index dd28cc397674..0a43582168a8 100644
> --- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> @@ -120,7 +120,21 @@ required:
>    - reg
>    - ports
>  
> -additionalProperties: false
> +additionalProperties:
> +  anyOf:
> +    - type: object
> +      allOf:
> +        - $ref: /schemas/media/i2c/maxim,max96717-pinctrl.yaml#

You can drop the allOf here.

> +
> +      unevaluatedProperties: false
> +
> +    - type: object
> +      additionalProperties:
> +        type: object
> +        allOf:
> +          - $ref: /schemas/media/i2c/maxim,max96717-pinctrl.yaml#

And here.

> +
> +        unevaluatedProperties: false

Do you really need to support 2 forms?

This also allows the node names to be anything. We do that for existing 
cases, but for new ones you should define some prefix or suffix. 
Typically, '-pins$' is used.

Rob


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

* Re: [RFC PATCH v2 05/16] dt-bindings: media: i2c: max96717: add support for MAX9295A
  2025-03-09  8:47 ` [RFC PATCH v2 05/16] dt-bindings: media: i2c: max96717: add support for MAX9295A Cosmin Tanislav
@ 2025-03-11 18:28   ` Rob Herring
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring @ 2025-03-11 18:28 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Conor Dooley, Niklas Söderlund,
	Julien Massot, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Liam Girdwood, Mark Brown, Linus Walleij, Bartosz Golaszewski,
	Bjorn Andersson, Geert Uytterhoeven, Dmitry Baryshkov,
	Arnd Bergmann, Taniya Das, Biju Das,
	Nícolas F . R . A . Prado, Eric Biggers, Javier Carrasco,
	Ross Burton, Hans Verkuil, Sakari Ailus, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

On Sun, Mar 09, 2025 at 10:47:57AM +0200, Cosmin Tanislav wrote:
> MAX9295A is an older variant of the MAX96717 which does not support
> tunnel mode.
> 
> Document the compatibility.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../devicetree/bindings/media/i2c/maxim,max96717.yaml          | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> index 0a43582168a8..31fb62debdc7 100644
> --- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> @@ -24,11 +24,14 @@ description:
>  
>    The GMSL2 serial link operates at a fixed rate of 3Gbps or 6Gbps in the
>    forward direction and 187.5Mbps in the reverse direction.
> +
>    MAX96717F only supports a fixed rate of 3Gbps in the forward direction.
> +  MAX9295A only supports pixel mode.
>  
>  properties:
>    compatible:
>      oneOf:
> +      - const: maxim,max9295a
>        - const: maxim,max96717f

Make these 2 a single 'enum'.

>        - items:
>            - enum:
> -- 
> 2.48.1
> 


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

* Re: [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793
  2025-03-09  8:47 ` [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793 Cosmin Tanislav
@ 2025-03-11 18:30   ` Rob Herring (Arm)
  2025-03-13 12:25   ` Sakari Ailus
  1 sibling, 0 replies; 39+ messages in thread
From: Rob Herring (Arm) @ 2025-03-11 18:30 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Mark Brown, Catalin Marinas, Ihor Matushchak, linux-kernel,
	linux-media, Eric Biggers, Tomi Valkeinen, Bjorn Andersson,
	Nícolas F . R . A . Prado, Laurentiu Palcu, Cosmin Tanislav,
	Linus Walleij, linux-arm-kernel, Hans Verkuil, Greg Kroah-Hartman,
	Conor Dooley, Laurent Pinchart, Taniya Das, Dongcheng Yan,
	Mauro Carvalho Chehab, Tommaso Merciai,
	AngeloGioacchino Del Regno, Krzysztof Kozlowski,
	Bartosz Golaszewski, devicetree, Julien Massot, Kieran Bingham,
	Liam Girdwood, Ross Burton, Geert Uytterhoeven,
	Niklas Söderlund, Dmitry Baryshkov, Will Deacon, Zhi Mao,
	linux-gpio, Benjamin Mugnier, Biju Das, Sakari Ailus,
	Arnd Bergmann, Javier Carrasco, Dan Carpenter, linux-staging


On Sun, 09 Mar 2025 10:47:58 +0200, Cosmin Tanislav wrote:
> MAX96793 is a newer variant of the MAX96717 which also supports GMSL3
> links.
> 
> Document this compatibility.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml | 2 ++
>  1 file changed, 2 insertions(+)
> 

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>



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

* Re: [RFC PATCH v2 07/16] dt-bindings: media: i2c: max96712: add myself as maintainer
  2025-03-09  8:47 ` [RFC PATCH v2 07/16] dt-bindings: media: i2c: max96712: add myself as maintainer Cosmin Tanislav
@ 2025-03-11 18:54   ` Rob Herring (Arm)
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring (Arm) @ 2025-03-11 18:54 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Benjamin Mugnier, Dan Carpenter, linux-staging, Dmitry Baryshkov,
	Javier Carrasco, Linus Walleij, Biju Das, devicetree,
	Liam Girdwood, Zhi Mao, Julien Massot, Sakari Ailus, Ross Burton,
	Dongcheng Yan, Nícolas F . R . A . Prado,
	Krzysztof Kozlowski, Tomi Valkeinen, Tommaso Merciai,
	Arnd Bergmann, Ihor Matushchak, AngeloGioacchino Del Regno,
	Hans Verkuil, Taniya Das, linux-arm-kernel, Laurent Pinchart,
	Laurentiu Palcu, Mark Brown, linux-gpio, linux-kernel,
	Eric Biggers, Catalin Marinas, Mauro Carvalho Chehab, linux-media,
	Bartosz Golaszewski, Kieran Bingham, Niklas Söderlund,
	Greg Kroah-Hartman, Bjorn Andersson, Conor Dooley,
	Geert Uytterhoeven, Will Deacon, Cosmin Tanislav


On Sun, 09 Mar 2025 10:47:59 +0200, Cosmin Tanislav wrote:
> Analog Devices is taking responsability for the maintenance of the Maxim
> GMSL2/3 devices.
> Add myself to the maintainers list and to the device tree bindings.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml | 1 +
>  MAINTAINERS                                                     | 1 +
>  2 files changed, 2 insertions(+)
> 

Acked-by: Rob Herring (Arm) <robh@kernel.org>



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

* Re: [RFC PATCH v2 08/16] dt-bindings: media: i2c: max96712: use pattern properties for ports
  2025-03-09  8:48 ` [RFC PATCH v2 08/16] dt-bindings: media: i2c: max96712: use pattern properties for ports Cosmin Tanislav
@ 2025-03-11 19:00   ` Rob Herring
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring @ 2025-03-11 19:00 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Conor Dooley, Niklas Söderlund,
	Julien Massot, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Liam Girdwood, Mark Brown, Linus Walleij, Bartosz Golaszewski,
	Bjorn Andersson, Geert Uytterhoeven, Dmitry Baryshkov,
	Arnd Bergmann, Taniya Das, Biju Das,
	Nícolas F . R . A . Prado, Eric Biggers, Javier Carrasco,
	Ross Burton, Hans Verkuil, Sakari Ailus, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

On Sun, Mar 09, 2025 at 10:48:00AM +0200, Cosmin Tanislav wrote:
> The MAX96712 and MAX96724 support up to 4 separate PHYs, depending on
> the selected PHY configuration. Use patternProperties to document this.
> 
> The input ports are all the same, use patternProperties for them.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../bindings/media/i2c/maxim,max96712.yaml    | 29 +++++++------------
>  1 file changed, 10 insertions(+), 19 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
> index efdece2b33b9..bf8c861c836b 100644
> --- a/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96712.yaml
> @@ -40,27 +40,15 @@ properties:
>    ports:
>      $ref: /schemas/graph.yaml#/properties/ports
>  
> -    properties:
> -      port@0:
> +    patternProperties:
> +      '^port@[0-3]$':
>          $ref: /schemas/graph.yaml#/properties/port
> -        description: GMSL Input 0
> +        description: GMSL Input port

GMSL Inputs 0-3

Though generally every port needs to be documented. So really, this was 
correct before.

>  
> -      port@1:
> -        $ref: /schemas/graph.yaml#/properties/port
> -        description: GMSL Input 1
> -
> -      port@2:
> -        $ref: /schemas/graph.yaml#/properties/port
> -        description: GMSL Input 2
> -
> -      port@3:
> -        $ref: /schemas/graph.yaml#/properties/port
> -        description: GMSL Input 3
> -
> -      port@4:
> +      '^port@[4-7]$':
>          $ref: /schemas/graph.yaml#/$defs/port-base
>          unevaluatedProperties: false
> -        description: CSI-2 Output
> +        description: CSI-2 Output port

The input port numbers are 1:1 with Input numbering. I imagine that's 
not the case here, so the relationship of port #s to outputs needs to be 
documented.

>  
>          properties:
>            endpoint:
> @@ -78,8 +66,11 @@ properties:
>                - data-lanes
>                - bus-type
>  
> -    required:
> -      - port@4
> +    anyOf:
> +      - required: [port@4]
> +      - required: [port@5]
> +      - required: [port@6]
> +      - required: [port@7]
>  
>  required:
>    - compatible
> -- 
> 2.48.1
> 


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

* Re: [RFC PATCH v2 09/16] dt-bindings: media: i2c: max96712: add support for I2C MUX
  2025-03-09  8:48 ` [RFC PATCH v2 09/16] dt-bindings: media: i2c: max96712: add support for I2C MUX Cosmin Tanislav
@ 2025-03-11 19:01   ` Rob Herring (Arm)
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring (Arm) @ 2025-03-11 19:01 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Ross Burton, Julien Massot, Benjamin Mugnier, Dan Carpenter,
	Conor Dooley, Nícolas F . R . A . Prado, Laurentiu Palcu,
	linux-gpio, Bartosz Golaszewski, Eric Biggers,
	AngeloGioacchino Del Regno, Mauro Carvalho Chehab, Kieran Bingham,
	Geert Uytterhoeven, Greg Kroah-Hartman, Arnd Bergmann,
	Liam Girdwood, linux-media, Will Deacon, Javier Carrasco,
	linux-staging, Krzysztof Kozlowski, Laurent Pinchart,
	Niklas Söderlund, Sakari Ailus, linux-arm-kernel,
	Catalin Marinas, Hans Verkuil, Taniya Das, Mark Brown,
	Tomi Valkeinen, Tommaso Merciai, Linus Walleij, Cosmin Tanislav,
	Biju Das, Bjorn Andersson, Zhi Mao, Ihor Matushchak,
	Dongcheng Yan, linux-kernel, devicetree, Dmitry Baryshkov


On Sun, 09 Mar 2025 10:48:01 +0200, Cosmin Tanislav wrote:
> MAX96712 and MAX96724 have more than one GMSL2 link, and each link is
> capable of connecting to a separate serializer. If these serializers
> have the same CFG pins configuration, they will also have the same I2C
> address, causing conflicts unless the deserializer muxes the I2C
> channels. Moreover, the serializers can have the same hardware attached
> to their respective I2C bus.
> 
> The MAX96712 and MAX96724 suppot I2C channel muxing via the GMSL2 link
> to facilitate communication to each of the connected serializers.
> 
> Document this capability.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../bindings/media/i2c/maxim,max96712.yaml          | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>



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

* Re: [RFC PATCH v2 10/16] dt-bindings: media: i2c: max96712: add support for POC supplies
  2025-03-09  8:48 ` [RFC PATCH v2 10/16] dt-bindings: media: i2c: max96712: add support for POC supplies Cosmin Tanislav
@ 2025-03-11 19:02   ` Rob Herring (Arm)
  0 siblings, 0 replies; 39+ messages in thread
From: Rob Herring (Arm) @ 2025-03-11 19:02 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Nícolas F . R . A . Prado, linux-kernel, Greg Kroah-Hartman,
	devicetree, Arnd Bergmann, Taniya Das, Cosmin Tanislav,
	Dmitry Baryshkov, linux-media, Krzysztof Kozlowski, Eric Biggers,
	Ihor Matushchak, Laurentiu Palcu, Will Deacon, Dan Carpenter,
	Conor Dooley, Bartosz Golaszewski, linux-staging, linux-gpio,
	Mark Brown, Dongcheng Yan, Geert Uytterhoeven, Liam Girdwood,
	linux-arm-kernel, AngeloGioacchino Del Regno, Tommaso Merciai,
	Bjorn Andersson, Ross Burton, Kieran Bingham, Tomi Valkeinen,
	Julien Massot, Hans Verkuil, Zhi Mao, Niklas Söderlund,
	Benjamin Mugnier, Catalin Marinas, Linus Walleij, Sakari Ailus,
	Mauro Carvalho Chehab, Javier Carrasco, Laurent Pinchart,
	Biju Das


On Sun, 09 Mar 2025 10:48:02 +0200, Cosmin Tanislav wrote:
> The GMSL links can carry power to the serializer when using coaxial
> cables.
> 
> Document this capability.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../devicetree/bindings/media/i2c/maxim,max96712.yaml         | 4 ++++
>  1 file changed, 4 insertions(+)
> 

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>



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

* Re: [RFC PATCH v2 11/16] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A
  2025-03-09  8:48 ` [RFC PATCH v2 11/16] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A Cosmin Tanislav
@ 2025-03-11 19:07   ` Rob Herring
  2025-03-11 22:26     ` Cosmin Tanislav
  0 siblings, 1 reply; 39+ messages in thread
From: Rob Herring @ 2025-03-11 19:07 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Conor Dooley, Niklas Söderlund,
	Julien Massot, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Liam Girdwood, Mark Brown, Linus Walleij, Bartosz Golaszewski,
	Bjorn Andersson, Geert Uytterhoeven, Dmitry Baryshkov,
	Arnd Bergmann, Taniya Das, Biju Das,
	Nícolas F . R . A . Prado, Eric Biggers, Javier Carrasco,
	Ross Burton, Hans Verkuil, Sakari Ailus, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

On Sun, Mar 09, 2025 at 10:48:03AM +0200, Cosmin Tanislav wrote:
> The MAX9296A deserializer converts single or dual serial inputs to MIPI
> CSI-2 outputs. The GMSL2 links operate at a fixed rate of 3Gbps or 6Gbps
> in the forward direction and 187.5Mbps in the reverse direction.
> In GMSL1 mode, each serial link can be paired with 3.12Gbps or 1.5Gbps
> GMSL1 serializers or operate up to 4.5Gbps with GMSL2 serializers with
> GMSL1 backward compatibility. The MAX9296A supports mixed GMSL2 and
> GMSL1 links. The serial inputs operate independently, allowing videos
> with different timings and resolutions to be received on each input.
> 
> MAX96716A supports both tunnel and pixel mode.
> MAX96792A supports both tunnel and pixel mode, and has two GMSL3 links.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  .../bindings/media/i2c/maxim,max9296a.yaml    | 281 ++++++++++++++++++
>  MAINTAINERS                                   |   6 +
>  2 files changed, 287 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
> new file mode 100644
> index 000000000000..97731549d161
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
> @@ -0,0 +1,281 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +# Copyright (C) 2024 Collabora Ltd.
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/media/i2c/maxim,max9296a.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim MAX9296A GMSL2 to CSI-2 Deserializer
> +
> +maintainers:
> +  - Cosmin Tanislav <cosmin.tanislav@analog.com>
> +
> +description:

Needs '>' token as you have paragraphs.

> +  The MAX9296A deserializer converts single or dual serial inputs to
> +  MIPI CSI-2 outputs. The GMSL2 links operate at a fixed rate of 3Gbps
> +  or 6Gbps in the forward direction and 187.5Mbps in the reverse
> +  direction. In GMSL1 mode, each serial link can be paired with 3.12Gbps
> +  or 1.5Gbps GMSL1 serializers or operate up to 4.5Gbps with GMSL2
> +  serializers with GMSL1 backward compatibility. The MAX9296A supports
> +  mixed GMSL2 and GMSL1 links. The serial inputs operate independently,
> +  allowing videos with different timings and resolutions to be received
> +  on each input.
> +
> +  MAX96716A supports both tunnel and pixel mode.
> +  MAX96792A supports both tunnel and pixel mode, and has two GMSL3 links.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - maxim,max9296a
> +      - maxim,max96716a
> +      - maxim,max96792a
> +
> +  reg:
> +    maxItems: 1
> +
> +  powerdown-gpios:
> +    maxItems: 1
> +    description: Specifier for the GPIO connected to the PWDNB pin.
> +
> +  port0-poc-supply:
> +    description: Regulator providing Power over Coax for GMSL port 0
> +
> +  port1-poc-supply:
> +    description: Regulator providing Power over Coax for GMSL port 1
> +
> +  i2c-mux:
> +    $ref: /schemas/i2c/i2c-mux.yaml#
> +    unevaluatedProperties: false
> +    patternProperties:
> +      '^i2c@[0-1]$':
> +        $ref: /schemas/i2c/i2c-controller.yaml#
> +        unevaluatedProperties: false
> +        properties:
> +          reg:
> +            items:
> +              minimum: 0
> +              maximum: 1
> +
> +  i2c-alias-pool:
> +    maxItems: 2
> +
> +  i2c-atr:
> +    type: object
> +    additionalProperties: false
> +
> +    properties:
> +      '#address-cells':
> +        const: 1
> +
> +      '#size-cells':
> +        const: 0
> +
> +    patternProperties:
> +      '^i2c@[0-1]$':
> +        $ref: /schemas/i2c/i2c-controller.yaml#
> +        unevaluatedProperties: false
> +        properties:
> +          reg:
> +            items:
> +              minimum: 0
> +              maximum: 1
> +
> +  ports:
> +    $ref: /schemas/graph.yaml#/properties/ports
> +
> +    patternProperties:
> +      '^port@[0-1]$':
> +        $ref: /schemas/graph.yaml#/properties/port
> +        unevaluatedProperties: false
> +        description: GMSL Input
> +        properties:
> +          endpoint:
> +            $ref: /schemas/media/video-interfaces.yaml#

What properties are you using from here?

None actually because /schemas/graph.yaml#/properties/port won't allow 
any.


> +            unevaluatedProperties: false
> +            description: Endpoint for GMSL2-Link port.
> +
> +      '^port@[2-3]$':
> +        $ref: /schemas/graph.yaml#/$defs/port-base
> +        unevaluatedProperties: false
> +        description: CSI-2 Output port
> +        properties:
> +          endpoint:
> +            $ref: /schemas/media/video-interfaces.yaml#
> +            unevaluatedProperties: false
> +
> +            properties:
> +              data-lanes:
> +                minItems: 1
> +                maxItems: 4
> +
> +              lane-polarities:
> +                minItems: 1
> +                maxItems: 5
> +
> +              link-frequencies:
> +                maxItems: 1
> +
> +            required:
> +              - data-lanes
> +
> +    anyOf:
> +      - required:
> +          - port@2
> +      - required:
> +          - port@3
> +
> +required:
> +  - compatible
> +  - reg
> +  - ports
> +
> +additionalProperties: false
> +
> +allOf:
> +  - $ref: /schemas/i2c/i2c-atr.yaml#
> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            enum:
> +              - maxim,max9296a
> +              - maxim,max96792a
> +    then:
> +      not:
> +        required: [i2c-mux]
> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            enum:
> +              - maxim,max96716a
> +    then:
> +      not:
> +        required: [i2c-atr]
> +
> +dependentRequired:
> +  i2c-atr: [i2c-alias-pool]
> +  i2c-alias-pool: [i2c-atr]
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +    #include <dt-bindings/media/video-interfaces.h>
> +
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        deserializer@28 {
> +            compatible = "maxim,max9296a";
> +            reg = <0x28>;
> +            powerdown-gpios = <&main_gpio0 37 GPIO_ACTIVE_LOW>;
> +
> +            i2c-alias-pool = <0x40 0x41>;
> +
> +            ports {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +
> +                port@0 {
> +                    reg = <0>;
> +                    des_gmsl_in_0: endpoint {
> +                        remote-endpoint = <&ser_0_gmsl_out>;
> +                    };
> +                };
> +
> +                port@1 {
> +                    reg = <1>;
> +                    des_gmsl_in_1: endpoint {
> +                        remote-endpoint = <&ser_1_gmsl_out>;
> +                    };
> +                };
> +
> +                port@2 {
> +                    reg = <2>;
> +                    des_csi_out: endpoint {
> +                        data-lanes = <1 2 3 4>;
> +                        link-frequencies = /bits/ 64 <400000000>;
> +                        remote-endpoint = <&csi_in>;
> +                    };
> +                };
> +            };
> +
> +            i2c-atr {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +
> +                i2c@0 {
> +                    #address-cells = <1>;
> +                    #size-cells = <0>;
> +                    reg = <0>;
> +
> +                    serializer@40 {
> +                        compatible = "maxim,max96717";
> +                        reg = <0x40>;
> +                        gpio-controller;
> +                        #gpio-cells = <2>;
> +                        #clock-cells = <0>;
> +
> +                        ports {
> +                            #address-cells = <1>;
> +                            #size-cells = <0>;
> +
> +                            port@0 {
> +                                reg = <0>;
> +                                ser_0_csi_in: endpoint {
> +                                    data-lanes = <1 2>;
> +                                    remote-endpoint = <&sensor_0_out>;
> +                                };
> +                            };
> +
> +                            port@1 {
> +                                reg = <1>;
> +                                ser_0_gmsl_out: endpoint {
> +                                    remote-endpoint = <&des_gmsl_in_0>;
> +                                };
> +                            };
> +                        };
> +                    };
> +                };
> +
> +                i2c@1 {
> +                    #address-cells = <1>;
> +                    #size-cells = <0>;
> +                    reg = <1>;
> +
> +                    serializer@40 {
> +                        compatible = "maxim,max96717";
> +                        reg = <0x40>;
> +                        gpio-controller;
> +                        #gpio-cells = <2>;
> +                        #clock-cells = <0>;
> +
> +                        ports {
> +                            #address-cells = <1>;
> +                            #size-cells = <0>;
> +
> +                            port@0 {
> +                                reg = <0>;
> +                                ser_1_csi_in: endpoint {
> +                                    data-lanes = <1 2>;
> +                                    remote-endpoint = <&sensor_1_out>;
> +                                };
> +                            };
> +
> +                            port@1 {
> +                                reg = <1>;
> +                                ser_1_gmsl_out: endpoint {
> +                                    remote-endpoint = <&des_gmsl_in_1>;
> +                                };
> +                            };
> +                        };
> +                    };
> +                };
> +            };
> +        };
> +    };
> +...
> diff --git a/MAINTAINERS b/MAINTAINERS
> index abf3afc95fc9..c1e01668e81a 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -14220,6 +14220,12 @@ S:	Maintained
>  F:	Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.yaml
>  F:	drivers/iio/proximity/mb1232.c
>  
> +MAXIM GMSL2 SERIALIZERS AND DESERIALIZERS
> +M:	Cosmin Tanislav <cosmin.tanislav@analog.com>
> +L:	linux-media@vger.kernel.org
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
> +
>  MAXIM MAX11205 DRIVER
>  M:	Ramona Bolboaca <ramona.bolboaca@analog.com>
>  L:	linux-iio@vger.kernel.org
> -- 
> 2.48.1
> 


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

* Re: [RFC PATCH v2 11/16] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A
  2025-03-11 19:07   ` Rob Herring
@ 2025-03-11 22:26     ` Cosmin Tanislav
  0 siblings, 0 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-03-11 22:26 UTC (permalink / raw)
  To: Rob Herring
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Conor Dooley, Niklas Söderlund,
	Julien Massot, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Liam Girdwood, Mark Brown, Linus Walleij, Bartosz Golaszewski,
	Bjorn Andersson, Geert Uytterhoeven, Dmitry Baryshkov,
	Arnd Bergmann, Taniya Das, Biju Das,
	Nícolas F . R . A . Prado, Eric Biggers, Javier Carrasco,
	Ross Burton, Hans Verkuil, Sakari Ailus, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio



On 3/11/25 9:07 PM, Rob Herring wrote:
> On Sun, Mar 09, 2025 at 10:48:03AM +0200, Cosmin Tanislav wrote:
>> The MAX9296A deserializer converts single or dual serial inputs to MIPI
>> CSI-2 outputs. The GMSL2 links operate at a fixed rate of 3Gbps or 6Gbps
>> in the forward direction and 187.5Mbps in the reverse direction.
>> In GMSL1 mode, each serial link can be paired with 3.12Gbps or 1.5Gbps
>> GMSL1 serializers or operate up to 4.5Gbps with GMSL2 serializers with
>> GMSL1 backward compatibility. The MAX9296A supports mixed GMSL2 and
>> GMSL1 links. The serial inputs operate independently, allowing videos
>> with different timings and resolutions to be received on each input.
>>
>> MAX96716A supports both tunnel and pixel mode.
>> MAX96792A supports both tunnel and pixel mode, and has two GMSL3 links.
>>
>> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
>> ---
>>   .../bindings/media/i2c/maxim,max9296a.yaml    | 281 ++++++++++++++++++
>>   MAINTAINERS                                   |   6 +
>>   2 files changed, 287 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
>> new file mode 100644
>> index 000000000000..97731549d161
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
>> @@ -0,0 +1,281 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +# Copyright (C) 2024 Collabora Ltd.
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/media/i2c/maxim,max9296a.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Maxim MAX9296A GMSL2 to CSI-2 Deserializer
>> +
>> +maintainers:
>> +  - Cosmin Tanislav <cosmin.tanislav@analog.com>
>> +
>> +description:
> 
> Needs '>' token as you have paragraphs.
> 
>> +  The MAX9296A deserializer converts single or dual serial inputs to
>> +  MIPI CSI-2 outputs. The GMSL2 links operate at a fixed rate of 3Gbps
>> +  or 6Gbps in the forward direction and 187.5Mbps in the reverse
>> +  direction. In GMSL1 mode, each serial link can be paired with 3.12Gbps
>> +  or 1.5Gbps GMSL1 serializers or operate up to 4.5Gbps with GMSL2
>> +  serializers with GMSL1 backward compatibility. The MAX9296A supports
>> +  mixed GMSL2 and GMSL1 links. The serial inputs operate independently,
>> +  allowing videos with different timings and resolutions to be received
>> +  on each input.
>> +
>> +  MAX96716A supports both tunnel and pixel mode.
>> +  MAX96792A supports both tunnel and pixel mode, and has two GMSL3 links.
>> +
>> +properties:
>> +  compatible:
>> +    enum:
>> +      - maxim,max9296a
>> +      - maxim,max96716a
>> +      - maxim,max96792a
>> +
>> +  reg:
>> +    maxItems: 1
>> +
>> +  powerdown-gpios:
>> +    maxItems: 1
>> +    description: Specifier for the GPIO connected to the PWDNB pin.
>> +
>> +  port0-poc-supply:
>> +    description: Regulator providing Power over Coax for GMSL port 0
>> +
>> +  port1-poc-supply:
>> +    description: Regulator providing Power over Coax for GMSL port 1
>> +
>> +  i2c-mux:
>> +    $ref: /schemas/i2c/i2c-mux.yaml#
>> +    unevaluatedProperties: false
>> +    patternProperties:
>> +      '^i2c@[0-1]$':
>> +        $ref: /schemas/i2c/i2c-controller.yaml#
>> +        unevaluatedProperties: false
>> +        properties:
>> +          reg:
>> +            items:
>> +              minimum: 0
>> +              maximum: 1
>> +
>> +  i2c-alias-pool:
>> +    maxItems: 2
>> +
>> +  i2c-atr:
>> +    type: object
>> +    additionalProperties: false
>> +
>> +    properties:
>> +      '#address-cells':
>> +        const: 1
>> +
>> +      '#size-cells':
>> +        const: 0
>> +
>> +    patternProperties:
>> +      '^i2c@[0-1]$':
>> +        $ref: /schemas/i2c/i2c-controller.yaml#
>> +        unevaluatedProperties: false
>> +        properties:
>> +          reg:
>> +            items:
>> +              minimum: 0
>> +              maximum: 1
>> +
>> +  ports:
>> +    $ref: /schemas/graph.yaml#/properties/ports
>> +
>> +    patternProperties:
>> +      '^port@[0-1]$':
>> +        $ref: /schemas/graph.yaml#/properties/port
>> +        unevaluatedProperties: false
>> +        description: GMSL Input
>> +        properties:
>> +          endpoint:
>> +            $ref: /schemas/media/video-interfaces.yaml#
> 
> What properties are you using from here?
> 
> None actually because /schemas/graph.yaml#/properties/port won't allow
> any.
> 

So these lines should be removed.

         unevaluatedProperties: false
         properties:
           endpoint:
             $ref: /schemas/media/video-interfaces.yaml#
             unevaluatedProperties: false
             description:
               Endpoint for GMSL2-Link port.

Should I submit patches to do the same for the maxim,max96714.yaml file?

I basically copied these bindings from there and adapted them, and those
bindings seem to have the same issue.

> 
>> +            unevaluatedProperties: false
>> +            description: Endpoint for GMSL2-Link port.
>> +
>> +      '^port@[2-3]$':
>> +        $ref: /schemas/graph.yaml#/$defs/port-base
>> +        unevaluatedProperties: false
>> +        description: CSI-2 Output port
>> +        properties:
>> +          endpoint:
>> +            $ref: /schemas/media/video-interfaces.yaml#
>> +            unevaluatedProperties: false
>> +
>> +            properties:
>> +              data-lanes:
>> +                minItems: 1
>> +                maxItems: 4
>> +
>> +              lane-polarities:
>> +                minItems: 1
>> +                maxItems: 5
>> +
>> +              link-frequencies:
>> +                maxItems: 1
>> +
>> +            required:
>> +              - data-lanes
>> +
>> +    anyOf:
>> +      - required:
>> +          - port@2
>> +      - required:
>> +          - port@3
>> +
>> +required:
>> +  - compatible
>> +  - reg
>> +  - ports
>> +
>> +additionalProperties: false
>> +
>> +allOf:
>> +  - $ref: /schemas/i2c/i2c-atr.yaml#
>> +
>> +  - if:
>> +      properties:
>> +        compatible:
>> +          contains:
>> +            enum:
>> +              - maxim,max9296a
>> +              - maxim,max96792a
>> +    then:
>> +      not:
>> +        required: [i2c-mux]
>> +
>> +  - if:
>> +      properties:
>> +        compatible:
>> +          contains:
>> +            enum:
>> +              - maxim,max96716a
>> +    then:
>> +      not:
>> +        required: [i2c-atr]
>> +
>> +dependentRequired:
>> +  i2c-atr: [i2c-alias-pool]
>> +  i2c-alias-pool: [i2c-atr]
>> +
>> +examples:
>> +  - |
>> +    #include <dt-bindings/gpio/gpio.h>
>> +    #include <dt-bindings/media/video-interfaces.h>
>> +
>> +    i2c {
>> +        #address-cells = <1>;
>> +        #size-cells = <0>;
>> +
>> +        deserializer@28 {
>> +            compatible = "maxim,max9296a";
>> +            reg = <0x28>;
>> +            powerdown-gpios = <&main_gpio0 37 GPIO_ACTIVE_LOW>;
>> +
>> +            i2c-alias-pool = <0x40 0x41>;
>> +
>> +            ports {
>> +                #address-cells = <1>;
>> +                #size-cells = <0>;
>> +
>> +                port@0 {
>> +                    reg = <0>;
>> +                    des_gmsl_in_0: endpoint {
>> +                        remote-endpoint = <&ser_0_gmsl_out>;
>> +                    };
>> +                };
>> +
>> +                port@1 {
>> +                    reg = <1>;
>> +                    des_gmsl_in_1: endpoint {
>> +                        remote-endpoint = <&ser_1_gmsl_out>;
>> +                    };
>> +                };
>> +
>> +                port@2 {
>> +                    reg = <2>;
>> +                    des_csi_out: endpoint {
>> +                        data-lanes = <1 2 3 4>;
>> +                        link-frequencies = /bits/ 64 <400000000>;
>> +                        remote-endpoint = <&csi_in>;
>> +                    };
>> +                };
>> +            };
>> +
>> +            i2c-atr {
>> +                #address-cells = <1>;
>> +                #size-cells = <0>;
>> +
>> +                i2c@0 {
>> +                    #address-cells = <1>;
>> +                    #size-cells = <0>;
>> +                    reg = <0>;
>> +
>> +                    serializer@40 {
>> +                        compatible = "maxim,max96717";
>> +                        reg = <0x40>;
>> +                        gpio-controller;
>> +                        #gpio-cells = <2>;
>> +                        #clock-cells = <0>;
>> +
>> +                        ports {
>> +                            #address-cells = <1>;
>> +                            #size-cells = <0>;
>> +
>> +                            port@0 {
>> +                                reg = <0>;
>> +                                ser_0_csi_in: endpoint {
>> +                                    data-lanes = <1 2>;
>> +                                    remote-endpoint = <&sensor_0_out>;
>> +                                };
>> +                            };
>> +
>> +                            port@1 {
>> +                                reg = <1>;
>> +                                ser_0_gmsl_out: endpoint {
>> +                                    remote-endpoint = <&des_gmsl_in_0>;
>> +                                };
>> +                            };
>> +                        };
>> +                    };
>> +                };
>> +
>> +                i2c@1 {
>> +                    #address-cells = <1>;
>> +                    #size-cells = <0>;
>> +                    reg = <1>;
>> +
>> +                    serializer@40 {
>> +                        compatible = "maxim,max96717";
>> +                        reg = <0x40>;
>> +                        gpio-controller;
>> +                        #gpio-cells = <2>;
>> +                        #clock-cells = <0>;
>> +
>> +                        ports {
>> +                            #address-cells = <1>;
>> +                            #size-cells = <0>;
>> +
>> +                            port@0 {
>> +                                reg = <0>;
>> +                                ser_1_csi_in: endpoint {
>> +                                    data-lanes = <1 2>;
>> +                                    remote-endpoint = <&sensor_1_out>;
>> +                                };
>> +                            };
>> +
>> +                            port@1 {
>> +                                reg = <1>;
>> +                                ser_1_gmsl_out: endpoint {
>> +                                    remote-endpoint = <&des_gmsl_in_1>;
>> +                                };
>> +                            };
>> +                        };
>> +                    };
>> +                };
>> +            };
>> +        };
>> +    };
>> +...
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index abf3afc95fc9..c1e01668e81a 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -14220,6 +14220,12 @@ S:	Maintained
>>   F:	Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.yaml
>>   F:	drivers/iio/proximity/mb1232.c
>>   
>> +MAXIM GMSL2 SERIALIZERS AND DESERIALIZERS
>> +M:	Cosmin Tanislav <cosmin.tanislav@analog.com>
>> +L:	linux-media@vger.kernel.org
>> +S:	Maintained
>> +F:	Documentation/devicetree/bindings/media/i2c/maxim,max9296a.yaml
>> +
>>   MAXIM MAX11205 DRIVER
>>   M:	Ramona Bolboaca <ramona.bolboaca@analog.com>
>>   L:	linux-iio@vger.kernel.org
>> -- 
>> 2.48.1
>>



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

* Re: [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793
  2025-03-09  8:47 ` [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793 Cosmin Tanislav
  2025-03-11 18:30   ` Rob Herring (Arm)
@ 2025-03-13 12:25   ` Sakari Ailus
  1 sibling, 0 replies; 39+ messages in thread
From: Sakari Ailus @ 2025-03-13 12:25 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Laurent Pinchart,
	Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

Hi Cosmin,

On Sun, Mar 09, 2025 at 10:47:58AM +0200, Cosmin Tanislav wrote:
> MAX96793 is a newer variant of the MAX96717 which also supports GMSL3
> links.
> 
> Document this compatibility.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
>  Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> index 31fb62debdc7..02857f0364c4 100644
> --- a/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> +++ b/Documentation/devicetree/bindings/media/i2c/maxim,max96717.yaml
> @@ -27,6 +27,7 @@ description:
>  
>    MAX96717F only supports a fixed rate of 3Gbps in the forward direction.
>    MAX9295A only supports pixel mode.
> +  MAX96793 also supports GMSL3 mode.

Fits on the previous line. Same goes for some of the commit messages in the
set: the limit is 75 characters per line.

>  
>  properties:
>    compatible:
> @@ -36,6 +37,7 @@ properties:
>        - items:
>            - enum:
>                - maxim,max96717
> +              - maxim,max96793
>            - const: maxim,max96717f
>  
>    '#gpio-cells':

-- 
Regards,

Sakari Ailus


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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
       [not found] ` <20250309084814.3114794-13-demonsingur@gmail.com>
@ 2025-05-06 18:33   ` Jakub Kostiw
  2025-05-06 19:01     ` Cosmin Tanislav
  2025-05-07 11:22     ` Dave Stevenson
  0 siblings, 2 replies; 39+ messages in thread
From: Jakub Kostiw @ 2025-05-06 18:33 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

Hi Cosmin

Awesome work. The initiative to establish a common framework for GMSL 
devices is a great idea.

I believe that we have found few bugs:

> +#define MAX9296A_BACKTOP22(x)			(0x31d * (x) * 0x3)

The first multiplication is wrong and should be replaced with addition:

+#define MAX9296A_BACKTOP22(x)			(0x31d + (x) * 0x3)

The same goes for MAX96724 equivalent macro:

> +#define MAX96724_BACKTOP22(x)			(0x415 * (x) * 0x3)

In MAX96714 driver there is an issue with setting up lane-polarities.

> +static const struct max9296a_chip_info max96714_info = {
> +	.max_register = 0x5011,
> +	.set_pipe_stream_id = max96714_set_pipe_stream_id,
> +	.set_pipe_enable = max96714_set_pipe_enable,
> +	.set_pipe_tunnel_enable = max96714_set_pipe_tunnel_enable,
> +	.phys_configs = {
> +		.num_configs = ARRAY_SIZE(max96714_phys_configs),
> +		.configs = max96714_phys_configs,
> +	},
> +	.polarity_on_physical_lanes = true,
> +	.supports_phy_log = true,
> +	.adjust_rlms = true,
> +	.num_pipes = 1,
> +	.pipe_hw_ids = { 1 },
> +	.num_phys = 1,
> +	.phy_hw_ids = { 1 },
> +	.num_links = 1,
> +};

In order to make thing work we had to set

> +	.polarity_on_physical_lanes = true,

To false. So this field is either improperly set for MAX96714, or handling of this case is wrong:

> +		if (priv->info->polarity_on_physical_lanes)
> +			map = phy->mipi.data_lanes[i];
> +		else
> +			map = i;

Upon mentioned changes we have successfully tested two GMSL2 
combinations on Raspberry 5 platform:

1. MAX96724 + MAX96717 (only 2 MIPI-CSI2 lanes with single camera due to 
hardware limitations)

2. MAX96714 + MAX96717

We have also been wondering about these registers:

> +#define MAX9296A_DPLL_0(x)			(0x1c00 + ((x) == 0 ? 1 : 2) * 0x100)
> +#define MAX96724_DPLL_0(x)			(0x1c00 + (x) * 0x100)

There are writes to these addresses but we could not find any reference to these in either MAX96714 or MAX96724 datasheets.

Are You willing to add support for mapping MIPI-CSI2 lanes? This is a very convenient feature which comes in handy during HW design.



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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-06 18:33   ` [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Jakub Kostiw
@ 2025-05-06 19:01     ` Cosmin Tanislav
  2025-05-06 19:15       ` Jakub Kostiw
  2025-05-07 11:22     ` Dave Stevenson
  1 sibling, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-05-06 19:01 UTC (permalink / raw)
  To: Jakub Kostiw
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio



On 5/6/25 9:33 PM, Jakub Kostiw wrote:
> Hi Cosmin
> 
> Awesome work. The initiative to establish a common framework for GMSL 
> devices is a great idea.
> 

Hi! Thanks for the feedback.

> I believe that we have found few bugs:
> 
>> +#define MAX9296A_BACKTOP22(x)            (0x31d * (x) * 0x3)
> 
> The first multiplication is wrong and should be replaced with addition:
> 
> +#define MAX9296A_BACKTOP22(x)            (0x31d + (x) * 0x3)
> 

I'm aware of this issue and had it fixed locally, just haven't submitted
a new version yet.

> The same goes for MAX96724 equivalent macro:
> 
>> +#define MAX96724_BACKTOP22(x)            (0x415 * (x) * 0x3)
> 

Although I haven't noticed that it applied to MAX96724 too, thanks.

> In MAX96714 driver there is an issue with setting up lane-polarities.
> 
>> +static const struct max9296a_chip_info max96714_info = {
>> +    .max_register = 0x5011,
>> +    .set_pipe_stream_id = max96714_set_pipe_stream_id,
>> +    .set_pipe_enable = max96714_set_pipe_enable,
>> +    .set_pipe_tunnel_enable = max96714_set_pipe_tunnel_enable,
>> +    .phys_configs = {
>> +        .num_configs = ARRAY_SIZE(max96714_phys_configs),
>> +        .configs = max96714_phys_configs,
>> +    },
>> +    .polarity_on_physical_lanes = true,
>> +    .supports_phy_log = true,
>> +    .adjust_rlms = true,
>> +    .num_pipes = 1,
>> +    .pipe_hw_ids = { 1 },
>> +    .num_phys = 1,
>> +    .phy_hw_ids = { 1 },
>> +    .num_links = 1,
>> +};
> 
> In order to make thing work we had to set
> 
>> +    .polarity_on_physical_lanes = true,
> 
> To false. So this field is either improperly set for MAX96714, or 
> handling of this case is wrong:
> 
>> +        if (priv->info->polarity_on_physical_lanes)
>> +            map = phy->mipi.data_lanes[i];
>> +        else
>> +            map = i;
> 

MAX96714 has different value meanings for the polarity register
(compared to MAX9296A). On MAX96714, the bits represent the
polarity of the hardware lane (not taking mapping into account).
On MAX9296A, mapping is taken into account by hardware, so
the polarity can be retrieved directly. See the comments surrounding
that piece of code. It's entirely possible that I was wrong when
writing this code, but this was cross-checked with the datasheet
and the GMSL SerDes GUI. It's not out of the question that any of
these could be wrong.

Are you setting a specific polarity on the lanes? I've validated
MAX96714 (after the upstream submission) myself and it works.

> Upon mentioned changes we have successfully tested two GMSL2 
> combinations on Raspberry 5 platform:
> 
> 1. MAX96724 + MAX96717 (only 2 MIPI-CSI2 lanes with single camera due to 
> hardware limitations)
> 
> 2. MAX96714 + MAX96717
> 
> We have also been wondering about these registers:
> 
>> +#define MAX9296A_DPLL_0(x)            (0x1c00 + ((x) == 0 ? 1 : 2) * 
>> 0x100)
>> +#define MAX96724_DPLL_0(x)            (0x1c00 + (x) * 0x100)
> 
> There are writes to these addresses but we could not find any reference 
> to these in either MAX96714 or MAX96724 datasheets.
> 

These registers are not mentioned in the datasheet of MAX96714 or
MAX96724, as they're considered "hidden". You can look at MAX96716A
datasheet for a description.

> Are You willing to add support for mapping MIPI-CSI2 lanes? This is a 
> very convenient feature which comes in handy during HW design.
> 

This should already be implemented by using different numbers in
data-lanes property in devicetree.



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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-06 19:01     ` Cosmin Tanislav
@ 2025-05-06 19:15       ` Jakub Kostiw
  2025-05-06 19:46         ` Cosmin Tanislav
  0 siblings, 1 reply; 39+ messages in thread
From: Jakub Kostiw @ 2025-05-06 19:15 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

 > I'm aware of this issue and had it fixed locally, just haven't submitted
 > a new version yet.

Great !

 > Are you setting a specific polarity on the lanes? I've validated
 > MAX96714 (after the upstream submission) myself and it works.

Our design has all lanes inverted, so we used:
lane-polarities = <1 1 1>;

Only after mentioned change we managed to get the video stream.

 > This should already be implemented by using different numbers in
 > data-lanes property in devicetree.

Awesome, this will come in handy for sure.



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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-06 19:15       ` Jakub Kostiw
@ 2025-05-06 19:46         ` Cosmin Tanislav
  2025-05-07  7:28           ` Jakub Kostiw
  0 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-05-06 19:46 UTC (permalink / raw)
  To: Jakub Kostiw
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio



On 5/6/25 10:15 PM, Jakub Kostiw wrote:
>  > I'm aware of this issue and had it fixed locally, just haven't submitted
>  > a new version yet.
> 
> Great !
> 
>  > Are you setting a specific polarity on the lanes? I've validated
>  > MAX96714 (after the upstream submission) myself and it works.
> 
> Our design has all lanes inverted, so we used:
> lane-polarities = <1 1 1>;
> 

Got it.

Can you revert the change you made to polarity_on_physical_lanes, and
try the following?

diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c 
b/drivers/media/i2c/maxim-serdes/max9296a.c
index f48f5b68a750..dea0518fd790 100644
--- a/drivers/media/i2c/maxim-serdes/max9296a.c
+++ b/drivers/media/i2c/maxim-serdes/max9296a.c
@@ -474,7 +474,7 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
                  */

                 if (priv->info->polarity_on_physical_lanes)
-                       map = phy->mipi.data_lanes[i];
+                       map = phy->mipi.data_lanes[i] - 1;
                 else
                         map = i;

data_lanes is 1-based (since 0 is the clock lane), but the bits
in register 0x335 start from 0. That means we should adjust the
values in data_lanes to be 0-based.

> Only after mentioned change we managed to get the video stream.
> 
>  > This should already be implemented by using different numbers in
>  > data-lanes property in devicetree.
> 
> Awesome, this will come in handy for sure.
> 



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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-06 19:46         ` Cosmin Tanislav
@ 2025-05-07  7:28           ` Jakub Kostiw
  2025-05-07  8:49             ` Cosmin Tanislav
  0 siblings, 1 reply; 39+ messages in thread
From: Jakub Kostiw @ 2025-05-07  7:28 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

> Can you revert the change you made to polarity_on_physical_lanes, and
> try the following?
>
> diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c 
> b/drivers/media/i2c/maxim-serdes/max9296a.c
> index f48f5b68a750..dea0518fd790 100644
> --- a/drivers/media/i2c/maxim-serdes/max9296a.c
> +++ b/drivers/media/i2c/maxim-serdes/max9296a.c
> @@ -474,7 +474,7 @@ static int max9296a_init_phy(struct max_des *des, 
> struct max_des_phy *phy)
>                  */
>
>                 if (priv->info->polarity_on_physical_lanes)
> -                       map = phy->mipi.data_lanes[i];
> +                       map = phy->mipi.data_lanes[i] - 1;
>                 else
>                         map = i;
>
> data_lanes is 1-based (since 0 is the clock lane), but the bits
> in register 0x335 start from 0. That means we should adjust the
> values in data_lanes to be 0-based. 

I have applied your patch and polarity settings seems to be correct now 
(based on register contents).
However, I have came across another issue.
When I was debugging the driver for MAX96714, before I found out that 
the issue was with polarity settings, I have commented out calls to 
MAX9296A_DPLL_0. Probably because I thought it was there by mistake. I 
totally forgot about that change.
Before applying your patch I reverted any changes to the driver, so 
MAX9296A_DPLL_0 writes were back again. Sadly, video stream did not 
work. So I began to wonder, and just for sake of testing, commented 
these calls again (added some logs for quick tracing purposes):

diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c 
b/drivers/media/i2c/maxim-serdes/max9296a.c
index f48f5b68a..b24a8e2d6 100644
--- a/drivers/media/i2c/maxim-serdes/max9296a.c
+++ b/drivers/media/i2c/maxim-serdes/max9296a.c
@@ -391,6 +391,8 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
          * PHY1 Lane 1 = D3
          */

+       dev_info(priv->dev, "Using  %d lanes", num_data_lanes);
+
         /* Configure a lane count. */
         ret = regmap_update_bits(priv->regmap, 
MAX9296A_MIPI_TX10(hw_index),
                                  MAX9296A_MIPI_TX10_CSI2_LANE_CNT,
@@ -474,7 +476,7 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
                  */

                 if (priv->info->polarity_on_physical_lanes)
-                       map = phy->mipi.data_lanes[i];
+                       map = phy->mipi.data_lanes[i] - 1;
                 else
                         map = i;

@@ -484,6 +486,9 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
         if (phy->index == 0 && priv->info->phy0_lanes_0_1_on_second_phy)
                 val = ((val & 0x3) << 2) | ((val >> 2) & 0x3);

+       dev_info(priv->dev, "Val for MIPI_PHY5 (0_1): %lx", 
FIELD_PREP(MAX9296A_MIPI_PHY5_PHY_POL_MAP_0_1, val));
+       dev_info(priv->dev, "Val for MIPI_PHY5 (2_3): %lx", 
FIELD_PREP(MAX9296A_MIPI_PHY5_PHY_POL_MAP_2_3, val >> 2));
+
         ret = regmap_update_bits(priv->regmap, MAX9296A_MIPI_PHY5(index),
MAX9296A_MIPI_PHY5_PHY_POL_MAP_0_1 |
MAX9296A_MIPI_PHY5_PHY_POL_MAP_2_3,
@@ -499,10 +504,10 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
                 return ret;

         /* Put DPLL block into reset. */
-       ret = regmap_clear_bits(priv->regmap, MAX9296A_DPLL_0(hw_index),
- MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
-       if (ret)
-               return ret;
+       //ret = regmap_clear_bits(priv->regmap, MAX9296A_DPLL_0(hw_index),
+       // MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
+       //if (ret)
+       //      return ret;

         /* Set DPLL frequency. */
         ret = regmap_update_bits(priv->regmap, MAX9296A_BACKTOP22(index),
@@ -519,10 +524,10 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
                 return ret;

         /* Pull DPLL block out of reset. */
-       ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(index),
-                             MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
-       if (ret)
-               return ret;
+       //ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(index),
+       //                    MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
+       //if (ret)
+       //      return ret;

         if (dpll_freq > 1500000000ull) {
                 /* Enable initial deskew with 2 x 32k UI. */

To my surprise it works this way. I tested this 2 times back and forth. 
Can these calls really cause some issues?


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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-07  7:28           ` Jakub Kostiw
@ 2025-05-07  8:49             ` Cosmin Tanislav
  2025-05-07  9:02               ` Jakub Kostiw
  0 siblings, 1 reply; 39+ messages in thread
From: Cosmin Tanislav @ 2025-05-07  8:49 UTC (permalink / raw)
  To: Jakub Kostiw
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio



On 5/7/25 10:28 AM, Jakub Kostiw wrote:
>> Can you revert the change you made to polarity_on_physical_lanes, and
>> try the following?
>>
>> diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c b/drivers/ 
>> media/i2c/maxim-serdes/max9296a.c
>> index f48f5b68a750..dea0518fd790 100644
>> --- a/drivers/media/i2c/maxim-serdes/max9296a.c
>> +++ b/drivers/media/i2c/maxim-serdes/max9296a.c
>> @@ -474,7 +474,7 @@ static int max9296a_init_phy(struct max_des *des, 
>> struct max_des_phy *phy)
>>                  */
>>
>>                 if (priv->info->polarity_on_physical_lanes)
>> -                       map = phy->mipi.data_lanes[i];
>> +                       map = phy->mipi.data_lanes[i] - 1;
>>                 else
>>                         map = i;
>>
>> data_lanes is 1-based (since 0 is the clock lane), but the bits
>> in register 0x335 start from 0. That means we should adjust the
>> values in data_lanes to be 0-based. 
> 
> I have applied your patch and polarity settings seems to be correct now 
> (based on register contents).
> However, I have came across another issue.
> When I was debugging the driver for MAX96714, before I found out that 
> the issue was with polarity settings, I have commented out calls to 
> MAX9296A_DPLL_0. Probably because I thought it was there by mistake. I 
> totally forgot about that change.
> Before applying your patch I reverted any changes to the driver, so 
> MAX9296A_DPLL_0 writes were back again. Sadly, video stream did not 
> work. So I began to wonder, and just for sake of testing, commented 
> these calls again (added some logs for quick tracing purposes):
> 
> diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c b/drivers/media/ 
> i2c/maxim-serdes/max9296a.c
> index f48f5b68a..b24a8e2d6 100644
> --- a/drivers/media/i2c/maxim-serdes/max9296a.c
> +++ b/drivers/media/i2c/maxim-serdes/max9296a.c
> @@ -391,6 +391,8 @@ static int max9296a_init_phy(struct max_des *des, 
> struct max_des_phy *phy)
>           * PHY1 Lane 1 = D3
>           */
> 
> +       dev_info(priv->dev, "Using  %d lanes", num_data_lanes);
> +
>          /* Configure a lane count. */
>          ret = regmap_update_bits(priv->regmap, 
> MAX9296A_MIPI_TX10(hw_index),
>                                   MAX9296A_MIPI_TX10_CSI2_LANE_CNT,
> @@ -474,7 +476,7 @@ static int max9296a_init_phy(struct max_des *des, 
> struct max_des_phy *phy)
>                   */
> 
>                  if (priv->info->polarity_on_physical_lanes)
> -                       map = phy->mipi.data_lanes[i];
> +                       map = phy->mipi.data_lanes[i] - 1;
>                  else
>                          map = i;
> 
> @@ -484,6 +486,9 @@ static int max9296a_init_phy(struct max_des *des, 
> struct max_des_phy *phy)
>          if (phy->index == 0 && priv->info->phy0_lanes_0_1_on_second_phy)
>                  val = ((val & 0x3) << 2) | ((val >> 2) & 0x3);
> 
> +       dev_info(priv->dev, "Val for MIPI_PHY5 (0_1): %lx", 
> FIELD_PREP(MAX9296A_MIPI_PHY5_PHY_POL_MAP_0_1, val));
> +       dev_info(priv->dev, "Val for MIPI_PHY5 (2_3): %lx", 
> FIELD_PREP(MAX9296A_MIPI_PHY5_PHY_POL_MAP_2_3, val >> 2));
> +
>          ret = regmap_update_bits(priv->regmap, MAX9296A_MIPI_PHY5(index),
> MAX9296A_MIPI_PHY5_PHY_POL_MAP_0_1 |
> MAX9296A_MIPI_PHY5_PHY_POL_MAP_2_3,
> @@ -499,10 +504,10 @@ static int max9296a_init_phy(struct max_des *des, 
> struct max_des_phy *phy)
>                  return ret;
> 
>          /* Put DPLL block into reset. */
> -       ret = regmap_clear_bits(priv->regmap, MAX9296A_DPLL_0(hw_index),
> - MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
> -       if (ret)
> -               return ret;
> +       //ret = regmap_clear_bits(priv->regmap, MAX9296A_DPLL_0(hw_index),
> +       // MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
> +       //if (ret)
> +       //      return ret;
> 
>          /* Set DPLL frequency. */
>          ret = regmap_update_bits(priv->regmap, MAX9296A_BACKTOP22(index),
> @@ -519,10 +524,10 @@ static int max9296a_init_phy(struct max_des *des, 
> struct max_des_phy *phy)
>                  return ret;
> 
>          /* Pull DPLL block out of reset. */
> -       ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(index),
> -                             MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
> -       if (ret)
> -               return ret;
> +       //ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(index),
> +       //                    MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
> +       //if (ret)
> +       //      return ret;
> 
>          if (dpll_freq > 1500000000ull) {
>                  /* Enable initial deskew with 2 x 32k UI. */
> 
> To my surprise it works this way. I tested this 2 times back and forth. 
> Can these calls really cause some issues?


Can you revert your changes and try this?

diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c 
b/drivers/media/i2c/maxim-serdes/max9296a.c
index dea0518fd790..3bb80fe42a22 100644
--- a/drivers/media/i2c/maxim-serdes/max9296a.c
+++ b/drivers/media/i2c/maxim-serdes/max9296a.c
@@ -519,7 +519,7 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
  		return ret;

  	/* Pull DPLL block out of reset. */
-	ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(index),
+	ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(hw_index),
  			      MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
  	if (ret)
  		return ret;




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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-07  8:49             ` Cosmin Tanislav
@ 2025-05-07  9:02               ` Jakub Kostiw
  0 siblings, 0 replies; 39+ messages in thread
From: Jakub Kostiw @ 2025-05-07  9:02 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

 > Can you revert your changes and try this?
 >
 > diff --git a/drivers/media/i2c/maxim-serdes/max9296a.c 
b/drivers/media/i2c/maxim-serdes/max9296a.c
 > index dea0518fd790..3bb80fe42a22 100644
 > --- a/drivers/media/i2c/maxim-serdes/max9296a.c
 > +++ b/drivers/media/i2c/maxim-serdes/max9296a.c
 > @@ -519,7 +519,7 @@ static int max9296a_init_phy(struct max_des *des, 
struct max_des_phy *phy)
 >         return ret;
 >
 >     /* Pull DPLL block out of reset. */
 > -    ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(index),
 > +    ret = regmap_set_bits(priv->regmap, MAX9296A_DPLL_0(hw_index),
 >                   MAX9296A_DPLL_0_CONFIG_SOFT_RST_N);
 >     if (ret)
 >         return ret;

This fixes the issue, great work!


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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-06 18:33   ` [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Jakub Kostiw
  2025-05-06 19:01     ` Cosmin Tanislav
@ 2025-05-07 11:22     ` Dave Stevenson
  2025-05-07 11:38       ` Cosmin Tanislav
  2025-05-07 11:41       ` Jakub Kostiw
  1 sibling, 2 replies; 39+ messages in thread
From: Dave Stevenson @ 2025-05-07 11:22 UTC (permalink / raw)
  To: Jakub Kostiw
  Cc: Cosmin Tanislav, Tomi Valkeinen, Cosmin Tanislav,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Niklas Söderlund, Julien Massot,
	Catalin Marinas, Will Deacon, Greg Kroah-Hartman, Liam Girdwood,
	Mark Brown, Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

Hi Jakub and Cosmin

On Tue, 6 May 2025 at 19:34, Jakub Kostiw <jakub.kostiw@videtronic.com> wrote:
>
> Hi Cosmin
>
> Awesome work. The initiative to establish a common framework for GMSL
> devices is a great idea.
>
> I believe that we have found few bugs:
>
> > +#define MAX9296A_BACKTOP22(x)                        (0x31d * (x) * 0x3)
>
> The first multiplication is wrong and should be replaced with addition:
>
> +#define MAX9296A_BACKTOP22(x)                  (0x31d + (x) * 0x3)
>
> The same goes for MAX96724 equivalent macro:
>
> > +#define MAX96724_BACKTOP22(x)                        (0x415 * (x) * 0x3)
>
> In MAX96714 driver there is an issue with setting up lane-polarities.
>
> > +static const struct max9296a_chip_info max96714_info = {
> > +     .max_register = 0x5011,
> > +     .set_pipe_stream_id = max96714_set_pipe_stream_id,
> > +     .set_pipe_enable = max96714_set_pipe_enable,
> > +     .set_pipe_tunnel_enable = max96714_set_pipe_tunnel_enable,
> > +     .phys_configs = {
> > +             .num_configs = ARRAY_SIZE(max96714_phys_configs),
> > +             .configs = max96714_phys_configs,
> > +     },
> > +     .polarity_on_physical_lanes = true,
> > +     .supports_phy_log = true,
> > +     .adjust_rlms = true,
> > +     .num_pipes = 1,
> > +     .pipe_hw_ids = { 1 },
> > +     .num_phys = 1,
> > +     .phy_hw_ids = { 1 },
> > +     .num_links = 1,
> > +};
>
> In order to make thing work we had to set
>
> > +     .polarity_on_physical_lanes = true,
>
> To false. So this field is either improperly set for MAX96714, or handling of this case is wrong:
>
> > +             if (priv->info->polarity_on_physical_lanes)
> > +                     map = phy->mipi.data_lanes[i];
> > +             else
> > +                     map = i;
>
> Upon mentioned changes we have successfully tested two GMSL2
> combinations on Raspberry 5 platform:
>
> 1. MAX96724 + MAX96717 (only 2 MIPI-CSI2 lanes with single camera due to
> hardware limitations)
>
> 2. MAX96714 + MAX96717

Feel free to shout if you want help on the Pi side.

Pi5 should be able to extract multiple virtual channels to support
several sensors simultaneously (up to 4 VC/DT combinations). It does
need a rework so the CFE runs from memory rather than being fed data
directly from the CSI-2 receiver, but I believe that is pencilled in
as future work with libcamera already.

Unless things have regressed, libcamera should report all connected
sensors to SerDes setups, and set up Media Controller appropriately to
use them one at a time. I know I've had that working with simple CSI-2
multiplexers and thought I'd had it working with TI FPD-Link III
SerDes (Arducam's IMX219 V3Link kit, modded to remove their MCU). I
don't have any GMSL hardware to test with.

We're also fairly open to merging drivers and overlays for 3rd party
hardware into the downstream Pi kernel. If they've been reviewed and
merged upstream then that is the ideal, but if you're prepared to
support them, then it saves the user the headache of having to build
out-of-tree modules.

Cheers
  Dave


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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-07 11:22     ` Dave Stevenson
@ 2025-05-07 11:38       ` Cosmin Tanislav
  2025-05-07 11:41       ` Jakub Kostiw
  1 sibling, 0 replies; 39+ messages in thread
From: Cosmin Tanislav @ 2025-05-07 11:38 UTC (permalink / raw)
  To: Dave Stevenson, Jakub Kostiw
  Cc: Tomi Valkeinen, Cosmin Tanislav, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Niklas Söderlund, Julien Massot, Catalin Marinas,
	Will Deacon, Greg Kroah-Hartman, Liam Girdwood, Mark Brown,
	Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio



On 5/7/25 2:22 PM, Dave Stevenson wrote:
> Hi Jakub and Cosmin
> 
> On Tue, 6 May 2025 at 19:34, Jakub Kostiw <jakub.kostiw@videtronic.com> wrote:
>>
>> Hi Cosmin
>>
>> Awesome work. The initiative to establish a common framework for GMSL
>> devices is a great idea.
>>
>> I believe that we have found few bugs:
>>
>>> +#define MAX9296A_BACKTOP22(x)                        (0x31d * (x) * 0x3)
>>
>> The first multiplication is wrong and should be replaced with addition:
>>
>> +#define MAX9296A_BACKTOP22(x)                  (0x31d + (x) * 0x3)
>>
>> The same goes for MAX96724 equivalent macro:
>>
>>> +#define MAX96724_BACKTOP22(x)                        (0x415 * (x) * 0x3)
>>
>> In MAX96714 driver there is an issue with setting up lane-polarities.
>>
>>> +static const struct max9296a_chip_info max96714_info = {
>>> +     .max_register = 0x5011,
>>> +     .set_pipe_stream_id = max96714_set_pipe_stream_id,
>>> +     .set_pipe_enable = max96714_set_pipe_enable,
>>> +     .set_pipe_tunnel_enable = max96714_set_pipe_tunnel_enable,
>>> +     .phys_configs = {
>>> +             .num_configs = ARRAY_SIZE(max96714_phys_configs),
>>> +             .configs = max96714_phys_configs,
>>> +     },
>>> +     .polarity_on_physical_lanes = true,
>>> +     .supports_phy_log = true,
>>> +     .adjust_rlms = true,
>>> +     .num_pipes = 1,
>>> +     .pipe_hw_ids = { 1 },
>>> +     .num_phys = 1,
>>> +     .phy_hw_ids = { 1 },
>>> +     .num_links = 1,
>>> +};
>>
>> In order to make thing work we had to set
>>
>>> +     .polarity_on_physical_lanes = true,
>>
>> To false. So this field is either improperly set for MAX96714, or handling of this case is wrong:
>>
>>> +             if (priv->info->polarity_on_physical_lanes)
>>> +                     map = phy->mipi.data_lanes[i];
>>> +             else
>>> +                     map = i;
>>
>> Upon mentioned changes we have successfully tested two GMSL2
>> combinations on Raspberry 5 platform:
>>
>> 1. MAX96724 + MAX96717 (only 2 MIPI-CSI2 lanes with single camera due to
>> hardware limitations)
>>
>> 2. MAX96714 + MAX96717
> 
> Feel free to shout if you want help on the Pi side.
> 
> Pi5 should be able to extract multiple virtual channels to support
> several sensors simultaneously (up to 4 VC/DT combinations). It does
> need a rework so the CFE runs from memory rather than being fed data
> directly from the CSI-2 receiver, but I believe that is pencilled in
> as future work with libcamera already.
> 

Hi Dave, thanks for your input! I'm glad this is getting some traction.

I'm currently testing using Tomi's pyv4l2 tool, which already contains
RPi5 GMSL configs.

I've tested the multi-camera simultaneously streaming usecase already,
all is working well, and I was able to get 4 separate camera image
streams (or 2 image and 2 meta), streaming to the RPi5, and then to
a remote host (where debayer is feasible to do without the help of an
ISP).

Last time I tried libcamera it was not able to properly configure all
entities, so testing with just the mainline CFE using pyv4l2 makes it
much simpler, since we're only interested in getting our hardware
supported.

> Unless things have regressed, libcamera should report all connected
> sensors to SerDes setups, and set up Media Controller appropriately to
> use them one at a time. I know I've had that working with simple CSI-2
> multiplexers and thought I'd had it working with TI FPD-Link III
> SerDes (Arducam's IMX219 V3Link kit, modded to remove their MCU). I
> don't have any GMSL hardware to test with.
> 
> We're also fairly open to merging drivers and overlays for 3rd party
> hardware into the downstream Pi kernel. If they've been reviewed and
> merged upstream then that is the ideal, but if you're prepared to
> support them, then it saves the user the headache of having to build
> out-of-tree modules.
> 
> Cheers
>    Dave



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

* Re: [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers
  2025-05-07 11:22     ` Dave Stevenson
  2025-05-07 11:38       ` Cosmin Tanislav
@ 2025-05-07 11:41       ` Jakub Kostiw
  1 sibling, 0 replies; 39+ messages in thread
From: Jakub Kostiw @ 2025-05-07 11:41 UTC (permalink / raw)
  To: Dave Stevenson
  Cc: Cosmin Tanislav, Tomi Valkeinen, Cosmin Tanislav,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Niklas Söderlund, Julien Massot,
	Catalin Marinas, Will Deacon, Greg Kroah-Hartman, Liam Girdwood,
	Mark Brown, Linus Walleij, Bartosz Golaszewski, Bjorn Andersson,
	Geert Uytterhoeven, Dmitry Baryshkov, Arnd Bergmann, Taniya Das,
	Biju Das, Nícolas F . R . A . Prado, Eric Biggers,
	Javier Carrasco, Ross Burton, Hans Verkuil, Sakari Ailus,
	Laurent Pinchart, Zhi Mao, Kieran Bingham, Dongcheng Yan,
	AngeloGioacchino Del Regno, Benjamin Mugnier, Tommaso Merciai,
	Dan Carpenter, Ihor Matushchak, Laurentiu Palcu, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, linux-staging,
	linux-gpio

> Feel free to shout if you want help on the Pi side.
>
> Pi5 should be able to extract multiple virtual channels to support
> several sensors simultaneously (up to 4 VC/DT combinations). It does
> need a rework so the CFE runs from memory rather than being fed data
> directly from the CSI-2 receiver, but I believe that is pencilled in
> as future work with libcamera already.
>
> Unless things have regressed, libcamera should report all connected
> sensors to SerDes setups, and set up Media Controller appropriately to
> use them one at a time. I know I've had that working with simple CSI-2
> multiplexers and thought I'd had it working with TI FPD-Link III
> SerDes (Arducam's IMX219 V3Link kit, modded to remove their MCU). I
> don't have any GMSL hardware to test with.
>
> We're also fairly open to merging drivers and overlays for 3rd party
> hardware into the downstream Pi kernel. If they've been reviewed and
> merged upstream then that is the ideal, but if you're prepared to
> support them, then it saves the user the headache of having to build
> out-of-tree modules.
Hi Dave

Great to hear. Our initial test were made on a hardware that was 
designed for other platform (Toradex) so our test options are limited. 
However, after evaluating Cosmins drivers we designed a proper hardware 
for Raspberry Pi platform. We are now in a process of review and will 
soon manufacture it.  We should have them in our offices in upcoming weeks.

It would be great to work with you to setup everything properly. We can 
send samples to you if you wish.


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

end of thread, other threads:[~2025-05-07 11:43 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-09  8:47 [RFC PATCH v2 00/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Cosmin Tanislav
2025-03-09  8:47 ` [RFC PATCH v2 01/16] dt-bindings: media: i2c: max96717: add myself as maintainer Cosmin Tanislav
2025-03-11 18:06   ` Rob Herring (Arm)
2025-03-09  8:47 ` [RFC PATCH v2 02/16] dt-bindings: media: i2c: max96717: reflow text Cosmin Tanislav
2025-03-11 18:09   ` Rob Herring
2025-03-09  8:47 ` [RFC PATCH v2 03/16] dt-bindings: media: i2c: max96717: add support for I2C ATR Cosmin Tanislav
2025-03-11 18:15   ` Rob Herring
2025-03-09  8:47 ` [RFC PATCH v2 04/16] dt-bindings: media: i2c: max96717: add support for pinctrl/pinconf Cosmin Tanislav
2025-03-11 18:23   ` Rob Herring
2025-03-09  8:47 ` [RFC PATCH v2 05/16] dt-bindings: media: i2c: max96717: add support for MAX9295A Cosmin Tanislav
2025-03-11 18:28   ` Rob Herring
2025-03-09  8:47 ` [RFC PATCH v2 06/16] dt-bindings: media: i2c: max96717: add support for MAX96793 Cosmin Tanislav
2025-03-11 18:30   ` Rob Herring (Arm)
2025-03-13 12:25   ` Sakari Ailus
2025-03-09  8:47 ` [RFC PATCH v2 07/16] dt-bindings: media: i2c: max96712: add myself as maintainer Cosmin Tanislav
2025-03-11 18:54   ` Rob Herring (Arm)
2025-03-09  8:48 ` [RFC PATCH v2 08/16] dt-bindings: media: i2c: max96712: use pattern properties for ports Cosmin Tanislav
2025-03-11 19:00   ` Rob Herring
2025-03-09  8:48 ` [RFC PATCH v2 09/16] dt-bindings: media: i2c: max96712: add support for I2C MUX Cosmin Tanislav
2025-03-11 19:01   ` Rob Herring (Arm)
2025-03-09  8:48 ` [RFC PATCH v2 10/16] dt-bindings: media: i2c: max96712: add support for POC supplies Cosmin Tanislav
2025-03-11 19:02   ` Rob Herring (Arm)
2025-03-09  8:48 ` [RFC PATCH v2 11/16] dt-bindings: media: i2c: add MAX9296A, MAX96716A, MAX96792A Cosmin Tanislav
2025-03-11 19:07   ` Rob Herring
2025-03-11 22:26     ` Cosmin Tanislav
2025-03-09  8:48 ` [RFC PATCH v2 13/16] arm64: defconfig: disable deprecated MAX96712 driver Cosmin Tanislav
2025-03-09  8:48 ` [RFC PATCH v2 14/16] staging: media: remove " Cosmin Tanislav
2025-03-09  8:48 ` [RFC PATCH v2 15/16] media: i2c: remove MAX96717 driver Cosmin Tanislav
2025-03-09  8:48 ` [RFC PATCH v2 16/16] media: i2c: remove MAX96714 driver Cosmin Tanislav
     [not found] ` <20250309084814.3114794-13-demonsingur@gmail.com>
2025-05-06 18:33   ` [RFC PATCH v2 12/16] media: i2c: add Maxim GMSL2/3 serializer and deserializer drivers Jakub Kostiw
2025-05-06 19:01     ` Cosmin Tanislav
2025-05-06 19:15       ` Jakub Kostiw
2025-05-06 19:46         ` Cosmin Tanislav
2025-05-07  7:28           ` Jakub Kostiw
2025-05-07  8:49             ` Cosmin Tanislav
2025-05-07  9:02               ` Jakub Kostiw
2025-05-07 11:22     ` Dave Stevenson
2025-05-07 11:38       ` Cosmin Tanislav
2025-05-07 11:41       ` Jakub Kostiw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).