CSI device tree configuration

Revision as of 11:56, 20 October 2023 by Registered User (→‎DT configuration (board level))
Applicable for STM32MP25x lines

1. Article purpose[edit source]

The purpose of this article is to explain how to configure the CSI internal peripheral using the device tree mechanism, relying on the bindings documentation, that is the description of the required and optional device-tree properties.

The peripheral can be assigned to different contexts/software components, depending on the final product needs. Refer to How to assign an internal peripheral to an execution context for guidelines on this configuration .

2. DT bindings documentation[edit source]

The device tree binding documents are stored either in the given applicable components listed below, or in the Linux kernel repository:

  • Linux® OS :
    • for example: STM32 CSI device tree bindings:[1]
Warning white.png Warning
The STM32 CSI device tree bindings file will be renamed st,stm32-csi.yaml in final delivery.

3. DT configuration[edit source]

This hardware description is a combination of the STM32 microprocessor device tree files (.dtsi extension) and board device tree files (.dts extension). See the Device tree for an explanation of the device-tree file organization.

STM32CubeMX can be used to generate the board device tree. Refer to How to configure the DT using STM32CubeMX for more details.

3.1. DT configuration (STM32 level/SoC level)[edit source]

The CSI device tree node is located in stm32mp251.dtsi [2].

The declaration (shown below) provides the hardware registers base address, interrupts, reset line and clocks used.

		csi2host: csi2host@48020000 {
			compatible = "st,stm32-csi2host";
			reg = <0x48020000 0x2000>;
			interrupts = <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>;
			resets = <&rcc CSI_R>;
			clocks = <&rcc CK_KER_CSI>, <&rcc CK_KER_CSITXESC>,
				      <&rcc CK_KER_CSIPHY>;
			clock-names = "pclk", "txesc", "csi2phy";
			feature-domains = <&rifsc STM32MP25_RIFSC_CSI_ID>;
			status = "disabled";
		};
Warning white.png Warning
This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.
Warning white.png Warning
The compatible property will be renamed st,stm32-csi and node name renamed csi instead of csi2host in final delivery.

When using a different sensor camera device, only the sensor-related configuration part must be adapted in the associated board device tree file (see #DT configuration (board level)).

Refer to STM32 CSI device tree bindings file[1] for more details.

3.2. DT configuration (board level)[edit source]

The objective of this chapter is to explain how to enable and configure the CSI DT nodes for a board.

&csi2host {
	status = "okay";
	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			csi2host_sink: endpoint {
				remote-endpoint = <&imx335_ep>;
				data-lanes = <0 1>;
				bus-type = <4>;
			};
		};
		port@1 {
			reg = <1>;
			csi2host_source: endpoint {
				remote-endpoint = <&dcmipp_0>;
			};
		};
	};
};

&dcmipp {
	status = "okay";
	port {
		dcmipp_0: endpoint {
			remote-endpoint = <&csi2host_source>;
			bus-type = <4>;
		};
	};
};

[...]

	imx335: imx335@1a {
		compatible = "sony,imx335";
		reg = <0x1a>;
		clocks = <&clk_ext_camera>;
		reset-gpios = <&gpioi 7 (GPIO_ACTIVE_HIGH | GPIO_PUSH_PULL)>;
		powerdown-gpios = <&gpioi 0 (GPIO_ACTIVE_HIGH | GPIO_PUSH_PULL)>;
		status = "okay";	

		port {
			imx335_ep: endpoint {
				remote-endpoint = <&csi2host_sink>;
				clock-lanes = <0>;
				data-lanes = <1 2>;
				link-frequencies = /bits/ 64 <594000000>;
			};
		};
	};

This section, part of the STM32MP257x-EV1 Evaluation board More info green.png device tree file[3], shows how is configured the CSI internal peripheral to interconnect with a Sony IMX335 CSI sensor module and to the DCMIPP[4] internal peripheral. The csi2host node has two ports, one which must be connected to the video device (such as sensor) from which the CSI will receive data from, and one that must be connected to the input port of the DCMIPP node. The configurable settings are the following:

  • remote-endpoint: in this case, the Sony IMX335 sensor model[5].
  • Number and ordering of CSI-2 data lanes: one or two entries. In case of two lanes <1 2> means that lane are not crossed while <2 1> means that physical lane 2 becomes logical lane 1.
  • bus-type: should not be changed, this corresponds to CSI2 DPHY bus type.

Refer to STM32 CSI device tree bindings file[1] for more details.

4. How to configure the DT using STM32CubeMX[edit source]

The STM32CubeMX tool can be used to configure the STM32MPU device and get the corresponding platform configuration device tree files.
The STM32CubeMX may not support all the properties described in the above DT bindings documentation paragraph. If so, the tool inserts user sections in the generated device tree. These sections can then be edited to add some properties and they are preserved from one generation to another. Refer to STM32CubeMX user manual for further information.

5. References[edit source]

Refer to the following links for additional information: