Skip to content

Bring-up, not for merge: the Pixel 9a's GNSS SPI test code behind MODEM-PLAN G3 - #137

Closed
W4HO-ham wants to merge 36 commits into
derekross:omamobilefrom
W4HO-ham:tegu-gnss-spi-bringup
Closed

W4HO-ham wants to merge 36 commits into
derekross:omamobilefrom
W4HO-ham:tegu-gnss-spi-bringup

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

Not for merge. This branch exists so the omarchy-mobile plan can link each of MODEM-PLAN G3's tries (derekross/omarchy-mobile#138, point 4 of the review) to the code it ran, by commit. Nobody else could read the module directories on my build machine or the scripts in my logs, so here they are, as they ran on the palmtop on the night of 2026-10-28/29 and the morning after.

GNSS is parked (the owner's decision, 10-29): no logic analyzer and no more module-level guessing. The palmtop runs the as-ported driver of the first commit on the kernel of #135. Nothing here is meant to merge; the two real fixes that came out of the night, spi-s3c64xx not cutting a transfer that fills the FIFO and clk-zumapro letting USI3 reach OSCCLK, are #135, and this branch is based on that branch's head so they are in it.

What is in it, one commit per step, each a diff on the one before, in the order of the plan's tries:

  • bb99995 gnssif_spi: Google's GNSS SPI driver as ported for the Pixel 9a
  • 401016f gnssif_spi: 32-byte reads
  • 21cea1d gnssif_spi: spi_mode and speed_hz module parameters
  • 45b4921 gnssif_spi: 32-bit words, byte-swapped in software
  • 7eec925 gnssif_spi: cut transfers into 60-byte pieces of one message
  • c5223f5 gnssif_spi: 32-bit words in 32-byte pieces, 32-byte reads
  • cc78f33 gnssif_spi: fb_delay, cs_setup_us, osc and speed_hz parameters
  • 840cac1 gnssif_spi: 8-bit words with the same parameters
  • e497c8b gnssif_spi: hs=1 forces HIGH_SPEED_EN, one spi_sync per 32-byte piece
  • f8013d0 gnssif_spi: hs=1 with 60-byte reads in one transfer
  • b587e76 gnssif_spi: div holds the USI3 divider (stock's 12 MHz, osc=1 div=1)
  • f2dcd52 gnssif_spi: rx_cpha=1 reads in SPI mode 1, writes in mode 0
  • e8d4d64 gnssif_spi: hold=1 keeps chip select across a Kepler message
  • b5229f3 gnssif_spi: realign=1 shifts every read left one bit
  • ff0eadd gnssif_spi: txshift=1 sends every write one bit later
  • dacf3e3 gnssif_spi: realign=2 chooses the shift per read from the CHPP preamble
  • a0877ab gnssif_spi: realign=3 tracks Kepler's bit offset 0-7, txk delays writes by it
  • dae13a1 gnssif_spi: piece sets the transfer size within a message
  • 9c63641 gnssif_spi: carry=1 carries the dropped bit into the next read
  • 2d0bdd6 gnssif_spi: rx_gap_us waits before each read
  • 60cd315 gnssif_spi: dump every byte of every transfer to the kernel log
  • 27bae61 gnssif_spi: tx_gap_us waits before each write
  • 0f0e7b0 gnssif_spi: pad every write to a whole 64-byte exchange
  • 24f64e7 gnssif_spi: psr writes the SPI block's prescaler, bench times reads
  • b8c423d gnssif_spi: cs_hold_us keeps chip select after the last clock
  • 5f786c8 soc: samsung: tegu-pdma-probe: Read the Pixel 9a's pdma1 PrimeCell IDs
  • 288a87e soc: samsung: tegu-pdma-rt: Register pdma1 at runtime and run a memcpy
  • 4d5548b arm64: dts: exynos: google: zumapro-tegu: The GNSS SPI test overlays
  • 8d77391 tools/tegu-gnss: The scripts behind MODEM-PLAN G3's tries

The gnssif_spi driver is the gnssif_spi directory of google-modules/soc/gs in Google's GPL zumapro kernel, ported to this tree, under drivers/soc/google (new on this branch; the symbol defaults to n). The two pdma1 test modules sit next to tegu-mif-sleep in drivers/soc/samsung, as #127's modules did. The device-tree pieces are overlays on the palmtop's integration DTB, since there is no zumapro-tegu.dts on this branch to change; each test DTB went onto slot B through the kit's omamobile images (packed twice, the packs compared) and omamobile push. The scripts and the offline CRC checks are under tools/tegu-gnss with a README.

No binaries, no firmware, no RAM dump and no captured GNSS data; I checked the diff for identifiers and sign-offs before pushing.

@derekross

Copy link
Copy Markdown
Owner

Thank you for publishing all of this. It's exactly what I asked for on derekross/omarchy-mobile#138. Each try now has the code it ran, one commit per variant, and the plan links them by id. The imported gnssif_spi files keep Samsung's copyright and their GPL-2.0 headers, and the policy check finds no identifiers or blobs.

I'll leave this as a draft and won't merge it. The red CI is the gate refusing commits without a sign-off and with "Bring-up, not for merge" subjects, which is what we'd expect on a reference branch. You're welcome to close it once #153 merges, since the commit ids live on in your fork's branch. If you keep it open, adding your Signed-off-by to commits you've posted publicly is a good habit, but it isn't needed for a branch that never merges.

A few notes for whoever picks GNSS up again, none of them needed now:

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Thanks for the read. Your two notes on the scripts were right, and the second had a cause: the palmtop's g7-short was never g7-min. It was the fifth try's 240 s strace session writing to /var/log/omamobile/g7/, which is the directory run-short.sh counts; I recovered the palmtop's copy and it's on the branch now, with run-short.sh naming itself in its usage line and the README saying which script is which (e343760). I'll close this once derekross/omarchy-mobile#153 merges, as you suggest; the ids stay on the fork's branch. If the overlays ever become a step they'll move to device/tegu/overlays, agreed.

derekross pushed a commit to derekross/omarchy-mobile that referenced this pull request Oct 30, 2026
… and GNSS parked (#153)

MODEM-PLAN's GNSS section from the night of 10-28 into 10-29. The "KEP
M7 HARDFAULT" at every engine start is gnssd's soft watchdog resetting
Kepler because the CHPP link over the GNSS SPI loses bytes. Two kernel
causes were found, USI3 stuck on the 399.36 MHz parent and spi-s3c64xx
cutting a full-FIFO transfer into 63 + 1 bytes; both are in
derekross/linux-omarchy-mobile#138, in review. With them, mode 0 is
marginal and mode 1 loses the first byte of each back-to-back block.
Stock's SPI setup, read from its device tree and Google's driver, is
automatic chip select, feedback delay 0 and the controller's byte swap,
in PIO; no try has run that at stock's clock, so it is the first boot
(G3-A) when GNSS resumes. GNSS is parked at the owner's decision. Every
try links its commit on derekross/linux-omarchy-mobile#137.

The CP link hang stays open. The morning's 24 ramoops consoles hold
eight watchdog hangs, each ending between the cp2ap_wakeup edge and the
link coming back, while the link cycles quickly. G3-L1 (attended, on the
charger, capped, M0.1 before and after) first holds the link up with a
bring-up cpif parameter, then traces CPIF's BAR accesses. The six
protected partitions matched the 10-28 backup after the night's and
morning's boots. NOTES records two resets at about 34 s after Bluetooth
started, the 03:03 one read back from the journal.

Test images reached slot B through bin/omamobile push only.

Co-authored-by: W4HO-ham <87742609+W4HO-ham@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Thanks for keeping this current with the G3-A tries (derekross/omarchy-mobile#179 is merged now). Since derekross/omarchy-mobile#153 has merged too, close this whenever G3-A is done; until then it's a good record as it is. If the swap-mode change ever becomes a real fix, it would follow #138's pattern: a port flag set only for zumapro.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

G3-A2 ran tonight (2026-10-30) on the palmtop: the swap-mode change (11ea0ef) rebuilt into the gn3 tree's own kernel (release unchanged; the first build from the GNSS worktree lacked the S2MPG15 rails and couldn't power the receiver), gn3 plus the autocs, fb0 and swap-mode overlays, gnss_spi with word32=1 piece=32 (32-bit words, no software swap, the controller swapping). Modem up, CP ONLINE, gnssd CODELOAD -> OPERATIONAL, then the same chppPlatformNotifierWait in STATE_PERMANENT_FAILURE; all counters zero, no UFS errors.

What's new is in the raw frames. The chip's replies carry the CHPP header 68 43 shifted right by a varying number of bits:

TX(20): 68 43 00 00 01 01 06 00 ...
RX(64): 00 00 1a 10 c0 08 ...   (68 43 >> 2 bits)
RX(64): 06 84 30 02 00 10 ...   (68 43 >> 4 bits)
RX(64): 00 00 01 a1 0c 00 ...   (68 43 >> 6 bits)

So the bytes are intact but sampled out of step with SCK, by an amount that changes from read to read. That points at the receive sampling (clock phase, or the feedback delay that stock sets to 0 and we now also set to 0) or at the chip clocking its MISO on the other edge, rather than at byte order, word size or chip select, which G3-A and G3-A2 have now each changed without effect. The next step on the trace is a CPHA/feedback-delay sweep at 32 bits. The palmtop is back on the kit's gn3 + osc2 images; GNSS stays parked.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

The Pixel 9a's GNSS gets a fix (2026-10-30 evening, on the palmtop, cable in, near a window): in a 3-minute session 23 of 25 GGA sentences carry fix quality 1, up to 13 satellites used, HDOP 0.8, with GPS, Galileo, BeiDou and GLONASS tracked at C/N0 up to about 41 dB-Hz. CHPP is clean: every received read at bit 0 with a valid CRC32, no ACK timeouts, no permanent failure, no Kepler fault.

Two things fixed it, now on this branch at d6b10ef:

  1. spi-s3c64xx's flush order. s3c64xx_flush_fifo() clears PACKET_CNT, and with it PACKET_CNT_EN, while RXCH_ON is still set; for that write the controller clocks freely and, with automatic chip select, the slave stays selected and shifts bits out that the flush discards. Kepler streams CHPP across chip-select cycles, so every transfer lost a couple of bits: tonight's reads arrived 0, 2, 4 or 6 bits off and frames that crossed reads broke. Google's driver turns the channels off first; the commit does the same. This one is a real upstream candidate for spi-s3c64xx; it doesn't change anything for slaves that restart per chip-select cycle (the touchscreen bus is unaffected).
  2. The GNSS SPI's pins. Our SPI21 node had no pinctrl, so gpp22-0..3 ran on the bootloader's state at drive 0; a bring-up overlay gives them function 2 and drive 3, as gpp21 (the other PERIC1 SPI bus) has. Clean data inside a read came with this.

The rest is stock's configuration: mode 0, 32-bit words with the controller's swap (11ea0ef), feedback delay 0, automatic chip select (google,gs101-spi), 64-byte reads (piece=64), no software realign. The palmtop is back on the kit's images; the session logs are kept on it under /var/log/omamobile/g7min-first-fix-20261030. I'll split this into proper PRs (the spi-s3c64xx fix alone, then the 9a's GNSS DT pieces) once the owner signs off the kernel commit.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Follow-up: the fix now runs on the palmtop's normal boot (the gn3 kernel with 11ea0ef and d6b10ef, the autocs, fb0, swap-mode and pin overlays in the kit's default list, gnss_spi word32=1 piece=64 spi_mode=0). A first 3-minute session there got 62 fixes and then hit the CP link hang (CLUSTER0_NONCPU_WDTRESET at about 260 s, as on 10-29). G3-L1's hold-the-link step settles it, with one change: cpif's keep_link_up=1 from load stops the CP from ever reaching ONLINE (cbd exit 143, CP BOOTING), because the CP needs its link cycles while it boots; set after ONLINE (the parameter is writable at runtime), the link is never isolated again. With that, a 3-minute session (36 of 38 GGA fixed, 13 satellites, HDOP 0.8) and a 10-minute session (38 of 43 fixed, no ACK timeout, no bad checksum, no permanent failure, no Kepler fault, no link isolation, no UFS error, no reset at 11 minutes of uptime) ran clean. So the link hang was the link going down under gnssd's traffic, and holding it after ONLINE is the bring-up answer until CPIF's power-off path is made safe.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Last piece of the SPI side: the swap-mode property isn't needed. With the byte swap done in gnss_spi instead (word32=2, 734f5f8 on this branch) and no swap-mode in the DT, a 3-minute session got 54 of 56 GGA fixed (10 satellites, HDOP 1.2), no ACK timeouts, bad checksums or permanent failures. So upstream needs only #150 (the flush order) and #151 (the SPI21 pins); 11ea0ef stays a bring-up experiment. The palmtop's normal boot runs that way now.

What remains for GNSS on the published kernel is the driver side: gnssif/gnss_spi and CPIF aren't in the tree yet, and CPIF's link power-off needs a real fix where keep_link_up (set after ONLINE) stands in today. I'll keep this PR as the bring-up record and close it when those land.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Correction to my two comments above: the 3- and 10-minute sessions were not clean. In every boot that set keep_link_up=1 after ONLINE (six tonight) the CP crashed 103-108 s after ONLINE (cp_active_handler: PHONE_ACTIVE 0, ONLINE -> CRASH_EXIT; nothing in the kernel log before it, CHPP healthy), and the fixes I counted were the minute before that; the fixed-of-total counting hid the short totals. So refusing the CP's power-down crashes the CP about 105 s later, and letting the link cycle hangs the SoC about 170 s after ONLINE (10-29, and once tonight). The SPI side (#150, #151) stands; the CP link under GNSS traffic is G3-L1's trace, which I'm on now.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

The CP link, three ways, tonight (same kernel plus the doorbell commit on tegu-cpif-doorbell):

cpif keep_link_up The link Result
0 cycles twice a second under GNSS traffic fixes arrive; the SoC hangs. 170 s after ONLINE without the doorbell commit (five boots); with it one session got to 26 minutes of uptime before the same CLUSTER0_NONCPU_WDTRESET, the console ending mid-cycle right after wake enabled for irq 96
1 held, ap2cp_wakeup left high fixes for about a minute; the CP crashes 103-108 s after ONLINE (PHONE_ACTIVE drops, ONLINE -> CRASH_EXIT), six boots of six
2 held, ap2cp_wakeup answered as the full path does nothing hangs or crashes: 16 minutes ONLINE, no isolation, no UFS error, and no GNSS at all (gnss_spi transferred nothing all boot; the HAL reported status 1 and 3 and served no sentence)

So the wake line isn't a formality: high means the AP wants the link, and the CP stops serving GNSS when it goes low, while leaving it high with the link held makes the CP declare a fault. The link has to cycle, and the fix has to make cycling safe. The doorbell commit moved the hang from 170 s to 26 minutes, so that access was one of the unguarded ones and not the last. Left in that window: the MSI set-up and s51xx_pcie_restore_state() on the way up, CPIF's own BAR reads (offset_boot_indicator, the capability and magic words, and any queue pointer that sits in the window rather than in the reserved DRAM), and the cycle itself, whose every step writes the PMU through the secure monitor. That's the trace, and it's next.

The two SPI commits (#150, #151) are unaffected by any of this.

…ed for the Pixel 9a

Bring-up, not for merge. The gnssif_spi driver that runs the Pixel 9a's
GNSS core (Kepler, on SPI 21 of USI3 in HSI0) as it ran on the palmtop at
the start of the night of 2026-10-28/29, before any of MODEM-PLAN G3's
link experiments: the base every later commit on this branch changes.

It is the gnssif_spi directory of google-modules/soc/gs in Google's GPL
zumapro kernel (drivers/soc/google/gnssif_spi, Samsung's GPL-2.0 files),
ported to this tree: mainline spi-s3c64xx has no swap mode, so the port
sends 8-bit words to put the bytes on the wire in memory order (stock
sends 32-bit words with the vendor driver's byte and half-word swap), and
the Kepler control device uses the GNSS firmware carve-out and the two
GPIO lines of the device tree's gnssif node. gnss_spi binds the
samsung,gnss-spi device under spi21; gnssif gives gnssd /dev/gnss_ipc,
/dev/gnss_boot and the control ioctls (IOCTL_LOAD_GNSS_IMAGE copies
kepler.bin into the carve-out in RAM; nothing touches a partition).

This is the "as ported" setting of G3's tables (8-bit words, 64-byte
reads, feedback delay 2, SPI mode 0): the control row of the ninth to
fourteenth tries and the baseline of the fifteenth to twenty-third, and
what the palmtop runs again now that GNSS is parked. The Kconfig symbol
defaults to n. The published omamobile branch has no drivers/soc/google
yet, so this adds the directory with only this driver in it.
Bring-up, not for merge. DEFAULT_SPI_RX_SIZE 64 to 32, so rx_work reads
Kepler in 32-byte transfers, which stay under spi-s3c64xx's 64-byte FIFO
and never get cut. MODEM-PLAN G3, ninth to fourteenth tries: the "rx chunk
32" rows (mode 0, delay 2: 17 bad checksums, Kepler opstate 0; then with
the feedback-delay-0 DTB of this branch: 93). Smaller reads alone did not
give a working link.
…ameters

Bring-up, not for merge. gnss_spi takes spi_mode (0-3, written into
spi->mode at probe) and speed_hz (spi->max_speed_hz), so one module tries
the SPI modes and a slower clock without a DTB round. MODEM-PLAN G3,
ninth to fourteenth tries: mode 1 with 32-byte reads (34 bad checksums,
opstate 0), mode 1 with 64-byte reads (RX clean, but Kepler never sees
our RESET-ACK: TX lost), mode 0 at "1 MHz" (63; the clock did not change,
see the twenty-fourth try) and mode 3 (32). The 32-byte read size of the
previous commit stays in gnss_spi.h; the 64-byte row put it back by hand.
…ftware

Bring-up, not for merge. SPI_BITS_PER_WORD 32, as stock, with every word
swapped (swab32) before a write and after a read, so the bytes go on the
wire in memory order as the vendor driver's swap-mode does; CHPP frames
are padded to a multiple of 4 and a size that is not is refused. The
spi_mode and speed_hz parameters go. MODEM-PLAN G3, ninth to fourteenth
tries, "32-bit words (swapped in gnss_spi)": 1 bad checksum, but every
64-byte RX transfer timed out (-110) under mainline spi-s3c64xx and
Kepler stayed at opstate 0, with and without the auto-chip-select DTB of
this branch. The cause was found later: spi-s3c64xx cut a 64-byte PIO
transfer into 63 + 1 bytes, which 32-bit words cannot be split into
(fixed in kernel PR derekross#135, the base of this branch).
…s of one message

Bring-up, not for merge. Back to 8-bit words; gnss_spi_xfer() splits every
transfer into 60-byte spi_transfers of one spi_message (chip select held
between them), so every pause falls on a 32-bit boundary and spi-s3c64xx,
which cut PIO transfers of 64 bytes or more into 63-byte pieces, never
cuts. MODEM-PLAN G3, "What the link does (10-29, night)": with the cut
gone the link garbled just the same (369 bad checksums, Kepler tracking,
then its watchdog), so the split alone was not the cause.
…32-byte reads

Bring-up, not for merge. 32-bit swapped words again, every transfer cut
into 32-byte spi_transfers of one message (each fits the polling path, as
stock's 64-byte reads do in Google's driver), and DEFAULT_SPI_RX_SIZE 32.
MODEM-PLAN G3, fifteenth to twenty-third tries: the "w32rx32" row (7 bad
checksums, no watchdog, the link stops after RESET-ACK) and, with 64-byte
reads, the "w32p32" row (19). The raw bytes later showed why the counts
are low: with 32-bit words the CHPP frames arrive at any bit offset, so
few frames are recognised at all.
…peed_hz parameters

Bring-up, not for merge. 64-byte reads again, and four module parameters:
fb_delay overrides the controller's feedback delay (s3c64xx_spi_csinfo
fb_delay, FB_CLK_SEL) after spi_setup; cs_setup_us sets spi->cs_setup;
speed_hz the rate asked for; and osc=1 writes bit 0 of CMU_HSI0's USI3
mux (0x11001020) at probe, behind the clock framework's back, moving the
mux from its 399.36 MHz parent to OSCCLK; the divider (0x11001820) is
read and logged after the first transfer. MODEM-PLAN G3, fifteenth to
twenty-third tries: "fb3" (delay 3: 5 bad checksums), "cs200" (delay 3,
200 us setup: 0), "osc" (OSCCLK, about 1.5 MHz: 0) and "acs" (the
auto-chip-select DTB: 0), all 32-bit, all stopping after RESET-ACK. The
divider read showed the real clock: the mux sat on 399.36 MHz and the
4-bit divider stops at /16, so the SPI ran at 6.24 MHz, twice stock's,
whatever the driver asked for. Writing CMU registers from a module is a
bring-up shortcut, replaced by the clk-zumapro change of kernel PR derekross#135.
…ters

Bring-up, not for merge. SPI_BITS_PER_WORD back to 8 with the swap and
the multiple-of-4 check skipped for 8-bit words, and one transfer per
message (piece size 64 KiB). MODEM-PLAN G3, fifteenth to twenty-third
tries, "osc8": 8-bit, OSCCLK (about 1.5 MHz), feedback delay 0: 1 bad
checksum, the link still stopping after RESET-ACK.
…pi_sync per 32-byte piece

Bring-up, not for merge. hs=1 keeps the controller runtime-resumed, maps
SPI 21's registers (0x111e0000) and sets CH_CFG bit 6 (HIGH_SPEED_EN,
which spi-s3c64xx sets only at 30 MHz and up and clears in every FIFO
flush) before every transfer; each 32-byte piece is its own spi_sync so
the bit is set again after the flush. MODEM-PLAN G3, fifteenth to
twenty-third tries, "hs": 17 bad checksums, stopping after RESET-ACK.
…ransfer

Bring-up, not for merge. The same HIGH_SPEED_EN parameter with one
transfer per message and DEFAULT_SPI_RX_SIZE 60, so spi-s3c64xx never
splits a read. MODEM-PLAN G3, fifteenth to twenty-third tries, "hs60":
408 bad checksums, Kepler tracking satellites, then its watchdog (38
hard faults). The reset at 348 s that followed came from the modem's
PCIe link ("PHY isolated"), not from the SPI path.
…k's 12 MHz, osc=1 div=1)

Bring-up, not for merge. The hs parameter goes; div >= 0 maps CMU_HSI0's
USI3 divider and holds it at that value, written at probe and again
around every transfer (the clock driver sets it back to /16 whenever
spi-s3c64xx asks for a rate), waiting for the divider's busy bit. With
osc=1 div=1 this is Google's zuma CMU table for USI3's 12 MHz
(cmucal-vclk.c, div_clk_hsi0_usix_12mhz_lut_params: OSCCLK / 2, 12.288
MHz, a 3.07 MHz SPI clock). 64-byte reads again. MODEM-PLAN G3,
"Stock's clock, tried (twenty-fourth try)": 8-bit, delay 0, 1 bad
checksum, and Kepler's frames arriving shifted by the same 4, then 5,
then 6 bits across many reads, so its bit counter runs on across
chip-select cycles and gains or loses clocks on OSCCLK. This is the
"module that set USI3's mux and divider behind the clock framework";
kernel PR derekross#135 lets the framework do it instead.
…rites in mode 0

Bring-up, not for merge. rx_cpha=1 switches spi->mode per transfer under
the driver's mutex: read-only transfers get SPI_CPHA (mode 1), transfers
with a tx buffer run in mode 0. spi-s3c64xx takes the mode from spi->mode
each time it reconfigures, and it reconfigures on every transfer here
because its cur_speed (the 6.24 MHz it gets) never equals the rate asked.
MODEM-PLAN G3, twenty-fifth to twenty-seventh tries: every frame at bit
offset 0 for the first time on the as-ported clock, short frames pass,
the engine reports satellites, the watchdog fires later (260 bad
checksums; 101 with cs_setup_us=50 in the twenty-seventh try, through 14
Kepler watchdog resets without a reset of the palmtop); long frames
(279 bytes) lose one or two bytes at each 64-byte read boundary. The
twenty-sixth try ran this module with 60-byte reads (DEFAULT_SPI_RX_SIZE
60 as in the hs60 commit), with no change.
…a Kepler message

Bring-up, not for merge. hold=1 sets cs_change on the last transfer of
every read, so chip select stays asserted between rx_work's consecutive
reads of one Kepler message; gnss_spi_release() (an empty transfer the
core ends with chip select off) releases it when gnss2ap drops at the end
of rx_work's loop and before every write. MODEM-PLAN G3, twenty-eighth
try: with mode 1 reads it made things worse (292 bad checksums, 279-byte
frames ending in zeros, footer 0): Kepler wants chip select released
between its 64-byte reads, as stock does.
… one bit

Bring-up, not for merge. The hold parameter and the link device's release
call go. realign=1 shifts every received buffer left by one bit before
the swap, because at feedback delay 3 (mode 0, 8 bits, the as-ported
clock) Kepler's frames arrived intact but one bit late: offline, shifting
the saved reads left one bit turned 11 valid CHPP frames into 123 (CRC32
over the 8-byte header and payload), where at delay 2 the same shift
recovered nothing. MODEM-PLAN G3, twenty-ninth and thirtieth tries:
Kepler is on time just after it starts and one bit late later, so the
fixed shift lost its first RESET-ACKs for 2 s and set off a reset storm
(125 RESETs from Kepler, 144 RESET-ACKs from gnssd).
…bit later

Bring-up, not for merge. txshift=1 shifts each write right by one bit
into a buffer one byte longer (the last bit lands in the extra byte) and
drops the extra received byte, in case Kepler sampled our writes a slot
late as it sent its own data a slot late. MODEM-PLAN G3, thirty-first
try: it killed the link outright (0 RESET-ACKs, nothing received), so our
writes were right as they were.
…read from the CHPP preamble

Bring-up, not for merge. txshift goes. realign=2 looks for the CHPP
preamble (68 43) in each read: found at bit 0, the read is kept; at bit
1, the read is shifted left one bit; a read without a preamble keeps the
last choice, and each change is logged. MODEM-PLAN G3, thirty-second
try: clean short frames and the engine reporting satellites, but the
279- and 361-byte frames still failed (290 bad checksums, 34 hard faults
over the session); offline, setting the one dropped bit at each 64-byte
boundary every possible way (tools/tegu-gnss/offline/brute.py) repaired
none of them, so more than a bit goes missing at each chip-select
release.
…fset 0-7, txk delays writes by it

Bring-up, not for merge. realign=3 finds the preamble at any of the 8 bit
offsets, shifts the read by the offset found and keeps it for reads
without one, logging each change; txk=1 then sends writes that many bits
later, so they land on Kepler's byte boundaries. MODEM-PLAN G3,
thirty-third and thirty-fourth tries, at stock's clock through the
osc/div parameters: at OSCCLK / 2 (osc=1 div=1, 3.07 MHz) the offset
walked by one or two bits about every 100 ms (0, 2, 3, 5, 6, 7, 0, 1, 3
in the first second), and with the writes delayed to match, 20 frames
came through clean but Kepler only answered RESETs; at OSCCLK / 1
(div=0, 6.14 MHz) the offset changed twice in 100 s. So the drift grows
as the clock slows. The 05:02 reset in that session was the CP link
(CLUSTER0_NONCPU_WDTRESET), not the SPI.
…l 9a's pdma1 PrimeCell IDs

Bring-up, not for merge. Stock drives the GNSS SPI with DMA through
pdma1, a PL330 at 0x10130000 (GIC SPI 806) that our device tree does not
have. Before giving it a node, this module reads its four PrimeCell ID
registers once from Linux, one register per read, and returns -EAGAIN so
nothing stays loaded. MODEM-PLAN G3, "DMA" (2026-10-29): periph 0x30
0x13, cell 0x0d 0xf0, read without an abort, so a DT node can probe it
(logs/tegu-gnss-autocs-20261029/pdma-probe-kmsg.txt). It ran as
tegu-pdma-probe.ko on the gn3 kernel; the Kconfig entry defaults to n.
…t runtime and run a memcpy

Bring-up, not for merge. The "runtime test module" of MODEM-PLAN G3's DMA
step (2026-10-29, night): it maps GIC SPI 806 through the GIC's fwnode,
registers a fixed 200 MHz clock as pdma1's apb_pclk, allocates an AMBA
device "10130000.pdma" for stock's pdma1 (PL330 at 0x10130000) and adds
it, so the built-in pl330 driver probes it, then asks for a DMA_MEMCPY
channel of that device and copies 256 bytes through it. On the palmtop
the pl330 driver probed it ("DMAC-341330, 8 channels, 32 peripherals")
and the copy matched (logs/tegu-gnss-dma-20261029/pdma-rt-kmsg.txt),
which is why a DT node for pdma1 followed. With that node and dmas on
the GNSS SPI, RX DMA moved nothing (residue 64): the SPI's requests do
not reach pdma1, so some routing stock sets up is still missing. It ran
as tegu-pdma-rt.ko on the gn3 kernel; the Kconfig entry defaults to n.
…e GNSS SPI test overlays

Bring-up, not for merge. The device-tree changes behind MODEM-PLAN G3's
tries on the Pixel 9a, as overlays on the palmtop's integration DTB
(gn3; the published omamobile branch has no zumapro-tegu.dts yet, so
there is no board file here to change):

- zumapro-tegu-gnss-spi-fb0.dtso: stock's feedback delay 0 on the GNSS
  SPI device (ninth to fourteenth tries, the "feedback delay 0" rows);
- zumapro-tegu-gnss-spi-autocs.dtso: automatic chip select, by leaving
  spi21 with the google,gs101-spi compatible only (the "auto CS" rows of
  the ninth to fourteenth tries and "acs" of the fifteenth to
  twenty-third: no change with 8-bit words);
- zumapro-tegu-pdma1.dtso: stock's pdma1 (PL330 at 0x10130000, GIC SPI
  806, a fixed 200 MHz APB clock) and dmas on spi21 in stock's order
  (0x14 tx, 0x15 rx): the pl330 driver probed it at boot, but RX DMA
  moved nothing (residue 64);
- zumapro-tegu-pdma1-swapped.dtso: the second boot, channels the other
  way round, the same result; the boot after it reset at 69 s, cause not
  seen.

Each test DTB was the gn3 DTB with the change compiled in (the dts in
logs/tegu-gnss-dma-20261029 is gn3's source with the pdma1 node), copied
into the build kit, packed into slot B's images by the kit's "omamobile
images" twice (the two packs had to match) and written with "omamobile
push"; the palmtop is back on the gn3 DTB without any of them. The
overlays are not wired into the Makefile: the board DTB they apply to is
not in this tree.
…AN G3's tries

Bring-up, not for merge. The on-palmtop scripts (g7-strace.sh from the
fifth try on, g7-min for the morning's short sessions), the laptop's
run-case.sh and run-short.sh that ran one case per fresh boot with the
gnss_spi module parameters in GNSS_SPI_ARGS, and the offline Python
checks of the saved reads (CHPP CRC32, bit offsets, shifts, the
boundary brute force), as they were in /tmp/w32p32 on the laptop and
logs/tegu-modem-20261027/phone in the omarchy-mobile tree, with one
change: the three scripts that imported from /tmp/w32p32 now import
from their own directory. The README says what each does. No captured
GNSS data is included.
… run-short.sh's usage line

g7-short on the palmtop was the fifth try's 240 s strace session writing to /var/log/omamobile/g7/, not g7-min; run-short.sh counts that directory, so it now ships the real script and names itself in its usage line.
… 32-bit words

Stock drives the Pixel 9a's GNSS SPI with 32-bit words and the controller's own byte and half-word swap (SWAP_CFG, programmed by Google's spi-s3c64xx.c when the node has swap-mode), so the bytes land in memory in wire order. Mainline has no swap support and the night's 32-bit tries swapped in software. This adds the property and programs SWAP_CFG by word size as Google does, for G3-A's second step (32-bit words at stock's clock with the controller's swap). Compiles W=1 clean against the palmtop's tree; not booted.
…o software swap

Stock drives the Pixel 9a's GNSS SPI with 32-bit words and the controller's own byte and half-word swap (SWAP_CFG), so the bytes reach the wire in memory order. Our 8-bit path, and the 32-bit tries that swapped each word in software, have never matched stock's framing. With word32=1 the transfers use 32-bit words and leave the swapping to a controller running with Google's swap-mode (the spi-s3c64xx change on this branch). Default off: nothing changes for the 8-bit path.
For the G3-A3 clock-phase sweep: in G3-A2 the chip's replies arrived intact but shifted right by 2, 4 and 6 bits on successive reads, sampled out of step with SCK. spi_mode 0..3 sets the mode for every transfer before spi_setup in probe and logs the result; -1 keeps the device tree's.
s3c64xx_flush_fifo() cleared PACKET_CNT (and with it PACKET_CNT_EN) while
RXCH_ON was still set. For that register write the controller clocks
freely, and with automatic chip select the slave stays selected, so it
shifts out bits that the flush then discards. A slave that streams across
chip-select cycles, like the Pixel 9a's GNSS core over CHPP, loses a
couple of bits per transfer: on the 9a every read arrived 0, 2, 4 or 6
bits off. Google's driver turns the channels off first; do the same.

With this, the 9a's GNSS SPI in stock's configuration (mode 0, 32-bit
words, swap mode, feedback delay 0, automatic chip select) reads every
frame at bit 0 with a valid CRC, and the receiver gets a fix.

Also adds the bring-up overlay that gives the GNSS SPI's pins (gpp22-0..3)
function 2 and drive 3: without a pinctrl the bus ran on the bootloader's
drive 0.
@W4HO-ham
W4HO-ham force-pushed the tegu-gnss-spi-bringup branch from 734f5f8 to 77c05f4 Compare October 31, 2026 04:09
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Rebased onto today's omamobile; the commits you've landed since are dropped, so what remains is the bring-up test code and the two SPI commits (the flush order here is the same one as #150). Still a draft, not for merge.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Next step on the hang is staged rather than guessed. I audited every register path in the cycling window from the source, and none is unguarded: DBI goes through the guarded accessors (cp_dbi_read/cp_dbi_write under dbi_lock, which covers the per-queue MSI handlers' dw_pcie_readl_dbi()), the control interrupt handler returns early unless cfg_root_ok under cfg_lock and is disabled with disable_irq() first in cp_link_down(), configuration space is behind the same flags, and the modem's shared memory is reserved DRAM (cp_shmem_get_region(), memremap()) rather than the BAR window, so the boot indicator, magic, capability and queue pointers are all safe while the link is down. The doorbell was the exception and is fixed.

So the hang is most likely not a stray read but something that accumulates across the cycles: about 3000 of them in the 26 minutes that session lasted, each with a PMU write through the secure monitor, a phy_init()/phy_exit() pair, an MSI re-arm and a root-port window restore. The interrupt enable and disable calls are paired behind ctrl_irq_on and msi_irqs_on, so a plain imbalance is out.

On the branch now: a bring-up commit that numbers every cycle and logs each step of link_down and link_up behind trace=1, so the kept console names the cycle and the step the hang interrupted. The module is built and the session runner is ready; the palmtop is hung awaiting a forced restart, so the run itself is the next thing I do when it is back.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Found why the link cycles twice a second in the first place, which I think changes the order of work here.

gs201_pcie_cp_l1ss() in our controller returns 0 and does nothing; its own comment says L1 substates are never enabled on this link. The modem driver asks for them after every link-up (s51xx_pcie_restore_state() → s51xx_pcie_l1ss_ctrl(1, ...)), and Google's driver implements that: exynos_pcie_rc_set_l1ss() finds the endpoint's L1SS capability and writes PCI_L1SS_CTL1/CTL2 and PCI_EXP_LNKCTL on both ends, for the Samsung modem endpoint among others, behind a use_l1ss property in its DT.

So on stock an idle modem link parks in L1.2 and stays up. On ours the modem's only way to save power when it goes idle is to ask the AP to power the link off, which is the isolate and un-isolate pair we see about twice a second under GNSS traffic. That is not a symptom of the hang; it is what makes the hang reachable in minutes, since every cycle is another chance at whatever breaks and the console shows the hang falling inside one.

So the next change after the trace is to implement gs201_pcie_cp_l1ss() for real. If the cycling stops, a GNSS session stops hitting the hang even before its root cause is found, and the keep_link_up diagnostic can go away. It needs the link up and the ATU set, which is why Google defers the request and keeps a pending mask for it. I have not written it: the palmtop is hung awaiting a forced restart, and I would rather not push untested PCIe register writes for this link while I cannot boot them.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Wrote it after all, as a draft on tegu-cpif-doorbell: "PCI: gs201-cp: enable L1 substates on the modem link". It follows Google's exynos_pcie_rc_set_l1ss() for the modem endpoint only, in Google's order: the LTR mechanism and L1SS on both ends, the endpoint's entrance latency and TPowerOn as they program them, and ASPM L1 last so the link only starts using the substates once both ends are set; undoing it clears ASPM first. A request that arrives while the link is down is remembered and applied after the next link up, where the configuration accessors are open again, which is also where Google defers it. Builds for arm64 with W=1, checkpatch clean.

It has never been booted: the palmtop was unreachable when I wrote it, so nothing here is tested, and I would want it booted before anyone trusts it. The module is built and staged next to the trace runner, so the first run after the palmtop comes back can answer the one question that matters, whether the isolate and un-isolate pairs drop from thousands in a session to a handful. If they do, a GNSS session stops meeting the hang, and the keep_link_up diagnostic can go.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

G3-L1 is answered, and it was the L1 substates: with them the link stops being torn down and the session holds.

before (10-30 night) with L1 substates (10-31 morning)
isolate/un-isolate pairs under GNSS traffic about 2 a second, thousands in a session 2 in the first 2.5 min, 7 in 5 min
the SoC hang about 170 s after ONLINE, or 26 min with the doorbell fix none
the CP crashed 103-108 s after ONLINE when the link was held instead ONLINE throughout
fixes about a minute's worth 157 of 165 GGA sentences fixed at 5 minutes, still running

So the hang was never reached, because the link stopped being torn down thousands of times, which is what stock does and what the modem asks for after every link up.

One correction to the commit I pushed last night: the modem driver's last call in s51xx_pcie_restore_state() is an unconditional enable, and it also arrives during the ROM boot. Acting on it there stops the image download: the CP never leaves BOOTING and cpif reports "no PCIe endpoint for the ROM boot", three boots of three. So the requests are remembered and only acted on with the l1ss parameter set (written once the CP is ONLINE) and only while the link is up with the ATU set. That is 47d1193 on tegu-cpif-doorbell.

Three mistakes of mine before I got a module that even bound, in case they save you time on a port: the module for this palmtop must carry google,zumapro-pcie-cp in its match table and treat samsung,sysreg as optional, which the in-tree branch does not, so a module built from it never binds and the failure looks like a modem problem; a module built without LOCALVERSION=-s2mpg15-m1 is refused as "Invalid module format", and a plain make drivers/.../x.o in the shared output tree rewrites utsrelease.h so later module builds inherit the wrong release; and the controller needs allow_hw=1, which my edit to the start script's insmod line had dropped.

Still a bring-up parameter rather than a finished design: the proper shape is the id mask Google keeps, so a disable during boot cannot be undone by the enable that follows it.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Two more runs this morning sharpen that result, and one of them walks part of it back.

L1.2 (l1ss_mask 0xf, Google's value): the cycling stops, the session holds for minutes, then the link drops on its own. At 325 s: link down completion timeout (IRQ0/1/2 0x0 0x400 0x371b1000) with IRQ1 bit 10 (LINK_DOWN) latched, then s51xx 0001:01:00.0: Unable to change power state from D0 to D3hot, device inaccessible and cpif's Can't set D3 state!!!!. So the link was already down when the orderly power-off began, PME_Turn_Off could not complete, and the SoC went with it. cp_pme_turn_off() does request an L1 exit first, so this is the link leaving L1.2 by itself rather than a missing exit request. CLKREQ#, which L1.2 needs in order to remove the reference clock, is the first thing I would check on this board.

L1.1 only (l1ss_mask 0xa): the cycling does not stop. Without L1.2 the modem still asks for a full power-off when it goes idle, so the isolate and un-isolate pairs continue and the original hang came back at 165.9 s, the console ending right after a link-up, the same shape as 10-29 and 10-30.

So: the avoidance needs L1.2, and L1.2 has a problem of its own. The commit now carries l1ss_mask so both can be tried. What is left is why the link leaves L1.2 after minutes (CLKREQ# wiring, and the timings the commit programs: TPowerOn 200 us, TCommon 32 us, entrance latency 64 us, all worth checking against stock's), and handling an unexpected link-down in that state instead of dying with it.

Best session so far, for the record: 157 of 165 GGA sentences fixed over five and a half minutes, CP ONLINE throughout, 7 link power-downs in that time instead of several hundred.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Third run, and it corrects a guess of mine. I raised tpoweron to Google's largest value (0xfa, 3100 us) on the theory that the endpoint needed longer to restore its clock after an L1.2 exit. The opposite happened: the cycling did not stop at all, the trace counted 486 link cycles by 244 s, and the console ends mid-cycle right after PHY isolated, which is the original hang. So the 200 us Google uses for this modem is right, and a longer TPowerOn makes L1.2 unusable, after which the modem goes back to asking for a full power-off.

l1ss_mask / tpoweron link cycles result
0xf / 0xa1 (Google's) 7 in 5 minutes 157 of 165 GGA fixed, CP ONLINE throughout, then an unexpected LINK_DOWN at 325 s and the SoC with it
0xa / 0xa1 (no L1.2) continuous the original hang at 165.9 s
0xf / 0xfa (3100 us) 486 by 244 s the original hang

On the pin side I checked what I suspected and it is fine: the overlay gives pcie@12100000 pinctrl-0 = <&pcie0_clkreq>, <&pcie0_perst> under the name "active", the driver selects that state before the PHY, and gph0-1 is function 2, pull-up, drive 3, the same through power-down. MSTR_PEND_SEL_NAK, DBI_L1_EXIT_DISABLE ("use aux_clk in L1.2") and the HW L1-exit mode all match your driver's equivalents.

So the open item is narrower than this morning: not the configuration, but the unexpected LINK_DOWN while parked in L1.2, and surviving it rather than dying with it. Next for me: read the LTSSM and the endpoint's L1SS status at the moment it latches, and let the controller's existing recovery handle it instead of the power-off path running into a dead link.

The trace earns its keep, by the way: it is what turned "the console stops" into "the console stops in cycle 486, at the isolate step".

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

I have to walk back the three-row table above: those runs were measuring nothing, and the instrumentation is what caught it.

With the link-down capture in place, every drop printed L1SS_CTL1 0x0, CTL2 0x0 with LNKCTL 0x...42. So the root port's substate control was zero while ASPM L1 was on. Two reasons:

  • The offsets. I took PCIE_LINK_L1SS_CONTROL 0x19c and CONTROL2 0x1a0 from your driver's register map. On this controller the L1SS capability is at 0x160, on both the root port and the endpoint, read from the hardware with pci_find_ext_capability(). 0x19c is something else here, so my writes landed on unrelated registers and read back as zero.
  • The write lock. Those registers are behind DBI's read-only lock and need dw_pcie_dbi_ro_wr_en(). I added that, and it changed nothing on its own, because the offset was still wrong.

So l1ss_mask and tpoweron never reached the hardware, and the differences between those three runs are not the substates. The one change that did take is plain ASPM L1 in the link control register, which is what the five-minute session actually had.

Read live during a session, with the link up:

capability CTL1 CTL2
root port 0000:00:00.0 0x160 0x40a30a00 (substates off) 0x79
endpoint 0000:01:00.0 0x160 0x40a30000 (substates off) 0x79

The LTR threshold and TCommon fields are already populated; only the four enable bits are clear. The implementation now reads both offsets from the hardware and logs CTL1 back after writing, so the next run reports whether the substates are actually on instead of me assuming it. Running that now.

Worth saying plainly: an earlier reading of mine that suggested the endpoint had no L1SS capability at all was also wrong, taken while the link was down, where the whole config space reads 0xffff.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Closing the loop on the substates with what the hardware actually says, read live with the link up:

CAP supports CTL1 enables TCommon LTR threshold TPowerOn
root port 0000:00:00.0 0x280a1f PCI-PM L1.1/L1.2, ASPM L1.1/L1.2, L1 PM substates 0 10 us 163 x scale 2 57 x scale 1
endpoint 0000:01:00.0 0x790a1f the same four 0 0 163 x scale 2 57 x scale 1

So both ends are willing, the timing fields are already populated by whoever set them, and only the four enable bits are clear. From userspace with setpci the root port takes the bits (CTL1 0x4600 to 0x460f) and both link controls take ASPM L1; the endpoint's CTL1 I have not yet seen written, because a window with both config spaces readable is hard to catch once the CP is ONLINE and the link is down most of the time (a 1 Hz poll missed it for 120 s; a 50 Hz poll caught one and the boot ended first).

The branch now has the implementation that reads the capability offset from each end (a8a6514) instead of Google's 0x19c, keeps TCommon when setting the enables, and reads CTL1 back into the trace. It has not yet been observed to take effect in the driver, so the next step is a print at the entry of gs201_pcie_cp_l1ss() to learn whether the modem driver's request arrives at all. I'm pausing the hardware runs there: each attempt costs a reset of the palmtop, and the record now has everything needed to pick it up cleanly.

For the record, the palmtop is back on the module without any of this (f06066614cad75fb), and the GNSS result that stands is the one from #150 and #151: a fix, served through the Location switch, for about a minute to five per session depending on how the link behaves.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham, for keeping this record so complete. A fix on the 9a's GNSS, with the flush-order fix split out and merged as #150, is a great result, and the per-try commits made every step of it traceable.

G3-A is done, so as we agreed on the 30th, this can be closed. Please do one thing first. The rebase on the 31st (734f5f8c8920 to 77c05f405131) gave every commit a new id, and none of the ids that device/tegu/MODEM-PLAN.md links on main (bb9999570 through 8d77391d9, and 11ea0ef5e), nor 734f5f8c8, which omarchy-mobile#202 adds, is on the branch any more. GitHub still serves them today from the force-push history, but nothing keeps them once the PR is closed. All of them are ancestors of the old head, so a single tag preserves the whole record:

git tag tegu-gnss-g3-record 734f5f8c89202fe0326a38c2aee57c77b64cc63a
git push <your fork> tegu-gnss-g3-record

Updating the plan's links to the new ids would also work, but the tag is less work and keeps the plan as written. Once it's pushed, please close this. The PR's description, which still lists the old ids and the #135 base, then doesn't matter.

The L1-substate work from the 31st isn't GNSS SPI code, so please carry it on tegu-cpif-doorbell and in omarchy-mobile#202, where its record is, rather than here. One thing about those runs I'd like answered before the next one. G3-L1's runbook stops at two SoC resets, with no further boot of that kernel the same day and three sessions in all. It also asks for M0.1's partition check after every reset with the modem up. This thread describes at least three resets on the morning of the 31st alone (the link drop at 325 s, the hang at 165.9 s and the one at 244 s), after the night's. It also describes root-port L1SS writes with setpci on the live modem link, and no plan step covers those. Was M0.1 run after those resets, and did it match? And please make any further config-space write on that link a step in MODEM-PLAN, with its own cap, before it runs. I'll follow up on #202, but I wanted you to have the question in the thread where the runs were reported.

W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Nov 2, 2026
…fers

Google's gnss_spi sends 32-bit words in one transfer per call, and
relies on Google's SPI controller driver for two things this kernel's
spi-s3c64xx does not do:

- The board's SPI 21 node has swap-mode = <1>, for which Google's
  driver programs the controller's SWAP_CFG to swap the bytes and
  half-words of each word on TX and RX, so the bytes go on the wire in
  memory order. spi-s3c64xx shifts a 32-bit word out most significant
  byte first, which on a little-endian CPU reverses every group of
  four bytes. Swap each word in gnss_spi instead, on the way out and on
  the way in, and give the caller its TX buffer back unswapped. Every
  transfer is a whole number of words (gnssif rounds writes up to 4
  bytes and reads 64), so an odd size is refused.
- The core's data comes in 64-byte blocks, and reads are one block per
  transfer. spi-s3c64xx moves a transfer that fills the 64-byte FIFO in
  one piece on zumapro, but cuts a longer one into 60-byte pieces. Send
  writes as one message of transfers of 64 bytes at most, as the reads
  are.

On the Pixel 9a (MODEM-PLAN G3, 2026-10-30, the bring-up driver of
linux-omarchy-mobile#137 with these two settings, SPI mode 0, stock's
feedback delay 0 and the controller driving chip select) the receiver
got its position fix: in a session by a window 54 of 56 GGA sentences
had a fix, with 10 satellites, HDOP 1.2, and no CHPP checksum error,
ACK timeout or permanent failure. That boot had no swap mode in the
controller, which a bring-up patch also tried with the same result, so
neither the device tree nor spi-s3c64xx needs one. The palmtop has run
this setting since.

8-bit words would put the bytes in memory order too, but they have not
been tried since the SPI flush fix ("spi: s3c64xx: turn the channels off
before clearing the packet count") that ended the link's bit slips, so
this keeps stock's word size. The bring-up's module parameters for the
word size, the transfer size and the SPI mode are not carried over:
these are fixed, and the mode and clock come from the device tree.

Link: derekross#137
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Nov 2, 2026
…fers

Google's gnss_spi sends 32-bit words in one transfer per call, and
relies on Google's SPI controller driver for two things this kernel's
spi-s3c64xx does not do:

- The board's SPI 21 node has swap-mode = <1>, for which Google's
  driver programs the controller's SWAP_CFG to swap the bytes and
  half-words of each word on TX and RX, so the bytes go on the wire in
  memory order. spi-s3c64xx shifts a 32-bit word out most significant
  byte first, which on a little-endian CPU reverses every group of
  four bytes. Swap each word in gnss_spi instead, on the way out and on
  the way in, and give the caller its TX buffer back unswapped. Every
  transfer is a whole number of words (gnssif rounds writes up to 4
  bytes and reads 64), so an odd size is refused.
- The core's data comes in 64-byte blocks, and reads are one block per
  transfer. spi-s3c64xx moves a transfer that fills the 64-byte FIFO in
  one piece on zumapro, but cuts a longer one into 60-byte pieces. Send
  writes as one message of transfers of 64 bytes at most, as the reads
  are.

On the Pixel 9a (MODEM-PLAN G3, 2026-10-30, the bring-up driver of
linux-omarchy-mobile#137 with these two settings, SPI mode 0, stock's
feedback delay 0 and the controller driving chip select) the receiver
got its position fix: in a session by a window 54 of 56 GGA sentences
had a fix, with 10 satellites, HDOP 1.2, and no CHPP checksum error,
ACK timeout or permanent failure. That boot had no swap mode in the
controller, which a bring-up patch also tried with the same result, so
neither the device tree nor spi-s3c64xx needs one. The palmtop has run
this setting since.

8-bit words would put the bytes in memory order too, but they have not
been tried since the SPI flush fix ("spi: s3c64xx: turn the channels off
before clearing the packet count") that ended the link's bit slips, so
this keeps stock's word size. The bring-up's module parameters for the
word size, the transfer size and the SPI mode are not carried over:
these are fixed, and the mode and clock come from the device tree.

Link: derekross#137
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Nov 2, 2026
…fers

Google's gnss_spi sends 32-bit words in one transfer per call, and
relies on Google's SPI controller driver for two things this kernel's
spi-s3c64xx does not do:

- The board's SPI 21 node has swap-mode = <1>, for which Google's
  driver programs the controller's SWAP_CFG to swap the bytes and
  half-words of each word on TX and RX, so the bytes go on the wire in
  memory order. spi-s3c64xx shifts a 32-bit word out most significant
  byte first, which on a little-endian CPU reverses every group of
  four bytes. Swap each word in gnss_spi instead, on the way out and on
  the way in, and give the caller its TX buffer back unswapped. Every
  transfer is a whole number of words (gnssif rounds writes up to 4
  bytes and reads 64), so an odd size is refused.
- The core's data comes in 64-byte blocks, and reads are one block per
  transfer. spi-s3c64xx moves a transfer that fills the 64-byte FIFO in
  one piece on zumapro, but cuts a longer one into 60-byte pieces. Send
  writes as one message of transfers of 64 bytes at most, as the reads
  are.

On the Pixel 9a (MODEM-PLAN G3, 2026-10-30, the bring-up driver of
linux-omarchy-mobile#137 with these two settings, SPI mode 0, stock's
feedback delay 0 and the controller driving chip select) the receiver
got its position fix: in a session by a window 54 of 56 GGA sentences
had a fix, with 10 satellites, HDOP 1.2, and no CHPP checksum error,
ACK timeout or permanent failure. That boot had no swap mode in the
controller, which a bring-up patch also tried with the same result, so
neither the device tree nor spi-s3c64xx needs one. The palmtop has run
this setting since.

8-bit words would put the bytes in memory order too, but they have not
been tried since the SPI flush fix ("spi: s3c64xx: turn the channels off
before clearing the packet count") that ended the link's bit slips, so
this keeps stock's word size. The bring-up's module parameters for the
word size, the transfer size and the SPI mode are not carried over:
these are fixed, and the mode and clock come from the device tree.

Link: derekross#137
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
derekross pushed a commit that referenced this pull request Nov 3, 2026
…fers

Google's gnss_spi sends 32-bit words in one transfer per call, and
relies on Google's SPI controller driver for two things this kernel's
spi-s3c64xx does not do:

- The board's SPI 21 node has swap-mode = <1>, for which Google's
  driver programs the controller's SWAP_CFG to swap the bytes and
  half-words of each word on TX and RX, so the bytes go on the wire in
  memory order. spi-s3c64xx shifts a 32-bit word out most significant
  byte first, which on a little-endian CPU reverses every group of
  four bytes. Swap each word in gnss_spi instead, on the way out and on
  the way in, and give the caller its TX buffer back unswapped. Every
  transfer is a whole number of words (gnssif rounds writes up to 4
  bytes and reads 64), so an odd size is refused.
- The core's data comes in 64-byte blocks, and reads are one block per
  transfer. spi-s3c64xx moves a transfer that fills the 64-byte FIFO in
  one piece on zumapro, but cuts a longer one into 60-byte pieces. Send
  writes as one message of transfers of 64 bytes at most, as the reads
  are.

On the Pixel 9a (MODEM-PLAN G3, 2026-10-30, the bring-up driver of
linux-omarchy-mobile#137 with these two settings, SPI mode 0, stock's
feedback delay 0 and the controller driving chip select) the receiver
got its position fix: in a session by a window 54 of 56 GGA sentences
had a fix, with 10 satellites, HDOP 1.2, and no CHPP checksum error,
ACK timeout or permanent failure. That boot had no swap mode in the
controller, which a bring-up patch also tried with the same result, so
neither the device tree nor spi-s3c64xx needs one. The palmtop has run
this setting since.

8-bit words would put the bytes in memory order too, but they have not
been tried since the SPI flush fix ("spi: s3c64xx: turn the channels off
before clearing the packet count") that ended the link's bit slips, so
this keeps stock's word size. The bring-up's module parameters for the
word size, the transfer size and the SPI mode are not carried over:
these are fixed, and the mode and clock come from the device tree.

Link: #137
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@derekross

Copy link
Copy Markdown
Owner

Closing: #185 is merged and replaces this bring-up series (as planned). Thanks, @W4HO-ham.

@derekross derekross closed this Nov 3, 2026
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
… and GNSS parked (derekross#153)

MODEM-PLAN's GNSS section from the night of 10-28 into 10-29. The "KEP
M7 HARDFAULT" at every engine start is gnssd's soft watchdog resetting
Kepler because the CHPP link over the GNSS SPI loses bytes. Two kernel
causes were found, USI3 stuck on the 399.36 MHz parent and spi-s3c64xx
cutting a full-FIFO transfer into 63 + 1 bytes; both are in
derekross/linux-omarchy-mobile#138, in review. With them, mode 0 is
marginal and mode 1 loses the first byte of each back-to-back block.
Stock's SPI setup, read from its device tree and Google's driver, is
automatic chip select, feedback delay 0 and the controller's byte swap,
in PIO; no try has run that at stock's clock, so it is the first boot
(G3-A) when GNSS resumes. GNSS is parked at the owner's decision. Every
try links its commit on derekross/linux-omarchy-mobile#137.

The CP link hang stays open. The morning's 24 ramoops consoles hold
eight watchdog hangs, each ending between the cp2ap_wakeup edge and the
link coming back, while the link cycles quickly. G3-L1 (attended, on the
charger, capped, M0.1 before and after) first holds the link up with a
bring-up cpif parameter, then traces CPIF's BAR accesses. The six
protected partitions matched the 10-28 backup after the night's and
morning's boots. NOTES records two resets at about 34 s after Bluetooth
started, the 03:03 one read back from the journal.

Test images reached slot B through bin/omamobile push only.

Co-authored-by: W4HO-ham <87742609+W4HO-ham@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants