Skip to main content
Graduate
June 14, 2024
Solved

Configurate alternate function pins in zephyr device tree

  • June 14, 2024
  • 1 reply
  • 2610 views

Hello,

I have created my own board in zephyr (using STM32U575).

Now I would like to configure the power mode pins (CSLEEP, CDSTOP, SRDSTOP ) in the devicetree of the board.

I have therefore implemented the configuration for the pins in the .dts file:

 

&pinctrl {
    csleep: csleep {
        pinmux = <STM32_PINMUX('A', 5, AF0)>;
    };
    cdstop: cdstop {
        pinmux = <STM32_PINMUX('A', 6, AF0)>;
    };
    srdstop: srdstop {
        pinmux = <STM32_PINMUX('A', 7, AF0)>;
    };
};

However, the pins are not set correctly with this setting alone.

Normally, the pins should now be assigned to a periphery.

If I now assign these pins to any periphery, it works:

 

&lpuart1 {
    pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3 &csleep &cdstop &srdstop>;
    pinctrl-names = "default";
    current-speed = <115200>;
    status = "okay";
};

 

But these pins have nothing to do with any peripheral.

How else could I solve this if I don't want to make any settings in the application code?

 

Thank you for the answers.

 

 

 

    This topic has been closed for replies.
    Best answer by Sarra.S

    Hello @JoachimO

    The problem here is that the device tree is primarily used to describe hardware configurations, and it's not typically used to control the power modes directly

    you might need to create and implement a custom power management driver in the device tree, something like this: 

     

    custom_power: custom_power {
     compatible = "xx,custom-power";
     csleep-gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
     cdstop-gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>;
     srdstop-gpios = <&gpioa 7 GPIO_ACTIVE_HIGH>;
     status = "okay";
    };

     

    and of course, add the necessary Kconfig options to enable your custom power management driver: 

     

    CONFIG_CUSTOM_POWER_MANAGEMENT=y

     

    Hope that helps! 

    1 reply

    Super User
    June 14, 2024

    The declaration of pinctrl by itself does not do anything. Notice the  status = "okay" in the uart node, this is what causes activation of this node and pinctrl as its dependency. It looks like you need some fake device node with status = okay.

     

    JoachimOAuthor
    Graduate
    June 17, 2024

    How can I do this?

    Are any changes necessary in the soc driver?

     

    Sarra.SAnswer
    ST Employee
    June 25, 2024

    Hello @JoachimO

    The problem here is that the device tree is primarily used to describe hardware configurations, and it's not typically used to control the power modes directly

    you might need to create and implement a custom power management driver in the device tree, something like this: 

     

    custom_power: custom_power {
     compatible = "xx,custom-power";
     csleep-gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
     cdstop-gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>;
     srdstop-gpios = <&gpioa 7 GPIO_ACTIVE_HIGH>;
     status = "okay";
    };

     

    and of course, add the necessary Kconfig options to enable your custom power management driver: 

     

    CONFIG_CUSTOM_POWER_MANAGEMENT=y

     

    Hope that helps!