drivers/mtd/nand/raw/mpc5121_nfc.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/mpc5121_nfc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/mpc5121_nfc.c- Extension
.c- Size
- 20901 bytes
- Lines
- 850
- 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/module.hlinux/clk.hlinux/gfp.hlinux/delay.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hasm/mpc5121.h
Detected Declarations
struct mpc5121_nfc_prvfunction nfc_readfunction nfc_writefunction nfc_setfunction nfc_clearfunction mpc5121_nfc_send_addrfunction mpc5121_nfc_send_cmdfunction mpc5121_nfc_send_prog_pagefunction mpc5121_nfc_send_read_pagefunction mpc5121_nfc_send_read_idfunction mpc5121_nfc_send_read_statusfunction mpc5121_nfc_irqfunction mpc5121_nfc_donefunction mpc5121_nfc_addr_cyclefunction mpc5121_nfc_select_chipfunction ads5121_chipselect_initfunction ads5121_select_chipfunction mpc5121_nfc_dev_readyfunction mpc5121_nfc_commandfunction mpc5121_nfc_copy_sparefunction mpc5121_nfc_buf_copyfunction mpc5121_nfc_read_buffunction mpc5121_nfc_write_buffunction mpc5121_nfc_read_bytefunction mpc5121_nfc_read_hw_configfunction mpc5121_nfc_freefunction mpc5121_nfc_attach_chipfunction mpc5121_nfc_probefunction mpc5121_nfc_remove
Annotated Snippet
struct mpc5121_nfc_prv {
struct nand_controller controller;
struct nand_chip chip;
int irq;
void __iomem *regs;
struct clk *clk;
wait_queue_head_t irq_waitq;
uint column;
int spareonly;
void __iomem *csreg;
struct device *dev;
};
static void mpc5121_nfc_done(struct mtd_info *mtd);
/* Read NFC register */
static inline u16 nfc_read(struct mtd_info *mtd, uint reg)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct mpc5121_nfc_prv *prv = nand_get_controller_data(chip);
return in_be16(prv->regs + reg);
}
/* Write NFC register */
static inline void nfc_write(struct mtd_info *mtd, uint reg, u16 val)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct mpc5121_nfc_prv *prv = nand_get_controller_data(chip);
out_be16(prv->regs + reg, val);
}
/* Set bits in NFC register */
static inline void nfc_set(struct mtd_info *mtd, uint reg, u16 bits)
{
nfc_write(mtd, reg, nfc_read(mtd, reg) | bits);
}
/* Clear bits in NFC register */
static inline void nfc_clear(struct mtd_info *mtd, uint reg, u16 bits)
{
nfc_write(mtd, reg, nfc_read(mtd, reg) & ~bits);
}
/* Invoke address cycle */
static inline void mpc5121_nfc_send_addr(struct mtd_info *mtd, u16 addr)
{
nfc_write(mtd, NFC_FLASH_ADDR, addr);
nfc_write(mtd, NFC_CONFIG2, NFC_ADDRESS);
mpc5121_nfc_done(mtd);
}
/* Invoke command cycle */
static inline void mpc5121_nfc_send_cmd(struct mtd_info *mtd, u16 cmd)
{
nfc_write(mtd, NFC_FLASH_CMD, cmd);
nfc_write(mtd, NFC_CONFIG2, NFC_COMMAND);
mpc5121_nfc_done(mtd);
}
/* Send data from NFC buffers to NAND flash */
static inline void mpc5121_nfc_send_prog_page(struct mtd_info *mtd)
{
nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK);
nfc_write(mtd, NFC_CONFIG2, NFC_INPUT);
mpc5121_nfc_done(mtd);
}
/* Receive data from NAND flash */
static inline void mpc5121_nfc_send_read_page(struct mtd_info *mtd)
{
nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK);
nfc_write(mtd, NFC_CONFIG2, NFC_OUTPUT);
mpc5121_nfc_done(mtd);
}
/* Receive ID from NAND flash */
static inline void mpc5121_nfc_send_read_id(struct mtd_info *mtd)
{
nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK);
nfc_write(mtd, NFC_CONFIG2, NFC_ID);
mpc5121_nfc_done(mtd);
}
/* Receive status from NAND flash */
static inline void mpc5121_nfc_send_read_status(struct mtd_info *mtd)
{
nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK);
nfc_write(mtd, NFC_CONFIG2, NFC_STATUS);
Annotation
- Immediate include surface: `linux/module.h`, `linux/clk.h`, `linux/gfp.h`, `linux/delay.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/mtd/mtd.h`.
- Detected declarations: `struct mpc5121_nfc_prv`, `function nfc_read`, `function nfc_write`, `function nfc_set`, `function nfc_clear`, `function mpc5121_nfc_send_addr`, `function mpc5121_nfc_send_cmd`, `function mpc5121_nfc_send_prog_page`, `function mpc5121_nfc_send_read_page`, `function mpc5121_nfc_send_read_id`.
- 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.