DAC device tree configuration
来自百问网嵌入式Linux wiki
目录
Purpose
本文旨在说明将数模转换器(DAC)[1] 分配给 Linux® 操作系统时如何进行配置, 尤其是:
- 如何配置和启用DACperipheral
- 如何配置板、DAC通道、基准电压调节器和引脚。
使用设备树机制执行配置[2].
DAC Linux driver使用它在 IIO framework中注册相关信息,例如IIO设备,通道和电压标度。
如果外围设备已分配给另一个执行上下文,请参阅 How to assign an internal peripheral to a runtime context 文章,以获取有关外围设备分配和配置的准则。
DT bindings documentation
带有所有必需或可选属性的“ STM32 DAC设备树绑定”[3] 协议。
DT configuration
该硬件描述是STM32和电路板设备树文件的组合。 有关分割设备树文件的说明,请参见 Device tree。
STM32CubeMX可用于生成板卡设备树。 有关更多详细信息,请参考How to configure the DT using STM32CubeMX 。
DT configuration (STM32 level)
DAC节点在stm32mp157c.dtsi中声明[4]:
- DT根节点('dac')描述DAC硬件模块参数,例如寄存器区域和时钟。
- DT子节点('dac1'和'dac2')独立描述DAC通道。
dac: dac@address {
compatible = "st,stm32h7-dac-core";
... /* common resources in 'dac' root node. */
dac1: dac@1 {
compatible = "st,stm32-dac";
reg = <1>; /* DAC identifier (e.g. 1 for DAC1) */
... /* private resources in 'dac1' child node. */
};
dac2: dac@2 {
compatible = "st,stm32-dac";
reg = <2>; /* DAC identifier (e.g. 2 for DAC2) */
... /* private resources in 'dac2' child node. */
};
};
| 该设备树部分与STM32微处理器有关。 它应该保持原样,而不要由最终用户修改。 |
DT configuration (board level)
请按照以下顺序在板上配置和启用DAC:
- 通过设置status =“ okay”启用名为'dac'的DT根节点。
- 通过 pinctrl至pinctrl-0和pinctrl-names配置正在使用的引脚。
- 通过设置vref-supply = <&your_regulator>来配置模拟参考电压稳压器[5] 。
- 通过设置status =“ okay”为启用的'dac1'和/或'dac2'通道启用DT子节点 。
| DAC可以使用内部VREFBUF[6] 或连接到VREF +引脚的任何其他外部稳压器[5] |
.
DT configuration example
下面的示例显示如何配置DAC1和DAC2通道:
- PA4和PA5引脚均配置为模拟引脚 (更多信息,请参见 Pinctrl device tree configuration)
- VREFBUF[6] 用作参考电压
dac_ch1_pins_a: dac-ch1 {
pins {
pinmux = <STM32_PINMUX('A', 4, ANALOG)>; /* configure 'PA4' as ANALOG */
};
};
dac_ch2_pins_a: dac-ch2 {
pins {
pinmux = <STM32_PINMUX('A', 5, ANALOG)>; /* configure 'PA5' as ANALOG */
};
};
&dac {
pinctrl-names = "default";
pinctrl-0 = <&dac_ch1_pins_a &dac_ch2_pins_a>; /* Use PA4 and PA5 pin as ANALOG */
vref-supply = <&vrefbuf>; /* Example to use VREFBUF (It needs to be enabled as well) */
status = "okay"; /* Enable the DAC block */
dac1: dac@1 {
status = "okay"; /* Enable DAC1 */
};
dac2: dac@2 {
status = "okay"; /* Enable DAC2 */
};
};
How to configure the DT using STM32CubeMX
STM32CubeMX 工具可用于配置STM32MPU设备并获取相应的 platform configuration device tree 文件。
STM32CubeMX可能不支持以上 DT bindings documentation 段中描述的所有属性。 如果是这样,该工具会在生成的设备树中插入用户部分。 然后可以编辑这些部分以添加一些属性,并将它们一代一代地保留下来。 有关更多信息,请参见 STM32CubeMX 用户手册。
References
有关更多信息,请参考以下链接:
- ↑ DAC internal peripheral
- ↑ Device tree
- ↑ Documentation/devicetree/bindings/iio/dac/st,stm32-dac.txt | |}} Documentation/devicetree/bindings/iio/dac/st,stm32-dac.txt , STM32 DAC device tree bindings
- ↑ arch/arm/boot/dts/stm32mp157c.dtsi | |}} STM32MP157C device tree file
- ↑ 5.05.1 Regulator overview
- ↑ 6.06.1 VREFBUF internal peripheral