Device-tree queries in userspace

Hello ,

Managed to get some sensors and actuators up and running on BBB (kernel version 4.1). Still
can’t wrap my head around all the logic regarding overlays and pinmuxing.

I notice that several programs and libraries manipulating device tree (overlay and pinmux)
contain some sort of table with pin names and properties (such as pinmux possibilities, cpu gpio
number and offset). I find this kind of table in the projects ‘beaglebone-universal-io’ (file
‘config-pin’), ‘adafruit-beaglebone-io-python’ (file ‘source/common.c’) and
‘PyBBIO’(bbio/platform/beaglebone/config.py).
Is this information not contained within the device tree? I notice that the ‘cape-universaln’
overlay contains alot of similar information (pin names, offsets,…). Why do libraries seem to
duplicate this information? How to query this device-tree-information in userspace (I assume
it’s somewhere it’s somewhere in /sys/devices/platform/ or /proc/device-tree)?

Secondly, I already noticed that if you manipulate the device files they still will not work if
the OCP device is not enabled in the PinMux. This is confirmed in some documention
(http://www.OfItselfSo.com/BeagleNotes/AboutTheDeviceTree.pdf)
This means that if I wish to use pwm on for example pin 9.42 (ecappwm0, addr 48300100), I must
1: update the pinmux ‘state’ in /sys/devices/platform/ocp/ocp:${PIN}_pinmux/state and
2: ‘echo 0 > /sys/class/pwm/pwmchip[number]/export’ and
3: ‘echo 7 > /sys/class/gpio/unexport’ (this step is not essential, but seems logical since
this gpio on pin 9.42 is not available anymore)

It doesn’t really make sense to me that I’m allowed to ‘echo 0 >
/sys/class/pwm/pwmchip[number]/export’ if the state of the pin has not yet been set to pwm.
Isn’t the information required to disallow such mistakes available to the kernel in the pinmux
section of the device tree? Why is export still required if i’ve already told the kernel that it has
to set pinmux to pwm? Information from device tree should already tell you that you’ll
do the export in the next step.

Doesn’t really make sense to me… Or perhaps I’m looking at it from a wrong angle…
Would like some clarification.

kind regards,
Dieter