TAMP device tree configuration

Applicable for STM32MP13x lines, STM32MP15x lines

1 Article purpose[edit]

This article explains how to configure TAMP internal peripheral.
This article describes the TAMP configuration performed using the device tree mechanism, which provides an hardware description of the TAMP peripheral.

2 DT bindings documentation[edit]

The following binding-related documentation explains how to write device tree files for TAMP:

  • TF-A: Tamper related part: tf-a/docs/devicetree/bindings/soc/st,stm32-tamp.txt"[1]
  • OP-TEE: there is no specific documentation in the source code.
  • Linux Kernel: Backup register management: Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml'[2]

3 DT configuration[edit]

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 split.

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 level)[edit]

3.1.1 STM32 TAMP node in Linux[edit]

  • for STM32MP13x lines Warning.png in stm32mp131.dtsi[3]
tamp: tamp@5c00a000 {
        reg = <0x5c00a000 0x400>;
};
  • for STM32MP15x lines More info.png in stm32mp151.dtsi[4]
tamp: tamp@5c00a000 {
        compatible = "simple-bus", "syscon", "simple-mfd";
        reg = <0x5c00a000 0x400>;

        reboot-mode {
                compatible = "syscon-reboot-mode";
                offset = <0x150>; /* reg20 */
                mask = <0xff>;
                mode-normal = <0>;
                mode-fastboot = <0x1>;
                mode-recovery = <0x2>;
                mode-stm32cubeprogrammer = <0x3>;
                mode-ums_mmc0 = <0x10>;
                mode-ums_mmc1 = <0x11>;
                mode-ums_mmc2 = <0x12>;
        };
};
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.1.2 STM32 TAMP node in OP-TEE[edit]

  • for STM32MP13x lines Warning.png in stm32mp131.dtsi[5]
tamp: tamp@5c00a000 {
        compatible = "st,stm32mp13-tamp", "syscon", "simple-mfd";
        reg = <0x5c00a000 0x400>;
        secure-interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&rcc RTCAPB>;
        st,tamp_passive_precharge = <0>;
        st,tamp_passive_nb_sample = <0>;
        st,tamp_passive_sample_clk_div = <32768>;
        st,tamp_active_clk_div = <1>;
};
  • for STM32MP15x lines More info.png in stm32mp151.dtsi[6]
tamp: tamp@5c00a000 {
        compatible = "st,stm32-tamp", "syscon", "simple-mfd";
        reg = <0x5c00a000 0x400>;
        secure-interrupts = <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&rcc RTCAPB>;
};
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]

3.2.1 STM32MP1 TAMP node append[edit]

The board definition in the device tree may include some additional board-specific pin control management.

Warning white.png Warning
By default, no pinctrl description is required for tamper, the associated GPIO pins are configured by TAMP settings that take over the current GPIO pin configuration. Despite of the hardware management, It may be better to describe the pinctrl to avoid any software double pin request.
 &tamp {
            pinctrl-0 = <&tamp1_pins_a>;              // Must be defined in the pinctrl corresponding to the board
            wakeup-source;                            // Enable the tamper as wake up source
 };

3.2.2 STM32MP1 TAMP node append (OP-TEE specific)[edit]

The board definition in the device tree may include some additional board-specific pin control management, and some global configuration for the external tamper. Per example for STM32MP13x lines Warning.png in stm32mp135f-dk.dts[7]

&tamp {
    st,tamp_passive_nb_sample = <4>;
    st,tamp_passive_sample_clk_div = <16384>;
    tamp_passive@2 {
            pinctrl-0 = <&tamp0_in2_pin_a>;
            status = "okay";
    };
    /* Connect pin24 and pin28 from CN8 */
    tamp_active@1 {
            pinctrl-0 = <&tamp0_in1_pin_a &tamp0_out1_pin_a>;
            status = "disabled";
    };
};

Some system configuration can be overrided in the board tamp node, as these depend of the board. These global configuration are defined for all external tampers.

  • st,tamp_passive_precharge can be 0, 1, 2, 4, 8.
    • 0 is no precharge, so the pull-up is disabled for all external passive tamper.
    • 1, 2, 3, 4, 8 define the number of cycle the STM32 precharge the pin before checking the value (low/high) for all external tamper.
  • st,tamp_passive_nb_sample: the number of sample to read in a row to raise a passive tamper. Can be 0 (activation on edge), 2, 4, 8.
  • st,tamp_passive_sample_clk_div: clock divider to define frequency to read a sample for a passive tamper.
  • st,tamp_active_filter:
    • 0: Active tamper filtering disable
    • 1: Active tamper filtering enable: a tamper event is detected when 2 comparison mismatches occur out of 4 consecutive samples.
  • st,tamp_active_clk_div: clock divider to define the frequency of read/write cycle for all active tampers.
  • wakeup-source: not yet implemented. TAMP event will exit from low power mode.

Each sub-node define an external tamper, and within this node:

  • pinctrl-0 entry defines which pin for which tamper id (see stm32mp13-pinctrl.dtsi [8] for possible values). If only one pin is defined, the external tamper is a passive one, otherwise the external tamper is an active one (first entry is the input pin, second the output pin)
  • st,trig_on defines the active level to activate this passive tamper (not used if pintctrl-0 as 2 entries). It depends also of st,tamp_passive_precharge value.
    • if st,tamp_passive_precharge=0 this passive tamper activate at edge.
    • if st,tamp_passive_precharge != 0, with st,trig_on defined, this passive tamper will activate if st,tamp_passive_nb_sample in a row are high. If not defined the passive tamper event is raised if st,tamp_passive_nb_sample in a row are low.

4 How to configure the DT using STM32CubeMX[edit]

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 the documents listed in DT bindings documentation above. If so, the tool inserts user sections in the generated device tree. These sections can then be edited to add some properties that are preserved from one generation to another. Refer to the STM32CubeMX user manual for further information.

5 References[edit]

Please refer to the following links for additional information: