drivers/mtd/nand/raw/fsl_ifc_nand.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/fsl_ifc_nand.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/fsl_ifc_nand.c- Extension
.c- Size
- 31991 bytes
- Lines
- 1149
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cleanup.hlinux/module.hlinux/platform_device.hlinux/types.hlinux/kernel.hlinux/of_address.hlinux/slab.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/fsl_ifc.hlinux/iopoll.h
Detected Declarations
struct fsl_ifc_ctrlstruct fsl_ifc_mtdstruct fsl_ifc_nand_ctrlfunction fsl_ifc_ooblayout_eccfunction fsl_ifc_ooblayout_freefunction set_addrfunction check_read_eccfunction fsl_ifc_run_commandfunction fsl_ifc_do_readfunction fsl_ifc_cmdfuncfunction fsl_ifc_select_chipfunction fsl_ifc_read_bytefunction fsl_ifc_read_byte16function fsl_ifc_read_buffunction fsl_ifc_waitfunction check_erased_pagefunction fsl_ifc_read_pagefunction fsl_ifc_write_pagefunction fsl_ifc_attach_chipfunction fsl_ifc_sram_initfunction fsl_ifc_chip_initfunction fsl_ifc_chip_removefunction match_bankfunction fsl_ifc_nand_probefunction fsl_ifc_nand_remove
Annotated Snippet
struct fsl_ifc_mtd {
struct nand_chip chip;
struct fsl_ifc_ctrl *ctrl;
struct device *dev;
int bank; /* Chip select bank number */
unsigned int bufnum_mask; /* bufnum = page & bufnum_mask */
u8 __iomem *vbase; /* Chip select base virtual address */
};
/* overview of the fsl ifc controller */
struct fsl_ifc_nand_ctrl {
struct nand_controller controller;
struct fsl_ifc_mtd *chips[FSL_IFC_BANK_COUNT];
void __iomem *addr; /* Address of assigned IFC buffer */
unsigned int page; /* Last page written to / read from */
unsigned int read_bytes;/* Number of bytes read during command */
unsigned int column; /* Saved column from SEQIN */
unsigned int index; /* Pointer to next byte to 'read' */
unsigned int oob; /* Non zero if operating on OOB data */
unsigned int eccread; /* Non zero for a full-page ECC read */
unsigned int counter; /* counter for the initializations */
unsigned int max_bitflips; /* Saved during READ0 cmd */
};
static struct fsl_ifc_nand_ctrl *ifc_nand_ctrl;
/*
* Generic flash bbt descriptors
*/
static u8 bbt_pattern[] = {'B', 'b', 't', '0' };
static u8 mirror_pattern[] = {'1', 't', 'b', 'B' };
static struct nand_bbt_descr bbt_main_descr = {
.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
NAND_BBT_2BIT | NAND_BBT_VERSION,
.offs = 2, /* 0 on 8-bit small page */
.len = 4,
.veroffs = 6,
.maxblocks = 4,
.pattern = bbt_pattern,
};
static struct nand_bbt_descr bbt_mirror_descr = {
.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
NAND_BBT_2BIT | NAND_BBT_VERSION,
.offs = 2, /* 0 on 8-bit small page */
.len = 4,
.veroffs = 6,
.maxblocks = 4,
.pattern = mirror_pattern,
};
static int fsl_ifc_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
if (section)
return -ERANGE;
oobregion->offset = 8;
oobregion->length = chip->ecc.total;
return 0;
}
static int fsl_ifc_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
if (section > 1)
return -ERANGE;
if (mtd->writesize == 512 &&
!(chip->options & NAND_BUSWIDTH_16)) {
if (!section) {
oobregion->offset = 0;
oobregion->length = 5;
} else {
oobregion->offset = 6;
oobregion->length = 2;
}
return 0;
}
if (!section) {
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/module.h`, `linux/platform_device.h`, `linux/types.h`, `linux/kernel.h`, `linux/of_address.h`, `linux/slab.h`, `linux/mtd/mtd.h`.
- Detected declarations: `struct fsl_ifc_ctrl`, `struct fsl_ifc_mtd`, `struct fsl_ifc_nand_ctrl`, `function fsl_ifc_ooblayout_ecc`, `function fsl_ifc_ooblayout_free`, `function set_addr`, `function check_read_ecc`, `function fsl_ifc_run_command`, `function fsl_ifc_do_read`, `function fsl_ifc_cmdfunc`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.