Last edited one month ago

CSI device tree configuration

Applicable for   STM32MP23x lines  STM32MP25x lines

1. Article purpose[edit | edit source]

The purpose of this article is to explain how to configure the CSI internal peripheral by using the device tree mechanism. The explanation relies on the binding documentation that corresponds to the description of the required and optional device-tree properties.

The peripheral can be assigned to different context or software components, depending on the final product needs. Refer to How to assign an internal peripheral to an execution context for more information about this configuration.

2. DT bindings documentation[edit | edit source]

The CSI internal peripheral is documented through the STM32 CSI device tree bindings file Documentation/devicetree/bindings/media/st,stm32-csi.yaml [1].

3. DT configuration[edit | 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 section 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 | edit source]

The CSI device tree node is declared in:

...
	soc@0 {
...
		rifsc: bus@42080000 {
...
			csi: csi@48020000 {
				compatible = "st,stm32mp25-csi";
				reg = <0x48020000 0x0 0x2000>;
				interrupts = <GIC_SPI 129 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";
				access-controllers = <&rifsc 86>;
				status = "disabled";
			};
...
...
	soc@0 {
...
		rifsc: bus@42080000 {
...
			csi: csi@48020000 {
				compatible = "st,stm32mp25-csi";
				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";
				access-controllers = <&rifsc 86>;
				status = "disabled";
			};
...
...
	soc@0 {
...
		rifsc: bus@42080000 {
...
			csi: csi@48020000 {
				compatible = "st,stm32mp25-csi";
				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";
				access-controllers = <&rifsc 86>;
				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.

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) chapter).

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

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

...
&csi {
	vdd-supply =  <&scmi_vddcore>;
	vdda18-supply = <&scmi_v1v8>;
	status = "okay";
	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			csi_sink: endpoint {
				remote-endpoint = <&imx335_ep>;
				data-lanes = <0 1>;
				bus-type = <4>;
			};
		};
		port@1 {
			reg = <1>;
			csi_source: endpoint {
				remote-endpoint = <&dcmipp_0>;
			};
		};
	};
};

&dcmipp {
	status = "okay";
	port {
		dcmipp_0: endpoint {
			remote-endpoint = <&csi_source>;
			bus-type = <4>;
		};
	};
};
...
&i2c2 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&i2c2_pins_a>;
	pinctrl-1 = <&i2c2_sleep_pins_a>;
	i2c-scl-rising-time-ns = <100>;
	i2c-scl-falling-time-ns = <13>;
	clock-frequency = <400000>;
	status = "okay";
	/* spare dmas for other usage */
	/delete-property/dmas;
	/delete-property/dma-names;

	imx335: imx335@1a {
		compatible = "sony,imx335";
		reg = <0x1a>;
		clocks = <&clk_ext_camera>;
		avdd-supply = <&imx335_2v9>;
		ovdd-supply = <&imx335_1v8>;
		dvdd-supply = <&imx335_1v2>;
		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 = <&csi_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 arch/arm64/boot/dts/st/stm32mp257f-ev1.dts [2], shows how the CSI internal peripheral is configured to interconnect with a Sony IMX335 CSI sensor module and to the DCMIPP[3] internal peripheral. The CSI node has two ports: one that must be connected to the video device (such as a sensor) from which the CSI receives data from, and one that must be connected to the input port of the DCMIPP node. The configurable settings are the following ones:

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


The following board device trees can be used as examples to:


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

4. How to configure the DT using STM32CubeMX[edit | 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 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 | edit source]

Refer to the following links for additional information: