IRQ GPIO / pps-gpio on LaFrite S805X

Hi all,

I’m running a Debian Bookworm downloaded from the Libretech hub, with the rolling kernel, and would like to set up pps-gpio on one of the GPIO pins of the LaFrite board (AML-S805X-AC).

Cabling:

GPS     7J1 Pin 
Vcc ----- 4, 5volts
Gnd ----- 6, Ground
Tx  ----- 8, UART_TX_A
Rx  ----- 10, UART_RX_A
PPS ----- 11, GPIOAO_8

Kernel is the following - which does have the gpio irq patches added:

6.6.31-00070-gb1edc9b0c128

When pps-gpio is loaded, it does register the gpio as IRQ, and then sets up pps-gpio:

[  479.589334] gpio irq setup: hwirq: 0x8 irqfirst: 0x0 irqlast: 0x9 pin[8]
[  479.594186] pps pps0: new PPS source pps-gpio.-1
[  479.598368] pps pps0: Registered IRQ 48 as PPS source
# cat /sys/kernel/debug/gpio |grep pps-gpio
 gpio-520 (HDMI CEC            |pps-gpio            ) in  hi

As on 6.6 the gpiochip numbering is different to the earlier kernels, gpio-520 still seems to be the correct one.

# ls -l /sys/class/gpio/
total 0
--w------- 1 root root 4096 Jun  4 23:06 export
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip512 -> ../../devices/platform/soc/c8100000.bus/c8100000.bus:pinctrl@14/gpio/gpiochip512
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip523 -> ../../devices/platform/soc/c8834000.bus/c8834000.bus:pinctrl@4b0/gpio/gpiochip523
--w------- 1 root root 4096 Jun  4 23:06 unexport

Still, attaching the PPS pin to 7J11 doesn’t seem to kick in any interrupts:

# ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)

Checking with gpiomon, the result is the same - no state changes appear:

# gpiomon gpiochip0 8

(console log shows a similar "gpio irq setup" as when the pps-gpio module is loaded)

# cat /sys/kernel/debug/gpio |grep gpiomon
 gpio-520 (HDMI CEC            |gpiomon             ) in  hi

The DTS overlay I’m using is the following:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/gpio/meson-gxl-gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/interrupt-controller/amlogic,meson-gxl-gpio-intc.h>

/ {
        compatible = "libretech,aml-s805x-cc", "amlogic,s805x", "amlogic,meson-gxl";

        fragment@0 {
                target-path = "/";
                __overlay__ {
                        pps_gpio: pps-gpio {
                                compatible = "pps-gpio";
                                pinctrl-names = "default";
                                pinctrl-o = <&ao_cec_pins>;
                                gpios = <&gpio_ao GPIOAO_8 GPIO_ACTIVE_HIGH>;
                                interrupt-parent = <&gpio_intc>;
                                interrupts = <IRQID_GPIOAO_8 IRQ_TYPE_EDGE_RISING>;
                                assert-rising-edge;
                                status = "okay";
                        };
                };
        };
};

Based on the gpiomap, I’m using the correct GPIO pin and the correct GPIOAO interrupt. A similar setup with the same GPS module (u-blox 7) does work on another board, along with the PPS kicks. What could I be doing wrong?

Thanks,
-w-

I was just looking for PPS for the Frite, so thank you. Have you gotten this working? The only thing I see from a quick look is that header pin 11 “Requires 9J3 jumper to be positioned to pass GPIOAO_8 to 40 pin header”, and I didn’t see any mention that you had that setup.

This is only mentioned in a confusing footnote on the Headers spreadsheet, and FWIW the Frite I got had NO jumper on 9J3.

UPDATE: after dicking around to get the fragment to compile (where did you get the amlogic,meson-gxl-gpio-intc.h from - it’s not in the ltc-headers package?), pps0 is up and ticking. I’m connecting to the center pin of 9J3, not the big header. I know I have dozens of those once ubiquitous little buggers around here, but I’m not sure where they got filed now that motherboards and peripherals that use them have all but vanished…

Funny I came across this only after going through the same process haha Pin 11 definitely needs the jumper to connect to the 40p header, otherwise that overlay should work. Wish I had thought to just connect to the jumper pin though!

Not having any jumpers on hand, and not satisfied with my jury rig, I modified the overlay to just use pin 12, which also conveniently matches zab4522’s instructions

pps-gpio-7j1-12.dts:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/gpio/meson-gxl-gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/interrupt-controller/amlogic,meson-gxl-gpio-intc.h>

/ {
        compatible = "libretech,aml-s805x-ac", "amlogic,s805x", "amlogic,meson-gxl";

        fragment@0 {
                target-path = "/";
                __overlay__ {
                        pps_gpio: pps-gpio {
                                compatible = "pps-gpio";
                                pinctrl-names = "default";
                                pinctrl-o = <&i2s_out_ao_clk_pins>;
                                gpios = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
                                interrupts = <&gpio_intc IRQID_GPIOH_7 IRQ_TYPE_EDGE_RISING>;
                                assert-rising-edge;
                                status = "okay";
                        };
                };
        };
};

The meson-gxl-gpio-intc.h include is in the official pps overlay from the s905x that I copied over.

For the record, yes, I did get it to work with the DTS overlay posted above, connecting PPS to pin 11 - the point that was missing was indeed the 9J3 jumper change. Thanks for the heads-up about it.

Out of interest - did someone got this working on the lc-lts (6.12) kernel? I’m getting a stackdump:

[ 1161.637750] WARNING: CPU: 0 PID: 0 at drivers/gpio/gpiolib.c:3256 gpiod_get_value+0x64/0xa0
[ 1161.646748] Modules linked in: pps_gpio pps_ldisc nvme_fabrics nvme_core cpufreq_conservative cpufreq_powersave rtl2832_sdr videobuf2_vmalloc r820t rtl2832 meson_vdec(C) videobuf2_dma_contig dvb_usb_rtl28xxu v4l2_mem2mem dvb_usb_v2 dvb_core videobuf2_memops videobuf2_v4l2 videobuf2_common crct10dif_ce lima videodev snd_soc_meson_gx_sound_card snd_soc_meson_card_utils gpu_sched binfmt_misc mc amlogic_gxl_crypto meson_rng crypto_engine meson_ir ao_cec rc_core dw_hdmi_i2s_audio scpi_hwmon snd_soc_meson_t9015 snd_soc_meson_aiu drm_shmem_helper snd_soc_meson_codec_glue simplefb cfg80211 rfkill pkcs8_key_parser fuse efi_pstore pstore dm_mod ip_tables x_tables ipv6 crc_ccitt autofs4 rtc_meson_vrtc [last unloaded: pps_gpio]
[ 1161.724434] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Tainted: G WC 6.12.73-g6b2d05eda916 #1
[ 1161.732517] Tainted: [W]=WARN, [C]=CRAP
[ 1161.734719] Hardware name: libre-computer aml-s805x-ac/aml-s805x-ac, BIOS 2023.07+ 07/01/2023
[ 1161.744824] pstate: 800000c5 (Nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 1161.749583] pc : gpiod_get_value+0x64/0xa0
[ 1161.753625] lr : pps_gpio_irq_handler+0x5c/0xe0 [pps_gpio]
[ 1161.759119] sp : ffff800080003e60
[ 1161.762379] x29: ffff800080003e60 x28: ffffcd31bffe7fc0 x27: ffffcd31bfa39c08
[ 1161.769520] x26: ffffcd31bfa39c08 x25: ffffcd31bffe7fc0 x24: ffff6d6442361a00
[ 1161.776576] x23: ffffcd31bffde9f8 x22: 0000000000000031 x21: 0000000000000000
[ 1161.783675] x20: ffff6d6442361a30 x19: ffff6d6442079540 x18: 0000000000000001
[ 1161.790770] x17: ffffa032bec92000 x16: ffffcd31be8f9008 x15: 0000000000000000
[ 1161.797844] x14: ffffcd31bf6a5ce8 x13: 00000000000002f5 x12: 0000000000000000
[ 1161.804920] x11: 00000000000000c0 x10: 0000000000000a20 x9 : ffffcd318957f124
[ 1161.812028] x8 : ffffcd31bffe8a40 x7 : 0000000000000000 x6 : 0000000010d96d4c
[ 1161.819092] x5 : ffffcd31bddb0008 x4 : 0044b82fa09b5a53 x3 : 18cc6276acd33a1d
[ 1161.826185] x2 : 0000035410d5b009 x1 : 0000000000439e1d x0 : 0000000000000001
[ 1161.833283] Call trace:
[ 1161.835827] gpiod_get_value+0x64/0xa0
[ 1161.839401] pps_gpio_irq_handler+0x5c/0xe0 [pps_gpio]
[ 1161.844523] __handle_irq_event_percpu+0x60/0x220
[ 1161.849174] handle_irq_event+0x54/0xc0
[ 1161.852961] handle_fasteoi_irq+0xa8/0x1d0
[ 1161.856966] handle_irq_desc+0x3c/0x68
[ 1161.860615] generic_handle_domain_irq+0x24/0x40
[ 1161.865164] gic_handle_irq+0x48/0xe0
[ 1161.868729] call_on_irq_stack+0x30/0x88
[ 1161.872558] do_interrupt_handler+0x88/0xa0
[ 1161.876632] el1_interrupt+0x34/0x88
[ 1161.880089] el1h_64_irq_handler+0x18/0x28
[ 1161.884092] el1h_64_irq+0x64/0x68
[ 1161.887383] default_idle_call+0x34/0x180
[ 1161.891302] do_idle+0x204/0x268
[ 1161.894427] cpu_startup_entry+0x3c/0x50
[ 1161.898271] rest_init+0xe0/0xe8
[ 1161.901416] start_kernel+0x6dc/0x6e8
[ 1161.905046] __primary_switched+0x80/0x90
[ 1161.908970] ---[ end trace 0000000000000000 ]---
[ 1162.635905] ------------[ cut here ]------------

The DTS has been changed to reflect the updated interrupt layout:

/ {
compatible = "libretech,aml-s805x-cc", "amlogic,s805x", "amlogic,meson-gxl";

    fragment@0 {
            target-path = "/";
            __overlay__ {
                    pps_gpio: pps-gpio {
                            compatible = "pps-gpio";
                            pinctrl-names = "default";
                            pinctrl-o = <&ao_cec_pins>;
                            gpios = <&gpio_ao GPIOAO_8 GPIO_ACTIVE_HIGH>;
                            interrupts = <&gpio_intc IRQID_GPIOAO_8 IRQ_TYPE_LEVEL_HIGH>;
                            assert-rising-edge;
                            status = "okay";
                    };
            };
    };

};