Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5175

Advanced users • Re: Setting gpio pullup in kernel module that is using the GPIO API

$
0
0
Andy - sorry it's taken a while to get back to you.

The reason your pinctrl declaration has no effect is that nothing is making any use of it - it's currently just a description of a possible configuration.

A DT node which is description of a hardware device along with a compatible string - let's call it a "device node" - can request that certain configuration changes have already happened before their probe() function is called. Replacing code with data is usually a good thing, and by moving setup code from each device driver into a common subsystem you save a lot of space. For pinctrl, the device node requires at least two properties - a series of "pinctrl-<n>" properties, each of which holds an array of references to pinctrl declarations such as yours, and an array of names for those configurations which is called "pinctrl-names". You usually find that there is only one configuration, named "default" and given the index of 0. Yours would look like this:

Code:

pinctrl-0 = <&joystick_pins>;pinctrl-names = "default";
Now you just need somewhere to stick it. Normally it would be the device node associated with your driver, but if you don't have one you may be able to enlist the help of another device node that doesn't require any pinctrl configuration of its own. A common donor/victims is the "leds" node, which on Pi 2 looks like this:

Code:

leds: leds {compatible = "gpio-leds";led_act: led-act {label = "ACT";default-state = "off";linux,default-trigger = "mmc0";gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;};led_pwr: led-pwr {label = "PWR";gpios = <&gpio 35 GPIO_ACTIVE_HIGH>;default-state = "off";linux,default-trigger = "input";};};
As you can see, there is no pinctrl declaration here, so you can extend your own overlay to add one:

Code:

fragment@1 {target = <&leds>;__overlay__ {pinctrl-0 = <&joystick_pins>;pinctrl-names = "default";};};
Does that help?

Statistics: Posted by PhilE — Mon Dec 23, 2024 2:35 pm



Viewing all articles
Browse latest Browse all 5175

Trending Articles