drivers/mtd/nand/onenand/onenand_samsung.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/onenand/onenand_samsung.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/onenand/onenand_samsung.c- Extension
.c- Size
- 25253 bytes
- Lines
- 1002
- 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/platform_device.hlinux/sched.hlinux/slab.hlinux/mtd/mtd.hlinux/mtd/onenand.hlinux/mtd/partitions.hlinux/dma-mapping.hlinux/interrupt.hlinux/io.hsamsung.h
Detected Declarations
struct s3c_onenandenum soc_typefunction s3c_read_regfunction s3c_write_regfunction s3c_read_cmdfunction s3c_write_cmdfunction s3c_dump_regfunction s3c64xx_cmd_mapfunction s3c6400_mem_addrfunction s3c6410_mem_addrfunction s3c_onenand_resetfunction s3c_onenand_readwfunction s3c_onenand_writewfunction s3c_onenand_waitfunction recoveryfunction s3c_onenand_commandfunction onenand_read_bufferramfunction onenand_write_bufferramfunction s5pc110_dma_pollfunction s5pc110_onenand_irqfunction s5pc110_dma_irqfunction s5pc110_read_bufferramfunction s5pc110_chip_probefunction s3c_onenand_bbt_waitfunction s3c_onenand_check_lock_statusfunction s3c_onenand_do_lock_cmdfunction s3c_unlock_allfunction s3c_onenand_setupfunction s3c_onenand_probefunction s3c_onenand_removefunction s3c_pm_ops_suspendfunction s3c_pm_ops_resume
Annotated Snippet
struct s3c_onenand {
struct mtd_info *mtd;
struct platform_device *pdev;
enum soc_type type;
void __iomem *base;
void __iomem *ahb_addr;
int bootram_command;
void *page_buf;
void *oob_buf;
unsigned int (*mem_addr)(int fba, int fpa, int fsa);
unsigned int (*cmd_map)(unsigned int type, unsigned int val);
void __iomem *dma_addr;
unsigned long phys_base;
struct completion complete;
};
#define CMD_MAP_00(dev, addr) (dev->cmd_map(MAP_00, ((addr) << 1)))
#define CMD_MAP_01(dev, mem_addr) (dev->cmd_map(MAP_01, (mem_addr)))
#define CMD_MAP_10(dev, mem_addr) (dev->cmd_map(MAP_10, (mem_addr)))
#define CMD_MAP_11(dev, addr) (dev->cmd_map(MAP_11, ((addr) << 2)))
static struct s3c_onenand *onenand;
static inline int s3c_read_reg(int offset)
{
return readl(onenand->base + offset);
}
static inline void s3c_write_reg(int value, int offset)
{
writel(value, onenand->base + offset);
}
static inline int s3c_read_cmd(unsigned int cmd)
{
return readl(onenand->ahb_addr + cmd);
}
static inline void s3c_write_cmd(int value, unsigned int cmd)
{
writel(value, onenand->ahb_addr + cmd);
}
#ifdef SAMSUNG_DEBUG
static void s3c_dump_reg(void)
{
int i;
for (i = 0; i < 0x400; i += 0x40) {
printk(KERN_INFO "0x%08X: 0x%08x 0x%08x 0x%08x 0x%08x\n",
(unsigned int) onenand->base + i,
s3c_read_reg(i), s3c_read_reg(i + 0x10),
s3c_read_reg(i + 0x20), s3c_read_reg(i + 0x30));
}
}
#endif
static unsigned int s3c64xx_cmd_map(unsigned type, unsigned val)
{
return (type << S3C64XX_CMD_MAP_SHIFT) | val;
}
static unsigned int s3c6400_mem_addr(int fba, int fpa, int fsa)
{
return (fba << S3C6400_FBA_SHIFT) | (fpa << S3C6400_FPA_SHIFT) |
(fsa << S3C6400_FSA_SHIFT);
}
static unsigned int s3c6410_mem_addr(int fba, int fpa, int fsa)
{
return (fba << S3C6410_FBA_SHIFT) | (fpa << S3C6410_FPA_SHIFT) |
(fsa << S3C6410_FSA_SHIFT);
}
static void s3c_onenand_reset(void)
{
unsigned long timeout = 0x10000;
int stat;
s3c_write_reg(ONENAND_MEM_RESET_COLD, MEM_RESET_OFFSET);
while (1 && timeout--) {
stat = s3c_read_reg(INT_ERR_STAT_OFFSET);
if (stat & RST_CMP)
break;
}
stat = s3c_read_reg(INT_ERR_STAT_OFFSET);
s3c_write_reg(stat, INT_ERR_ACK_OFFSET);
/* Clear interrupt */
s3c_write_reg(0x0, INT_ERR_ACK_OFFSET);
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/sched.h`, `linux/slab.h`, `linux/mtd/mtd.h`, `linux/mtd/onenand.h`, `linux/mtd/partitions.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct s3c_onenand`, `enum soc_type`, `function s3c_read_reg`, `function s3c_write_reg`, `function s3c_read_cmd`, `function s3c_write_cmd`, `function s3c_dump_reg`, `function s3c64xx_cmd_map`, `function s3c6400_mem_addr`, `function s3c6410_mem_addr`.
- 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.