drivers/mtd/nand/raw/tegra_nand.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/tegra_nand.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/tegra_nand.c- Extension
.c- Size
- 35337 bytes
- Lines
- 1291
- 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/clk.hlinux/completion.hlinux/dma-mapping.hlinux/err.hlinux/gpio/consumer.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/mtd/partitions.hlinux/mtd/rawnand.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hsoc/tegra/common.h
Detected Declarations
struct tegra_nand_controllerstruct tegra_nand_chipfunction to_tegra_ctrlfunction tegra_nand_ooblayout_rs_eccfunction tegra_nand_ooblayout_no_freefunction tegra_nand_ooblayout_bch_eccfunction tegra_nand_irqfunction tegra_nand_dump_regfunction tegra_nand_controller_abortfunction tegra_nand_cmdfunction tegra_nand_select_targetfunction tegra_nand_exec_opfunction tegra_nand_hw_eccfunction tegra_nand_page_xferfunction tegra_nand_read_page_rawfunction tegra_nand_write_page_rawfunction tegra_nand_read_oobfunction tegra_nand_write_oobfunction tegra_nand_read_page_hweccfunction for_each_set_bitfunction tegra_nand_write_page_hweccfunction tegra_nand_setup_timingfunction tegra_nand_setup_interfacefunction tegra_nand_get_strengthfunction tegra_nand_select_strengthfunction tegra_nand_attach_chipfunction tegra_nand_chips_initfunction tegra_nand_probefunction tegra_nand_removefunction tegra_nand_runtime_resumefunction tegra_nand_runtime_suspend
Annotated Snippet
struct tegra_nand_controller {
struct nand_controller controller;
struct device *dev;
void __iomem *regs;
int irq;
struct clk *clk;
struct completion command_complete;
struct completion dma_complete;
bool last_read_error;
int cur_cs;
struct nand_chip *chip;
};
struct tegra_nand_chip {
struct nand_chip chip;
struct gpio_desc *wp_gpio;
struct mtd_oob_region ecc;
u32 config;
u32 config_ecc;
u32 bch_config;
int cs[1];
};
static inline struct tegra_nand_controller *
to_tegra_ctrl(struct nand_controller *hw_ctrl)
{
return container_of(hw_ctrl, struct tegra_nand_controller, controller);
}
static inline struct tegra_nand_chip *to_tegra_chip(struct nand_chip *chip)
{
return container_of(chip, struct tegra_nand_chip, chip);
}
static int tegra_nand_ooblayout_rs_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
int bytes_per_step = DIV_ROUND_UP(BITS_PER_STEP_RS * chip->ecc.strength,
BITS_PER_BYTE);
if (section > 0)
return -ERANGE;
oobregion->offset = SKIP_SPARE_BYTES;
oobregion->length = round_up(bytes_per_step * chip->ecc.steps, 4);
return 0;
}
static int tegra_nand_ooblayout_no_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
return -ERANGE;
}
static const struct mtd_ooblayout_ops tegra_nand_oob_rs_ops = {
.ecc = tegra_nand_ooblayout_rs_ecc,
.free = tegra_nand_ooblayout_no_free,
};
static int tegra_nand_ooblayout_bch_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
int bytes_per_step = DIV_ROUND_UP(BITS_PER_STEP_BCH * chip->ecc.strength,
BITS_PER_BYTE);
if (section > 0)
return -ERANGE;
oobregion->offset = SKIP_SPARE_BYTES;
oobregion->length = round_up(bytes_per_step * chip->ecc.steps, 4);
return 0;
}
static const struct mtd_ooblayout_ops tegra_nand_oob_bch_ops = {
.ecc = tegra_nand_ooblayout_bch_ecc,
.free = tegra_nand_ooblayout_no_free,
};
static irqreturn_t tegra_nand_irq(int irq, void *data)
{
struct tegra_nand_controller *ctrl = data;
u32 isr, dma;
isr = readl_relaxed(ctrl->regs + ISR);
dma = readl_relaxed(ctrl->regs + DMA_MST_CTRL);
dev_dbg(ctrl->dev, "isr %08x\n", isr);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct tegra_nand_controller`, `struct tegra_nand_chip`, `function to_tegra_ctrl`, `function tegra_nand_ooblayout_rs_ecc`, `function tegra_nand_ooblayout_no_free`, `function tegra_nand_ooblayout_bch_ecc`, `function tegra_nand_irq`, `function tegra_nand_dump_reg`, `function tegra_nand_controller_abort`, `function tegra_nand_cmd`.
- 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.