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.

Dependency Surface

Detected Declarations

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

Implementation Notes