drivers/mtd/nand/raw/fsmc_nand.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/fsmc_nand.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/fsmc_nand.c- Extension
.c- Size
- 31224 bytes
- Lines
- 1243
- 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/delay.hlinux/dmaengine.hlinux/dma-direction.hlinux/dma-mapping.hlinux/err.hlinux/init.hlinux/module.hlinux/resource.hlinux/sched.hlinux/types.hlinux/mtd/mtd.hlinux/mtd/nand-ecc-sw-hamming.hlinux/mtd/rawnand.hlinux/platform_device.hlinux/of.hlinux/mtd/partitions.hlinux/io.hlinux/slab.hlinux/amba/bus.hmtd/mtd-abi.h
Detected Declarations
struct fsmc_nand_timingsstruct fsmc_nand_dataenum access_modefunction fsmc_ecc1_ooblayout_eccfunction fsmc_ecc1_ooblayout_freefunction fsmc_ecc4_ooblayout_eccfunction fsmc_ecc4_ooblayout_freefunction fsmc_nand_setupfunction fsmc_calc_timingsfunction fsmc_setup_interfacefunction fsmc_enable_hweccfunction fsmc_read_hwecc_ecc4function fsmc_read_hwecc_ecc1function fsmc_correct_ecc1function count_written_bitsfunction dma_completefunction dma_xferfunction fsmc_write_buffunction fsmc_read_buffunction fsmc_read_buf_dmafunction fsmc_write_buf_dmafunction fsmc_exec_opfunction datafunction fsmc_bch8_correct_datafunction filterfunction fsmc_nand_probe_config_dtfunction fsmc_nand_attach_chipfunction fsmc_nand_disablefunction fsmc_nand_probefunction fsmc_nand_removefunction fsmc_nand_suspendfunction fsmc_nand_resume
Annotated Snippet
struct fsmc_nand_timings {
u8 tclr;
u8 tar;
u8 thiz;
u8 thold;
u8 twait;
u8 tset;
};
enum access_mode {
USE_DMA_ACCESS = 1,
USE_WORD_ACCESS,
};
/**
* struct fsmc_nand_data - structure for FSMC NAND device state
*
* @base: Inherit from the nand_controller struct
* @pid: Part ID on the AMBA PrimeCell format
* @nand: Chip related info for a NAND flash.
*
* @bank: Bank number for probed device.
* @dev: Parent device
* @mode: Access mode
* @clk: Clock structure for FSMC.
*
* @read_dma_chan: DMA channel for read access
* @write_dma_chan: DMA channel for write access to NAND
* @dma_access_complete: Completion structure
*
* @dev_timings: NAND timings
*
* @data_pa: NAND Physical port for Data.
* @data_va: NAND port for Data.
* @cmd_va: NAND port for Command.
* @addr_va: NAND port for Address.
* @regs_va: Registers base address for a given bank.
*/
struct fsmc_nand_data {
struct nand_controller base;
u32 pid;
struct nand_chip nand;
unsigned int bank;
struct device *dev;
enum access_mode mode;
struct clk *clk;
/* DMA related objects */
struct dma_chan *read_dma_chan;
struct dma_chan *write_dma_chan;
struct completion dma_access_complete;
struct fsmc_nand_timings *dev_timings;
dma_addr_t data_pa;
void __iomem *data_va;
void __iomem *cmd_va;
void __iomem *addr_va;
void __iomem *regs_va;
};
static int fsmc_ecc1_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
if (section >= chip->ecc.steps)
return -ERANGE;
oobregion->offset = (section * 16) + 2;
oobregion->length = 3;
return 0;
}
static int fsmc_ecc1_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion)
{
struct nand_chip *chip = mtd_to_nand(mtd);
if (section >= chip->ecc.steps)
return -ERANGE;
oobregion->offset = (section * 16) + 8;
if (section < chip->ecc.steps - 1)
oobregion->length = 8;
else
oobregion->length = mtd->oobsize - oobregion->offset;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-direction.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/init.h`.
- Detected declarations: `struct fsmc_nand_timings`, `struct fsmc_nand_data`, `enum access_mode`, `function fsmc_ecc1_ooblayout_ecc`, `function fsmc_ecc1_ooblayout_free`, `function fsmc_ecc4_ooblayout_ecc`, `function fsmc_ecc4_ooblayout_free`, `function fsmc_nand_setup`, `function fsmc_calc_timings`, `function fsmc_setup_interface`.
- 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.