PCIe device tree configuration

Revision as of 18:08, 4 June 2024 by Registered User
Applicable for STM32MP25x lines

1. Article purpose[edit source]

The purpose of this article is to explain how to configure the PCIe internal peripheral using the device tree mechanism, relying on the bindings documentation, that is the description of the required and optional device-tree properties.

It is used by the PCIe Linux drivers [1] [2] which registers the relevant information in the PCIe framework.

2. DT bindings documentation[edit source]

The device tree binding documents are stored in the Linux® kernel repository:

for host mode:

for device mode:

3. DT configuration[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 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/SoC level)[edit source]

The PCIe controller can act either as a root complex (RC), or as an endpoint (EP). Each mode is composed of a set of properties, used to describe the PCIe controller: registers address, clocks, resets, ...

The pcie_rc and pcie_ep DT nodes are declared in:

  • stm32mp251.dtsi[3] on STM32MP25x lines More info.png

3.1.1. PCIe Host node[edit source]

pcie_rc: pcie-ep@48400000 {
     compatible = "st,stm32mp25-pcie-rc", "snps,dw-pcie";
     device_type = "pci";
     num-lanes = <1>;
     reg = <0x48400000 0x400000>,
              <0x10000000 0x10000>;
     reg-names = "dbi", "config";
     st,syscfg = <&syscfg>;
     #interrupt-cells = <1>;
     interrupt-map-mask = <0 0 0 7>;
     interrupt-map = <0 0 0 1 &intc 0 GIC_SPI 264 IRQ_TYPE_LEVEL_HIGH>,
                              <0 0 0 2 &intc 0 GIC_SPI 265 IRQ_TYPE_LEVEL_HIGH>,
                              <0 0 0 3 &intc 0 GIC_SPI 266 IRQ_TYPE_LEVEL_HIGH>,
                              <0 0 0 4 &intc 0 GIC_SPI 267 IRQ_TYPE_LEVEL_HIGH>;
     interrupts = <GIC_SPI 232 IRQ_TYPE_LEVEL_HIGH>,
                        <GIC_SPI 238 IRQ_TYPE_LEVEL_HIGH>;
     interrupt-names = "aer_msi", "pme_msi";
     #address-cells = <3>;
     #size-cells = <2>;
     ranges = <0x01000000 0 0x10010000 0x10010000 0 0x10000>,
                    <0x02000000 0 0x10020000 0x10020000 0 0x7fe0000>,
                    <0x42000000 0 0x18000000 0x18000000 0 0x8000000>;
     bus-range = <0x00 0xff>;
     clocks = <&rcc CK_BUS_PCIE>;
     clock-names = "core";
     resets = <&rcc PCIE_R>;
     reset-names = "pcie";
     phys = <&combophy PHY_TYPE_PCIE>;
     phy-names = "pcie-phy";
     msi-parent = <&v2m0>;
     feature-domains = <&rifsc STM32MP25_RIFSC_PCIE_ID>;
     power-domains = <&CLUSTER_PD>;
     status = "disabled";
};

3.1.2. PCIe Device node[edit source]

pcie_ep: pcie-ep@48400000 {
         compatible = "st,stm32mp25-pcie-ep", "snps,dw-pcie-ep";
         num-lanes = <1>;
         reg = <0x48400000 0x400000>,
                  <0x10000000 0x8000000>;
         reg-names = "dbi", "addr_space";
         st,syscfg = <&syscfg>;
         clocks = <&rcc CK_BUS_PCIE>;
         clock-names = "core";
         resets = <&rcc PCIE_R>;
         reset-names = "pcie";
         phys = <&combophy PHY_TYPE_PCIE>;
         phy-names = "pcie-phy";
         feature-domains = <&rifsc STM32MP25_RIFSC_PCIE_ID>;
         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.

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

The objective of this chapter is to explain how to enable and configure the "PCIe" DT node for a board.

Peripheral configuration should be done in specific board device tree files (board dts file).

3.3. DT configuration examples[edit source]

The example below shows how to enable and configure the PCIe in Host Mode with the perst# (reset) on GPIOJ8 and clkreq# using pinmux on GPIOJ0

&pcie_rc {
       pinctrl-names = "default", "init";
       pinctrl-0 = <&pcie_pins_a>;
       pinctrl-1 = <&pcie_init_pins_a>;
       reset-gpios = <&gpioj 8 GPIO_ACTIVE_LOW>;
       status = "okay";
};

The example below shows how to enable and configure the PCIe in Device Mode with the perst# (reset) on GPIOJ8 and clkreq# using pinmux on GPIOJ0

Warning white.png Warning
pcie_rc and pcie_ep nodes are exclusively enabled
&pcie_ep {
       pinctrl-names = "default", "init";
       pinctrl-0 = <&pcie_pins_a>;
       pinctrl-1 = <&pcie_init_pins_a>;
       reset-gpios = <&gpioj 8 GPIO_ACTIVE_LOW>;
       status = "okay";
};

4. How to configure the DT using STM32CubeMX[edit source]

The STM32CubeMX tool can be used to configure the STM32MPU device and get the corresponding platform configuration device tree files.
STM32CubeMX may not support all the properties described in DT binding files listed 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.

5. References[edit source]

Refer to the following links for additional information: