drivers/mtd/nand/raw/omap2.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/omap2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/omap2.c- Extension
.c- Size
- 65314 bytes
- Lines
- 2337
- 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/platform_device.hlinux/dmaengine.hlinux/dma-mapping.hlinux/delay.hlinux/gpio/consumer.hlinux/module.hlinux/interrupt.hlinux/jiffies.hlinux/sched.hlinux/mtd/mtd.hlinux/mtd/nand-ecc-sw-bch.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/omap-dma.hlinux/iopoll.hlinux/slab.hlinux/of.hlinux/of_platform.hlinux/platform_data/elm.hlinux/omap-gpmc.hlinux/platform_data/mtd-nand-omap2.h
Detected Declarations
struct omap_nand_infofunction omap_prefetch_enablefunction omap_prefetch_resetfunction omap_nand_data_in_preffunction omap_nand_data_out_preffunction omap_nand_dma_callbackfunction omap_nand_dma_transferfunction omap_nand_data_in_dma_preffunction omap_nand_data_out_dma_preffunction omap_nand_irqfunction omap_nand_data_in_irq_preffunction omap_nand_data_out_irq_preffunction gen_true_eccfunction omap_compare_eccfunction omap_correct_datafunction omap_calculate_eccfunction omap_enable_hweccfunction correctionfunction _omap_calculate_ecc_bchfunction omap_calculate_ecc_bch_swfunction omap_calculate_ecc_bch_multifunction erased_sector_bitflipsfunction omap_elm_correct_datafunction omap_write_page_bchfunction omap_write_subpage_bchfunction omap_read_page_bchfunction is_elm_presentfunction omap2_nand_ecc_checkfunction omap_get_dt_infofunction omap_ooblayout_eccfunction omap_ooblayout_freefunction omap_sw_ooblayout_eccfunction omap_sw_ooblayout_freefunction omap_nand_attach_chipfunction omap_nand_detach_chipfunction omap_nand_data_infunction omap_nand_data_outfunction omap_nand_exec_instrfunction omap_nand_exec_opfunction omap_nand_probefunction omap_nand_remove
Annotated Snippet
struct omap_nand_info {
struct nand_chip nand;
struct platform_device *pdev;
int gpmc_cs;
bool dev_ready;
enum nand_io xfer_type;
enum omap_ecc ecc_opt;
struct device_node *elm_of_node;
unsigned long phys_base;
struct completion comp;
struct dma_chan *dma;
int gpmc_irq_fifo;
int gpmc_irq_count;
enum {
OMAP_NAND_IO_READ = 0, /* read */
OMAP_NAND_IO_WRITE, /* write */
} iomode;
u_char *buf;
int buf_len;
/* Interface to GPMC */
void __iomem *fifo;
struct gpmc_nand_regs reg;
struct gpmc_nand_ops *ops;
bool flash_bbt;
/* fields specific for BCHx_HW ECC scheme */
struct device *elm_dev;
/* NAND ready gpio */
struct gpio_desc *ready_gpiod;
unsigned int neccpg;
unsigned int nsteps_per_eccpg;
unsigned int eccpg_size;
unsigned int eccpg_bytes;
void (*data_in)(struct nand_chip *chip, void *buf,
unsigned int len, bool force_8bit);
void (*data_out)(struct nand_chip *chip,
const void *buf, unsigned int len,
bool force_8bit);
};
static inline struct omap_nand_info *mtd_to_omap(struct mtd_info *mtd)
{
return container_of(mtd_to_nand(mtd), struct omap_nand_info, nand);
}
static void omap_nand_data_in(struct nand_chip *chip, void *buf,
unsigned int len, bool force_8bit);
static void omap_nand_data_out(struct nand_chip *chip,
const void *buf, unsigned int len,
bool force_8bit);
/**
* omap_prefetch_enable - configures and starts prefetch transfer
* @cs: cs (chip select) number
* @fifo_th: fifo threshold to be used for read/ write
* @dma_mode: dma mode enable (1) or disable (0)
* @u32_count: number of bytes to be transferred
* @is_write: prefetch read(0) or write post(1) mode
* @info: NAND device structure containing platform data
*/
static int omap_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write, struct omap_nand_info *info)
{
u32 val;
if (fifo_th > PREFETCH_FIFOTHRESHOLD_MAX)
return -1;
if (readl(info->reg.gpmc_prefetch_control))
return -EBUSY;
/* Set the amount of bytes to be prefetched */
writel(u32_count, info->reg.gpmc_prefetch_config2);
/* Set dma/mpu mode, the prefetch read / post write and
* enable the engine. Set which cs is has requested for.
*/
val = ((cs << PREFETCH_CONFIG1_CS_SHIFT) |
PREFETCH_FIFOTHRESHOLD(fifo_th) | ENABLE_PREFETCH |
(dma_mode << DMA_MPU_MODE_SHIFT) | (is_write & 0x1));
writel(val, info->reg.gpmc_prefetch_config1);
/* Start the prefetch engine */
writel(0x1, info->reg.gpmc_prefetch_control);
return 0;
}
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/interrupt.h`, `linux/jiffies.h`.
- Detected declarations: `struct omap_nand_info`, `function omap_prefetch_enable`, `function omap_prefetch_reset`, `function omap_nand_data_in_pref`, `function omap_nand_data_out_pref`, `function omap_nand_dma_callback`, `function omap_nand_dma_transfer`, `function omap_nand_data_in_dma_pref`, `function omap_nand_data_out_dma_pref`, `function omap_nand_irq`.
- 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.