drivers/mtd/nand/raw/pl35x-nand-controller.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/pl35x-nand-controller.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/pl35x-nand-controller.c- Extension
.c- Size
- 33535 bytes
- Lines
- 1205
- 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/amba/bus.hlinux/err.hlinux/delay.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/iopoll.hlinux/irq.hlinux/module.hlinux/moduleparam.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/clk.h
Detected Declarations
struct pl35x_nand_timingsstruct pl35x_nandstruct pl35x_nandcfunction pl35x_ecc_ooblayout16_eccfunction pl35x_ecc_ooblayout16_freefunction pl35x_smc_update_regsfunction pl35x_smc_set_buswidthfunction pl35x_smc_clear_irqfunction pl35x_smc_wait_for_irqfunction pl35x_smc_wait_for_ecc_donefunction pl35x_smc_set_ecc_modefunction pl35x_smc_force_byte_accessfunction pl35x_nand_select_targetfunction pl35x_nand_read_data_opfunction pl35x_nand_write_data_opfunction pl35x_nand_correct_datafunction pl35x_nand_ecc_reg_to_arrayfunction pl35x_nand_read_eccbytesfunction pl35x_nand_recover_data_hweccfunction pl35x_nand_write_page_hweccfunction pl35x_nand_read_page_hweccfunction pl35x_nand_exec_opfunction pl35x_nfc_exec_opfunction pl35x_nfc_setup_interfacefunction pl35x_smc_set_ecc_pg_sizefunction pl35x_nand_init_hw_ecc_controllerfunction pl35x_nand_attach_chipfunction pl35x_nand_reset_statefunction pl35x_nand_chip_initfunction pl35x_nand_chips_cleanupfunction list_for_each_entry_safefunction pl35x_nand_chips_initfunction for_each_child_of_node_scopedfunction pl35x_nand_probefunction pl35x_nand_remove
Annotated Snippet
struct pl35x_nand_timings {
unsigned int t_rc:4;
unsigned int t_wc:4;
unsigned int t_rea:3;
unsigned int t_wp:3;
unsigned int t_clr:3;
unsigned int t_ar:3;
unsigned int t_rr:4;
unsigned int rsvd:8;
};
struct pl35x_nand {
struct list_head node;
struct nand_chip chip;
unsigned int cs;
unsigned int addr_cycles;
u32 ecc_cfg;
u32 timings;
};
/**
* struct pl35x_nandc - NAND flash controller driver structure
* @dev: Kernel device
* @conf_regs: SMC configuration registers for command phase
* @io_regs: NAND data registers for data phase
* @controller: Core NAND controller structure
* @chips: List of connected NAND chips
* @selected_chip: NAND chip currently selected by the controller
* @assigned_cs: List of assigned CS
* @ecc_buf: Temporary buffer to extract ECC bytes
*/
struct pl35x_nandc {
struct device *dev;
void __iomem *conf_regs;
void __iomem *io_regs;
struct nand_controller controller;
struct list_head chips;
struct nand_chip *selected_chip;
unsigned long assigned_cs;
u8 *ecc_buf;
};
static inline struct pl35x_nandc *to_pl35x_nandc(struct nand_controller *ctrl)
{
return container_of(ctrl, struct pl35x_nandc, controller);
}
static inline struct pl35x_nand *to_pl35x_nand(struct nand_chip *chip)
{
return container_of(chip, struct pl35x_nand, chip);
}
static int pl35x_ecc_ooblayout16_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
if (section >= chip->ecc.steps)
return -ERANGE;
oobregion->offset = (section * chip->ecc.bytes);
oobregion->length = chip->ecc.bytes;
return 0;
}
static int pl35x_ecc_ooblayout16_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
if (section >= chip->ecc.steps)
return -ERANGE;
oobregion->offset = (section * chip->ecc.bytes) + 8;
oobregion->length = 8;
return 0;
}
static const struct mtd_ooblayout_ops pl35x_ecc_ooblayout16_ops = {
.ecc = pl35x_ecc_ooblayout16_ecc,
.free = pl35x_ecc_ooblayout16_free,
};
/* 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 = {
Annotation
- Immediate include surface: `linux/amba/bus.h`, `linux/err.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/io.h`, `linux/ioport.h`, `linux/iopoll.h`, `linux/irq.h`.
- Detected declarations: `struct pl35x_nand_timings`, `struct pl35x_nand`, `struct pl35x_nandc`, `function pl35x_ecc_ooblayout16_ecc`, `function pl35x_ecc_ooblayout16_free`, `function pl35x_smc_update_regs`, `function pl35x_smc_set_buswidth`, `function pl35x_smc_clear_irq`, `function pl35x_smc_wait_for_irq`, `function pl35x_smc_wait_for_ecc_done`.
- 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.