“FDCAN device tree configuration”的版本间的差异
(未显示2个用户的7个中间版本) | |||
第1行: | 第1行: | ||
− | [[ | + | == Article purpose == |
− | + | 本文介绍了如何配置[[FDCAN internal peripheral|FDCAN]] when it is assigned to the Linux<sup>®</sup> 操作系统。 在这种情况下,它由 [[CAN overview|CAN framework]] 用于Bosch M_CAN控制器。 | |
− | + | ||
− | + | 使用 [[Device tree|device tree]]机制执行配置,该机制提供了FDCAN外设的硬件描述,并由M_CAN Linux驱动程序和 NET/CAN 框架使用。 | |
− | [[ | + | |
+ | 如果外围设备已分配给另一个执行上下文,请参阅[[How to assign an internal peripheral to a runtime context]] 文章,以获取有关外围设备分配和配置的准则。 | ||
+ | |||
+ | == DT bindings documentation == | ||
+ | M_CAN设备树绑定<ref>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/net/can/m_can.txt | Documentation/devicetree/bindings/net/can/m_can.txt}} M_CAN device tree bindings</ref> 描述了所有必需和可选属性。 | ||
+ | |||
+ | == DT configuration == | ||
+ | 该硬件描述是 '''STM32 microprocessor''' 设备树文件(扩展名为.dtsi)和“''板子”设备树文件(扩展名为.dts)的组合。 有关设备树文件分割的说明,请参见[[Device tree]]。 | ||
+ | |||
+ | '''STM32CubeMX''' 可用于生成板卡设备树。有关更多详细信息,请参考[[#How_to_configure_the_DT_using_STM32CubeMX|How to configure the DT using STM32CubeMX]]。 | ||
+ | |||
+ | ===DT configuration (STM32 level) === | ||
+ | |||
+ | 所有M_CAN节点均在stm32mp157c.dtsi中进行了描述 <ref>{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi | arch/arm/boot/dts/stm32mp157c.dtsi}}, STM32MP157C device tree file</ref> 文件,该文件具有禁用状态和必需的属性,例如: | ||
+ | |||
+ | * 物理基址和设备寄存器映射的大小 | ||
+ | * 消息RAM地址和大小(CAN SRAM) | ||
+ | * 主机时钟和CAN时钟 | ||
+ | * 消息RAM配置 | ||
+ | |||
+ | 这是一组属性,对于给定的STM32器件可能不会改变。 | ||
+ | m_can1: can@4400e000 { | ||
+ | compatible = "bosch,m_can"; | ||
+ | reg = <0x4400e000 0x400>, <0x44011000 0x1400>; {{highlight|/* FDCAN1 uses only the first half of the dedicated CAN_SRAM */}} | ||
+ | reg-names = "m_can", "message_ram"; | ||
+ | interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>, | ||
+ | <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; | ||
+ | interrupt-names = "int0", "int1"; | ||
+ | clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>; | ||
+ | clock-names = "hclk", "cclk"; | ||
+ | bosch,mram-cfg = <0x0 0 0 32 0 0 2 2>; | ||
+ | status = "disabled"; | ||
+ | }; | ||
+ | |||
+ | m_can2: can@4400f000 { | ||
+ | compatible = "bosch,m_can"; | ||
+ | reg = <0x4400f000 0x400>, <0x44011000 0x2800>; {{highlight|/* The 10 Kbytes of the CAN_SRAM are mapped */}} | ||
+ | reg-names = "m_can", "message_ram"; | ||
+ | interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>, | ||
+ | <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>; | ||
+ | interrupt-names = "int0", "int1"; | ||
+ | clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>; | ||
+ | clock-names = "hclk", "cclk"; | ||
+ | bosch,mram-cfg = <0x1400 0 0 32 0 0 2 2>; {{highlight|/* Set mram-cfg offset to write FDCAN2 data on the second half of the dedicated CAN_SRAM */}} | ||
+ | status = "disabled"; | ||
+ | }; | ||
+ | [[FDCAN_device_tree_configuration#DT_bindings_documentation|bindings files]]中完整描述了必需和可选的属性。 | ||
+ | |||
+ | {{Warning|该设备树部分与STM32微处理器有关。它必须保持原样,而不能由最终用户修改。}} | ||
+ | |||
+ | === DT configuration (board level) === | ||
+ | [[Device tree|device tree]] 的一部分用于描述在给定板上使用的FDCAN硬件。 DT节点 ('''"m_can"''') 必须填写: | ||
+ | * 通过设置 '''status = "okay".'''来启用CAN块。 | ||
+ | * 通过 [[Pinctrl overview|pinctrl]], through '''pinctrl-0''' (default pins), '''pinctrl-1''' (sleep pins) and '''pinctrl-names'''来配置正在使用的管脚。 | ||
+ | |||
+ | === DT configuration examples === | ||
+ | 以下示例显示了如何在板级上配置和启用FDCAN1实例: | ||
+ | &m_can1 { | ||
+ | pinctrl-names = "default", "sleep"; {{highlight|/* configure pinctrl modes for m_can1 */}} | ||
+ | pinctrl-0 = <&m_can1_pins_a>; {{highlight|/* configure m_can1_pins_a as default pinctrl configuration for m_can1 */}} | ||
+ | pinctrl-1 = <&m_can1_sleep_pins_a>; {{highlight|/* configure m_can1_sleep_pins_a as sleep pinctrl configuration for m_can1 */}} | ||
+ | status = "okay"; {{highlight|/* enable m_can1 */}} | ||
+ | }; | ||
+ | |||
+ | ==How to configure the DT using STM32CubeMX== | ||
+ | The [[STM32CubeMX]] 工具可用于配置STM32MPU设备并获取相应的[[Device_tree#STM32|platform configuration device tree]] 文件。<br /> | ||
+ | STM32CubeMX可能不支持以上[[#DT bindings documentation|DT bindings documentation]] 段中描述的所有属性。 如果是,该工具会在生成的设备树中插入 '''user sections''' 。 然后可以编辑这些部分以添加一些属性,并将它们一代一代地保留下来。 有关更多信息,请参见[[STM32CubeMX]] 用户手册。 | ||
+ | |||
+ | ==References== | ||
+ | 请参考以下链接以获取更多信息: | ||
+ | <references /> |
2020年11月6日 (五) 16:20的最新版本
目录
Article purpose
本文介绍了如何配置FDCAN when it is assigned to the Linux® 操作系统。 在这种情况下,它由 CAN framework 用于Bosch M_CAN控制器。
使用 device tree机制执行配置,该机制提供了FDCAN外设的硬件描述,并由M_CAN Linux驱动程序和 NET/CAN 框架使用。
如果外围设备已分配给另一个执行上下文,请参阅How to assign an internal peripheral to a runtime context 文章,以获取有关外围设备分配和配置的准则。
DT bindings documentation
M_CAN设备树绑定[1] 描述了所有必需和可选属性。
DT configuration
该硬件描述是 STM32 microprocessor 设备树文件(扩展名为.dtsi)和“板子”设备树文件(扩展名为.dts)的组合。 有关设备树文件分割的说明,请参见Device tree。
STM32CubeMX 可用于生成板卡设备树。有关更多详细信息,请参考How to configure the DT using STM32CubeMX。
DT configuration (STM32 level)
所有M_CAN节点均在stm32mp157c.dtsi中进行了描述 [2] 文件,该文件具有禁用状态和必需的属性,例如:
- 物理基址和设备寄存器映射的大小
- 消息RAM地址和大小(CAN SRAM)
- 主机时钟和CAN时钟
- 消息RAM配置
这是一组属性,对于给定的STM32器件可能不会改变。
m_can1: can@4400e000 { compatible = "bosch,m_can"; reg = <0x4400e000 0x400>, <0x44011000 0x1400>; /* FDCAN1 uses only the first half of the dedicated CAN_SRAM */ reg-names = "m_can", "message_ram"; interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "int0", "int1"; clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>; clock-names = "hclk", "cclk"; bosch,mram-cfg = <0x0 0 0 32 0 0 2 2>; status = "disabled"; }; m_can2: can@4400f000 { compatible = "bosch,m_can"; reg = <0x4400f000 0x400>, <0x44011000 0x2800>; /* The 10 Kbytes of the CAN_SRAM are mapped */ reg-names = "m_can", "message_ram"; interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "int0", "int1"; clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>; clock-names = "hclk", "cclk"; bosch,mram-cfg = <0x1400 0 0 32 0 0 2 2>; /* Set mram-cfg offset to write FDCAN2 data on the second half of the dedicated CAN_SRAM */ status = "disabled"; };
bindings files中完整描述了必需和可选的属性。
![]() |
该设备树部分与STM32微处理器有关。它必须保持原样,而不能由最终用户修改。 |
DT configuration (board level)
device tree 的一部分用于描述在给定板上使用的FDCAN硬件。 DT节点 ("m_can") 必须填写:
- 通过设置 status = "okay".来启用CAN块。
- 通过 pinctrl, through pinctrl-0 (default pins), pinctrl-1 (sleep pins) and pinctrl-names来配置正在使用的管脚。
DT configuration examples
以下示例显示了如何在板级上配置和启用FDCAN1实例:
&m_can1 { pinctrl-names = "default", "sleep"; /* configure pinctrl modes for m_can1 */ pinctrl-0 = <&m_can1_pins_a>; /* configure m_can1_pins_a as default pinctrl configuration for m_can1 */ pinctrl-1 = <&m_can1_sleep_pins_a>; /* configure m_can1_sleep_pins_a as sleep pinctrl configuration for m_can1 */ status = "okay"; /* enable m_can1 */ };
How to configure the DT using STM32CubeMX
The STM32CubeMX 工具可用于配置STM32MPU设备并获取相应的platform configuration device tree 文件。
STM32CubeMX可能不支持以上DT bindings documentation 段中描述的所有属性。 如果是,该工具会在生成的设备树中插入 user sections 。 然后可以编辑这些部分以添加一些属性,并将它们一代一代地保留下来。 有关更多信息,请参见STM32CubeMX 用户手册。
References
请参考以下链接以获取更多信息:
- ↑ Documentation/devicetree/bindings/net/can/m_can.txt | |}} Documentation/devicetree/bindings/net/can/m_can.txt M_CAN device tree bindings
- ↑ arch/arm/boot/dts/stm32mp157c.dtsi | |}} arch/arm/boot/dts/stm32mp157c.dtsi , STM32MP157C device tree file