Skip to main content
Visitor II
June 29, 2022
Question

How do I configure an stm32mp157c GPIO pin to output?

  • June 29, 2022
  • 2 replies
  • 1466 views

I have configured the pins for uart7 to communicate with our zwave chip.

in kernel-source/arch/arm/boot/dts/stm32mp157c-dk2.dts

&uart7{
 pinctrl-names = "default", "sleep";
 pinctrl-0 = <&uart7_pins_a>;
 pinctrl-1 = <&uart7_sleep_pins_a>;
 status = "okay";
 
 zwave {
 uart7-gpios = <&gpioi 5 GPIO_ACTIVE_LOW>,
 <&gpioi 7 GPIO_ACTIVE_LOW>,
 <&gpioc 7 GPIO_ACTIVE_LOW>;
 };
 /* USER CODE BEGIN uart7 */
 /* USER CODE END uart7 */
};

kernel-source/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi :

 uart7_pins_a: uart7-0 {
 pins1 {
 pinmux = <STM32_PINMUX('A', 15, AF13)>; /* UART7_TX */
 bias-disable;
 drive-push-pull;
 slew-rate = <0>;
 };
 pins2 {
 pinmux = <STM32_PINMUX('E', 7, AF7)>; /* UART7_RX */
 bias-disable;
 };
 };
 
 uart7_sleep_pins_a: uart7-sleep-0 {
 pins {
 pinmux = <STM32_PINMUX('A', 15, ANALOG)>, /* UART7_TX */
 <STM32_PINMUX('E', 7, ANALOG)>; /* UART7_RX */
 };
 };

I want to control the chip with three output GPIO pins (C7, I5, and I7).

When I bitbake this and load it on the board, the configuration does not change. For C

# gpiodetect
gpiochip0 [GPIOA] (16 lines)
gpiochip1 [GPIOB] (16 lines)
gpiochip2 [GPIOC] (16 lines)
gpiochip3 [GPIOD] (16 lines)
gpiochip4 [GPIOE] (16 lines)
gpiochip5 [GPIOF] (16 lines)
gpiochip6 [GPIOG] (16 lines)
gpiochip7 [GPIOH] (16 lines)
gpiochip8 [GPIOI] (12 lines)
gpiochip9 [GPIOZ] (8 lines)

gpiochip2 - 16 lines:
 line 0: unnamed unused input active-high
 line 1: unnamed kernel input active-high [used]
 line 2: unnamed kernel input active-high [used]
 line 3: unnamed unused input active-high
 line 4: unnamed kernel input active-high [used]
 line 5: unnamed kernel input active-high [used]
 line 6: unnamed unused input active-high
 line 7: unnamed unused input active-high
 line 8: unnamed kernel input active-high [used]
 line 9: unnamed kernel input active-high [used]
 line 10: unnamed kernel input active-high [used]
 line 11: unnamed kernel input active-high [used]
 line 12: unnamed kernel input active-high [used]
 line 13: unnamed unused input active-high
 line 14: unnamed unused input active-high
 line 15: unnamed unused input active-high

and I

gpiochip8 - 12 lines:
 line 0: unnamed unused input active-high
 line 1: unnamed unused input active-high
 line 2: unnamed unused input active-high
 line 3: unnamed kernel input active-high [used]
 line 4: unnamed unused input active-high
 line 5: unnamed kernel input active-high [used]
 line 6: unnamed kernel input active-high [used]
 line 7: unnamed kernel input active-high [used]
 line 8: unnamed kernel input active-high [used]
 line 9: unnamed unused input active-high
 line 10: unnamed unused input active-high
 line 11: unnamed "interrupt" input active-high [used]

Where and how can I change the GPIO pins?

Can I change them in the kernel-source/arch/arm/boot/dts/stm32mp157c-dk2.dts and/or in kernel-source/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi ?

Thanks in advance,

George

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    July 4, 2022

    Hi @GeorgeR​ 

    I'm not expert, but you should probably need to declare a driver in your 'zwave' section (something like "compatible = ....").

    Or use a dummy device (i.e. no driver)

    https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_kernel_space

    Otherwise, without specific driver nor any DT, you could control any 'free' GPIO:

    https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_userspace

    This method could be used from any code (e.g. C or python), see also https://community.st.com/s/question/0D53W00001UZllVSAT

    Regards.

    GeorgeRAuthor
    Visitor II
    July 5, 2022

    Thank you @PatrickF​, I will check out the information.

    Regards,

    @GeorgeR​