drivers/mtd/devices/mtd_intel_dg.c
Source file repositories/reference/linux-study-clean/drivers/mtd/devices/mtd_intel_dg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/devices/mtd_intel_dg.c- Extension
.c- Size
- 20525 bytes
- Lines
- 884
- 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.
- 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/bitfield.hlinux/bits.hlinux/cleanup.hlinux/delay.hlinux/device.hlinux/intel_dg_nvm_aux.hlinux/io.hlinux/io-64-nonatomic-lo-hi.hlinux/kernel.hlinux/module.hlinux/mtd/mtd.hlinux/mtd/partitions.hlinux/pm_runtime.hlinux/string.hlinux/slab.hlinux/sizes.hlinux/types.h
Detected Declarations
struct intel_dg_nvmfunction idg_nvm_set_region_idfunction idg_nvm_errorfunction idg_nvm_read32function idg_nvm_read64function idg_nvm_write32function idg_nvm_write64function idg_nvm_get_access_mapfunction idg_nvm_region_readablefunction idg_nvm_region_writablefunction idg_nvm_is_validfunction idg_nvm_get_regionfunction idg_nvm_rewrite_partialfunction idg_writefunction idg_readfunction idg_erasefunction intel_dg_nvm_initfunction intel_dg_mtd_erasefunction intel_dg_mtd_readfunction intel_dg_mtd_writefunction intel_dg_nvm_releasefunction intel_dg_mtd_get_devicefunction intel_dg_mtd_put_devicefunction intel_dg_nvm_init_mtdfunction intel_dg_mtd_probefunction intel_dg_mtd_remove
Annotated Snippet
struct intel_dg_nvm {
struct kref refcnt;
struct mtd_info mtd;
struct device *dev;
struct mutex lock; /* region access lock */
void __iomem *base;
void __iomem *base2;
bool non_posted_erase;
size_t size;
unsigned int nregions;
struct {
const char *name;
u8 id;
u64 offset;
u64 size;
unsigned int is_readable:1;
unsigned int is_writable:1;
} regions[] __counted_by(nregions);
};
#define NVM_TRIGGER_REG 0x00000000
#define NVM_VALSIG_REG 0x00000010
#define NVM_ADDRESS_REG 0x00000040
#define NVM_REGION_ID_REG 0x00000044
#define NVM_DEBUG_REG 0x00000000
/*
* [15:0]-Erase size = 0x0010 4K 0x0080 32K 0x0100 64K
* [23:16]-Reserved
* [31:24]-Erase MEM RegionID
*/
#define NVM_ERASE_REG 0x00000048
#define NVM_ACCESS_ERROR_REG 0x00000070
#define NVM_ADDRESS_ERROR_REG 0x00000074
/* Flash Valid Signature */
#define NVM_FLVALSIG 0x0FF0A55A
#define NVM_MAP_ADDR_MASK GENMASK(7, 0)
#define NVM_MAP_ADDR_SHIFT 0x00000004
#define NVM_REGION_ID_DESCRIPTOR 0
/* Flash Region Base Address */
#define NVM_FRBA 0x40
/* Flash Region __n - Flash Descriptor Record */
#define NVM_FLREG(__n) (NVM_FRBA + ((__n) * 4))
/* Flash Map 1 Register */
#define NVM_FLMAP1_REG 0x18
#define NVM_FLMSTR4_OFFSET 0x00C
#define NVM_ACCESS_ERROR_PCIE_MASK 0x7
#define NVM_FREG_BASE_MASK GENMASK(15, 0)
#define NVM_FREG_ADDR_MASK GENMASK(31, 16)
#define NVM_FREG_ADDR_SHIFT 12
#define NVM_FREG_MIN_REGION_SIZE 0xFFF
#define NVM_NON_POSTED_ERASE_DONE BIT(23)
#define NVM_NON_POSTED_ERASE_DONE_ITER 3000
static inline void idg_nvm_set_region_id(struct intel_dg_nvm *nvm, u8 region)
{
iowrite32((u32)region, nvm->base + NVM_REGION_ID_REG);
}
static inline u32 idg_nvm_error(struct intel_dg_nvm *nvm)
{
void __iomem *base = nvm->base;
u32 reg = ioread32(base + NVM_ACCESS_ERROR_REG) & NVM_ACCESS_ERROR_PCIE_MASK;
/* reset error bits */
if (reg)
iowrite32(reg, base + NVM_ACCESS_ERROR_REG);
return reg;
}
static inline u32 idg_nvm_read32(struct intel_dg_nvm *nvm, u32 address)
{
void __iomem *base = nvm->base;
iowrite32(address, base + NVM_ADDRESS_REG);
return ioread32(base + NVM_TRIGGER_REG);
}
static inline u64 idg_nvm_read64(struct intel_dg_nvm *nvm, u32 address)
{
void __iomem *base = nvm->base;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/delay.h`, `linux/device.h`, `linux/intel_dg_nvm_aux.h`, `linux/io.h`, `linux/io-64-nonatomic-lo-hi.h`.
- Detected declarations: `struct intel_dg_nvm`, `function idg_nvm_set_region_id`, `function idg_nvm_error`, `function idg_nvm_read32`, `function idg_nvm_read64`, `function idg_nvm_write32`, `function idg_nvm_write64`, `function idg_nvm_get_access_map`, `function idg_nvm_region_readable`, `function idg_nvm_region_writable`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
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.