How can I edit a pinmux for BeagleBone Black on linux kernel 3.17?
Asked Answered
T

2

7

I can take a peek at /sys/kernel/debug/pinctrl/44e10800.pinmux/pins and see the pin I am interested in:

pin 38 (44e10898.0) 00000037 pinctrl-single 

This corresponds to GPIO[2]4, or P8.10.

I'm using Fedora 21, with kernel 3.17.7-300.fc21.armv7hl.

I would like to change the mux to 0x27. In words, this would configure the pin to have an internal pull-down resistor (before, it was pull up).

The desired output would be:

pin 38 (44e10898.0) 00000027 pinctrl-single 

What can be done?

Note: There is no /sys/devices/bone_capemgr.*, as this is not on Angstrom. The typical DTO approach exports the changes by modifying the cape manager. This is not an option.

Edit: Following exploration from tad's line of thought, I did: dtc -I dtb -O dts -o ~/am335x-boneblack.dts /boot/dtb-3.17.7-300.fc21.armv7hl/am335x-boneblack.dtb. I edited this file to have:

...
    pinmux@44e10800 {
        ...

        example { 
            pinctrl-single,pins = <0x898 0x27>;
        };
    };
...

Then, I compiled it again with dtc, stuck it in /boot/dtb-3.17.7-300.fc21.armv7hl/, and rebooted. However, nothing changed. What's happening?

Edit:

As indicated by Charles Steinkuehler, the 0x800 needs to be subtracted from the offset, and "something" needs to reference "example".

If I add 0x098 0x27 to my entry for user_leds_s0, the desired behavior is observed:

...
    user_leds_s0 {
        pinctrl-single,pins = <0x54 0x7 0x58 0x17 0x5c 0x7 0x60 0x170 0x098 0x27>;
        linux,phandle = <0x3f>;
        phandle = <0x3f>;
    };
...

Now, this is all fine and gets me where I need to go. However, that pin isn't really a user_led. It should be in a separate field of some kind. So, what is the "something" I need to do to get the "example" field or similar to work?

Tope answered 11/1, 2015 at 21:48 Comment(4)
AFAIK the concept of overlays were removed. You need to manipulate the original .dts file in order to get things done. FYI, this is not related to the flavor of the root file system(in your case, Angstrom). This entirely depends on the kernel version.Quan
Pardon my ignorance; Can you elaborate a little more on what would be required, supposing that I found the dts file Fedora uses?Tope
Did you edit the "example" pin definition or add it? If you added this, I see two problems. First, something somewhere needs to reference the "example" pin configuration or it will have no effect. Second, your pinmux register offsets is 0x800 off from what I would expect (ie: 0x898 pinmux register offset turns into 0x098 in the device tree, since the AM335x pinmux driver adds 0x800 for you). If this is an entry you edited, I am unfamiliar with the device tree naming conventions for your particular kernel.Vaasta
I added the "example" pin definition. Is it better to modify an existing definition? Which one? I wasn't able to get it to work by adding 0x98 0x27 to one of them, nor renaming example to pinmux_P8_07_default_pin. The decompiled dtb looks to be identical to github.com/torvalds/linux/blob/… after the includes. Notably, I don't see 0x98 anywhere, so I don't know how it is being set to 0x37 in the first place.Tope
S
3

I believe the cape manager stuff has not been ported past the 3.8 kernel. Not sure if it is planned to be or not, but in the mean time, you can edit the flat device tree instead. The easiest way I have found (and I'm still looking for the best way) is to grab the repository at

https://github.com/RobertCNelson/dtb-rebuilder

In the src/arm directory, edit the am335x-bone-common-pinmux.dtsi file. In it, you can search for "P8_10_default_pin:". This section tell the pinmux to use 0x37 as its default setting. Change this to 0x27 and save.

Now, build the new compiled device tree (.dtb) file by running make. On ubuntu, "make install" puts all of the files in the correct place. I'm not sure on fedora where they go, but digging around in /boot/ should prove interesting. On ubuntu, the correct spot is

/boot/dtbs/`uname -r`/

In my case, I am running 3.14.26-ti-r43. After reboot (and exporting the pin), the above change enables the pulldown on the receiver and the open state (value) reads as 0.

root@arm:~# grep 898 /sys/kernel/debug/pinctrl/44e10800.pinmux/pins
pin 38 (44e10898.0) 00000027 pinctrl-single 

root@arm:~# echo 36 > /sys/class/gpio/export
root@arm:~# cat /sys/class/gpio/gpio36/value 
0

I'm sure there is a more elegant way to accomplish the goal, but this works for me.

Stodge answered 20/1, 2015 at 20:30 Comment(3)
The repos and method you provide is only for 3.14. On the other hand, this has been helpful since I see the .dtb files in /boot/dtbs/$(uname -r)/. It seems like I need to modify the .dts(i) file for my specific kernel, but I can't seem to figure out the final step: github.com/torvalds/linux/blob/… . Any idea how to edit P8.10 in that file (or one of the other bone files?)Tope
There is also a branch in the repo for 3.19. You could take a look at that one too. My guess is that the files aren't materially different, certainly not for the pin you are looking at which doesn't appear to have any particularly tricky other uses. At the very least, you could have a look at what the makefile is doing and duplicate it in the mainline kernel source tree. If I have a chance I'll pull down a fedora image and poke around a bit.Stodge
I assigned the bounty, but am still looking for a more complete answer. I used dtc to get the am335x-boneblack.dts file and added a new group under the pinmux@44e10800 header that looks like example { pinctrl-single,pins = <0x898 0x27>;};, but this does not seem to get picked up.Tope
V
1

If you're using Robert Nelson's kernels (or the ones from BeagleBoard), the pinmux should be under the control of a pinmux-helper driver which allows for run-time setting of the pinmux registers to various predefined values. Look for the file /sys/devices/ocp./P8_10_pinmux./state. If this exists, you can change the pin to an input with pull-down by:

# echo gpio_pd > /sys/devices/ocp.*/P8_10_pinmux.*/state

...or if you're running one of RCN's Debian builds or have installed my universal overlay you can just:

$ config-pin P8.10 in-

The overlay (for 3.8.13 kernels) and config-pin utility (for any kernel with similar pinmux-helper device-tree entries) can be found here: https://github.com/cdsteinkuehler/beaglebone-universal-io

Vaasta answered 22/1, 2015 at 3:37 Comment(1)
This will not work for my kernel. As stated in the original question, the kernel is 3.17.7-300.fc21.armv7hl provided by Fedora.Tope

© 2022 - 2024 — McMap. All rights reserved.