drivers/spi/spi-rockchip-sfc.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-rockchip-sfc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-rockchip-sfc.c- Extension
.c- Size
- 21282 bytes
- Lines
- 843
- 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/bitops.hlinux/clk.hlinux/completion.hlinux/dma-mapping.hlinux/iopoll.hlinux/interrupt.hlinux/mm.hlinux/module.hlinux/of.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/spi/spi-mem.h
Detected Declarations
struct rockchip_sfcfunction rockchip_sfc_resetfunction rockchip_sfc_get_versionfunction rockchip_sfc_get_max_iosizefunction rockchip_sfc_clk_set_ratefunction rockchip_sfc_clk_get_ratefunction rockchip_sfc_irq_unmaskfunction rockchip_sfc_irq_maskfunction rockchip_sfc_initfunction rockchip_sfc_wait_txfifo_readyfunction rockchip_sfc_wait_rxfifo_readyfunction rockchip_sfc_adjust_op_workfunction rockchip_sfc_xfer_setupfunction rockchip_sfc_write_fifofunction rockchip_sfc_read_fifofunction rockchip_sfc_fifo_transfer_dmafunction rockchip_sfc_xfer_data_pollfunction rockchip_sfc_xfer_data_dmafunction rockchip_sfc_xfer_donefunction rockchip_sfc_exec_mem_opfunction rockchip_sfc_adjust_op_sizefunction rockchip_sfc_irq_handlerfunction rockchip_sfc_probefunction rockchip_sfc_removefunction rockchip_sfc_runtime_suspendfunction rockchip_sfc_runtime_resumefunction rockchip_sfc_suspendfunction rockchip_sfc_resume
Annotated Snippet
struct rockchip_sfc {
struct device *dev;
void __iomem *regbase;
struct clk *hclk;
struct clk *clk;
u32 speed[SFC_MAX_CHIPSELECT_NUM];
/* virtual mapped addr for dma_buffer */
void *buffer;
dma_addr_t dma_buffer;
struct completion cp;
bool use_dma;
u32 max_iosize;
u16 version;
struct spi_controller *host;
};
static int rockchip_sfc_reset(struct rockchip_sfc *sfc)
{
int err;
u32 status;
writel_relaxed(SFC_RCVR_RESET, sfc->regbase + SFC_RCVR);
err = readl_poll_timeout(sfc->regbase + SFC_RCVR, status,
!(status & SFC_RCVR_RESET), 20,
jiffies_to_usecs(HZ));
if (err)
dev_err(sfc->dev, "SFC reset never finished\n");
/* Still need to clear the masked interrupt from RISR */
writel_relaxed(0xFFFFFFFF, sfc->regbase + SFC_ICLR);
dev_dbg(sfc->dev, "reset\n");
return err;
}
static u16 rockchip_sfc_get_version(struct rockchip_sfc *sfc)
{
return (u16)(readl(sfc->regbase + SFC_VER) & 0xffff);
}
static u32 rockchip_sfc_get_max_iosize(struct rockchip_sfc *sfc)
{
return SFC_MAX_IOSIZE_VER3;
}
static int rockchip_sfc_clk_set_rate(struct rockchip_sfc *sfc, unsigned long speed)
{
if (sfc->version >= SFC_VER_8)
return clk_set_rate(sfc->clk, speed * 2);
else
return clk_set_rate(sfc->clk, speed);
}
static unsigned long rockchip_sfc_clk_get_rate(struct rockchip_sfc *sfc)
{
if (sfc->version >= SFC_VER_8)
return clk_get_rate(sfc->clk) / 2;
else
return clk_get_rate(sfc->clk);
}
static void rockchip_sfc_irq_unmask(struct rockchip_sfc *sfc, u32 mask)
{
u32 reg;
/* Enable transfer complete interrupt */
reg = readl(sfc->regbase + SFC_IMR);
reg &= ~mask;
writel(reg, sfc->regbase + SFC_IMR);
}
static void rockchip_sfc_irq_mask(struct rockchip_sfc *sfc, u32 mask)
{
u32 reg;
/* Disable transfer finish interrupt */
reg = readl(sfc->regbase + SFC_IMR);
reg |= mask;
writel(reg, sfc->regbase + SFC_IMR);
}
static int rockchip_sfc_init(struct rockchip_sfc *sfc)
{
writel(0, sfc->regbase + SFC_CTRL);
writel(0xFFFFFFFF, sfc->regbase + SFC_ICLR);
rockchip_sfc_irq_mask(sfc, 0xFFFFFFFF);
if (rockchip_sfc_get_version(sfc) >= SFC_VER_4)
writel(SFC_LEN_CTRL_TRB_SEL, sfc->regbase + SFC_LEN_CTRL);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/completion.h`, `linux/dma-mapping.h`, `linux/iopoll.h`, `linux/interrupt.h`, `linux/mm.h`, `linux/module.h`.
- Detected declarations: `struct rockchip_sfc`, `function rockchip_sfc_reset`, `function rockchip_sfc_get_version`, `function rockchip_sfc_get_max_iosize`, `function rockchip_sfc_clk_set_rate`, `function rockchip_sfc_clk_get_rate`, `function rockchip_sfc_irq_unmask`, `function rockchip_sfc_irq_mask`, `function rockchip_sfc_init`, `function rockchip_sfc_wait_txfifo_ready`.
- 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.