From 468b7b2b8e8d9f564991b8f03577081193f59dff Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 09:04:21 -0647 Subject: [PATCH 1/2] spi: s3c64xx: Do not cut a PIO transfer that fills the FIFO 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> --- drivers/spi/spi-s3c64xx.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 827a2439b4..870aae6592 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -177,6 +177,7 @@ struct s3c64xx_spi_port_config { bool manual_native_cs; bool has_loopback; bool use_32bit_io; + bool poll_full_fifo; }; /** @@ -832,6 +833,7 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host, const void *tx_buf = NULL; void *rx_buf = NULL; int target_len = 0, origin_len = 0; + unsigned int pio_len; int use_dma = 0; bool use_irq = false; int status; @@ -856,20 +858,33 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host, return status; } + /* + * A PIO piece must stay below the FIFO depth and hold whole words, or + * the packet count rounds down and the transfer times out. + */ + pio_len = rounddown(fifo_len - 1, DIV_ROUND_UP(bpw, BITS_PER_BYTE)); + if (!is_polling(sdd) && xfer->len >= fifo_len && sdd->rx_dma.ch && sdd->tx_dma.ch) { use_dma = 1; - } else if (xfer->len >= fifo_len) { + } else if (xfer->len > fifo_len || + (xfer->len == fifo_len && !sdd->port_conf->poll_full_fifo)) { tx_buf = xfer->tx_buf; rx_buf = xfer->rx_buf; origin_len = xfer->len; target_len = xfer->len; - xfer->len = fifo_len - 1; + xfer->len = pio_len; } do { - /* transfer size is greater than 32, change to IRQ mode */ - if (!use_dma && xfer->len > S3C64XX_SPI_POLLING_SIZE) + /* + * Transfers above 32 bytes use the RX trigger interrupt. Its + * level field stops one short of the FIFO, so a transfer that + * fills the FIFO exactly (poll_full_fifo ports) is polled + * instead of being cut. + */ + if (!use_dma && xfer->len > S3C64XX_SPI_POLLING_SIZE && + xfer->len < fifo_len) use_irq = true; if (use_irq) { @@ -960,7 +975,7 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host, xfer->rx_buf += xfer->len; if (target_len >= fifo_len) - xfer->len = fifo_len - 1; + xfer->len = pio_len; else xfer->len = target_len; } @@ -1648,6 +1663,7 @@ static const struct s3c64xx_spi_port_config zumapro_spi_port_config = { .has_loopback = true, .use_32bit_io = true, .manual_native_cs = true, + .poll_full_fifo = true, }; static const struct platform_device_id s3c64xx_spi_driver_ids[] = { From 94038887fb9e9ef0725695c62732c5e48959c816 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Thu, 29 Oct 2026 09:04:33 -0647 Subject: [PATCH 2/2] clk: samsung: zumapro: Let USI3 reach OSCCLK for the GNSS SPI 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> --- drivers/clk/samsung/clk-zumapro.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/clk/samsung/clk-zumapro.c b/drivers/clk/samsung/clk-zumapro.c index 44e3f211b9..7b9f1fff50 100644 --- a/drivers/clk/samsung/clk-zumapro.c +++ b/drivers/clk/samsung/clk-zumapro.c @@ -625,9 +625,8 @@ static const struct samsung_mux_clock hsi0_muxes[] __initconst = { MUX_F(CLK_MOUT_HSI0_USI2_LOCAL, "zumapro_mout_hsi0_usi2_local", mout_hsi0_usi2_local_parents, 0x101c, 0, 1, 0, CLK_MUX_READ_ONLY), - MUX_F(CLK_MOUT_HSI0_USI3_LOCAL, "zumapro_mout_hsi0_usi3_local", - mout_hsi0_usi3_local_parents, - 0x1020, 0, 1, 0, CLK_MUX_READ_ONLY), + nMUX(CLK_MOUT_HSI0_USI3_LOCAL, "zumapro_mout_hsi0_usi3_local", + mout_hsi0_usi3_local_parents, 0x1020, 0, 1), }; static const struct samsung_div_clock hsi0_dividers[] __initconst = { @@ -638,7 +637,7 @@ static const struct samsung_div_clock hsi0_dividers[] __initconst = { DIV_F(CLK_DOUT_HSI0_USI2, "zumapro_dout_hsi0_usi2", "zumapro_gout_hsi0_usi2_source", 0x181c, 0, 4, 0, 0), DIV_F(CLK_DOUT_HSI0_USI3, "zumapro_dout_hsi0_usi3", "zumapro_gout_hsi0_usi3_source", - 0x1820, 0, 4, 0, 0), + 0x1820, 0, 4, CLK_SET_RATE_PARENT, 0), }; static const struct samsung_gate_clock hsi0_gates[] __initconst = { @@ -651,7 +650,7 @@ static const struct samsung_gate_clock hsi0_gates[] __initconst = { 0x2100, 21, CLK_IGNORE_UNUSED, 0), GATE(CLK_GOUT_HSI0_USI3_SOURCE, "zumapro_gout_hsi0_usi3_source", "zumapro_mout_hsi0_usi3_local", - 0x2124, 21, CLK_IGNORE_UNUSED, 0), + 0x2124, 21, CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0), GATE(CLK_GOUT_HSI0_USI3_IP, "zumapro_gout_hsi0_usi3_ip", "zumapro_dout_hsi0_usi3", 0x2104, 21, CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0), GATE(CLK_GOUT_HSI0_USI3_PCLK, "zumapro_gout_hsi0_usi3_pclk", "zumapro_mout_hsi0_noc_local",