drivers/mtd/nand/raw/vf610_nfc.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/vf610_nfc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/vf610_nfc.c- Extension
.c- Size
- 25845 bytes
- Lines
- 950
- 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/bitops.hlinux/clk.hlinux/delay.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/slab.hlinux/swab.h
Detected Declarations
struct vf610_nfcenum vf610_nfc_variantfunction vf610_nfc_readfunction vf610_nfc_writefunction vf610_nfc_setfunction vf610_nfc_clearfunction vf610_nfc_set_fieldfunction vf610_nfc_kernel_is_little_endianfunction reasonfunction reasonfunction vf610_nfc_clear_statusfunction vf610_nfc_donefunction vf610_nfc_irqfunction vf610_nfc_ecc_modefunction vf610_nfc_runfunction vf610_get_next_instrfunction vf610_nfc_cmdfunction onlyfunction vf610_nfc_exec_opfunction vf610_nfc_correct_datafunction vf610_nfc_fill_rowfunction vf610_nfc_read_pagefunction vf610_nfc_write_pagefunction vf610_nfc_read_page_rawfunction vf610_nfc_write_page_rawfunction vf610_nfc_read_oobfunction vf610_nfc_write_oobfunction vf610_nfc_preinit_controllerfunction vf610_nfc_init_controllerfunction vf610_nfc_attach_chipfunction vf610_nfc_probefunction for_each_available_child_of_node_scopedfunction vf610_nfc_removefunction vf610_nfc_suspendfunction vf610_nfc_resume
Annotated Snippet
struct vf610_nfc {
struct nand_controller base;
struct nand_chip chip;
struct device *dev;
void __iomem *regs;
struct completion cmd_done;
/* Status and ID are in alternate locations. */
enum vf610_nfc_variant variant;
struct clk *clk;
/*
* Indicate that user data is accessed (full page/oob). This is
* useful to indicate the driver whether to swap byte endianness.
* See comments in vf610_nfc_rd_from_sram/vf610_nfc_wr_to_sram.
*/
bool data_access;
u32 ecc_mode;
};
static inline struct vf610_nfc *chip_to_nfc(struct nand_chip *chip)
{
return container_of(chip, struct vf610_nfc, chip);
}
static inline u32 vf610_nfc_read(struct vf610_nfc *nfc, uint reg)
{
return readl(nfc->regs + reg);
}
static inline void vf610_nfc_write(struct vf610_nfc *nfc, uint reg, u32 val)
{
writel(val, nfc->regs + reg);
}
static inline void vf610_nfc_set(struct vf610_nfc *nfc, uint reg, u32 bits)
{
vf610_nfc_write(nfc, reg, vf610_nfc_read(nfc, reg) | bits);
}
static inline void vf610_nfc_clear(struct vf610_nfc *nfc, uint reg, u32 bits)
{
vf610_nfc_write(nfc, reg, vf610_nfc_read(nfc, reg) & ~bits);
}
static inline void vf610_nfc_set_field(struct vf610_nfc *nfc, u32 reg,
u32 mask, u32 shift, u32 val)
{
vf610_nfc_write(nfc, reg,
(vf610_nfc_read(nfc, reg) & (~mask)) | val << shift);
}
static inline bool vf610_nfc_kernel_is_little_endian(void)
{
#ifdef __LITTLE_ENDIAN
return true;
#else
return false;
#endif
}
/*
* Read accessor for internal SRAM buffer
* @dst: destination address in regular memory
* @src: source address in SRAM buffer
* @len: bytes to copy
* @fix_endian: Fix endianness if required
*
* Use this accessor for the internal SRAM buffers. On the ARM
* Freescale Vybrid SoC it's known that the driver can treat
* the SRAM buffer as if it's memory. Other platform might need
* to treat the buffers differently.
*
* The controller stores bytes from the NAND chip internally in big
* endianness. On little endian platforms such as Vybrid this leads
* to reversed byte order.
* For performance reason (and earlier probably due to unawareness)
* the driver avoids correcting endianness where it has control over
* write and read side (e.g. page wise data access).
*/
static inline void vf610_nfc_rd_from_sram(void *dst, const void __iomem *src,
size_t len, bool fix_endian)
{
if (vf610_nfc_kernel_is_little_endian() && fix_endian) {
unsigned int i;
for (i = 0; i < len; i += 4) {
u32 val = swab32(__raw_readl(src + i));
memcpy(dst + i, &val, min(sizeof(val), len - i));
}
} else {
Annotation
- Immediate include surface: `linux/module.h`, `linux/bitops.h`, `linux/clk.h`, `linux/delay.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`, `linux/mtd/mtd.h`.
- Detected declarations: `struct vf610_nfc`, `enum vf610_nfc_variant`, `function vf610_nfc_read`, `function vf610_nfc_write`, `function vf610_nfc_set`, `function vf610_nfc_clear`, `function vf610_nfc_set_field`, `function vf610_nfc_kernel_is_little_endian`, `function reason`, `function reason`.
- 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.