drivers/mtd/nand/raw/brcmnand/brcmnand.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/brcmnand/brcmnand.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/brcmnand/brcmnand.c- Extension
.c- Size
- 97655 bytes
- Lines
- 3586
- Domain
- Driver Families
- Bucket
- drivers/mtd
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/module.hlinux/init.hlinux/delay.hlinux/device.hlinux/platform_device.hlinux/platform_data/brcmnand.hlinux/err.hlinux/completion.hlinux/interrupt.hlinux/spinlock.hlinux/dma-mapping.hlinux/ioport.hlinux/bug.hlinux/kernel.hlinux/bitops.hlinux/mm.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/of.hlinux/of_platform.hlinux/slab.hlinux/static_key.hlinux/list.hlinux/log2.hlinux/string_choices.hbrcmnand.h
Detected Declarations
struct brcm_nand_dma_descstruct brcmnand_hoststruct brcmnand_controllerstruct brcmnand_cfgstruct brcmnand_hostenum edu_regenum flash_dma_regenum brcmnand_regenum brcmnand_cs_regenum brcmnand_llop_typefunction brcmnand_non_mmio_opsfunction nand_readregfunction nand_writeregfunction brcmnand_revision_initfunction brcmnand_flash_dma_revision_initfunction brcmnand_read_regfunction brcmnand_write_regfunction brcmnand_rmw_regfunction brcmnand_read_fcfunction brcmnand_write_fcfunction edu_writelfunction edu_readlfunction brcmnand_read_data_busfunction brcmnand_clear_ecc_addrfunction brcmnand_get_uncorrecc_addrfunction brcmnand_get_correcc_addrfunction brcmnand_set_cmd_addrfunction brcmnand_cs_offsetfunction brcmnand_corr_totalfunction brcmnand_wr_corr_threshfunction brcmnand_cmd_shiftfunction brcmnand_spare_area_maskfunction brcmnand_ecc_level_maskfunction brcmnand_set_ecc_enabledfunction brcmnand_sector_1k_shiftfunction brcmnand_get_sector_size_1kfunction brcmnand_set_sector_size_1kfunction brcmnand_get_spare_sizefunction brcmnand_get_ecc_settingsfunction bcmnand_ctrl_poll_statusfunction brcmnand_set_wpfunction has_flash_dmafunction has_edufunction use_dmafunction disable_ctrl_irqsfunction flash_dma_buf_okfunction flash_dma_writelfunction flash_dma_readl
Annotated Snippet
struct brcm_nand_dma_desc {
u32 next_desc;
u32 next_desc_ext;
u32 cmd_irq;
u32 dram_addr;
u32 dram_addr_ext;
u32 tfr_len;
u32 total_len;
u32 flash_addr;
u32 flash_addr_ext;
u32 cs;
u32 pad2[5];
u32 status_valid;
} __packed;
/* Bitfields for brcm_nand_dma_desc::status_valid */
#define FLASH_DMA_ECC_ERROR (1 << 8)
#define FLASH_DMA_CORR_ERROR (1 << 9)
/* Bitfields for DMA_MODE */
#define FLASH_DMA_MODE_STOP_ON_ERROR BIT(1) /* stop in Uncorr ECC error */
#define FLASH_DMA_MODE_MODE BIT(0) /* link list */
#define FLASH_DMA_MODE_MASK (FLASH_DMA_MODE_STOP_ON_ERROR | \
FLASH_DMA_MODE_MODE)
/* 512B flash cache in the NAND controller HW */
#define FC_SHIFT 9U
#define FC_BYTES 512U
#define FC_WORDS (FC_BYTES >> 2)
#define BRCMNAND_MIN_PAGESIZE 512
#define BRCMNAND_MIN_BLOCKSIZE (8 * 1024)
#define BRCMNAND_MIN_DEVSIZE (4ULL * 1024 * 1024)
#define NAND_CTRL_RDY (INTFC_CTLR_READY | INTFC_FLASH_READY)
#define NAND_POLL_STATUS_TIMEOUT_MS 500
#define EDU_CMD_WRITE 0x00
#define EDU_CMD_READ 0x01
#define EDU_STATUS_ACTIVE BIT(0)
#define EDU_ERR_STATUS_ERRACK BIT(0)
#define EDU_DONE_MASK GENMASK(1, 0)
#define EDU_CONFIG_MODE_NAND BIT(0)
#define EDU_CONFIG_SWAP_BYTE BIT(1)
#ifdef CONFIG_CPU_BIG_ENDIAN
#define EDU_CONFIG_SWAP_CFG EDU_CONFIG_SWAP_BYTE
#else
#define EDU_CONFIG_SWAP_CFG 0
#endif
/* edu registers */
enum edu_reg {
EDU_CONFIG = 0,
EDU_DRAM_ADDR,
EDU_EXT_ADDR,
EDU_LENGTH,
EDU_CMD,
EDU_STOP,
EDU_STATUS,
EDU_DONE,
EDU_ERR_STATUS,
};
static const u16 edu_regs[] = {
[EDU_CONFIG] = 0x00,
[EDU_DRAM_ADDR] = 0x04,
[EDU_EXT_ADDR] = 0x08,
[EDU_LENGTH] = 0x0c,
[EDU_CMD] = 0x10,
[EDU_STOP] = 0x14,
[EDU_STATUS] = 0x18,
[EDU_DONE] = 0x1c,
[EDU_ERR_STATUS] = 0x20,
};
/* flash_dma registers */
enum flash_dma_reg {
FLASH_DMA_REVISION = 0,
FLASH_DMA_FIRST_DESC,
FLASH_DMA_FIRST_DESC_EXT,
FLASH_DMA_CTRL,
FLASH_DMA_MODE,
FLASH_DMA_STATUS,
FLASH_DMA_INTERRUPT_DESC,
FLASH_DMA_INTERRUPT_DESC_EXT,
FLASH_DMA_ERROR_STATUS,
FLASH_DMA_CURRENT_DESC,
FLASH_DMA_CURRENT_DESC_EXT,
};
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/device.h`, `linux/platform_device.h`, `linux/platform_data/brcmnand.h`, `linux/err.h`.
- Detected declarations: `struct brcm_nand_dma_desc`, `struct brcmnand_host`, `struct brcmnand_controller`, `struct brcmnand_cfg`, `struct brcmnand_host`, `enum edu_reg`, `enum flash_dma_reg`, `enum brcmnand_reg`, `enum brcmnand_cs_reg`, `enum brcmnand_llop_type`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: integration 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.