Skip to content

spi: s3c64xx, clk: zumapro: the Pixel 9a's GNSS SPI at stock's clock, without the 63+1 cut - #138

Merged
derekross merged 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-spi-word-pieces-v2
Oct 30, 2026
Merged

derekross merged 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-spi-word-pieces-v2

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

Two changes for the Pixel 9a's GNSS SPI (SPI21 on HSI0 USI3), each on its own.

spi: s3c64xx: Do not cut a PIO transfer that fills the FIFO. A 64-byte transfer on a 64-deep FIFO was cut into 63 + 1 with a channel reset between the pieces, because the interrupt mode's RX trigger level stops one short of the FIFO. On the GNSS link the slave moves one 64-byte block per chip-select cycle, and a 32 + 32 experiment with chip select held showed every frame that crossed a piece boundary failing its checksum, so the cut is what loses the data. A transfer of exactly the FIFO depth is now polled in one piece, as Google's driver does; pieces of longer transfers are kept a whole number of words, so a 32-bit transfer's packet count no longer rounds down and times out. The touchscreen (SPI20, the same driver) is unaffected: a day of use on the palmtop.

clk: samsung: zumapro: Let USI3 reach OSCCLK for the GNSS SPI. The bus asked for 12.5 MHz but got 24.96 MHz (a 6.24 MHz SPI clock, twice stock's): the mux was read-only on the 399.36 MHz parent and the 4-bit divider stops at /16. Google's clock table makes the 12 MHz setting from OSCCLK / 2. With nMUX (reparenting allowed) and CLK_SET_RATE_PARENT on the divider and the source gate, the framework picks OSCCLK and /2: zumapro_gout_hsi0_usi3_ip reads 12.288 MHz after the first transfer, a 3.072 MHz bus. USI2 (the touchscreen) keeps its read-only mux.

Both booted on the palmtop today from the gn3 integration source with gn3's reproducible build stamp; graphics, audio, touch and the rest come up as before. They do not make GNSS work yet: with the clock and the cut right, the reads still either sample half a bit off (mode 0) or lose the first byte of each back-to-back block (mode 1), which is a logic-analyzer question now (MODEM-PLAN G3 on omarchy-mobile #138). The changes stand on their own as fixes to what the driver and the clock table did wrong.

This replaces #135, whose two commits went up without my sign-off (CI caught it); the code is the same, cherry-picked with the sign-off. checkpatch's one CHECK is the nMUX name, which is Samsung's own macro.

@derekross

Copy link
Copy Markdown
Owner

Thanks for both fixes, and for re-posting them with your sign-off. The gate passes on the PR merged onto today's omamobile: sign-offs, prefixes, checkpatch (the one CHECK is the nMUX name, as you say) and W=1 builds of both files.

clk: samsung: zumapro. This one is ready. I checked it against Google's zuma CMU table: cmucal-vclklut.c has div_clk_hsi0_usix_12mhz_lut_params[] = { 1, 1 }, which is the divider at /2 and the mux on oscclk. That gives 12.288 MHz and a 3.072 MHz bus, as you measured. Only zumapro's table changes, and USI2 keeps its read-only mux. If you touch the commit again, a pointer to that table line in the message would help upstream reviewers, but it isn't required.

spi: s3c64xx. I think the change is right, but it reaches the Pixel 7 Pro, so it needs one change before merge. gs201's SPI nodes have no dmas, so on my phone every transfer of 64 bytes or more takes this PIO path today. Three clients run on it every day: the touchscreen, the two CS35L41 amplifiers (firmware download included) and the BCM4775 GNSS. All three use 8-bit words, so your pio_len rounding is neutral there (rounddown(63, 1) is still 63). The exact-FIFO case does change, though: a 64-byte transfer used to go as 63 bytes by interrupt plus 1 polled, and now goes as one polled 64-byte transfer. I read the new path and it looks sound. The RX level field is wide enough for 64, the RDY_LVL limit is 63 as your comment says, and Google's driver also polls up to the FIFO depth. Still, CONTRIBUTING §6.2 asks that shared drivers leave the 7 Pro as it is unless the change has a 7 Pro reason and has run on that phone.

The easiest way is the one you used in 709c18b33222 for native CS. Add a flag to s3c64xx_spi_port_config, set it only in zumapro_spi_port_config, and put the > fifo_len and < fifo_len changes behind it. The pio_len rounding can stay for everyone: it only fixes 16- and 32-bit transfers that could never complete. If you'd rather argue that the full-FIFO path is right for every board, I'm open to it. In that case the message needs that reason, and I'd run it on my 7 Pro before merging (the SPI commit applies cleanly to the tree my phone runs). Please tell me which way you prefer.

Two small things for the record:

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Thanks for the careful read of both.

spi: s3c64xx. I took the flag route, as a third commit (b8ce74a) rather than a rewrite, since I can't force-push from here today; please squash it into the first at merge if you prefer one commit. poll_full_fifo in s3c64xx_spi_port_config, set only in zumapro_spi_port_config: a transfer of exactly the FIFO depth is cut into FIFO-1 plus the rest everywhere else, exactly as before, and the pio_len rounding stays for everyone. W=1 clean against the palmtop's kernel, checkpatch clean.

clk: samsung: zumapro. Your pointer to div_clk_hsi0_usix_12mhz_lut_params[] = { 1, 1 } in cmucal-vclklut.c is the right citation; I'll put it in the message with the next rewrite of this branch, or you're welcome to add it at merge.

The boot, for the record. Release 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty (the LOCALVERSION is fixed in the build, so the night's and the morning's images share it; their Image sha256 told them apart). The gn3 tree's drivers/spi/spi-s3c64xx.c is blob a65dbe21d240, which is this branch's file byte for byte. Its drivers/clk/samsung/clk-zumapro.c is blob ffbba5d2690a, which can't equal this branch's: that tree carries an older revision of the driver (before the misc-to-ro rework on omamobile), with the same three-line USI3 change applied to it, which is the whole of the diff that matters: nMUX(CLK_MOUT_HSI0_USI3_LOCAL, …, 0x1020, 0, 1) at line 385, DIV_F(CLK_DOUT_HSI0_USI3, … CLK_SET_RATE_PARENT, 0) at 398 and GATE(CLK_GOUT_HSI0_USI3_IP, … CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0) at 413. The clock readout after that boot was zumapro_mout_hsi0_usi3_local 24576000, dout 12288000, gout_ip 12288000.

The smoke report below is from today's boot of that kernel (the palmtop has rebooted a few times since the morning on the same Image).

phone-smoke: tegu

Kernel 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, tools at 34778a2, 2026-10-29T18:06Z.

Check Result Detail
boot (required) ok kernel 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, slot b, up 66s
storage guard (required) ok 62 partitions; only userdata and slot B's boot images writable
root (required) ok ext4 on userdata, 19G free
kernel health (required) ok no oops or BUG; 0 WARN, 251 error lines in dmesg
systemd units ok none failed
USB gadget (required) ok bound to 11210000.usb
display ok card1-DSI-1 connected, 1080x2424
GPU ok render node on panthor
session (required) ok Hyprland and the Omarchy shell running
lock ok PAM file present, the shell can lock (passwordPam true, locked false)
touch ok Synaptics TouchComm Touchscreen
buttons ok gpio-keys
Wi-Fi ok wlan0 on brcmfmac, link up
Bluetooth ok hci0, powered true
battery ok 90% Unknown, 31 °C
sound cards ok googleteguaocsn
sensors ok Accelerometer AmbientLight Proximity
cameras ok 3 listed by libcamera
thermal ok hottest zone 43 °C

Packages: hyprland 0.56.2-5.1, libcamera 0.7.2-4.22, mesa 1:26.2.4-1.4, omacam 0.3.3-1, omamobile-apps 0.2.0-1, omamobile-audio 0.4.1-1, omamobile-device-tegu 0.2.0-1, omamobile-fingerprint 0.1.8-1, omamobile-firstboot 0.1.0-1, omamobile-gnss 0.2.1-1, omamobile-keyring 20261013-1, omamobile-mirror 0.1.1-1, omamobile-modem 0.1.4-1, omamobile-omarchy 0.1.12-1, omamobile-owl-widgets 0.1.1-1, omamobile-sensors 0.2.1-1, omamobile-shell 0.2.36-1, omarchy 4.0.6-1

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, @W4HO-ham, for the flag. With poll_full_fifo clear, the condition is the old >= fifo_len and pio_len stays at 63 for 8-bit words, so the Pixel 7 Pro keeps its transfers exactly as before; with it set, the 9a runs the logic you tested. Kernel PRs land commit by commit, though, so the first commit on its own would still change every board. As you invited, I'll fold the third commit into the first and reword its message to say the full-FIFO poll is for ports that ask for it, keeping your sign-off, and add the cmucal-vclklut.c pointer to the clk message. Then I'll merge.

A PIO transfer of fifo_depth bytes or more is cut into pieces of
fifo_depth - 1 bytes, because the RX trigger level of the interrupt
mode stops one short of the FIFO. On the Pixel 9a's GNSS link the
slave hands out one 64-byte block per chip-select cycle, and the cut
loses data at the piece boundary (the channel is reset between the
pieces). On ports that ask for it with the new port-config flag
poll_full_fifo, set only for zumapro, transfer a full FIFO in one
piece, polled, as the vendor driver does; every other board keeps its
transfers exactly as before, the cut having always worked there. For
all ports, keep the pieces of longer transfers a whole number of
words, so a 16- or 32-bit transfer's packet count does not round down
and time out.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The Pixel 9a's GNSS SPI (SPI21 on HSI0 USI3) asks for 12.5 MHz, but the
USI3 mux is read-only on the 399.36 MHz parent and its 4-bit divider
stops at /16, so the IP clock is 24.96 MHz and the bus runs at 6.24 MHz,
twice what stock uses. Google's clock table makes the 12 MHz setting
from OSCCLK / 2 (cmucal-vclklut.c, div_clk_hsi0_usix_12mhz_lut_params).
Let the rate request reach the mux (nMUX, so the clock framework may
reparent) and pass it up through the divider and the source gate; the
framework then picks OSCCLK and /2, 12.288 MHz, a 3.072 MHz bus. USI2
(the touchscreen) is unchanged.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@derekross
derekross force-pushed the tegu-spi-word-pieces-v2 branch from b8ce74a to 9403888 Compare October 30, 2026 20:24
@derekross
derekross merged commit 9650363 into derekross:omamobile Oct 30, 2026
1 check passed
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