drivers/mtd/nand/raw/lpc32xx_mlc.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/lpc32xx_mlc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/lpc32xx_mlc.c- Extension
.c- Size
- 25103 bytes
- Lines
- 908
- 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 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/slab.hlinux/module.hlinux/platform_device.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/clk.hlinux/err.hlinux/delay.hlinux/completion.hlinux/interrupt.hlinux/of.hlinux/gpio/consumer.hlinux/mtd/lpc32xx_mlc.hlinux/io.hlinux/mm.hlinux/dma-mapping.hlinux/dmaengine.h
Detected Declarations
struct lpc32xx_nand_cfg_mlcstruct lpc32xx_nand_hostfunction lpc32xx_ooblayout_eccfunction lpc32xx_ooblayout_freefunction lpc32xx_nand_setupfunction lpc32xx_nand_cmd_ctrlfunction Readyfunction lpc3xxx_nand_irqfunction lpc32xx_waitfunc_nandfunction lpc32xx_waitfunc_controllerfunction lpc32xx_waitfuncfunction lpc32xx_wp_enablefunction lpc32xx_wp_disablefunction lpc32xx_dma_complete_funcfunction lpc32xx_xmit_dmafunction lpc32xx_read_pagefunction lpc32xx_write_page_lowlevelfunction lpc32xx_read_oobfunction lpc32xx_write_oobfunction lpc32xx_ecc_enablefunction lpc32xx_nand_attach_chipfunction lpc32xx_nand_probefunction lpc32xx_nand_removefunction lpc32xx_nand_resumefunction lpc32xx_nand_suspend
Annotated Snippet
struct lpc32xx_nand_cfg_mlc {
uint32_t tcea_delay;
uint32_t busy_delay;
uint32_t nand_ta;
uint32_t rd_high;
uint32_t rd_low;
uint32_t wr_high;
uint32_t wr_low;
struct mtd_partition *parts;
unsigned num_parts;
};
static int lpc32xx_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *nand_chip = mtd_to_nand(mtd);
if (section >= nand_chip->ecc.steps)
return -ERANGE;
oobregion->offset = ((section + 1) * 16) - nand_chip->ecc.bytes;
oobregion->length = nand_chip->ecc.bytes;
return 0;
}
static int lpc32xx_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *nand_chip = mtd_to_nand(mtd);
if (section >= nand_chip->ecc.steps)
return -ERANGE;
oobregion->offset = 16 * section;
oobregion->length = 16 - nand_chip->ecc.bytes;
return 0;
}
static const struct mtd_ooblayout_ops lpc32xx_ooblayout_ops = {
.ecc = lpc32xx_ooblayout_ecc,
.free = lpc32xx_ooblayout_free,
};
static struct nand_bbt_descr lpc32xx_nand_bbt = {
.options = NAND_BBT_ABSPAGE | NAND_BBT_2BIT | NAND_BBT_NO_OOB |
NAND_BBT_WRITE,
.pages = { 524224, 0, 0, 0, 0, 0, 0, 0 },
};
static struct nand_bbt_descr lpc32xx_nand_bbt_mirror = {
.options = NAND_BBT_ABSPAGE | NAND_BBT_2BIT | NAND_BBT_NO_OOB |
NAND_BBT_WRITE,
.pages = { 524160, 0, 0, 0, 0, 0, 0, 0 },
};
struct lpc32xx_nand_host {
struct platform_device *pdev;
struct nand_chip nand_chip;
struct lpc32xx_mlc_platform_data *pdata;
struct clk *clk;
struct gpio_desc *wp_gpio;
void __iomem *io_base;
int irq;
struct lpc32xx_nand_cfg_mlc *ncfg;
struct completion comp_nand;
struct completion comp_controller;
uint32_t llptr;
/*
* Physical addresses of ECC buffer, DMA data buffers, OOB data buffer
*/
dma_addr_t oob_buf_phy;
/*
* Virtual addresses of ECC buffer, DMA data buffers, OOB data buffer
*/
uint8_t *oob_buf;
/* Physical address of DMA base address */
dma_addr_t io_base_phy;
struct completion comp_dma;
struct dma_chan *dma_chan;
struct dma_slave_config dma_slave_config;
struct scatterlist sgl;
uint8_t *dma_buf;
uint8_t *dummy_buf;
int mlcsubpages; /* number of 512bytes-subpages */
};
/*
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `linux/platform_device.h`, `linux/mtd/mtd.h`, `linux/mtd/rawnand.h`, `linux/mtd/partitions.h`, `linux/clk.h`, `linux/err.h`.
- Detected declarations: `struct lpc32xx_nand_cfg_mlc`, `struct lpc32xx_nand_host`, `function lpc32xx_ooblayout_ecc`, `function lpc32xx_ooblayout_free`, `function lpc32xx_nand_setup`, `function lpc32xx_nand_cmd_ctrl`, `function Ready`, `function lpc3xxx_nand_irq`, `function lpc32xx_waitfunc_nand`, `function lpc32xx_waitfunc_controller`.
- Atlas domain: Driver Families / drivers/mtd.
- 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.