Can't get overlay to set pinmux for IEP

Am I doing something wrong or are my expectations incorrect?

I created an overlay file BB-PRUDAP-00A0 to take over P9_17 and P9_18 and set them to the IEP.

I added it to uEnv.txt and apparently it loaded:

`
root@beaglebone:~/prudap/lkm/prudap_lkm# ls -al /proc/device-tree/chosen/overlays/
total 0
drwxr-xr-x 2 root root 0 Jan 24 07:11 .
drwxr-xr-x 3 root root 0 Jan 24 07:11 …
-r–r–r-- 1 root root 25 Jan 24 07:11 AM335X-PRU-RPROC-4-14-TI-00A0
-r–r–r-- 1 root root 25 Jan 24 07:11 BB-ADC-00A0
-r–r–r-- 1 root root 25 Jan 24 07:11 BB-BONE-eMMC1-01-00A0
-r–r–r-- 1 root root 25 Jan 24 07:11 BB-PRUDAP-00A0
-r–r–r-- 1 root root 9 Jan 24 07:11 name

`

It also seems to have exclusive control over the pins:

`
root@beaglebone:~# config-pin P9_17 pwm
ERROR: open() for /sys/devices/platform/ocp/ocp:P9_17_pinmux/state failed, No such file or directory

`

However, when I check the actual pinmux values, I get:

`
[ 77.897980] prudap: spi0_cs0 pinmux state: 0x37
[ 77.897986] prudap: spi0_d1 pinmux state: 0x37

`

That’s not what I expect. I expected to see 0x2E and 0x2D like I requested in the overlay file.

What did I do wrong in the BB-PRUDAP-00A0.dts file. Those values are not what I wanted, but I can override those values in a kernel module. However, I expected the pinmux to be already set up due to the overlay file.

Any help would be appreciated.

Thanks.

BB-PRUDAP-00A0.dts file:

`

/dts-v1/;
/plugin/;

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>

/ {
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;

// identification
part-number = “BB-PRUDAP”;
version = “00A0”;

// resources this cape uses
exclusive-use =
“P9.17”, // spi0_cs0
“P9.18”, // spi0_d1

“pruss_iep”; // hardware ip used

/*

  • Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
    */
    fragment@0 {
    target-path=“/”;
    overlay {

chosen {
overlays {
BB-PRUDAP-00A0 = TIMESTAMP;
};
};
};
};

/*

  • Free up the pins used by the cape from the pinmux helpers.
    /
    fragment@1 {
    target = <&ocp>;
    overlay {
    P9_17_pinmux { status = “disabled”; }; /
    spi0_cs0 /
    P9_18_pinmux { status = “disabled”; }; /
    spi0_d1 */
    };
    };

fragment@2 {
target = <&am33xx_pinmux>;
overlay {
bb_prudap_pins: pinmux_bb_prudap_pins {
pinctrl-single,pins = <
BONE_P9_17 0x2E /* spi0_cs0.i2c1_scl, SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | MODE6 (IEP-edio/digio data out 7) /
BONE_P9_18 0x2D /
spi0_d1.i2c1_sda, SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | MODE5 (IEP-edio/digio data in 6) */

;
};
};
};

fragment@3 {
target = <&pruss_iep>;
overlay {
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&bb_prudap_pins>;
};
};
};

`

/boot/uEnv.txt for completeness:

`
root@beaglebone:~/prudap/lkm/prudap_lkm# cat /boot/uEnv.txt
#Docs: Beagleboard:U-boot partitioning layout 2.0 - eLinux.org

uname_r=4.14.108-ti-r113
#uuid=
#dtb=

###U-Boot Overlays###
###Documentation: Beagleboard:BeagleBoneBlack Debian - eLinux.org
###Master Enable
enable_uboot_overlays=1

I guess your overlay cannot ‘disable’ pins that’re claimed by another overlay. And here you’re facing the core problem when working with device trees: you won’t get reliable error messages. Everything ends up with trail-and-error bug finding.

I’ve good reasons why I always drop config-pin and its overlays. Instead I developed and shared libpruio and its pinmuxing. Your target is over the capabilities of the standard tools, but is well covered by the libpruio scope.

The pruss_ieq doesn't have pinctrl, you need to stick it in the pruss node:

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/AM335X-PRU-RPROC-4-14-TI-PRUCAPE-00A0.dts#L119-L131

It's really best to copy AM335X-PRU-RPROC-4-14-TI-PRUCAPE-00A0.dts to
your overlay name, and then rip out the pins you don't use..

Regards,

Much appreciated, Robert. I updated to the PRUCAPE file and tore out a bunch of stuff I didn’t need and that seems to be setting the pinmux correctly.

Is there anything else in this file that can be removed?

Thanks.

`

// Code shamelessly copied from AM335X-PRU-RPROC-4-14-TI-PRUCAPE-00A0.dts

/dts-v1/;
/plugin/;

/ {
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;

// identification
part-number = “BB-PRUDAP”;
version = “00A0”;

/*

  • Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
    */
    fragment@0 {
    target-path=“/”;
    overlay {

chosen {
overlays {
BB-PRUDAP-00A0 = TIMESTAMP;
};
};
};
};

/*

  • Free up the pins used by the cape from the pinmux helpers.
    /
    fragment@1 {
    target = <&ocp>;
    overlay {
    P9_18_pinmux { status = “disabled”; }; /
    P9_18: spi0_d1 /
    P9_17_pinmux { status = “disabled”; }; /
    P9_17: spi0_cs0 */
    };
    };

fragment@2 {
target = <&am33xx_pinmux>;
overlay {
bb_prudap_pins: pinmux_bb_prudap_pins {
pinctrl-single,pins = <
0x158 0x2D /* P9_18: spi0_d1.i2c1_sda, SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | MODE5 (IEP-edio/digio data in 6) /
0x15c 0x2E /
P9_17: spi0_cs0.i2c1_scl, SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | MODE6 (IEP-edio/digio data out 7) */

;
};
};
};

fragment@3 {
target-path=“/”;
overlay {

ocp {
#address-cells = <1>;
#size-cells = <1>;

pruss_soc_bus: pruss_soc_bus@4a326004 {
compatible = “ti,am3356-pruss-soc-bus”;
reg = <0x4a326004 0x4>;
ti,hwmods = “pruss”;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0x0 0x4a300000 0x80000>;
status = “okay”;

pruss: pruss@0 {
compatible = “ti,am3356-pruss”;
reg = <0x0 0x80000>;
interrupts = <20 21 22 23 24 25 26 27>;
interrupt-names = “host2”, “host3”, “host4”,
“host5”, “host6”, “host7”,
“host8”, “host9”;
#address-cells = <1>;
#size-cells = <1>;
ranges;
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&bb_prudap_pins>;

pruss_iep: iep@2e000 {
compatible = “syscon”;
reg = <0x2e000 0x31c>;
};
};
};
};
};
};
};

`

I'd actually keep the whole "pruss_soc_bus" struct as it was, (with
those 5 or 6 extra nodes..)

More or less to just keep the driver happy..

Regards,