[LinuxPPS] PPS on Raspberry Pi - with device tree
tlhackque
tlhackque at yahoo.com
Wed Aug 10 00:46:38 CEST 2016
I recently updated my RPi to the latest released kernel (4.1.19+ ),
which has PPS built-in and a module for the GPIO input driver.
This release uses device trees. I ran into some problems. Here is the
recipe for any who follow.
Device Tree will load pps-gpio, so remove it from /etc/modules. Remove
any reference to pps from the kernel command line.
In config.txt, add
dtoverlay=pps-gpio,gpiopin=24 (Or whatever pin number you're using).
If (as I do), you require assert_falling_edge = true, you need to
customize the dtoverlay.
The driver supports it, but it's not in the DT overlay. (A patch has
been committed by Phil Elwell.)
Meantime, to fix:
copy
https://raw.githubusercontent.com/raspberrypi/linux/b761ab196d84a93a8ca7e9cfb77ead85347a57a2/arch/arm/boot/dts/overlays/pps-gpio-overlay.dts
to your RPi.
apt-get install device-tree-compiler
Run
sudo dtc -@ -o pps-gpio-overlay.dtb -O dtb -I dts pps-gpio-overlay.dts
rename the existing pps-gpio-overlay.dtb in /boot/overlays to .bak, and
cp -p pps-gpio-overlay.dtb to /boot/overlays.
Add assert_falling_edge=true to config.txt, e.g.:
dtoverlay=pps-gpio,gpiopin=24,assert_falling_edge=true
Reboot, and you're in business.
In debugging this, I noticed that the driver doesn't have a
"capture_clear" parameter for the device tree.
I think one should be added - there is code for this on the "pdata"
path. Something like:
if (of_get_property(np, "capture-clear", NULL))
data->capture_clear = true;
at line 122 should do it. Then the DT and pdata paths should be equivalent.
For reference, the RPi issue for this is
https://github.com/raspberrypi/linux/issues/1590
Enjoy.
More information about the discussions
mailing list