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

来自百问网嵌入式Linux wiki
第20行: 第20行:
  
 
== DT configuration ==
 
== DT configuration ==
This hardware description is a combination of STM32 microprocessor and board device tree files. See [[Device tree]] for more explanations on device tree file split.
+
该硬件描述是STM32微处理器和电路板设备树文件的组合。 有关设备树文件分割的更多说明,请参见 [[Device tree]]
  
The '''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.
+
'''STM32CubeMX'''可用于生成板卡设备树。 有关更多详细信息,请参考[[#How_to_configure_the_DT_using_STM32CubeMX|How to configure the DT using STM32CubeMX]]
  
 
===DT configuration (STM32 level) ===
 
===DT configuration (STM32 level) ===
  
DFSDM nodes are declared in stm32mp157c.dtsi<ref name="stm32mp157c_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi}}, STM32MP157C device tree file</ref>.
+
DFSDM节点在stm32mp157c.dtsi中声明<ref name="stm32mp157c_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi}}, STM32MP157C device tree file</ref>.
  
* DT root node ('dfsdm') describes the ADC hardware block parameters such as registers area, clocks.
+
* DT根节点('dfsdm')描述ADC硬件模块参数,例如寄存器区域,时钟。
* DT child nodes ('dfsdm0', 'dfsdm1', ...) describe each filter independently: compatible string, interrupts, DMAs.
+
* DT子节点('dfsdm0', 'dfsdm1', ...) 分别描述每个过滤器:兼容的字符串,中断,DMA。
 
  dfsdm: dfsdm@4400d000 {
 
  dfsdm: dfsdm@4400d000 {
 
  compatible = "st,stm32mp1-dfsdm";
 
  compatible = "st,stm32mp1-dfsdm";
第40行: 第40行:
 
  ...
 
  ...
 
  }
 
  }
{{Warning|This device tree part is related to STM32 microprocessors. It should be kept as is, without being modified by the end-user.}}
+
{{Warning|该设备树部分与STM32微处理器有关。它应该保持原样,而不要由最终用户修改。}}
  
 
=== DT configuration (board level) ===
 
=== DT configuration (board level) ===
Follow the sequences described in the below chapters to configure and enable the DFSDM on your board.
+
请按照以下章节中描述的顺序在板上配置和启用DFSDM。
  
 
==== Common resources for all DFSDM filters ====
 
==== Common resources for all DFSDM filters ====
Configure the 'dfsdm' '''DT root node''':
+
配置'dfsdm''''DT根节点'''
* Enable the DT root node for the DFSDM, by setting '''status = "okay"'''.
+
* 通过设置'''status =“ okay”'''为DFSDM启用DT根节点。
* Configure the pins in use via [[Pinctrl overview|pinctrl]], by setting '''pinctrl-0''', '''pinctrl-1''' and '''pinctrl-names'''.
+
* 通过设置'''pinctrl-0''''''pinctrl-1''''''pinctrl-names''',通过[[Pinctrl overview|pinctrl]]配置使用中的引脚。
* Configure the SPI clock output frequency, by setting '''spi-max-frequency''' (optional: only for SPI master mode).
+
* 通过设置'''spi-max-frequency'''(可选:仅用于SPI主模式),配置SPI时钟输出频率。
* Configure the audio clock to be used, by setting '''clocks''' and '''clock-names''' (optional: to use more accurate clock for audio).
+
* 通过设置'''clocks''''''clock-names'''(可选:为音频使用更准确的时钟),配置要使用的音频时钟。
{{ReviewsComments|-- [[User:Gerald Baeza|Gerald Baeza]] ([[User talk:Gerald Baeza|talk]]) 17:03, 19 December 2019 (CET)<br />About the audio clock, maybe you could insert here two lines showing what the device tree looks like when we add the audio clock}}
+
 
  
 
==== Private resources for each DFSDM filter ====
 
==== Private resources for each DFSDM filter ====
Configure the filter(s) '''DT child node(s)''':
+
配置过滤器''' DT子节点'''
* Enable the DT child node(s) for the DFSDM filter(s) in use, by setting '''status = "okay"'''.
+
* 通过设置'''status =“ okay”''',为正在使用的DFSDM过滤器启用DT子节点。
* Override the '''compatible''' string by setting '''"st,stm32-dfsdm-dmic"''' (optional: only for audio digital microphone).
+
* 通过设置'''“ st,stm32-dfsdm-dmic”'''(可选:仅适用于音频数字麦克风)覆盖'''compatible'''字符串。
* Enable the channel(s), by setting '''st,adc-channels = <0 1 2...>'''.
+
* 通过设置'''st,adc-channels = <0 1 2 ...>'''来启用通道。
* Configure the channel(s) by setting '''st,adc-channel-names''', '''st,adc-channel-types''' (e.g. SPI or manchester) and '''st,adc-channel-clk-src''' (e.g. external or internal).
+
* 通过设置'''st,adc-channel-names''''''st,adc-channel-types'''(例如SPI或曼彻斯特)和'''st,adc-channel来配置通道 -clk-src'''(例如外部或内部)。
* Configure the filter order, by setting '''st,filter-order'''.
+
* 通过设置'''st,filter-order'''配置过滤器顺序。
  
 
==== Additional configuration for DFSDM ADC ====
 
==== Additional configuration for DFSDM ADC ====
The DFSDM ADC device has an external analog front-end, the ''sigma delta modulator''.
+
DFSDM ADC器件具有一个外部模拟前端“ sigma delta调制器”。
 
 
Configure the external sigma delta modulator for each channel (optional, not needed for audio digital microphone):
 
* Add '''your_sd_modulator''' DT node in the board dts file (see the generic sd-modulator<ref name="sd-modulator"/> example here after).
 
* Add '''io-channels = <&your_sd_modulator>''' to the DFSDM filter child node in order to assign it to the filter channel(s).
 
  
 +
为每个通道配置外部sigma delta调制器(可选,音频数字麦克风不需要):
 +
* 在板载dts文件中添加'''your_sd_modulator'''DT节点(请参见下面的通用sd-modulator<ref name="sd-modulator"/> 示例)。
 +
* 将 '''io-channels = <&your_sd_modulator>''' 添加到DFSDM过滤器子节点,以便将其分配给过滤器通道。
 
==== Additional configuration for DFSDM audio ====
 
==== Additional configuration for DFSDM audio ====
Additional child nodes must be added for audio [[Soundcard_configuration|soundcard configuration]].
+
必须为音频[[Soundcard_configuration|soundcard configuration]]添加其他子节点。
  
 
=== DT configuration examples ===
 
=== DT configuration examples ===
The example below shows how to configure the DFSDM ADC channel 1, assigned to DFSDM filter 0:
+
下面的示例显示如何配置分配给DFSDM过滤器0的DFSDM ADC通道1:
* Declare pins used in pinctrl DT node (see [[Pinctrl device tree configuration]]):
+
* 声明pinctrl DT节点中使用的引脚 (请参见[[Pinctrl device tree configuration]]):
** Configure PB13 as DFSDM CLKOUT alternate function (AF3 by default, ANALOG for low-power mode).
+
** 将PB13配置为DFSDM CLKOUT备用功能(默认情况下为AF3,对于低功耗模式为ANALOG)。
** Configure PC3 as DFSDM DATA1 alternate function (AF3 by default, ANALOG for low-power mode).
+
** 将PC3配置为DFSDM DATA1备用功能(默认情况下为AF3,对于低功耗模式为ANALOG)。
 
  {{highlight|dfsdm_clkout_pins_a}}: dfsdm-clkout-pins-0 {
 
  {{highlight|dfsdm_clkout_pins_a}}: dfsdm-clkout-pins-0 {
 
  pins {
 
  pins {
第102行: 第101行:
 
  };
 
  };
 
  };
 
  };
* Add sd-modulator<ref name="sd-modulator"/> in the board dts file.
+
* 在板dts文件中添加sd-modulator <ref name="sd-modulator"/>
 
  {{highlight|sd_adc1}}: adc-1 {
 
  {{highlight|sd_adc1}}: adc-1 {
 
  compatible = "sd-modulator";
 
  compatible = "sd-modulator";
 
  #io-channel-cells = <0>;
 
  #io-channel-cells = <0>;
 
  };
 
  };
* Configure and enable DFSDM, configure {{highlight|channel 1}} to use SPI (rising edge), associate it to {{highlight|filter0}}.
+
* 配置并启用DFSDM,将{{highlight|channel 1}}配置为使用SPI(上升沿),并将其关联到{{highlight|filter0}}
 
  &dfsdm {
 
  &dfsdm {
 
  pinctrl-names = "default", "sleep";
 
  pinctrl-names = "default", "sleep";

2020年11月9日 (一) 16:35的版本

Article purpose

本文的目的是说明在将外围设备分配给Linux® OS时如何配置 DFSDM internal peripheral尤其是:

  • 如何配置DFSDM外设以启用过滤器和关联的通道
  • 如何配置电路板,例如 串行接口输入/输出引脚

使用 device tree mechanism执行配置。

DFSDM Linux driver 使用它在IIOALSA框架中注册相关信息。

如果外围设备已分配给另一个执行上下文,请参阅 How to assign an internal peripheral to a runtime context 文章,以获取有关外围设备分配和配置的准则。

DT bindings documentation

DFSDM可以用作各种功能:ADC和DMIC(用于音频)。

每一个都由单独的兼容字符串表示,在此处记录:

  • STM32 DFSDM ADC设备树绑定[1]
  • 音频DFSDM设备树绑定[2]

外部模拟前端(例如,Sigma-Delta调制器)记录如下:

  • 用于Sigma增量调制器的设备树绑定[3]

DT configuration

该硬件描述是STM32微处理器和电路板设备树文件的组合。 有关设备树文件分割的更多说明,请参见 Device tree

STM32CubeMX可用于生成板卡设备树。 有关更多详细信息,请参考How to configure the DT using STM32CubeMX

DT configuration (STM32 level)

DFSDM节点在stm32mp157c.dtsi中声明[4].

  • DT根节点('dfsdm')描述ADC硬件模块参数,例如寄存器区域,时钟。
  • DT子节点('dfsdm0', 'dfsdm1', ...) 分别描述每个过滤器:兼容的字符串,中断,DMA。
dfsdm: dfsdm@4400d000 {
	compatible = "st,stm32mp1-dfsdm";
	...                                                                            /* common resources in 'dfsdm' root node. */
	dfsdm0: filter@0 {
		compatible = "st,stm32-dfsdm-adc";                                     /* can either be st,stm32-dfsdm-(adc or dmic) */
		...                                                                    /* private resources in 'dfsdm0' child node. */
	}
	dfsdm1: filter@1 {
		...
	}
Warning.png 该设备树部分与STM32微处理器有关。它应该保持原样,而不要由最终用户修改。

DT configuration (board level)

请按照以下章节中描述的顺序在板上配置和启用DFSDM。

Common resources for all DFSDM filters

配置'dfsdm'DT根节点

  • 通过设置status =“ okay”为DFSDM启用DT根节点。
  • 通过设置pinctrl-0pinctrl-1pinctrl-names,通过pinctrl配置使用中的引脚。
  • 通过设置spi-max-frequency(可选:仅用于SPI主模式),配置SPI时钟输出频率。
  • 通过设置clocksclock-names(可选:为音频使用更准确的时钟),配置要使用的音频时钟。


Private resources for each DFSDM filter

配置过滤器 DT子节点

  • 通过设置status =“ okay”,为正在使用的DFSDM过滤器启用DT子节点。
  • 通过设置“ st,stm32-dfsdm-dmic”(可选:仅适用于音频数字麦克风)覆盖compatible字符串。
  • 通过设置st,adc-channels = <0 1 2 ...>来启用通道。
  • 通过设置st,adc-channel-namesst,adc-channel-types(例如SPI或曼彻斯特)和st,adc-channel来配置通道 -clk-src(例如外部或内部)。
  • 通过设置st,filter-order配置过滤器顺序。

Additional configuration for DFSDM ADC

DFSDM ADC器件具有一个外部模拟前端“ sigma delta调制器”。

为每个通道配置外部sigma delta调制器(可选,音频数字麦克风不需要):

  • 在板载dts文件中添加your_sd_modulatorDT节点(请参见下面的通用sd-modulator[3] 示例)。
  • io-channels = <&your_sd_modulator> 添加到DFSDM过滤器子节点,以便将其分配给过滤器通道。

Additional configuration for DFSDM audio

必须为音频soundcard configuration添加其他子节点。

DT configuration examples

下面的示例显示如何配置分配给DFSDM过滤器0的DFSDM ADC通道1:

  • 声明pinctrl DT节点中使用的引脚 (请参见Pinctrl device tree configuration):
    • 将PB13配置为DFSDM CLKOUT备用功能(默认情况下为AF3,对于低功耗模式为ANALOG)。
    • 将PC3配置为DFSDM DATA1备用功能(默认情况下为AF3,对于低功耗模式为ANALOG)。
dfsdm_clkout_pins_a: dfsdm-clkout-pins-0 {
	pins {
		pinmux = <STM32_PINMUX('B', 13, AF3)>;     /* DFSDM_CKOUT */
		bias-disable;
		drive-push-pull;
		slew-rate = <1>;
	};
};

dfsdm_clkout_sleep_pins_a: dfsdm-clkout-sleep-pins-0 {
	pins {
		pinmux = <STM32_PINMUX('B', 13, ANALOG)>;  /* DFSDM_CKOUT */
	};
};
dfsdm_data1_pins_a: dfsdm-data1-pins-0 {
	pins {
		pinmux = <STM32_PINMUX('C', 3, AF3)>;      /* DFSDM_DATA1 */
	};
};

dfsdm_data1_sleep_pins_a: dfsdm-data1-sleep-pins-0 {
	pins {
		pinmux = <STM32_PINMUX('C', 3, ANALOG)>;   /* DFSDM_DATA1 */
	};
};
  • 在板dts文件中添加sd-modulator [3]
sd_adc1: adc-1 {
	compatible = "sd-modulator";
	#io-channel-cells = <0>;
};
  • 配置并启用DFSDM,将channel 1配置为使用SPI(上升沿),并将其关联到filter0
&dfsdm {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&dfsdm_clkout_pins_a &dfsdm_data1_pins_a>;                        /* default pins */
	pinctrl-1 = <&dfsdm_clkout_sleep_pins_a &dfsdm_data1_sleep_pins_a>;            /* sleep pins for low-power mode */
	spi-max-frequency = <2048000>;                                                 /* desired maximum clock rate */
	status = "okay";
	dfsdm0: filter@0 {
		st,adc-channels = <1>;                                                 /* Assign channel 1 to this filter */
		st,adc-channel-names = "in1";                                          /* Give it a name */
		st,adc-channel-types = "SPI_R";                                        /* SPI data on rising edge */
		st,adc-channel-clk-src = "CLKOUT_F";                                   /* internal clock source used for conversion */
		io-channels = <&sd_adc1>;                                              /* phandle to the external sd-modulator */
		st,filter-order = <1>;
		status = "okay";
	};
};

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.

References

Please refer to the following links for additional information:

<securetransclude src="ProtectedTemplate:PublicationRequestId" params="9881 | 2018-12-05 | AlainF"></securetransclude> <securetransclude src="ProtectedTemplate:ArticleBasedOnModel" params="Peripheral or framework device tree configuration model"></securetransclude>