Skip to content

spi: loongson: Fixes, cleanup and IRQ support

Binbin Zhou linux-spi loongarch 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 1 replyIn review
  2. v18 patches 9 repliesSuperseded

Changes in v2 from the cover letter

- Patch count reduced from 8 to 7;
- Deferred the private-definition move and regmap conversion from v1; instead, register access is cleaned up with bitfield helpers.
- Reworked the CS fix to drop the redundant and wrong deassert in setup(), since the SPI core drives the idle CS after ->setup().
- Reordered the clock fixes so the ACPI/clk-rate fix comes before the divider fix.
- Reworked IRQ support: fifo-depth/icnt handling, spinlock-protected transfer state, handle_err() cleanup, bounded message splitting, PCI IRQ vector allocation, platform optional IRQ with -EPROBE_DEFER, and polling fallback.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7spi: loongson: Fix incorrect SPI mode caching logicdrivers/spi/spi-loongson-core.c+1 -10 replies
2/7spi: loongson: Drop redundant CS deassert in setup()drivers/spi/spi-loongson-core.c+0 -10 replies
3/7spi: loongson: Make suspend/resume registers PM-specificdrivers/spi/spi-loongson-core.c drivers/spi/spi-loongson.h+52 -420 replies
4/7spi: loongson: Fix clock rate retrieval on ACPI platformsdrivers/spi/spi-loongson-core.c drivers/spi/spi-loongson.h+39 -50 replies
5/7spi: loongson: Fix clock divider calculation with explicit tabledrivers/spi/spi-loongson-core.c drivers/spi/spi-loongson.h+75 -130 replies
6/7spi: loongson: Use bitfield helpers for register accessdrivers/spi/spi-loongson-core.c drivers/spi/spi-loongson.h+122 -810 replies
7/7spi: loongson: Add interrupt mode supportdrivers/spi/spi-loongson-core.c drivers/spi/spi-loongson-pci.c drivers/spi/spi-loongson-plat.c +1 more+285 -240 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/7] spi: loongson: Fixes, cleanup and IRQ support

Hi all:

This series fixes several long-standing bugs in the Loongson SPI controller driver, cleans up register access, and adds interrupt-driven transfers with a polling fallback.

Grouped as follows:

Bug fixes (suitable for stable):
1. Fix SPI mode caching so mode bits can be cleared.
2. Drop the redundant and wrong CS deassert in setup(); the SPI core already drives the idle CS after ->setup().
3. Separate PM register state from runtime state so set_clk() cannot corrupt the saved suspend state.
4. Fix clock retrieval on ACPI platforms: try clk, fall back to "clock-frequency", fail probe if neither is valid, manage the clock over suspend/resume.
5. Fix the clock divider calculation with an explicit table, avoid the off-by-one/out-of-bounds issue, propagate errors, and expose min/max speed to the SPI core.

Cleanup:
6. Use bitfield helpers and set/clear/update_bits() for register access. No functional change intended.

New feature:
7. Add interrupt mode support.

On a Loongson-2K3000 board, SPI flash reads improved from about 60 kB/s in polling mode to about 950 kB/s with IRQ mode.

Thanks.
Binbin

===========
V2:
- Patch count reduced from 8 to 7;
- Deferred the private-definition move and regmap conversion from v1; instead, register access is cleaned up with bitfield helpers.
- Reworked the CS fix to drop the redundant and wrong deassert in setup(), since the SPI core drives the idle CS after ->setup().
- Reordered the clock fixes so the ACPI/clk-rate fix comes before the divider fix.
- Reworked IRQ support: fifo-depth/icnt handling, spinlock-protected transfer state, handle_err() cleanup, bounded message splitting, PCI IRQ vector allocation, platform optional IRQ with -EPROBE_DEFER, and polling fallback.

Link to V1:
https://lore.kernel.org/all/[email protected]/

Binbin Zhou (7):
spi: loongson: Fix incorrect SPI mode caching logic
spi: loongson: Drop redundant CS deassert in setup()
spi: loongson: Make suspend/resume registers PM-specific
spi: loongson: Fix clock rate retrieval on ACPI platforms
spi: loongson: Fix clock divider calculation with explicit table
spi: loongson: Use bitfield helpers for register access
spi: loongson: Add interrupt mode support

 drivers/spi/spi-loongson-core.c | 519 ++++++++++++++++++++++++++------
 drivers/spi/spi-loongson-pci.c  |  28 +-
 drivers/spi/spi-loongson-plat.c |  17 +-
 drivers/spi/spi-loongson.h      | 129 ++++++--
 4 files changed, 550 insertions(+), 143 deletions(-)

base-commit: c0ccde965b4874afea9bd40f8cc2362ab9910711

Signature · 1 line
2.52.0