drivers/spi/spi-mtk-snfi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-mtk-snfi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-mtk-snfi.c- Extension
.c- Size
- 40783 bytes
- Lines
- 1503
- 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/kernel.hlinux/module.hlinux/init.hlinux/device.hlinux/mutex.hlinux/clk.hlinux/interrupt.hlinux/dma-mapping.hlinux/iopoll.hlinux/of.hlinux/platform_device.hlinux/mtd/nand-ecc-mtk.hlinux/spi/spi.hlinux/spi/spi-mem.hlinux/mtd/nand.h
Detected Declarations
struct mtk_snand_capsstruct mtk_snand_confstruct mtk_snandfunction snand_prepare_bouncebuffunction nfi_read32function nfi_write32function nfi_write16function nfi_rmw32function nfi_read_datafunction mtk_nfi_resetfunction mtk_snand_mac_resetfunction mtk_snand_mac_triggerfunction mtk_snand_mac_iofunction mtk_snand_setup_pagefmtfunction mtk_snand_ooblayout_eccfunction mtk_snand_ooblayout_freefunction mtk_snand_ecc_init_ctxfunction mtk_snand_ecc_cleanup_ctxfunction mtk_snand_ecc_prepare_io_reqfunction mtk_snand_ecc_finish_io_reqfunction mtk_snand_read_fdmfunction mtk_snand_write_fdmfunction mtk_snand_bm_swapfunction mtk_snand_fdm_bm_swapfunction mtk_snand_read_page_cachefunction mtk_snand_write_page_cachefunction mtk_snand_is_page_opsfunction mtk_snand_supports_opfunction mtk_snand_adjust_op_sizefunction mtk_snand_exec_opfunction mtk_unregister_ecc_enginefunction mtk_snand_irqfunction mtk_snand_probefunction mtk_snand_remove
Annotated Snippet
struct mtk_snand_caps {
u16 sector_size;
u16 max_sectors;
u16 fdm_size;
u16 fdm_ecc_size;
u16 fifo_size;
bool bbm_swap;
bool empty_page_check;
u32 mastersta_mask;
u32 nandfsm_mask;
const u8 *spare_sizes;
u32 num_spare_size;
};
static const struct mtk_snand_caps mt7622_snand_caps = {
.sector_size = 512,
.max_sectors = 8,
.fdm_size = 8,
.fdm_ecc_size = 1,
.fifo_size = 32,
.bbm_swap = false,
.empty_page_check = false,
.mastersta_mask = NFI_MASTERSTA_MASK_7622,
.nandfsm_mask = NFI_NAND_FSM_7622,
.spare_sizes = mt7622_spare_sizes,
.num_spare_size = ARRAY_SIZE(mt7622_spare_sizes)
};
static const struct mtk_snand_caps mt7629_snand_caps = {
.sector_size = 512,
.max_sectors = 8,
.fdm_size = 8,
.fdm_ecc_size = 1,
.fifo_size = 32,
.bbm_swap = true,
.empty_page_check = false,
.mastersta_mask = NFI_MASTERSTA_MASK_7622,
.nandfsm_mask = NFI_NAND_FSM_7622,
.spare_sizes = mt7622_spare_sizes,
.num_spare_size = ARRAY_SIZE(mt7622_spare_sizes)
};
static const struct mtk_snand_caps mt7986_snand_caps = {
.sector_size = 1024,
.max_sectors = 8,
.fdm_size = 8,
.fdm_ecc_size = 1,
.fifo_size = 64,
.bbm_swap = true,
.empty_page_check = true,
.mastersta_mask = NFI_MASTERSTA_MASK_7986,
.nandfsm_mask = NFI_NAND_FSM_7986,
.spare_sizes = mt7986_spare_sizes,
.num_spare_size = ARRAY_SIZE(mt7986_spare_sizes)
};
struct mtk_snand_conf {
size_t page_size;
size_t oob_size;
u8 nsectors;
u8 spare_size;
};
struct mtk_snand {
struct spi_controller *ctlr;
struct device *dev;
struct clk *nfi_clk;
struct clk *pad_clk;
struct clk *nfi_hclk;
void __iomem *nfi_base;
int irq;
struct completion op_done;
const struct mtk_snand_caps *caps;
struct mtk_ecc_config *ecc_cfg;
struct mtk_ecc *ecc;
struct mtk_snand_conf nfi_cfg;
struct mtk_ecc_stats ecc_stats;
struct nand_ecc_engine ecc_eng;
bool autofmt;
u8 *buf;
size_t buf_len;
};
static struct mtk_snand *nand_to_mtk_snand(struct nand_device *nand)
{
struct nand_ecc_engine *eng = nand->ecc.engine;
return container_of(eng, struct mtk_snand, ecc_eng);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/device.h`, `linux/mutex.h`, `linux/clk.h`, `linux/interrupt.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct mtk_snand_caps`, `struct mtk_snand_conf`, `struct mtk_snand`, `function snand_prepare_bouncebuf`, `function nfi_read32`, `function nfi_write32`, `function nfi_write16`, `function nfi_rmw32`, `function nfi_read_data`, `function mtk_nfi_reset`.
- 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.