Skip to content

spi: s3c64xx, clk: zumapro: the Pixel 9a's GNSS SPI at stock's clock, reads uncut - #135

Closed
W4HO-ham wants to merge 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-spi-word-pieces
Closed

W4HO-ham wants to merge 2 commits into
derekross:omamobilefrom
W4HO-ham:tegu-spi-word-pieces

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.

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). Transfer a full FIFO in one piece, polled, as the vendor
driver does; keep the pieces of longer transfers a whole number of
words, so a 32-bit transfer's packet count does not round down and
time out.
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. 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.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

CI is right: the two commits went up without my sign-off. The same two commits with it are #138 (cherry-picked, nothing else changed); closing this one in its favour.

@W4HO-ham W4HO-ham closed this Oct 29, 2026
W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Oct 31, 2026
…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).
W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Oct 31, 2026
…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.
W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Oct 31, 2026
…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.
W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Oct 31, 2026
…hin a message

Bring-up, not for merge. The fixed 64 KiB piece becomes the piece
parameter: the size of each spi_transfer within one message (chip select
held between them), 64 KiB meaning one transfer. MODEM-PLAN G3, the
morning of 10-29 ("the clock fixed, the cut fixed"): the 32 + 32 test
(piece=32) showed every frame that crossed a piece boundary failing with
chip select held, which pointed at spi-s3c64xx's cut rather than the
chip-select release as what lost the bytes, and led to the "Do not cut a
PIO transfer that fills the FIFO" commit of kernel PR derekross#135 (the p32 run
in logs/tegu-gnss-w32-20261029: 83 bad checksums, no watchdog).
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.

1 participant