drivers/spi/spi-rzv2h-rspi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-rzv2h-rspi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-rzv2h-rspi.c- Extension
.c- Size
- 22384 bytes
- Lines
- 866
- Domain
- Driver Families
- Bucket
- drivers/spi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bitops.hlinux/bits.hlinux/clk.hlinux/dmaengine.hlinux/interrupt.hlinux/io.hlinux/limits.hlinux/log2.hlinux/math.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/reset.hlinux/spi/spi.hlinux/wait.hinternals.h
Detected Declarations
struct rzv2h_rspi_best_clockstruct rzv2h_rspi_infostruct rzv2h_rspi_privfunction rzv2h_rspi_reg_rmwfunction rzv2h_rspi_spe_disablefunction rzv2h_rspi_spe_enablefunction rzv2h_rspi_clear_fifosfunction rzv2h_rspi_clear_all_irqsfunction rzv2h_rx_irq_handlerfunction rzv2h_rspi_wait_for_interruptfunction rzv2h_rspi_sendfunction rzv2h_rspi_receivefunction rzv2h_rspi_can_dmafunction rzv2h_rspi_transfer_piofunction rzv2h_rspi_dma_completefunction rzv2h_rspi_setup_dma_channelfunction rzv2h_rspi_dma_widthfunction rzv2h_rspi_transfer_dmafunction rzv2h_rspi_transfer_onefunction rzv2h_rspi_calc_bitratefunction rzv2h_rspi_find_rate_variablefunction rzv2h_rspi_find_rate_fixedfunction rzv2h_rspi_setup_clockfunction rzv2h_rspi_prepare_messagefunction list_for_each_entryfunction rzv2h_rspi_unprepare_messagefunction rzv2h_rspi_probefunction rzv2h_rspi_suspendfunction rzv2h_rspi_resume
Annotated Snippet
struct rzv2h_rspi_best_clock {
struct clk *clk;
unsigned long clk_rate;
unsigned long error;
u32 actual_hz;
u8 brdv;
u8 spr;
};
struct rzv2h_rspi_info {
void (*find_tclk_rate)(struct clk *clk, u32 hz,
struct rzv2h_rspi_best_clock *best_clk);
void (*find_pclk_rate)(struct clk *clk, u32 hz,
struct rzv2h_rspi_best_clock *best_clk);
const char *tclk_name;
unsigned int fifo_size;
unsigned int num_clks;
};
struct rzv2h_rspi_priv {
struct spi_controller *controller;
const struct rzv2h_rspi_info *info;
struct platform_device *pdev;
void __iomem *base;
struct clk *tclk;
struct clk *pclk;
wait_queue_head_t wait;
unsigned int bytes_per_word;
int irq_rx;
u32 last_speed_hz;
u32 freq;
u16 status;
u8 spr;
u8 brdv;
bool use_pclk;
bool dma_callbacked;
};
#define RZV2H_RSPI_TX(func, type) \
static inline void rzv2h_rspi_tx_##type(struct rzv2h_rspi_priv *rspi, \
const void *txbuf, \
unsigned int index) { \
type buf = ((type *)txbuf)[index]; \
func(buf, rspi->base + RSPI_SPDR); \
}
#define RZV2H_RSPI_RX(func, type) \
static inline void rzv2h_rspi_rx_##type(struct rzv2h_rspi_priv *rspi, \
void *rxbuf, \
unsigned int index) { \
type buf = func(rspi->base + RSPI_SPDR); \
((type *)rxbuf)[index] = buf; \
}
RZV2H_RSPI_TX(writel, u32)
RZV2H_RSPI_TX(writew, u16)
RZV2H_RSPI_TX(writeb, u8)
/* The read access size for RSPI_SPDR is fixed at 32 bits */
RZV2H_RSPI_RX(readl, u32)
RZV2H_RSPI_RX(readl, u16)
RZV2H_RSPI_RX(readl, u8)
static void rzv2h_rspi_reg_rmw(const struct rzv2h_rspi_priv *rspi,
int reg_offs, u32 bit_mask, u32 value)
{
u32 tmp;
value <<= __ffs(bit_mask);
tmp = (readl(rspi->base + reg_offs) & ~bit_mask) | value;
writel(tmp, rspi->base + reg_offs);
}
static inline void rzv2h_rspi_spe_disable(const struct rzv2h_rspi_priv *rspi)
{
rzv2h_rspi_reg_rmw(rspi, RSPI_SPCR, RSPI_SPCR_SPE, 0);
}
static inline void rzv2h_rspi_spe_enable(const struct rzv2h_rspi_priv *rspi)
{
rzv2h_rspi_reg_rmw(rspi, RSPI_SPCR, RSPI_SPCR_SPE, 1);
}
static inline void rzv2h_rspi_clear_fifos(const struct rzv2h_rspi_priv *rspi)
{
writeb(1, rspi->base + RSPI_SPFCR);
}
static inline void rzv2h_rspi_clear_all_irqs(struct rzv2h_rspi_priv *rspi)
{
writew(RSPI_SPSRC_CLEAR, rspi->base + RSPI_SPSRC);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/bits.h`, `linux/clk.h`, `linux/dmaengine.h`, `linux/interrupt.h`, `linux/io.h`, `linux/limits.h`.
- Detected declarations: `struct rzv2h_rspi_best_clock`, `struct rzv2h_rspi_info`, `struct rzv2h_rspi_priv`, `function rzv2h_rspi_reg_rmw`, `function rzv2h_rspi_spe_disable`, `function rzv2h_rspi_spe_enable`, `function rzv2h_rspi_clear_fifos`, `function rzv2h_rspi_clear_all_irqs`, `function rzv2h_rx_irq_handler`, `function rzv2h_rspi_wait_for_interrupt`.
- Atlas domain: Driver Families / drivers/spi.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.