cancel
Showing results for 
Search instead for 
Did you mean: 

Device Tree configuration form GPIO

KChoj.2312
Associate II

Hi,

Is there any example showing how to configure a simple GPIO line using DeviceTree? I would like to set the pullup/pulldown or open drain and then use the /sys/class/gpio to read or write the value. The only example I can find is the GPIO setting for particular peripheral and not for standalone input/output pin.

I have added the following section to the &pinctrl in my device tree but I think it has no effect on the pins configuration.

	gpio_pins_mx: gpio_pins_mx-0 {
		u-boot,dm-pre-reloc;
		pins {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('D', 11, GPIO)>,
				<STM32_PINMUX('C', 0, GPIO)>,
				<STM32_PINMUX('B', 7, GPIO)>;
			bias-pull-down;
		};
	};

Thank you,

Chris

3 REPLIES 3
Olivier GALLIEN
ST Employee

Hi @Community member​ 

Did you refer to https://wiki.st.com/stm32mpu/wiki/GPIO_device_tree_configuration ?

Did you check same pin are not used / configured for another peripheral ?

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.

Yes, I know this document, but is it not clear to me how i should configure the standalone GPIO. The article specifies the foo-device that controls the GPIO, however I need to configure a GPIO for the independent control with the /sys/class/gpio subsystem. The pins I listed are not used by any other device, but I suspect that I need to refer to them in the root node somehow.

I am able to control the GPIO by exporting them and using the direction and value files, however i still don't know hot to set the pull-ups etc.

Chris

rhaberkorn
Associate II

I would also be interested in this. The only answer I found so far is writing a dummy driver existing solely, so we can declare something in the device tree and reference the pinctrl node for our GPIO. There has got to be a simpler solution.