My first device overlays - trying to understand

I’ve managed to create a dtbo for pwm that doesn’t make the system barf at me. It shows up properly when I cat slots and I can see the pin assignments in pins. I’m not really understanding what the file does and what I can find for documentation on writing dts files never seems to resemble any of the overlays on the bone.

The first one I wrote I basically hacked up another file that enabled a single pwm ( ehrpwm2A) so I tried to make it work for ehrpwm0A and ehrpwm0B. I ended up with this

`
/dts-v1/;
/plugin/;

/{
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;
part-number = “PDM-PWM0”;
version = “00A0”;

exclusive-use =
/* PINS /
“P9.29”,
“P9.31”,
/
devices */
“ehrpwm0A”,
“ehrpwm0B”;

fragment@0 {
target = <&am33xx_pinmux>;
overlay {
pinctrl_spec: Panel_Pins {
pinctrl-single,pins = <
0x190 0x03 /* P9_29 MODE3 ehrpwm0A PWM /
0x194 0x03 /
P9_31 MODE3 ehrpwm0B PWM */

;
};
};
};

fragment@1 {
target = <&ocp>;
overlay {
test_helper: helper {
compatible = “bone-pinmux-helper”;
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_spec>;
status = “okay”;
};
};
};

fragment@2 {
target = <&epwmss0>;
overlay {
status = “okay”;
};
};

fragment@3 {
target = <&ehrpwm0>;
overlay {
status = “okay”;
};
};

};

`

Like I said, it seems to load OK and /sys/class/pwm shows pwmchip0 but I don’t have anything to actually test the PWM with at the moment. Does this look correct?

The exclusive_use part is pretty obvious.

I’m wondering if the names defined by lines like “pinctrl_spec: Panel_Pins” are pre-defined secret codes required to make things work or if they’re just arbitrary labels assigned by the person creating the file?

In fragment one there’s “test_helper: helper” which looks like an arbitrary label - but is it?

I would think that in "target = " the “whatever” has to be the proper name/device/whatever it is (like tscadc for analog inputs).

Then one other thing. I copied this file, renamed it PDM-PWM1-00A0.dts, changed the partno, defined pins, etc to be ehrpwm1


/dts-v1/;
/plugin/;

/{
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;
part-number = “PDM-PWM1”;
version = “00A0”;

exclusive-use =
/* PINS /
“P8.36”,
“P8.34”,
/
devices */
“ehrpwm1A”,
“ehrpwm1B”;

fragment@0 {
target = <&am33xx_pinmux>;
overlay {
pinctrl_spec: Panel_Pins {
pinctrl-single,pins = <
0x0C8 0x02 /* P8_36 MODE3 ehrpwm1A PWM /
0x0CC 0x02 /
P9_34 MODE3 ehrpwm1B PWM */

;
};
};
};

fragment@1 {
target = <&ocp>;
overlay {
test_helper: helper {
compatible = “bone-pinmux-helper”;
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_spec>;
status = “okay”;
};
};
};

fragment@2 {
target = <&epwmss1>;
overlay {
status = “okay”;
};
};

fragment@3 {
target = <&ehrpwm1>;
overlay {
status = “okay”;
};
};

};

and it seems to behave, I get pwmchip2 in /sys/class/pwm and it shows up in slots but in pins only the first file's pins are shown as assigned.

I don't know if the name Panel_Pins can't be the same in the two files or if maybe fragment 1's "pinctrl-0" needs to have a different number or what...

Any enlightenment and guidance would be massivly appreciated.

``

Well I’ve been experimenting and it does indeed look like the labels after pinctrl_spec and under overlay are arbitrary and that one or both must be unique (haven’t tried just one unique). If the names are not different than other dtbos then it does not appear in pinmux-pins although dmesg says its loaded and it appears in slots.

Still don’t know if any of these actually result in PWM activity but i should be able to set up a breadboard in the next couple of days.

I got the three ehrpwm sets done, now I’m just trying to figure out the names for the eCap pwms/