cancel
Showing results for 
Search instead for 
Did you mean: 

Can not controll GPIO from Kernel Space

SAman.1
Associate III

Hello i wanted to use the GPIOLib to control my pin manualy. so i added this in my device tree.

&usart3 {

pinctrl-names = "default", "sleep", "idle";

pinctrl-0 = <&usart3_pins_c>;

pinctrl-1 = <&usart3_sleep_pins_c>;

pinctrl-2 = <&usart3_idle_pins_c>;

uart-has-rtscts;

status = "ok";

ethernet {

compatible = "st,stm32_usart_net";

local-mac-address = [ A0 B0 C0 D0 E0 F0 ];

pinctrl-names = "default";

rts-gpios = <&gpioa 11 GPIO_ACTIVE_LOW>;

cts-gpios = <&gpioa 12 GPIO_ACTIVE_LOW>;

  };

};

and in my code i wanted to change the pin state like that:

rtsGpio = devm_gpiod_get(&serdev->dev, "rts-gpios", GPIOD_OUT_HIGH);

   

  ssleep(1);

gpiod_set_value(rtsGpio, 1);

but when i look at it the pin is not changing the status. and i get this log message:

gpiod_set_value: invalid GPIO (errorpointer)

4 REPLIES 4
TDK
Guru

I tagged this as MPU rather than MCU.

If you feel a post has answered your question, please click "Accept as Solution".
SAman.1
Associate III

Ok thanks fpr it. Is there a way to check if devm_gpiod_get was sucessfull or not?

SAman.1
Associate III

i tried diffent pins but i always get the same result. in my configuration i want to use the pin 3 and 5.

Olivier GALLIEN
ST Employee

Hi @SAman.1​ ,

Usage of GPIOLib is to control GPIO from Userspace.

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

And here you want to drive a pin which is allocate to usart3 .. which is not possible.

Pin allocate to UART might be drive through UART driver.

What do you want to achieve ?

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.