drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c- Extension
.c- Size
- 14216 bytes
- Lines
- 562
- 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.
- 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/delay.hlinux/init.hlinux/io.hlinux/list.hlinux/module.hlinux/of.hlinux/of_address.hlinux/gpio/consumer.hlinux/platform_device.hlinux/slab.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/jz4780-nemc.hingenic_ecc.h
Detected Declarations
struct jz_soc_infostruct ingenic_nand_csstruct ingenic_nfcstruct ingenic_nandfunction qi_lb60_ooblayout_eccfunction qi_lb60_ooblayout_freefunction jz4725b_ooblayout_eccfunction jz4725b_ooblayout_freefunction ingenic_nand_ecc_hwctlfunction ingenic_nand_ecc_calculatefunction ingenic_nand_ecc_correctfunction ingenic_nand_attach_chipfunction ingenic_nand_exec_instrfunction ingenic_nand_exec_opfunction ingenic_nand_init_chipfunction ingenic_nand_cleanup_chipsfunction ingenic_nand_init_chipsfunction for_each_child_of_node_scopedfunction ingenic_nand_probefunction ingenic_nand_remove
Annotated Snippet
struct jz_soc_info {
unsigned long data_offset;
unsigned long addr_offset;
unsigned long cmd_offset;
const struct mtd_ooblayout_ops *oob_layout;
bool oob_first;
};
struct ingenic_nand_cs {
unsigned int bank;
void __iomem *base;
};
struct ingenic_nfc {
struct device *dev;
struct ingenic_ecc *ecc;
const struct jz_soc_info *soc_info;
struct nand_controller controller;
unsigned int num_banks;
struct list_head chips;
struct ingenic_nand_cs cs[] __counted_by(num_banks);
};
struct ingenic_nand {
struct nand_chip chip;
struct list_head chip_list;
struct gpio_desc *busy_gpio;
struct gpio_desc *wp_gpio;
unsigned int reading: 1;
};
static inline struct ingenic_nand *to_ingenic_nand(struct mtd_info *mtd)
{
return container_of(mtd_to_nand(mtd), struct ingenic_nand, chip);
}
static inline struct ingenic_nfc *to_ingenic_nfc(struct nand_controller *ctrl)
{
return container_of(ctrl, struct ingenic_nfc, controller);
}
static int qi_lb60_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct nand_ecc_ctrl *ecc = &chip->ecc;
if (section || !ecc->total)
return -ERANGE;
oobregion->length = ecc->total;
oobregion->offset = 12;
return 0;
}
static int qi_lb60_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct nand_ecc_ctrl *ecc = &chip->ecc;
if (section)
return -ERANGE;
oobregion->length = mtd->oobsize - ecc->total - 12;
oobregion->offset = 12 + ecc->total;
return 0;
}
static const struct mtd_ooblayout_ops qi_lb60_ooblayout_ops = {
.ecc = qi_lb60_ooblayout_ecc,
.free = qi_lb60_ooblayout_free,
};
static int jz4725b_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct nand_ecc_ctrl *ecc = &chip->ecc;
if (section || !ecc->total)
return -ERANGE;
oobregion->length = ecc->total;
oobregion->offset = 3;
return 0;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/io.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct jz_soc_info`, `struct ingenic_nand_cs`, `struct ingenic_nfc`, `struct ingenic_nand`, `function qi_lb60_ooblayout_ecc`, `function qi_lb60_ooblayout_free`, `function jz4725b_ooblayout_ecc`, `function jz4725b_ooblayout_free`, `function ingenic_nand_ecc_hwctl`, `function ingenic_nand_ecc_calculate`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
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.