Skip to contentSkip to conversation

media: i2c: Add ON Semiconductor AP1302 ISP driver

PATCH In review Anil Kumar Mamidala 4 participants 8 messages Oct 6, 2021 – Nov 18, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 media: i2c: Add ON Semiconductor AP1302 ISP driver

The AP1302 is a standalone ISP for ON Semiconductor sensors. AP1302 ISP supports single and dual sensor inputs. The driver code supports AR1335, AR0144 and AR0330 sensors with single and dual mode by loading the corresponding firmware.

---
 MAINTAINERS                |    9 +
 drivers/media/i2c/Kconfig  |   14 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/ap1302.c | 2802 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 2826 insertions(+)
 create mode 100644 drivers/media/i2c/ap1302.c
MAINTAINERS +9 -0
index 19135a9..f6a0061 100644
@@ -1232,6 +1232,15 @@ L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 F:	sound/aoa/
 
+AP1302 ON SEMICONDUCTOR CAMERA ISP
+M:	Laurent Pinchart <[email protected]>
+M:	Anil Kumar Mamidala <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml
+F:	drivers/media/i2c/ap1302.c
+
 APEX EMBEDDED SYSTEMS STX104 IIO DRIVER
 M:	William Breathitt Gray <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +14 -0
index 588f8eb..4192455 100644
@@ -629,6 +629,20 @@ config VIDEO_UPD64083
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called upd64083.
+
+config VIDEO_AP1302
+	tristate "ON Semiconductor AP1302 ISP"
+	depends on I2C && VIDEO_V4L2
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+
+	help
+	  This is a Video4Linux2 sensor-level driver for the ON Semiconductor
+	  AP1302 ISP.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ap1302.
+
 endmenu
 
 menu "Audio/Video compression chips"
drivers/media/i2c/Makefile +1 -0
index 1168fa6..e7efd01 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
 obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
+obj-$(CONFIG_VIDEO_AP1302) += ap1302.o
 obj-$(CONFIG_VIDEO_OV02A10) += ov02a10.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
 obj-$(CONFIG_VIDEO_OV2680) += ov2680.o
drivers/media/i2c/ap1302.c new file +2802 -0

2,802 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/2 media: dt-bindings: media: i2c: Add bindings for AP1302

The AP1302 is a standalone ISP for ON Semiconductor sensors. Add corresponding DT bindings.

---
 .../devicetree/bindings/media/i2c/onnn,ap1302.yaml | 202 +++++++++++++++++++++
 1 file changed, 202 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +202 -0
new file mode 100644
index 0000000..d96e9db
@@ -0,0 +1,202 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,ap1302.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor AP1302 Advanced Image Coprocessor
+
+maintainers:
+  - Laurent Pinchart <[email protected]>
+  - Anil Kumar M <[email protected]>
+
+description: |-
+  The AP1302 is a standalone ISP for ON Semiconductor sensors. It interfaces to
+  up to two RAW CMOS sensors over MIPI CSI-2 connections, processes the two
+  video streams and outputs YUV frames to the host over a MIPI CSI-2 interface.
+  Frames are output side by side or on two virtual channels.
+
+  The sensors must be identical. They are connected to the AP1302 on dedicated
+  I2C buses, and are controlled by the AP1302 firmware. They are not accessible
+  from the host.
+
+properties:
+  compatible:
+    const: onnn,ap1302
+
+  reg:
+    description: I2C device address.
+    maxItems: 1
+
+  clocks:
+    description: Reference to the CLK clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Reference to the GPIO connected to the RST pin (active low).
+    maxItems: 1
+
+  standby-gpios:
+    description:
+      Reference to the GPIO connected to the STANDBY pin (active high).
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    unevaluatedProperties: false
+    description: MIPI CSI-2 output interface to the host.
+
+    properties:
+      endpoint:
+        $ref: /schemas/graph.yaml#/$defs/endpoint-base
+        unevaluatedProperties: false
+
+        properties:
+          clock-noncontinuous:
+            type: boolean
+
+          data-lanes:
+            oneOf:
+              - items:
+                  - const: 1
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+        required:
+          - data-lanes
+
+  sensors:
+    type: object
+    description: List of connected sensors
+
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
+        const: 0
+
+      onnn,model:
+        $ref: "/schemas/types.yaml#/definitions/string"
+        description: |
+          Model of the connected sensors. Must be a valid compatible string.
+
+          If no sensor is connected, this property must no be specified, and
+          the AP1302 can be used with it's internal test pattern generator.
+
+    patternProperties:
+      "^sensor@[01]":
+        type: object
+        description: |
+          Sensors connected to the first and second input, with one node per
+          sensor.
+
+        properties:
+          reg:
+            description: AP1302 input port number
+            maxItems: 1
+
+        patternProperties:
+          ".*-supply":
+            description: Power supplies for the sensor
+
+        required:
+          - reg
+
+        additionalProperties: false
+
+    required:
+      - "#address-cells"
+      - "#size-cells"
+
+    # How can we express that onnn,model requires one sensor object to be set ?
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - port
+  - sensors
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera@3c {
+            compatible = "onnn,ap1302";
+            reg = <0x3c>;
+
+            clocks = <&clk24mhz>;
+
+            reset-gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+            standby-gpios = <&pio 40 GPIO_ACTIVE_HIGH>;
+
+            port {
+                isp1_out: endpoint {
+                    remote-endpoint = <&seninf_in1>;
+                    data-lanes = <1 2 3 4>;
+                };
+            };
+
+            sensors {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                onnn,model = "onnn,ar0144";
+
+                sensor@0 {
+                    reg = <0>;
+
+                    vdd-supply = <&mt6358_vcamd_reg>;
+                    vaa-supply = <&mt6358_vcama1_reg>;
+                    vddio-supply = <&reg_1p8v_ext>;
+                };
+            };
+        };
+    };
+
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera@3c {
+            compatible = "onnn,ap1302";
+            reg = <0x3c>;
+
+            clocks = <&topckgen 0>;
+
+            reset-gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+            standby-gpios = <&pio 40 GPIO_ACTIVE_HIGH>;
+
+            port {
+                isp2_out: endpoint {
+                    remote-endpoint = <&seninf_in1>;
+                    data-lanes = <1 2>;
+                };
+            };
+
+            sensors {
+                #address-cells = <1>;
+                #size-cells = <0>;
+            };
+        };
+    };
+
+...
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v2 2/2] media: dt-bindings: media: i2c: Add bindings for AP1302

Quoted 29 lines · Anil Kumar Mamidala

The AP1302 is a standalone ISP for ON Semiconductor sensors. Add corresponding DT bindings.

---
 .../devicetree/bindings/media/i2c/onnn,ap1302.yaml | 202 +++++++++++++++++++++
 1 file changed, 202 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +11 -0
new file mode 100644
index 0000000..d96e9db
@@ -0,0 +1,202 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,ap1302.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor AP1302 Advanced Image Coprocessor
+
+maintainers:
+  - Laurent Pinchart <[email protected]>
+  - Anil Kumar M <[email protected]>

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 21

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +10 -0
+
+description: |-
+  The AP1302 is a standalone ISP for ON Semiconductor sensors. It interfaces to
+  up to two RAW CMOS sensors over MIPI CSI-2 connections, processes the two
+  video streams and outputs YUV frames to the host over a MIPI CSI-2 interface.
+  Frames are output side by side or on two virtual channels.
+
+  The sensors must be identical. They are connected to the AP1302 on dedicated
+  I2C buses, and are controlled by the AP1302 firmware. They are not accessible
+  from the host.

In your case, but in general I'd assume whatever sensors are used here could be attached directly to an SoC with a built-in ISP? The model and power supplies you specify wouldn't be different, so I think the same binding could be used for both. Though here, you probably just need a subset. More below.

Quoted 57 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +57 -0
+
+properties:
+  compatible:
+    const: onnn,ap1302
+
+  reg:
+    description: I2C device address.
+    maxItems: 1
+
+  clocks:
+    description: Reference to the CLK clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Reference to the GPIO connected to the RST pin (active low).
+    maxItems: 1
+
+  standby-gpios:
+    description:
+      Reference to the GPIO connected to the STANDBY pin (active high).
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    unevaluatedProperties: false
+    description: MIPI CSI-2 output interface to the host.
+
+    properties:
+      endpoint:
+        $ref: /schemas/graph.yaml#/$defs/endpoint-base
+        unevaluatedProperties: false
+
+        properties:
+          clock-noncontinuous:
+            type: boolean
+
+          data-lanes:
+            oneOf:
+              - items:
+                  - const: 1
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+        required:
+          - data-lanes
+
+  sensors:
+    type: object
+    description: List of connected sensors
+
+    properties:

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 88

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +10 -0
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
+        const: 0
+
+      onnn,model:
+        $ref: "/schemas/types.yaml#/definitions/string"
+        description: |
+          Model of the connected sensors. Must be a valid compatible string.

Then make it a compatible string and move into each child node.

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+
+          If no sensor is connected, this property must no be specified, and
+          the AP1302 can be used with it's internal test pattern generator.
+
+    patternProperties:

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 103

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +10 -0
+      "^sensor@[01]":
+        type: object
+        description: |
+          Sensors connected to the first and second input, with one node per
+          sensor.
+
+        properties:
+          reg:
+            description: AP1302 input port number
+            maxItems: 1

items:
- enum: [ 0, 1]

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 106

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +3 -0
+
+        patternProperties:
+          ".*-supply":

You need to list the supplies out. I would make this a schema for the sensor along with compatible. Here, you could either reference those if you want to document the list of supported sensors or don't reference them and just document 'reg'. With a compatible, the schema will be applied anyways.

Quoted 100 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +96 -0
+            description: Power supplies for the sensor
+
+        required:
+          - reg
+
+        additionalProperties: false
+
+    required:
+      - "#address-cells"
+      - "#size-cells"
+
+    # How can we express that onnn,model requires one sensor object to be set ?
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - port
+  - sensors
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera@3c {
+            compatible = "onnn,ap1302";
+            reg = <0x3c>;
+
+            clocks = <&clk24mhz>;
+
+            reset-gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+            standby-gpios = <&pio 40 GPIO_ACTIVE_HIGH>;
+
+            port {
+                isp1_out: endpoint {
+                    remote-endpoint = <&seninf_in1>;
+                    data-lanes = <1 2 3 4>;
+                };
+            };
+
+            sensors {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                onnn,model = "onnn,ar0144";
+
+                sensor@0 {
+                    reg = <0>;
+
+                    vdd-supply = <&mt6358_vcamd_reg>;
+                    vaa-supply = <&mt6358_vcama1_reg>;
+                    vddio-supply = <&reg_1p8v_ext>;
+                };
+            };
+        };
+    };
+
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera@3c {
+            compatible = "onnn,ap1302";
+            reg = <0x3c>;
+
+            clocks = <&topckgen 0>;
+
+            reset-gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+            standby-gpios = <&pio 40 GPIO_ACTIVE_HIGH>;
+
+            port {
+                isp2_out: endpoint {
+                    remote-endpoint = <&seninf_in1>;
+                    data-lanes = <1 2>;
+                };
+            };
+
+            sensors {
+                #address-cells = <1>;
+                #size-cells = <0>;
+            };
+        };
+    };
+
+...
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH v2 2/2] media: dt-bindings: media: i2c: Add bindings for AP1302

Hi Rob,

Quoted 35 lines · Rob Herring
Quoted 34 lines · Anil Kumar Mamidala

The AP1302 is a standalone ISP for ON Semiconductor sensors. Add corresponding DT bindings.

---
 .../devicetree/bindings/media/i2c/onnn,ap1302.yaml | 202 +++++++++++++++++++++
 1 file changed, 202 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +16 -0
new file mode 100644
index 0000000..d96e9db
@@ -0,0 +1,202 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,ap1302.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor AP1302 Advanced Image Coprocessor
+
+maintainers:
+  - Laurent Pinchart <[email protected]>
+  - Anil Kumar M <[email protected]>
+
+description: |-
+  The AP1302 is a standalone ISP for ON Semiconductor sensors. It interfaces to
+  up to two RAW CMOS sensors over MIPI CSI-2 connections, processes the two
+  video streams and outputs YUV frames to the host over a MIPI CSI-2 interface.
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+  Frames are output side by side or on two virtual channels.
+
+  The sensors must be identical. They are connected to the AP1302 on dedicated
+  I2C buses, and are controlled by the AP1302 firmware. They are not accessible
+  from the host.

In your case, but in general I'd assume whatever sensors are used here could be attached directly to an SoC with a built-in ISP?

That is correct, the same sensors can be used with a different ISP (built-in or not), or even without any ISP.

Quoted 66 lines

The model and
power supplies you specify wouldn't be different, so I think the same binding could be used for both. Though here, you probably just need a subset. More below.

Quoted 61 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +61 -0
+
+properties:
+  compatible:
+    const: onnn,ap1302
+
+  reg:
+    description: I2C device address.
+    maxItems: 1
+
+  clocks:
+    description: Reference to the CLK clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Reference to the GPIO connected to the RST pin (active low).
+    maxItems: 1
+
+  standby-gpios:
+    description:
+      Reference to the GPIO connected to the STANDBY pin (active high).
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    unevaluatedProperties: false
+    description: MIPI CSI-2 output interface to the host.
+
+    properties:
+      endpoint:
+        $ref: /schemas/graph.yaml#/$defs/endpoint-base
+        unevaluatedProperties: false
+
+        properties:
+          clock-noncontinuous:
+            type: boolean
+
+          data-lanes:
+            oneOf:
+              - items:
+                  - const: 1
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+        required:
+          - data-lanes
+
+  sensors:
+    type: object
+    description: List of connected sensors
+
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 88

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +6 -0
+        const: 0
+
+      onnn,model:
+        $ref: "/schemas/types.yaml#/definitions/string"
+        description: |
+          Model of the connected sensors. Must be a valid compatible string.

Then make it a compatible string and move into each child node.

We started with that, but considered that it made mistakes more easily in the device tree. As the two sensors have to be identical (it's a limitation of the AP1302), moving the model to the sensor nodes means that someone could set two different models, and the driver will have to include corresponding validation code. It's more code on the driver side, and more complexity on the DT side. Does it actually bring us anything ?

Quoted 19 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+
+          If no sensor is connected, this property must no be specified, and
+          the AP1302 can be used with it's internal test pattern generator.
+
+    patternProperties:

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 103

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +10 -0
+      "^sensor@[01]":
+        type: object
+        description: |
+          Sensors connected to the first and second input, with one node per
+          sensor.
+
+        properties:
+          reg:
+            description: AP1302 input port number
+            maxItems: 1

items:
- enum: [ 0, 1]

Quoted 5 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 106

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +3 -0
+
+        patternProperties:
+          ".*-supply":

You need to list the supplies out.

Fair point, given that we have a list of supply names per sensor in the AP1302 driver.

Quoted 5 lines

I would make this a schema for the
sensor along with compatible. Here, you could either reference those if you want to document the list of supported sensors or don't reference them and just document 'reg'. With a compatible, the schema will be applied anyways.

This I'm more concerned about. The sensors may be the same when used with the AP1302 or when used standalone, but their integration in the system is quite different. With the AP1302, the reg value is the AP1302 port number, while in the standalone case, it's an I2C address. We're just lucky that the #address-cells and #size-cells happen to be the same in both cases. In the standalone case, there will be more properties that are not applicable here. How would we prevent all those other properties from being evaluated in the AP1302 case ?

Quoted 96 lines
Quoted 96 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +96 -0
+            description: Power supplies for the sensor
+
+        required:
+          - reg
+
+        additionalProperties: false
+
+    required:
+      - "#address-cells"
+      - "#size-cells"
+
+    # How can we express that onnn,model requires one sensor object to be set ?
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - port
+  - sensors
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera@3c {
+            compatible = "onnn,ap1302";
+            reg = <0x3c>;
+
+            clocks = <&clk24mhz>;
+
+            reset-gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+            standby-gpios = <&pio 40 GPIO_ACTIVE_HIGH>;
+
+            port {
+                isp1_out: endpoint {
+                    remote-endpoint = <&seninf_in1>;
+                    data-lanes = <1 2 3 4>;
+                };
+            };
+
+            sensors {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                onnn,model = "onnn,ar0144";
+
+                sensor@0 {
+                    reg = <0>;
+
+                    vdd-supply = <&mt6358_vcamd_reg>;
+                    vaa-supply = <&mt6358_vcama1_reg>;
+                    vddio-supply = <&reg_1p8v_ext>;
+                };
+            };
+        };
+    };
+
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        camera@3c {
+            compatible = "onnn,ap1302";
+            reg = <0x3c>;
+
+            clocks = <&topckgen 0>;
+
+            reset-gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+            standby-gpios = <&pio 40 GPIO_ACTIVE_HIGH>;
+
+            port {
+                isp2_out: endpoint {
+                    remote-endpoint = <&seninf_in1>;
+                    data-lanes = <1 2>;
+                };
+            };
+
+            sensors {
+                #address-cells = <1>;
+                #size-cells = <0>;
+            };
+        };
+    };
+
+...
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer
#4 lore raw

Re: [PATCH v2 2/2] media: dt-bindings: media: i2c: Add bindings for AP1302

Quoted 126 lines · Laurent Pinchart

Hi Rob,

Quoted 35 lines · Rob Herring
Quoted 34 lines · Anil Kumar Mamidala

The AP1302 is a standalone ISP for ON Semiconductor sensors. Add corresponding DT bindings.

---
 .../devicetree/bindings/media/i2c/onnn,ap1302.yaml | 202 +++++++++++++++++++++
 1 file changed, 202 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +16 -0
new file mode 100644
index 0000000..d96e9db
@@ -0,0 +1,202 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,ap1302.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor AP1302 Advanced Image Coprocessor
+
+maintainers:
+  - Laurent Pinchart <[email protected]>
+  - Anil Kumar M <[email protected]>
+
+description: |-
+  The AP1302 is a standalone ISP for ON Semiconductor sensors. It interfaces to
+  up to two RAW CMOS sensors over MIPI CSI-2 connections, processes the two
+  video streams and outputs YUV frames to the host over a MIPI CSI-2 interface.
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+  Frames are output side by side or on two virtual channels.
+
+  The sensors must be identical. They are connected to the AP1302 on dedicated
+  I2C buses, and are controlled by the AP1302 firmware. They are not accessible
+  from the host.

In your case, but in general I'd assume whatever sensors are used here could be attached directly to an SoC with a built-in ISP?

That is correct, the same sensors can be used with a different ISP (built-in or not), or even without any ISP.

Quoted 66 lines

The model and
power supplies you specify wouldn't be different, so I think the same binding could be used for both. Though here, you probably just need a subset. More below.

Quoted 61 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +61 -0
+
+properties:
+  compatible:
+    const: onnn,ap1302
+
+  reg:
+    description: I2C device address.
+    maxItems: 1
+
+  clocks:
+    description: Reference to the CLK clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Reference to the GPIO connected to the RST pin (active low).
+    maxItems: 1
+
+  standby-gpios:
+    description:
+      Reference to the GPIO connected to the STANDBY pin (active high).
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    unevaluatedProperties: false
+    description: MIPI CSI-2 output interface to the host.
+
+    properties:
+      endpoint:
+        $ref: /schemas/graph.yaml#/$defs/endpoint-base
+        unevaluatedProperties: false
+
+        properties:
+          clock-noncontinuous:
+            type: boolean
+
+          data-lanes:
+            oneOf:
+              - items:
+                  - const: 1
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+        required:
+          - data-lanes
+
+  sensors:
+    type: object
+    description: List of connected sensors
+
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 88

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +6 -0
+        const: 0
+
+      onnn,model:
+        $ref: "/schemas/types.yaml#/definitions/string"
+        description: |
+          Model of the connected sensors. Must be a valid compatible string.

Then make it a compatible string and move into each child node.

Quoted 7 lines

We started with that, but considered that it made mistakes more easily in the device tree. As the two sensors have to be identical (it's a limitation of the AP1302), moving the model to the sensor nodes means that someone could set two different models, and the driver will have to include corresponding validation code. It's more code on the driver side, and more complexity on the DT side. Does it actually bring us anything ?

1 schema instead of 2.

That doesn't really seem much more complex given you probably need to make sure you have 2 and only 2 child nodes. You're checking a property either outside or inside a loop:

// check model or...
// for_each_of_child_node()
// ...check compatible
// parse rest of node

// check 2 nodes setup.

Quoted 35 lines
Quoted 20 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+
+          If no sensor is connected, this property must no be specified, and
+          the AP1302 can be used with it's internal test pattern generator.
+
+    patternProperties:

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 103

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +10 -0
+      "^sensor@[01]":
+        type: object
+        description: |
+          Sensors connected to the first and second input, with one node per
+          sensor.
+
+        properties:
+          reg:
+            description: AP1302 input port number
+            maxItems: 1

items:
- enum: [ 0, 1]

Quoted 5 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 106

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +3 -0
+
+        patternProperties:
+          ".*-supply":

You need to list the supplies out.

Fair point, given that we have a list of supply names per sensor in the AP1302 driver.

Quoted 5 lines

I would make this a schema for the
sensor along with compatible. Here, you could either reference those if you want to document the list of supported sensors or don't reference them and just document 'reg'. With a compatible, the schema will be applied anyways.

Quoted 6 lines

This I'm more concerned about. The sensors may be the same when used with the AP1302 or when used standalone, but their integration in the system is quite different. With the AP1302, the reg value is the AP1302 port number, while in the standalone case, it's an I2C address. We're just lucky that the #address-cells and #size-cells happen to be the same in both cases.

'reg' and everything associated with it are properties of the bus and outside the scope of this binding. We have the same binding on devices that can be on I2C or SPI for example.

Quoted 3 lines

In the standalone case, there will be more properties that are not applicable here. How would we prevent all those other properties from being evaluated in the AP1302 case ?

I'm not all that worried about that, but you could have a different compatible if you really wanted.

Rob

#5 lore raw

Re: [PATCH v2 2/2] media: dt-bindings: media: i2c: Add bindings for AP1302

Hi Rob,

Quoted 132 lines · Rob Herring
Quoted 123 lines · Laurent Pinchart
Quoted 35 lines · Rob Herring
Quoted 34 lines · Anil Kumar Mamidala

The AP1302 is a standalone ISP for ON Semiconductor sensors. Add corresponding DT bindings.

---
 .../devicetree/bindings/media/i2c/onnn,ap1302.yaml | 202 +++++++++++++++++++++
 1 file changed, 202 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +16 -0
new file mode 100644
index 0000000..d96e9db
@@ -0,0 +1,202 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,ap1302.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor AP1302 Advanced Image Coprocessor
+
+maintainers:
+  - Laurent Pinchart <[email protected]>
+  - Anil Kumar M <[email protected]>
+
+description: |-
+  The AP1302 is a standalone ISP for ON Semiconductor sensors. It interfaces to
+  up to two RAW CMOS sensors over MIPI CSI-2 connections, processes the two
+  video streams and outputs YUV frames to the host over a MIPI CSI-2 interface.
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+  Frames are output side by side or on two virtual channels.
+
+  The sensors must be identical. They are connected to the AP1302 on dedicated
+  I2C buses, and are controlled by the AP1302 firmware. They are not accessible
+  from the host.

In your case, but in general I'd assume whatever sensors are used here could be attached directly to an SoC with a built-in ISP?

That is correct, the same sensors can be used with a different ISP (built-in or not), or even without any ISP.

Quoted 66 lines

The model and
power supplies you specify wouldn't be different, so I think the same binding could be used for both. Though here, you probably just need a subset. More below.

Quoted 61 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +61 -0
+
+properties:
+  compatible:
+    const: onnn,ap1302
+
+  reg:
+    description: I2C device address.
+    maxItems: 1
+
+  clocks:
+    description: Reference to the CLK clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Reference to the GPIO connected to the RST pin (active low).
+    maxItems: 1
+
+  standby-gpios:
+    description:
+      Reference to the GPIO connected to the STANDBY pin (active high).
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    unevaluatedProperties: false
+    description: MIPI CSI-2 output interface to the host.
+
+    properties:
+      endpoint:
+        $ref: /schemas/graph.yaml#/$defs/endpoint-base
+        unevaluatedProperties: false
+
+        properties:
+          clock-noncontinuous:
+            type: boolean
+
+          data-lanes:
+            oneOf:
+              - items:
+                  - const: 1
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+        required:
+          - data-lanes
+
+  sensors:
+    type: object
+    description: List of connected sensors
+
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 88

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +6 -0
+        const: 0
+
+      onnn,model:
+        $ref: "/schemas/types.yaml#/definitions/string"
+        description: |
+          Model of the connected sensors. Must be a valid compatible string.

Then make it a compatible string and move into each child node.

Quoted 7 lines

We started with that, but considered that it made mistakes more easily in the device tree. As the two sensors have to be identical (it's a limitation of the AP1302), moving the model to the sensor nodes means that someone could set two different models, and the driver will have to include corresponding validation code. It's more code on the driver side, and more complexity on the DT side. Does it actually bring us anything ?

Quoted 1 line

1 schema instead of 2.

I'm not follow you here, given that we would need two different compatible strings according to your suggestion below. Won't that be two schemas ?

Quoted 10 lines

That doesn't really seem much more complex given you probably need to make sure you have 2 and only 2 child nodes. You're checking a property either outside or inside a loop:

// check model or...
// for_each_of_child_node()
// ...check compatible
// parse rest of node

// check 2 nodes setup.

I didn't say it would be extremely complex, but it's still additional complexity on both the driver side and the DT side.

Quoted 41 lines
Quoted 34 lines
Quoted 19 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+
+          If no sensor is connected, this property must no be specified, and
+          the AP1302 can be used with it's internal test pattern generator.
+
+    patternProperties:

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 103

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +10 -0
+      "^sensor@[01]":
+        type: object
+        description: |
+          Sensors connected to the first and second input, with one node per
+          sensor.
+
+        properties:
+          reg:
+            description: AP1302 input port number
+            maxItems: 1

items:
- enum: [ 0, 1]

Quoted 5 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 106

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +3 -0
+
+        patternProperties:
+          ".*-supply":

You need to list the supplies out.

Fair point, given that we have a list of supply names per sensor in the AP1302 driver.

Quoted 5 lines

I would make this a schema for the
sensor along with compatible. Here, you could either reference those if you want to document the list of supported sensors or don't reference them and just document 'reg'. With a compatible, the schema will be applied anyways.

Quoted 6 lines

This I'm more concerned about. The sensors may be the same when used with the AP1302 or when used standalone, but their integration in the system is quite different. With the AP1302, the reg value is the AP1302 port number, while in the standalone case, it's an I2C address. We're just lucky that the #address-cells and #size-cells happen to be the same in both cases.

Quoted 3 lines

'reg' and everything associated with it are properties of the bus and outside the scope of this binding. We have the same binding on devices that can be on I2C or SPI for example.

There's no "bus" as such in this case. The AP1302 firmware handles the sensors and hides them completely from Linux. We have no control bus accessible by Linux for the sensors, and thus no driver binding to the sensors. The reg property is specific to the AP1302 here, so it's not out of scope of this binding.

Quoted 6 lines
Quoted 3 lines

In the standalone case, there will be more properties that are not applicable here. How would we prevent all those other properties from being evaluated in the AP1302 case ?

I'm not all that worried about that, but you could have a different compatible if you really wanted.

So that's two schemas, one for the sensor when used normally, and one when used connected to the AP1302. That's not nice at all :-( I don't think it's a good idea, given that the sensors are not exposed to Linux.

Signature · 3 lines
Regards,

Laurent Pinchart
maintainer
#6 lore raw

Re: [PATCH v2 2/2] media: dt-bindings: media: i2c: Add bindings for AP1302

Quoted 136 lines · Laurent Pinchart

Hi Rob,

Quoted 132 lines · Rob Herring
Quoted 130 lines · Laurent Pinchart
Quoted 35 lines · Rob Herring
Quoted 34 lines · Anil Kumar Mamidala

The AP1302 is a standalone ISP for ON Semiconductor sensors. Add corresponding DT bindings.

---
 .../devicetree/bindings/media/i2c/onnn,ap1302.yaml | 202 +++++++++++++++++++++
 1 file changed, 202 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +16 -0
new file mode 100644
index 0000000..d96e9db
@@ -0,0 +1,202 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,ap1302.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor AP1302 Advanced Image Coprocessor
+
+maintainers:
+  - Laurent Pinchart <[email protected]>
+  - Anil Kumar M <[email protected]>
+
+description: |-
+  The AP1302 is a standalone ISP for ON Semiconductor sensors. It interfaces to
+  up to two RAW CMOS sensors over MIPI CSI-2 connections, processes the two
+  video streams and outputs YUV frames to the host over a MIPI CSI-2 interface.
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+  Frames are output side by side or on two virtual channels.
+
+  The sensors must be identical. They are connected to the AP1302 on dedicated
+  I2C buses, and are controlled by the AP1302 firmware. They are not accessible
+  from the host.

In your case, but in general I'd assume whatever sensors are used here could be attached directly to an SoC with a built-in ISP?

That is correct, the same sensors can be used with a different ISP (built-in or not), or even without any ISP.

Quoted 66 lines

The model and
power supplies you specify wouldn't be different, so I think the same binding could be used for both. Though here, you probably just need a subset. More below.

Quoted 61 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +61 -0
+
+properties:
+  compatible:
+    const: onnn,ap1302
+
+  reg:
+    description: I2C device address.
+    maxItems: 1
+
+  clocks:
+    description: Reference to the CLK clock.
+    maxItems: 1
+
+  reset-gpios:
+    description: Reference to the GPIO connected to the RST pin (active low).
+    maxItems: 1
+
+  standby-gpios:
+    description:
+      Reference to the GPIO connected to the STANDBY pin (active high).
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    unevaluatedProperties: false
+    description: MIPI CSI-2 output interface to the host.
+
+    properties:
+      endpoint:
+        $ref: /schemas/graph.yaml#/$defs/endpoint-base
+        unevaluatedProperties: false
+
+        properties:
+          clock-noncontinuous:
+            type: boolean
+
+          data-lanes:
+            oneOf:
+              - items:
+                  - const: 1
+              - items:
+                  - const: 1
+                  - const: 2
+              - items:
+                  - const: 1
+                  - const: 2
+                  - const: 3
+                  - const: 4
+
+        required:
+          - data-lanes
+
+  sensors:
+    type: object
+    description: List of connected sensors
+
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 88

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +6 -0
+        const: 0
+
+      onnn,model:
+        $ref: "/schemas/types.yaml#/definitions/string"
+        description: |
+          Model of the connected sensors. Must be a valid compatible string.

Then make it a compatible string and move into each child node.

We started with that, but considered that it made mistakes more easily in the device tree. As the two sensors have to be identical (it's a limitation of the AP1302), moving the model to the sensor nodes means that someone could set two different models, and the driver will have to include corresponding validation code. It's more code on the driver side, and more complexity on the DT side. Does it actually bring us anything ?

Quoted 5 lines
Quoted 1 line

1 schema instead of 2.

I'm not follow you here, given that we would need two different compatible strings according to your suggestion below. Won't that be two schemas ?

Depends on how different they are. If it's just disallowing some properties for one compatible, that's probably just an if/then schema. And I said you *could* have different ones.

Quoted 59 lines
Quoted 10 lines

That doesn't really seem much more complex given you probably need to make sure you have 2 and only 2 child nodes. You're checking a property either outside or inside a loop:

// check model or...
// for_each_of_child_node()
// ...check compatible
// parse rest of node

// check 2 nodes setup.

I didn't say it would be extremely complex, but it's still additional complexity on both the driver side and the DT side.

Quoted 41 lines
Quoted 34 lines
Quoted 19 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+
+          If no sensor is connected, this property must no be specified, and
+          the AP1302 can be used with it's internal test pattern generator.
+
+    patternProperties:

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 103

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +10 -0
+      "^sensor@[01]":
+        type: object
+        description: |
+          Sensors connected to the first and second input, with one node per
+          sensor.
+
+        properties:
+          reg:
+            description: AP1302 input port number
+            maxItems: 1

items:
- enum: [ 0, 1]

Quoted 5 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 106

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +3 -0
+
+        patternProperties:
+          ".*-supply":

You need to list the supplies out.

Fair point, given that we have a list of supply names per sensor in the AP1302 driver.

Quoted 5 lines

I would make this a schema for the
sensor along with compatible. Here, you could either reference those if you want to document the list of supported sensors or don't reference them and just document 'reg'. With a compatible, the schema will be applied anyways.

Quoted 6 lines

This I'm more concerned about. The sensors may be the same when used with the AP1302 or when used standalone, but their integration in the system is quite different. With the AP1302, the reg value is the AP1302 port number, while in the standalone case, it's an I2C address. We're just lucky that the #address-cells and #size-cells happen to be the same in both cases.

Quoted 3 lines

'reg' and everything associated with it are properties of the bus and outside the scope of this binding. We have the same binding on devices that can be on I2C or SPI for example.

Quoted 5 lines

There's no "bus" as such in this case. The AP1302 firmware handles the sensors and hides them completely from Linux. We have no control bus accessible by Linux for the sensors, and thus no driver binding to the sensors. The reg property is specific to the AP1302 here, so it's not out of scope of this binding.

If 'reg' is used, then then it is a bus of some kind in the DT definition of a bus. It's 'the way you address child devices' if you want to not use 'bus'.

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

In the standalone case, there will be more properties that are not applicable here. How would we prevent all those other properties from being evaluated in the AP1302 case ?

I'm not all that worried about that, but you could have a different compatible if you really wanted.

So that's two schemas, one for the sensor when used normally, and one when used connected to the AP1302. That's not nice at all :-( I don't think it's a good idea, given that the sensors are not exposed to Linux.

Obviously they are exposed in some way or we wouldn't be having this conversation.

Also, on the supplies, once you list them out, couldn't they be different per sensor model? How would you support that? That's going to mean a schema per sensor model.

Rob

#7 lore raw

Re: [PATCH v2 2/2] media: dt-bindings: media: i2c: Add bindings for AP1302

In reply to Rob Herring
Quoted 19 lines · Rob Herring
Quoted 18 lines · Anil Kumar Mamidala

The AP1302 is a standalone ISP for ON Semiconductor sensors. Add corresponding DT bindings.

---
  .../devicetree/bindings/media/i2c/onnn,ap1302.yaml | 202 +++++++++++++++++++++
  1 file changed, 202 insertions(+)

create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +0 -0
new file mode 100644
index 0000000..d96e9db
@@ -0,0 +1,202 @@

[snip]

Quoted 5 lines

Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml line 159

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/onnn,ap1302.yaml new file +5 -0
+            sensors {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                onnn,model = "onnn,ar0144";

Hello Anil, Laurent,

Is there a driver available for this sensor model ? (or maybe some patch in progress )
I am trying to see if I could use this sensor with current available software or not.

Thanks !