drivers/spi/spi-mt65xx.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-mt65xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-mt65xx.c- Extension
.c- Size
- 40381 bytes
- Lines
- 1500
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/device.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/module.hlinux/of.hlinux/gpio/consumer.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/platform_data/spi-mt65xx.hlinux/pm_runtime.hlinux/spi/spi.hlinux/spi/spi-mem.hlinux/dma-mapping.hlinux/pm_qos.h
Detected Declarations
struct mtk_spi_compatiblestruct mtk_spifunction mtk_spi_resetfunction mtk_spi_set_hw_cs_timingfunction mtk_spi_hw_initfunction mtk_spi_prepare_messagefunction mtk_spi_unprepare_messagefunction mtk_spi_set_csfunction mtk_spi_prepare_transferfunction mtk_spi_setup_packetfunction mtk_spi_set_nbitfunction mtk_spi_enable_transferfunction mtk_spi_get_mult_deltafunction mtk_spi_update_mdata_lenfunction mtk_spi_setup_dma_addrfunction mtk_spi_fifo_transferfunction mtk_spi_dma_transferfunction mtk_spi_transfer_onefunction mtk_spi_can_dmafunction mtk_spi_setupfunction mtk_spi_interrupt_threadfunction mtk_spi_interruptfunction mtk_spi_mem_adjust_op_sizefunction mtk_spi_mem_supports_opfunction mtk_spi_mem_setup_dma_xferfunction mtk_spi_transfer_waitfunction mtk_spi_mem_exec_opfunction mtk_spi_probefunction mtk_spi_removefunction mtk_spi_suspendfunction mtk_spi_resumefunction mtk_spi_runtime_suspendfunction mtk_spi_runtime_resume
Annotated Snippet
struct mtk_spi_compatible {
bool need_pad_sel;
bool must_tx;
bool enhance_timing;
bool dma_ext;
bool no_need_unprepare;
bool ipm_design;
};
/**
* struct mtk_spi - SPI driver instance
* @base: Start address of the SPI controller registers
* @state: SPI controller state
* @pad_num: Number of pad_sel entries
* @pad_sel: Groups of pins to select
* @parent_clk: Parent of sel_clk
* @sel_clk: SPI host mux clock
* @spi_clk: Peripheral clock
* @spi_hclk: AHB bus clock
* @cur_transfer: Currently processed SPI transfer
* @xfer_len: Number of bytes to transfer
* @num_xfered: Number of transferred bytes
* @tx_sgl: TX transfer scatterlist
* @rx_sgl: RX transfer scatterlist
* @tx_sgl_len: Size of TX DMA transfer
* @rx_sgl_len: Size of RX DMA transfer
* @dev_comp: Device data structure
* @qos_request: QoS request
* @spi_clk_hz: Current SPI clock in Hz
* @spimem_done: SPI-MEM operation completion
* @use_spimem: Enables SPI-MEM
* @dev: Device pointer
* @tx_dma: DMA start for SPI-MEM TX
* @rx_dma: DMA start for SPI-MEM RX
*/
struct mtk_spi {
void __iomem *base;
u32 state;
int pad_num;
u32 *pad_sel;
struct clk *parent_clk, *sel_clk, *spi_clk, *spi_hclk;
struct spi_transfer *cur_transfer;
u32 xfer_len;
u32 num_xfered;
struct scatterlist *tx_sgl, *rx_sgl;
u32 tx_sgl_len, rx_sgl_len;
const struct mtk_spi_compatible *dev_comp;
struct pm_qos_request qos_request;
u32 spi_clk_hz;
struct completion spimem_done;
bool use_spimem;
struct device *dev;
dma_addr_t tx_dma;
dma_addr_t rx_dma;
};
static const struct mtk_spi_compatible mtk_common_compat;
static const struct mtk_spi_compatible mt2712_compat = {
.must_tx = true,
};
static const struct mtk_spi_compatible mtk_ipm_compat = {
.enhance_timing = true,
.dma_ext = true,
.ipm_design = true,
};
static const struct mtk_spi_compatible mt6765_compat = {
.need_pad_sel = true,
.must_tx = true,
.enhance_timing = true,
.dma_ext = true,
};
static const struct mtk_spi_compatible mt7622_compat = {
.must_tx = true,
.enhance_timing = true,
};
static const struct mtk_spi_compatible mt8173_compat = {
.need_pad_sel = true,
.must_tx = true,
};
static const struct mtk_spi_compatible mt8183_compat = {
.need_pad_sel = true,
.must_tx = true,
.enhance_timing = true,
};
Annotation
- Immediate include surface: `linux/clk.h`, `linux/device.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/ioport.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct mtk_spi_compatible`, `struct mtk_spi`, `function mtk_spi_reset`, `function mtk_spi_set_hw_cs_timing`, `function mtk_spi_hw_init`, `function mtk_spi_prepare_message`, `function mtk_spi_unprepare_message`, `function mtk_spi_set_cs`, `function mtk_spi_prepare_transfer`, `function mtk_spi_setup_packet`.
- 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.