drivers/mtd/nand/raw/intel-nand-controller.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/intel-nand-controller.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/intel-nand-controller.c- Extension
.c- Size
- 19044 bytes
- Lines
- 743
- 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/dmaengine.hlinux/dma-direction.hlinux/dma-mapping.hlinux/err.hlinux/init.hlinux/iopoll.hlinux/kernel.hlinux/module.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/nand.hlinux/of.hlinux/platform_device.hlinux/sched.hlinux/slab.hlinux/types.hlinux/units.hlinux/unaligned.h
Detected Declarations
struct ebu_nand_csstruct ebu_nand_controllerfunction ebu_nand_waitrdyfunction ebu_nand_readbfunction ebu_nand_writebfunction ebu_read_buffunction ebu_write_buffunction ebu_nand_disablefunction ebu_select_chipfunction ebu_nand_set_timingsfunction ebu_nand_ooblayout_eccfunction ebu_nand_ooblayout_freefunction ebu_dma_rx_callbackfunction ebu_dma_tx_callbackfunction ebu_dma_startfunction ebu_nand_triggerfunction ebu_nand_read_page_hweccfunction ebu_nand_write_page_hweccfunction ebu_nand_attach_chipfunction ebu_nand_exec_opfunction ebu_dma_cleanupfunction ebu_nand_probefunction ebu_nand_remove
Annotated Snippet
struct ebu_nand_cs {
void __iomem *chipaddr;
u32 addr_sel;
};
struct ebu_nand_controller {
struct nand_controller controller;
struct nand_chip chip;
struct device *dev;
void __iomem *ebu;
void __iomem *hsnand;
struct dma_chan *dma_tx;
struct dma_chan *dma_rx;
struct completion dma_access_complete;
struct clk *clk;
u32 nd_para0;
u8 cs_num;
struct ebu_nand_cs cs[MAX_CS];
};
static inline struct ebu_nand_controller *nand_to_ebu(struct nand_chip *chip)
{
return container_of(chip, struct ebu_nand_controller, chip);
}
static int ebu_nand_waitrdy(struct nand_chip *chip, int timeout_ms)
{
struct ebu_nand_controller *ctrl = nand_to_ebu(chip);
u32 status;
return readl_poll_timeout(ctrl->ebu + EBU_WAIT, status,
(status & EBU_WAIT_RDBY) ||
(status & EBU_WAIT_WR_C), 20, timeout_ms);
}
static u8 ebu_nand_readb(struct nand_chip *chip)
{
struct ebu_nand_controller *ebu_host = nand_get_controller_data(chip);
u8 cs_num = ebu_host->cs_num;
u8 val;
val = readb(ebu_host->cs[cs_num].chipaddr + HSNAND_CS_OFFS);
ebu_nand_waitrdy(chip, 1000);
return val;
}
static void ebu_nand_writeb(struct nand_chip *chip, u32 offset, u8 value)
{
struct ebu_nand_controller *ebu_host = nand_get_controller_data(chip);
u8 cs_num = ebu_host->cs_num;
writeb(value, ebu_host->cs[cs_num].chipaddr + offset);
ebu_nand_waitrdy(chip, 1000);
}
static void ebu_read_buf(struct nand_chip *chip, u_char *buf, unsigned int len)
{
int i;
for (i = 0; i < len; i++)
buf[i] = ebu_nand_readb(chip);
}
static void ebu_write_buf(struct nand_chip *chip, const u_char *buf, int len)
{
int i;
for (i = 0; i < len; i++)
ebu_nand_writeb(chip, HSNAND_CS_OFFS, buf[i]);
}
static void ebu_nand_disable(struct nand_chip *chip)
{
struct ebu_nand_controller *ebu_host = nand_get_controller_data(chip);
writel(0, ebu_host->ebu + EBU_CON);
}
static void ebu_select_chip(struct nand_chip *chip)
{
struct ebu_nand_controller *ebu_host = nand_get_controller_data(chip);
void __iomem *nand_con = ebu_host->ebu + EBU_CON;
u32 cs = ebu_host->cs_num;
writel(EBU_CON_NANDM_EN | EBU_CON_CSMUX_E_EN | EBU_CON_CS_P_LOW |
EBU_CON_SE_P_LOW | EBU_CON_WP_P_LOW | EBU_CON_PRE_P_LOW |
EBU_CON_IN_CS_S(cs) | EBU_CON_OUT_CS_S(cs) |
EBU_CON_LAT_EN_CS_P, nand_con);
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/dmaengine.h`, `linux/dma-direction.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/init.h`, `linux/iopoll.h`.
- Detected declarations: `struct ebu_nand_cs`, `struct ebu_nand_controller`, `function ebu_nand_waitrdy`, `function ebu_nand_readb`, `function ebu_nand_writeb`, `function ebu_read_buf`, `function ebu_write_buf`, `function ebu_nand_disable`, `function ebu_select_chip`, `function ebu_nand_set_timings`.
- 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.