drivers/mtd/nand/raw/davinci_nand.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/davinci_nand.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/davinci_nand.c- Extension
.c- Size
- 30069 bytes
- Lines
- 1049
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/err.hlinux/iopoll.hlinux/kernel.hlinux/memory/ti-aemif.hlinux/module.hlinux/mtd/partitions.hlinux/mtd/rawnand.hlinux/platform_device.hlinux/property.hlinux/slab.h
Detected Declarations
struct davinci_nand_pdatastruct davinci_nand_infofunction davinci_nand_readlfunction davinci_nand_writelfunction nand_davinci_readecc_1bitfunction nand_davinci_hwctl_1bitfunction nand_davinci_calculate_1bitfunction nand_davinci_correct_1bitfunction nand_davinci_hwctl_4bitfunction nand_davinci_readecc_4bitfunction nand_davinci_calculate_4bitfunction nand_davinci_correct_4bitfunction hwecc4_ooblayout_small_eccfunction hwecc4_ooblayout_small_freefunction hwecc4_ooblayout_large_eccfunction hwecc4_ooblayout_large_freefunction nand_davinci_get_pdatafunction nand_davinci_get_pdatafunction davinci_nand_attach_chipfunction neededfunction nand_davinci_data_infunction nand_davinci_data_outfunction davinci_nand_exec_instrfunction davinci_nand_exec_opfunction davinci_nand_setup_interfacefunction nand_davinci_probefunction nand_davinci_remove
Annotated Snippet
struct davinci_nand_pdata {
uint32_t mask_ale;
uint32_t mask_cle;
/*
* 0-indexed chip-select number of the asynchronous
* interface to which the NAND device has been connected.
*
* So, if you have NAND connected to CS3 of DA850, you
* will pass '1' here. Since the asynchronous interface
* on DA850 starts from CS2.
*/
uint32_t core_chipsel;
/* for packages using two chipselects */
uint32_t mask_chipsel;
/* board's default static partition info */
struct mtd_partition *parts;
unsigned int nr_parts;
/* none == NAND_ECC_ENGINE_TYPE_NONE (strongly *not* advised!!)
* soft == NAND_ECC_ENGINE_TYPE_SOFT
* on-die == NAND_ECC_ENGINE_TYPE_ON_DIE
* else == NAND_ECC_ENGINE_TYPE_ON_HOST, according to ecc_bits
*
* All DaVinci-family chips support 1-bit hardware ECC.
* Newer ones also support 4-bit ECC, but are awkward
* using it with large page chips.
*/
enum nand_ecc_engine_type engine_type;
enum nand_ecc_placement ecc_placement;
u8 ecc_bits;
/* e.g. NAND_BUSWIDTH_16 */
unsigned int options;
/* e.g. NAND_BBT_USE_FLASH */
unsigned int bbt_options;
/* Main and mirror bbt descriptor overrides */
struct nand_bbt_descr *bbt_td;
struct nand_bbt_descr *bbt_md;
};
/*
* This is a device driver for the NAND flash controller found on the
* various DaVinci family chips. It handles up to four SoC chipselects,
* and some flavors of secondary chipselect (e.g. based on A12) as used
* with multichip packages.
*
* The 1-bit ECC hardware is supported, as well as the newer 4-bit ECC
* available on chips like the DM355 and OMAP-L137 and needed with the
* more error-prone MLC NAND chips.
*
* This driver assumes EM_WAIT connects all the NAND devices' RDY/nBUSY
* outputs in a "wire-AND" configuration, with no per-chip signals.
*/
struct davinci_nand_info {
struct nand_controller controller;
struct nand_chip chip;
struct platform_device *pdev;
bool is_readmode;
void __iomem *base;
void __iomem *vaddr;
void __iomem *current_cs;
uint32_t mask_chipsel;
uint32_t mask_ale;
uint32_t mask_cle;
uint32_t core_chipsel;
struct clk *clk;
struct aemif_device *aemif;
};
static DEFINE_SPINLOCK(davinci_nand_lock);
static bool ecc4_busy;
static inline struct davinci_nand_info *to_davinci_nand(struct mtd_info *mtd)
{
return container_of(mtd_to_nand(mtd), struct davinci_nand_info, chip);
}
static inline unsigned int davinci_nand_readl(struct davinci_nand_info *info,
int offset)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/err.h`, `linux/iopoll.h`, `linux/kernel.h`, `linux/memory/ti-aemif.h`, `linux/module.h`, `linux/mtd/partitions.h`, `linux/mtd/rawnand.h`.
- Detected declarations: `struct davinci_nand_pdata`, `struct davinci_nand_info`, `function davinci_nand_readl`, `function davinci_nand_writel`, `function nand_davinci_readecc_1bit`, `function nand_davinci_hwctl_1bit`, `function nand_davinci_calculate_1bit`, `function nand_davinci_correct_1bit`, `function nand_davinci_hwctl_4bit`, `function nand_davinci_readecc_4bit`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.