Beaglebone black edit default am335x-boneblack.dts device tree

2,527 views
Skip to first unread message

Paco Dupont

unread,
Aug 18, 2015, 8:01:41 AM8/18/15
to BeagleBoard
I need to modify the default configuration of pinmuxing on the BBB. To do so i'm trying to modify the am335x-boneblack.dts before recompiling the kernel. But that file is very awkward. I've only found information about overlay, but i need this to be default not overlay.

I've tried to write my one am335x-boneblack.dts, deleted every things related to HDMI, modified the include to am335x-bone-common-no-capemgr.dtsi :
/*
 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

/dts-v1/;

#include "am33xx.dtsi"
#include "am335x-bone-common-no-capemgr.dtsi"

/ {
    model
= "TI AM335x BeagleBone Black";
    compatible
= "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
};

&ldo3_reg {
    regulator
-min-microvolt = <1800000>;
    regulator
-max-microvolt = <1800000>;
    regulator
-always-on;
};

&mmc1 {
    vmmc
-supply = <&vmmcsd_fixed>;
};

&mmc2 {
    vmmc
-supply = <&vmmcsd_fixed>;
    pinctrl
-names = "default";
    pinctrl
-0 = <&emmc_pins>;
    bus
-width = <8>;
    status
= "okay";
};

&am33xx_pinmux {

    tor_output_pins
: tor_output_pins {
        pinctrl
-single,pins = <
           
0x078 0x07 /* P9_12 OUTPUT | MODE7 | PULLDOWN */
           
0x048 0x07 /* P9_14 OUTPUT | MODE7 | PULLDOWN */
           
0x040 0x07 /* P9_15 OUTPUT | MODE7 | PULLDOWN */
           
0x04c 0x07 /* P9_16 OUTPUT | MODE7 | PULLDOWN */
           
0x15c 0x07 /* P9_17 OUTPUT | MODE7 | PULLDOWN */
           
0x158 0x07 /* P9_18 OUTPUT | MODE7 | PULLDOWN */
           
0x044 0x07 /* P9_23 OUTPUT | MODE7 | PULLDOWN */
           
0x1ac 0x07 /* P9_25 OUTPUT | MODE7 | PULLDOWN */
       
>;
   
};

    tor_input
: tor_input {
        pinctrl
-single,pins = <
           
0x030 0x27 /* P8_12 INPUT | MODE7 | PULLDOWN */
           
0x024 0x27 /* P8_13 INPUT | MODE7 | PULLDOWN */
           
0x028 0x27 /* P8_14 INPUT | MODE7 | PULLDOWN */
           
0x03c 0x27 /* P8_15 INPUT | MODE7 | PULLDOWN */
           
0x038 0x27 /* P8_16 INPUT | MODE7 | PULLDOWN */
           
0x02c 0x27 /* P8_17 INPUT | MODE7 | PULLDOWN */
           
0x08c 0x27 /* P8_18 INPUT | MODE7 | PULLDOWN */
           
0x020 0x27 /* P8_19 INPUT | MODE7 | PULLDOWN */
       
>;
   
};

};


Booting from uboot using TFTP :
tftpboot 0x80F80000 am335x-bone-custom.dtb
tftpboot
0x80007FC0 uImage-BBB


Then looking at pins configuration :
root@arm:~# cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pins|grep 95c
pin
87 (44e1095c.0) 00000062 pinctrl-single

Should output :
pin 87 (44e1095c.0) 00000007 pinctrl-single


Why changes didn't take effect ? Did i missed something ?

Thank you for your time.

Paco Dupont

unread,
Aug 18, 2015, 8:56:07 AM8/18/15
to BeagleBoard
I've had that part in the .dts :
&ocp{
    torout
: torout  {
        pinctrl
-names = "default";
        pinctrl
-0 = <&tor_output_pins>;
        status
= "okay";
   
};

    torin
: torin    {
        pinctrl
-names = "default";
        pinctrl
-0 = <&tor_input_pins>;
        status
= "okay";
   
};
};

I think i'm close to get this work but I've probably missed something ... any idea ?

Paco Dupont

unread,
Aug 18, 2015, 9:16:30 AM8/18/15
to BeagleBoard
I've replace the last part I added (&ocp...) by Nelson's advice on this post : https://groups.google.com/d/msg/beagleboard/iW4i-xy9zJw/JFrr5M9_IwAJ
&gpio3 {
     torout0
{
          gpio
-hog;
          gpios
= <107 0>;
          output
-low;
          line
-name = "TOR input";
     
};
};

Just trying for 1 pin but still the same output no change ...

AndrewTaneGlen

unread,
Aug 19, 2015, 12:35:25 AM8/19/15
to BeagleBoard
I had trouble (viz. gave up) working with input pins with the device tree. I ended up doing all the init at run time (once I'd made sure nothing else was using the same pins in the device tree).
Check that you have removed any reference to the HDMI in your 'am335x-bone-common-no-capemgr.dtsi' file. I had to remove a 'status = "okay"' from the standard ''am335x-bone-common.dtsi', not sure if this is the same in the 'no cape' variant.

For BBB expansion header P9, pin 23 (GPIO 1_17), AKA pin 49, I do the following to intialise an input for use as a switch:

echo "49" > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio49/direction
echo 1 > /sys/class/gpio/gpio49/active_low

To read in the state I then use:
head -1 /sys/class/gpio/gpio49/value

e.g., in a script, use:

SWITCH=$(head -1 /sys/class/gpio/gpio49/value)

if [ ${SWITCH} = "1" ]; then
...
fi

For outputs I use the 'standard' led interface, as already used in the BBB device tree for the heartbeat/mmc leds.
e.g., with the pnmux as you have done, add something like the following to the 'leds' section in the common dtsi file:

led@6 {
    label = "my_led";
    gpios <&gpio1 16 GPIO_ACTIVE_HIGH>;
    linux,default-trigger = "none";
    default-state = "off";
};

Then set the output state as follows:

echo 1 > /sys/devices/leds.4/leds/my_led/value

Hope that helps.
Andrew.

Paco Dupont

unread,
Aug 19, 2015, 2:31:32 AM8/19/15
to BeagleBoard
Thanks for your answer Andrew but I need that the board setup correctly the pin at boot time (to avoid any trouble in the time elapsed between the DTB is load and the kernel is ready).
I'm actually facing a strange thing, 1st the number I used to set gpio3_21 was wrong : gpio = <107 0>; This call require the GPIO number on the bank and not the PIN number. So using : gpio = <21 0>; I end up with that result :

root@arm:~# cat /sys/kernel/debug/gpio
GPIOs 0-31, platform/44e07000.gpio, gpio:
 gpio
-6   (cd                  ) in  hi IRQ

GPIOs 32-63, platform/4804c000.gpio, gpio:
 gpio
-53  (?                   ) out lo    
 gpio
-54  (?                   ) out lo    
 gpio
-55  (?                   ) out hi    
 gpio
-56  (?                   ) out lo    

GPIOs 64-95, platform/481ac000.gpio, gpio:

GPIOs 96-127, platform/481ae000.gpio, gpio:
 gpio
-117 (TOR input           ) out lo    
root@arm
:~# cat /sys/kernel/debug/gpio
GPIOs 0-31, platform/44e07000.gpio, gpio:
 gpio
-6   (cd                  ) in  hi IRQ

GPIOs 32-63, platform/4804c000.gpio, gpio:
 gpio
-53  (?                   ) out hi    
 gpio
-54  (?                   ) out lo    
 gpio
-55  (?                   ) out hi    
 gpio
-56  (?                   ) out lo    

GPIOs 64-95, platform/481ac000.gpio, gpio:

GPIOs 96-127, platform/481ae000.gpio, gpio:
 gpio
-117 (TOR input           ) out lo

So this is nice because that's means my DTB is correctly loaded, but the pinmux register didn't change :
root@arm:~# cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pins|grep 9ac
pin
107 (44e109ac.0) 00000027 pinctrl-single

0x27 means the register is set to INPUT | MODE7 ... Why ???? The gpio setup and his register differ ... Can this cause me any trouble ? Or should I ignore it ? Is it a problem from my pinctrl,pin setup in the DTB ?

Leonardo Romor

unread,
Oct 12, 2016, 7:06:37 AM10/12/16
to BeagleBoard
Hello, I think I had a similar issue, and I would like to report it as well:

If you set a gpio configuration with the dto the kernel correctly loads it, but when you export one gpio from that peripheral for the first time, the kernel reset the configuration. I solved this by running a script on boot that exports the first GPIO for every peripheral and this actually solves this problem.
I think is an issue  of the kernel
Reply all
Reply to author
Forward
0 new messages