“DCMI device tree configuration”的版本间的差异

来自百问网嵌入式Linux wiki
 
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
[[Category:Linux_Operating_System]]
+
== Article purpose ==
[[Category:Visual]]
+
This article explains how to configure the [[DCMI internal peripheral | '''DCMI''' internal peripheral]] when assigned to the Linux<sup>&reg;</sup> OS. In that case, it is controlled by the [[V4L2 camera overview|V4L2 camera framework]].
[[Category:V4L2]]
+
 
 +
The configuration is performed using the [[Device tree|device tree]] mechanism that provides a hardware description of the DCMI peripheral, used by the STM32 DCMI Linux driver or by the V4L2 camera framework.
 +
 
 +
If the peripheral is assigned to another execution context, refer to [[How to assign an internal peripheral to a runtime context]] article for guidelines on peripheral assignment and configuration.
 +
 
 +
== DT bindings documentation ==
 +
The DCMI internal peripheral is documented through the STM32 DCMI device tree bindings file<ref name=bindings>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/media/st,stm32-dcmi.txt | Linux kernel STM32 DCMI bindings (st,stm32-dcmi.txt)}}</ref>.
 +
 
 +
== DT configuration ==
 +
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|device tree]] article for an explanation of the device tree file split.
 +
 
 +
'''STM32CubeMX''' can be used to generate the board device tree. Refer to [[#How_to_configure_the_DT_using_STM32CubeMX|How to configure the DT using STM32CubeMX]] for more details.
 +
 
 +
===DT configuration (STM32 level) ===
 +
The DCMI device tree node is declared in stm32mp157c.dtsi <ref name="stm32mp157c_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi | Linux kernel STM32MP157C device tree (stm32mp157c.dtsi)}}</ref>.
 +
 
 +
The declaration (shown below) provides the hardware registers base address, interrupts, reset line, clocks and dma channel used.
 +
<pre>
 +
dcmi: dcmi@4C006000 {
 +
compatible = "st,stm32-dcmi";
 +
reg = <0x4C006000 0x400>;
 +
interrupts = <GIC_SPI 78 IRQ_TYPE_NONE>;
 +
resets = <&rcc_rst CAMITF_R>;
 +
clocks = <&rcc_clk DCMI>;
 +
clock-names = "mclk";
 +
dmas = <&dmamux1 75 0x400 0x01>;
 +
dma-names = "tx";
 +
status = "disabled";
 +
};
 +
</pre>
 +
{{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 devicetree file (see [[#DT configuration (board level)]]).
 +
 
 +
Refer to stm32-dcmi bindings<ref name=bindings/> for more details.
 +
 
 +
=== DT configuration (board level) ===
 +
<pre>
 +
&dcmi {
 +
status = "okay";
 +
pinctrl-names = "default", "sleep";
 +
pinctrl-0 = <&dcmi_pins_a>;
 +
pinctrl-1 = <&dcmi_sleep_pins_a>;
 +
 
 +
port {
 +
dcmi_0: endpoint {
 +
remote-endpoint = <&ov5640_0>;
 +
bus-width = <8>;
 +
hsync-active = <0>;
 +
vsync-active = <0>;
 +
pclk-sample = <1>;
 +
pclk-max-frequency = <77000000>;
 +
};
 +
};
 +
};
 +
</pre>
 +
This section, part of the STM32MP15 evaluation board device tree file<ref name="stm32mp157ev1_bindings">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c-ev1.dts | Linux kernel STM32MP157 evaluation board device tree (stm32mp157c-ev1.dts)}}</ref>, shows how is configured the DCMI hardware block to interconnect with the sensor camera device. The configurable settings are the following:
 +
* Camera sensor endpoint: in this case, the Omnivision OV5640 model<ref name=ov5640_bindings>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/media/i2c/ov5640.txt | Linux kernel OV5640 bindings (ov5640.txt)}}</ref>.
 +
* Bus width: 8, 10, 12 or 14 bits
 +
* Horizontal synchronization line level: active low (0) or active high (1)
 +
* Vertical synchronization line level: active low (0) or active high (1)
 +
* Pixel clock polarity line level: active low (0) or active high (1)
 +
* Pixel clock maximum frequency in Hertz
 +
 
 +
This section also defines what is the DCMI pins multiplexing used for this board (''<&dcmi_pins_a>, <&dcmi_sleep_pins_a>''), exact pins details being defined in the STM32MP15 evaluation board pinctrl device tree file<ref name="stm32mp157_pinctrl_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157-pinctrl.dtsi | Linux kernel STM32MP157 pinctrl device tree (stm32mp157-pinctrl.dtsi)}}</ref>:
 +
<pre>
 +
dcmi_pins_a: dcmi-0 {
 +
pins {
 +
pinmux = <STM32_PINMUX('H', 8,  AF13)>,/* DCMI_HSYNC */
 +
<STM32_PINMUX('B', 7,  AF13)>,/* DCMI_VSYNC */
 +
<STM32_PINMUX('A', 6,  AF13)>,/* DCMI_PIXCLK */
 +
<STM32_PINMUX('H', 9,  AF13)>,/* DCMI_D0 */
 +
<STM32_PINMUX('H', 10, AF13)>,/* DCMI_D1 */
 +
<STM32_PINMUX('H', 11, AF13)>,/* DCMI_D2 */
 +
<STM32_PINMUX('H', 12, AF13)>,/* DCMI_D3 */
 +
<STM32_PINMUX('H', 14, AF13)>,/* DCMI_D4 */
 +
<STM32_PINMUX('I', 4,  AF13)>,/* DCMI_D5 */
 +
<STM32_PINMUX('B', 8,  AF13)>,/* DCMI_D6 */
 +
<STM32_PINMUX('E', 6,  AF13)>,/* DCMI_D7 */
 +
<STM32_PINMUX('I', 1,  AF13)>,/* DCMI_D8 */
 +
<STM32_PINMUX('H', 7,  AF13)>,/* DCMI_D9 */
 +
<STM32_PINMUX('I', 3,  AF13)>,/* DCMI_D10 */
 +
<STM32_PINMUX('H', 15, AF13)>;/* DCMI_D11 */
 +
bias-disable;
 +
};
 +
};
 +
 
 +
dcmi_sleep_pins_a: dcmi-sleep-0 {
 +
pins {
 +
pinmux = <STM32_PINMUX('H', 8,  ANALOG)>,/* DCMI_HSYNC */
 +
<STM32_PINMUX('B', 7,  ANALOG)>,/* DCMI_VSYNC */
 +
<STM32_PINMUX('A', 6,  ANALOG)>,/* DCMI_PIXCLK */
 +
<STM32_PINMUX('H', 9,  ANALOG)>,/* DCMI_D0 */
 +
<STM32_PINMUX('H', 10, ANALOG)>,/* DCMI_D1 */
 +
<STM32_PINMUX('H', 11, ANALOG)>,/* DCMI_D2 */
 +
<STM32_PINMUX('H', 12, ANALOG)>,/* DCMI_D3 */
 +
<STM32_PINMUX('H', 14, ANALOG)>,/* DCMI_D4 */
 +
<STM32_PINMUX('I', 4,  ANALOG)>,/* DCMI_D5 */
 +
<STM32_PINMUX('B', 8,  ANALOG)>,/* DCMI_D6 */
 +
<STM32_PINMUX('E', 6,  ANALOG)>,/* DCMI_D7 */
 +
<STM32_PINMUX('I', 1,  ANALOG)>,/* DCMI_D8 */
 +
<STM32_PINMUX('H', 7,  ANALOG)>,/* DCMI_D9 */
 +
<STM32_PINMUX('I', 3,  ANALOG)>,/* DCMI_D10 */
 +
<STM32_PINMUX('H', 15, ANALOG)>;/* DCMI_D11 */
 +
};
 +
};
 +
</pre>
 +
An alternate pin multiplexing could be defined (for example to fit a new board design) by modifying the STM32MP15 evaluation board pinctrl device tree file<ref name="stm32mp157_pinctrl_dtsi"/> following the possible pins assignment defined in the MPU reference manual<ref>[[STM32MP15 resources#Reference manuals|STM32MP15 reference manuals]]</ref>.
 +
 
 +
STM32CubeMX <ref>[[STM32CubeMX]]</ref> pins configurator is of great help to find valid alternatives thanks to its visual GUI.
 +
 
 +
Refer to STM32 DCMI bindings<ref name=bindings/> for more details.
 +
 
 +
=== DT configuration examples ===
 +
<pre>
 +
ov5640: camera@3c {
 +
compatible = "ovti,ov5640";
 +
reg = <0x3c>;
 +
clocks = <&clk_ext_camera>;
 +
clock-names = "xclk";
 +
DOVDD-supply = <&v2v8>;
 +
status = "okay";
 +
powerdown-gpios = <&stmfx_pinctrl 18 GPIO_ACTIVE_HIGH>;
 +
reset-gpios = <&stmfx_pinctrl 19 GPIO_ACTIVE_LOW>;
 +
rotation = <180>;
 +
pinctrl-names = "default";
 +
pinctrl-0 = <&ov5640_pins>;
 +
 
 +
port {
 +
ov5640_0: endpoint {
 +
remote-endpoint = <&dcmi_0>;
 +
bus-width = <8>;
 +
data-shift = <2>; /* lines 9:2 are used */
 +
hsync-active = <0>;
 +
vsync-active = <0>;
 +
pclk-sample = <1>;
 +
pclk-max-frequency = <77000000>;
 +
};
 +
};
 +
};
 +
 
 +
 
 +
stmfx: stmfx@42 {
 +
                [...]
 +
stmfx_pinctrl: stmfx-pin-controller {
 +
                        [...]
 +
ov5640_pins: camera {
 +
pins = "agpio2", "agpio3"; /* stmfx pins 18 & 19 */
 +
drive-push-pull;
 +
output-low;
 +
};
 +
};
 +
};
 +
</pre>
 +
This section, part of the STM32MP15 evaluation board device tree file<ref name="stm32mp157ev1_bindings"/>, enables the support of the OV5640 Omnivision camera sensor<ref name=ov5640_bindings/> located on the MB1379 camera daughter board<ref>[[MB1379 | MB1379 camera daughter board]]</ref> connected to the CN7 camera connector<ref>[[STM32MP157C-EV1 - hardware description#MB1262-CN7|STM32MP157C-EV1 Evaluation board CN7 Camera sensor connector]]</ref> of the STM32MP15 evaluation board<ref>[[STM32MP157C-EV1 - hardware description | STM32MP15 evaluation board]]</ref>.
 +
 
 +
Refer to the OV5640 bindings <ref name=ov5640_bindings/> for more details.
 +
 
 +
Documentation on various V4L2 camera sensors can be found inside I2C media bindings folder<ref name=i2c_bindings>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/media/i2c | Linux kernel I2C media devices bindings (bindings/media/i2c)}}</ref>. Refer to the dedicated sensor binding documentation to adapt your board devicetree file to this dedicated sensor.
 +
 
 +
==How to configure the DT using STM32CubeMX==
 +
The [[STM32CubeMX]] tool can be used to configure the STM32MPU device and get the corresponding [[Device_tree#STM32|platform configuration device tree]] files.<br />
 +
The STM32CubeMX may not support all the properties described in the above [[#DT bindings documentation|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.
 +
 
 +
==References==
 +
Please refer to the following links for additional information:
 +
 
 +
<references />
 +
 
 +
<noinclude>
 +
{{ArticleBasedOnModel | Peripheral or framework device tree configuration model}}
 +
{{PublicationRequestId | 9406 | 2019-10-31 | AlainF}}
 +
[[Category:Device tree configuration]]
 +
[[Category:V4L2]]
 +
</noinclude>

2020年5月6日 (三) 18:49的最新版本

Article purpose

This article explains how to configure the DCMI internal peripheral when assigned to the Linux® OS. In that case, it is controlled by the V4L2 camera framework.

The configuration is performed using the device tree mechanism that provides a hardware description of the DCMI peripheral, used by the STM32 DCMI Linux driver or by the V4L2 camera framework.

If the peripheral is assigned to another execution context, refer to How to assign an internal peripheral to a runtime context article for guidelines on peripheral assignment and configuration.

DT bindings documentation

The DCMI internal peripheral is documented through the STM32 DCMI device tree bindings file[1].

DT configuration

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 article for an explanation of the device tree file split.

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

DT configuration (STM32 level)

The DCMI device tree node is declared in stm32mp157c.dtsi [2].

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

		dcmi: dcmi@4C006000 {
			compatible = "st,stm32-dcmi";
			reg = <0x4C006000 0x400>;
			interrupts = <GIC_SPI 78 IRQ_TYPE_NONE>;
			resets = <&rcc_rst CAMITF_R>;
			clocks = <&rcc_clk DCMI>;
			clock-names = "mclk";
			dmas = <&dmamux1 75 0x400 0x01>;
			dma-names = "tx";
			status = "disabled";
		};
Warning.png 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 devicetree file (see #DT configuration (board level)).

Refer to stm32-dcmi bindings[1] for more details.

DT configuration (board level)

&dcmi {
	status = "okay";
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&dcmi_pins_a>;
	pinctrl-1 = <&dcmi_sleep_pins_a>;

	port {
		dcmi_0: endpoint {
			remote-endpoint = <&ov5640_0>;
			bus-width = <8>;
			hsync-active = <0>;
			vsync-active = <0>;
			pclk-sample = <1>;
			pclk-max-frequency = <77000000>;
		};
	};
};

This section, part of the STM32MP15 evaluation board device tree file[3], shows how is configured the DCMI hardware block to interconnect with the sensor camera device. The configurable settings are the following:

  • Camera sensor endpoint: in this case, the Omnivision OV5640 model[4].
  • Bus width: 8, 10, 12 or 14 bits
  • Horizontal synchronization line level: active low (0) or active high (1)
  • Vertical synchronization line level: active low (0) or active high (1)
  • Pixel clock polarity line level: active low (0) or active high (1)
  • Pixel clock maximum frequency in Hertz

This section also defines what is the DCMI pins multiplexing used for this board (<&dcmi_pins_a>, <&dcmi_sleep_pins_a>), exact pins details being defined in the STM32MP15 evaluation board pinctrl device tree file[5]:

			dcmi_pins_a: dcmi-0 {
				pins {
					pinmux = <STM32_PINMUX('H', 8,  AF13)>,/* DCMI_HSYNC */
						 <STM32_PINMUX('B', 7,  AF13)>,/* DCMI_VSYNC */
						 <STM32_PINMUX('A', 6,  AF13)>,/* DCMI_PIXCLK */
						 <STM32_PINMUX('H', 9,  AF13)>,/* DCMI_D0 */
						 <STM32_PINMUX('H', 10, AF13)>,/* DCMI_D1 */
						 <STM32_PINMUX('H', 11, AF13)>,/* DCMI_D2 */
						 <STM32_PINMUX('H', 12, AF13)>,/* DCMI_D3 */
						 <STM32_PINMUX('H', 14, AF13)>,/* DCMI_D4 */
						 <STM32_PINMUX('I', 4,  AF13)>,/* DCMI_D5 */
						 <STM32_PINMUX('B', 8,  AF13)>,/* DCMI_D6 */
						 <STM32_PINMUX('E', 6,  AF13)>,/* DCMI_D7 */
						 <STM32_PINMUX('I', 1,  AF13)>,/* DCMI_D8 */
						 <STM32_PINMUX('H', 7,  AF13)>,/* DCMI_D9 */
						 <STM32_PINMUX('I', 3,  AF13)>,/* DCMI_D10 */
						 <STM32_PINMUX('H', 15, AF13)>;/* DCMI_D11 */
					bias-disable;
				};
			};

			dcmi_sleep_pins_a: dcmi-sleep-0 {
				pins {
					pinmux = <STM32_PINMUX('H', 8,  ANALOG)>,/* DCMI_HSYNC */
						 <STM32_PINMUX('B', 7,  ANALOG)>,/* DCMI_VSYNC */
						 <STM32_PINMUX('A', 6,  ANALOG)>,/* DCMI_PIXCLK */
						 <STM32_PINMUX('H', 9,  ANALOG)>,/* DCMI_D0 */
						 <STM32_PINMUX('H', 10, ANALOG)>,/* DCMI_D1 */
						 <STM32_PINMUX('H', 11, ANALOG)>,/* DCMI_D2 */
						 <STM32_PINMUX('H', 12, ANALOG)>,/* DCMI_D3 */
						 <STM32_PINMUX('H', 14, ANALOG)>,/* DCMI_D4 */
						 <STM32_PINMUX('I', 4,  ANALOG)>,/* DCMI_D5 */
						 <STM32_PINMUX('B', 8,  ANALOG)>,/* DCMI_D6 */
						 <STM32_PINMUX('E', 6,  ANALOG)>,/* DCMI_D7 */
						 <STM32_PINMUX('I', 1,  ANALOG)>,/* DCMI_D8 */
						 <STM32_PINMUX('H', 7,  ANALOG)>,/* DCMI_D9 */
						 <STM32_PINMUX('I', 3,  ANALOG)>,/* DCMI_D10 */
						 <STM32_PINMUX('H', 15, ANALOG)>;/* DCMI_D11 */
				};
			};

An alternate pin multiplexing could be defined (for example to fit a new board design) by modifying the STM32MP15 evaluation board pinctrl device tree file[5] following the possible pins assignment defined in the MPU reference manual[6].

STM32CubeMX [7] pins configurator is of great help to find valid alternatives thanks to its visual GUI.

Refer to STM32 DCMI bindings[1] for more details.

DT configuration examples

ov5640: camera@3c {
		compatible = "ovti,ov5640";
		reg = <0x3c>;
		clocks = <&clk_ext_camera>;
		clock-names = "xclk";
		DOVDD-supply = <&v2v8>;
		status = "okay";
		powerdown-gpios = <&stmfx_pinctrl 18 GPIO_ACTIVE_HIGH>;
		reset-gpios = <&stmfx_pinctrl 19 GPIO_ACTIVE_LOW>;
		rotation = <180>;
		pinctrl-names = "default";
		pinctrl-0 = <&ov5640_pins>;

		port {
			ov5640_0: endpoint {
				remote-endpoint = <&dcmi_0>;
				bus-width = <8>;
				data-shift = <2>; /* lines 9:2 are used */
				hsync-active = <0>;
				vsync-active = <0>;
				pclk-sample = <1>;
				pclk-max-frequency = <77000000>;
			};
		};
	};


	stmfx: stmfx@42 {
                [...]
		stmfx_pinctrl: stmfx-pin-controller {
                        [...]
			ov5640_pins: camera {
				pins = "agpio2", "agpio3"; /* stmfx pins 18 & 19 */
				drive-push-pull;
				output-low;
			};
		};
	};

This section, part of the STM32MP15 evaluation board device tree file[3], enables the support of the OV5640 Omnivision camera sensor[4] located on the MB1379 camera daughter board[8] connected to the CN7 camera connector[9] of the STM32MP15 evaluation board[10].

Refer to the OV5640 bindings [4] for more details.

Documentation on various V4L2 camera sensors can be found inside I2C media bindings folder[11]. Refer to the dedicated sensor binding documentation to adapt your board devicetree file to this dedicated sensor.

How to configure the DT using STM32CubeMX

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.