drivers/mtd/nand/raw/meson_nand.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/meson_nand.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/meson_nand.c- Extension
.c- Size
- 41392 bytes
- Lines
- 1635
- Domain
- Driver Families
- Bucket
- drivers/mtd
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/platform_device.hlinux/dma-mapping.hlinux/interrupt.hlinux/clk.hlinux/clk-provider.hlinux/mtd/rawnand.hlinux/mtd/mtd.hlinux/mfd/syscon.hlinux/regmap.hlinux/slab.hlinux/module.hlinux/iopoll.hlinux/of.hlinux/sched/task_stack.h
Detected Declarations
struct meson_nfc_nand_chipstruct meson_nand_eccstruct meson_nfc_datastruct meson_nfc_paramstruct nand_rw_cmdstruct nand_timingstruct meson_nfcfunction meson_nand_calc_ecc_bytesfunction meson_nfc_select_chipfunction meson_nfc_cmd_idlefunction meson_nfc_cmd_seedfunction meson_nfc_is_boot_pagefunction meson_nfc_cmd_accessfunction meson_nfc_drain_cmdfunction meson_nfc_wait_cmd_finishfunction meson_nfc_wait_dma_finishfunction meson_nfc_get_data_oobfunction meson_nfc_set_data_oobfunction meson_nfc_wait_no_rb_pinfunction meson_nfc_wait_rb_pinfunction meson_nfc_queue_rbfunction meson_nfc_set_user_bytefunction meson_nfc_get_user_bytefunction meson_nfc_ecc_correctfunction meson_nfc_dma_buffer_setupfunction meson_nfc_dma_buffer_releasefunction meson_nfc_read_buffunction meson_nfc_write_buffunction meson_nfc_rw_cmd_prepare_and_executefunction meson_nfc_write_page_subfunction meson_nfc_write_page_rawfunction meson_nfc_write_page_hweccfunction meson_nfc_check_ecc_pages_validfunction meson_nfc_read_page_subfunction meson_nfc_read_page_rawfunction meson_nfc_read_page_hweccfunction meson_nfc_read_oob_rawfunction meson_nfc_read_oobfunction meson_nfc_is_buffer_dma_safefunction meson_nand_op_get_dma_safe_input_buffunction meson_nand_op_put_dma_safe_input_buffunction meson_nand_op_get_dma_safe_output_buffunction meson_nand_op_put_dma_safe_output_buffunction meson_nfc_check_opfunction meson_nfc_exec_opfunction meson_ooblayout_eccfunction meson_ooblayout_freefunction meson_nfc_clk_init
Annotated Snippet
struct meson_nfc_nand_chip {
struct list_head node;
struct nand_chip nand;
unsigned long clk_rate;
unsigned long level1_divider;
u32 bus_timing;
u32 twb;
u32 tadl;
u32 tbers_max;
u32 boot_pages;
u32 boot_page_step;
u32 bch_mode;
u8 *data_buf;
__le64 *info_buf;
u32 nsels;
u8 sels[] __counted_by(nsels);
};
struct meson_nand_ecc {
u32 bch;
u32 strength;
u32 size;
};
struct meson_nfc_data {
const struct nand_ecc_caps *ecc_caps;
};
struct meson_nfc_param {
u32 chip_select;
u32 rb_select;
};
struct nand_rw_cmd {
u32 cmd0;
u32 addrs[MAX_CYCLE_ADDRS];
u32 cmd1;
};
struct nand_timing {
u32 twb;
u32 tadl;
u32 tbers_max;
};
struct meson_nfc {
struct nand_controller controller;
struct clk *core_clk;
struct clk *device_clk;
struct clk *nand_clk;
struct clk_divider nand_divider;
unsigned long clk_rate;
u32 bus_timing;
struct device *dev;
void __iomem *reg_base;
void __iomem *reg_clk;
struct completion completion;
struct list_head chips;
const struct meson_nfc_data *data;
struct meson_nfc_param param;
struct nand_timing timing;
union {
int cmd[32];
struct nand_rw_cmd rw;
} cmdfifo;
dma_addr_t daddr;
dma_addr_t iaddr;
u32 info_bytes;
unsigned long assigned_cs;
bool no_rb_pin;
};
enum {
NFC_ECC_BCH8_512 = 1,
NFC_ECC_BCH8_1K,
NFC_ECC_BCH24_1K,
NFC_ECC_BCH30_1K,
NFC_ECC_BCH40_1K,
NFC_ECC_BCH50_1K,
NFC_ECC_BCH60_1K,
};
#define MESON_ECC_DATA(b, s, sz) { .bch = (b), .strength = (s), .size = (sz) }
static struct meson_nand_ecc meson_ecc[] = {
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/mtd/rawnand.h`, `linux/mtd/mtd.h`, `linux/mfd/syscon.h`.
- Detected declarations: `struct meson_nfc_nand_chip`, `struct meson_nand_ecc`, `struct meson_nfc_data`, `struct meson_nfc_param`, `struct nand_rw_cmd`, `struct nand_timing`, `struct meson_nfc`, `function meson_nand_calc_ecc_bytes`, `function meson_nfc_select_chip`, `function meson_nfc_cmd_idle`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.