PPS in GPIO pin, device tree configuration

Hello, I am currently trying to use a GPS for an accurate Network Time Protocol.

The router I am using is a Turris Omnia 2020(https://www.turris.com/en/omnia/overview/) and the gps is a sintrones VDB-810DR(https://www.sintrones.com/VDB-810DR.html).

I managed to conect the gps through usb and got it working. I also connected the PPS from the GPS to the GPIO44(MPP44) pin on the board, but I don’t know how I should configure the GPIO pin in the device tree(.dts file). The goal is to get the kmod-pps-gpio driver working.

I am building onto the openwrt open-source code.

All you need is the “dtc” package to de/-compile the existing dtb on the /boot partition.
I modified it (Release 5.x.x) this way:

--- armada-385-turris-omnia-phy.dts	2020-06-08 13:39:12.603583058 +0200
+++ armada-385-turris-omnia-phy-pps.dts	2020-06-08 13:44:53.589760925 +0200
@@ -466,6 +466,8 @@
 				#interrupt-cells = <0x02>;
 				interrupts = <0x00 0x35 0x04 0x00 0x36 0x04 0x00 0x37 0x04 0x00 0x38 0x04>;
 				clocks = <0x04 0x00>;
+				linux,phandle = <0x1e>;
+				phandle = <0x1e>;
 			};
 
 			gpio@18140 {
@@ -1055,4 +1057,11 @@
 		los-gpios = <0x1d 0x03 0x00>;
 		mod-def0-gpios = <0x1d 0x04 0x01>;
 	};
+
+	pps@18 {
+		gpios = <0x1e 0x12 0x0>;
+		compatible = "pps-gpio";
+		status = "okay";
+	};
+
 };

As you can see I’m using GPIO18 (Pin1: https://wiki.turris.cz/doc/_media/omnia-pinout.png)
Works great with my uputronics uBLOX MAX-M8Q.

I use gpsd+chrony to discipline the clock. Keep an eye on the default busybox/sysntpd which gets reactivated with every update and conflicts with chronyd.

For chronyd I use

refclock SHM 0 poll 3 refid UBLX offset 0.2 noselect
refclock PPS /dev/pps0 lock UBLX refid GPS

in chrony.conf.

gspd is running with

/usr/sbin/gpsd -N -n -S 2947 /dev/ttyS1 /dev/pps0

Since I use this since Turris OS 3.x I’m currently not sure if I modified the init script or if it’s the default from OS 5 to handle /etc/config/gpsd with

config gpsd 'core'
        option enabled '1'
        option device '/dev/ttyS1'
        option ppsdev '/dev/pps0'
        option port '2947'
        option listen_globally '0'

accordingly.

1 Like

Thank you very much for the quick response!
We are working on this device tree: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/boot/dts/armada-385-turris-omnia.dts?h=v5.4.80
Could you show me how the changes you included in you answer would apply to this code and on the gpio pin 44?

Thank you for the help,
Razvan

Sorry. I’m far from being an device-tree expert. I managed to decompile the existing binary tree, modify it based on RaspberryPi dtoverlay pps-gpio and recompile it. I’ve no idea were all the missing information from your kernel tree is added to build what I see on my omnia. Especially the sections gpio@18100 and gpio@18140.

Basically I added the next free phandle to gpio@18100 IIRC and used it in the pps@ section. It should work if you change pps@18 to pps@44 to use that pin.

But as I said. I’m far from expert on this topic. Maybe someone from Turris can help?

Ok, thanks!

I managed to get it working in the end. This is how my .dts patch looks like:

--- a/arch/arm/boot/dts/armada-385-turris-omnia.dts_orig	2020-12-02 15:10:37.810000000 +0100
+++ b/arch/arm/boot/dts/armada-385-turris-omnia.dts	2020-12-02 15:10:52.780000000 +0100
@@ -34,6 +34,14 @@
 		reg = <0x00000000 0x40000000>; /* 1024 MB */
 	};
 
+	pps {
+		compatible = "pps-gpio";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pps_pins>;
+		gpios = <&gpio1 26 GPIO_ACTIVE_HIGH>;
+		status = "okay";
+	};
+
 	soc {
 		ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
 			  MBUS_ID(0x01, 0x1d) 0 0xfff00000 0x100000
@@ -379,6 +387,11 @@
 		marvell,function = "gpio";
 	};
 
+	pps_pins: pps-pins {
+		marvell,pins = "mpp44";
+		marvell,function = "gpio";
+	};
+
 	spi0cs0_pins: spi0cs0-pins {
 		marvell,pins = "mpp25";
 		marvell,function = "spi0";

In case somebody needs a modified device-tree for TOS 6.0.x… basically the same as above, except the new (higher) phandle…

--- armada-385-turris601-omnia-phy.dts	2022-10-22 14:48:32.338737610 +0200
+++ armada-385-turris601-omnia-phy-pps.dts	2022-10-22 15:02:20.638737610 +0200
@@ -475,6 +475,7 @@
 				#interrupt-cells = <0x02>;
 				interrupts = <0x00 0x35 0x04 0x00 0x36 0x04 0x00 0x37 0x04 0x00 0x38 0x04>;
 				clocks = <0x04 0x00>;
+				phandle = <0x25>;
 			};
 
 			gpio@18140 {
@@ -1150,4 +1151,11 @@
 		status = "disabled";
 		phandle = <0x10>;
 	};
+
+        pps@18 {
+                gpios = <0x25 0x12 0x0>;
+                compatible = "pps-gpio";
+                status = "okay";
+        };
+
 };
1 Like