drivers/mtd/lpddr/lpddr2_nvm.c
Source file repositories/reference/linux-study-clean/drivers/mtd/lpddr/lpddr2_nvm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/lpddr/lpddr2_nvm.c- Extension
.c- Size
- 13692 bytes
- Lines
- 497
- 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/init.hlinux/io.hlinux/module.hlinux/kernel.hlinux/mtd/map.hlinux/mtd/mtd.hlinux/mtd/partitions.hlinux/slab.hlinux/platform_device.hlinux/ioport.hlinux/err.h
Detected Declarations
struct pcm_int_datafunction build_map_wordfunction build_mr_cfgmaskfunction build_sr_ok_datamaskfunction ow_reg_addfunction ow_enablefunction ow_disablefunction lpddr2_nvm_do_opfunction lpddr2_nvm_do_block_opfunction lpddr2_nvm_pfow_presentfunction lpddr2_nvm_readfunction lpddr2_nvm_writefunction lpddr2_nvm_erasefunction lpddr2_nvm_unlockfunction lpddr2_nvm_lockfunction lpddr2_nvm_probefunction lpddr2_nvm_remove
Annotated Snippet
struct pcm_int_data {
void __iomem *ctl_regs;
int bus_width;
};
static DEFINE_MUTEX(lpdd2_nvm_mutex);
/*
* Build a map_word starting from an u_long
*/
static inline map_word build_map_word(u_long myword)
{
map_word val = { {0} };
val.x[0] = myword;
return val;
}
/*
* Build Mode Register Configuration DataMask based on device bus-width
*/
static inline u_int build_mr_cfgmask(u_int bus_width)
{
u_int val = MR_CFGMASK;
if (bus_width == 0x0004) /* x32 device */
val = val << 16;
return val;
}
/*
* Build Status Register OK DataMask based on device bus-width
*/
static inline u_int build_sr_ok_datamask(u_int bus_width)
{
u_int val = SR_OK_DATAMASK;
if (bus_width == 0x0004) /* x32 device */
val = (val << 16)+val;
return val;
}
/*
* Evaluates Overlay Window Control Registers address
*/
static inline u_long ow_reg_add(struct map_info *map, u_long offset)
{
u_long val = 0;
struct pcm_int_data *pcm_data = map->fldrv_priv;
val = map->pfow_base + offset*pcm_data->bus_width;
return val;
}
/*
* Enable lpddr2-nvm Overlay Window
* Overlay Window is a memory mapped area containing all LPDDR2-NVM registers
* used by device commands as well as uservisible resources like Device Status
* Register, Device ID, etc
*/
static inline void ow_enable(struct map_info *map)
{
struct pcm_int_data *pcm_data = map->fldrv_priv;
writel_relaxed(build_mr_cfgmask(pcm_data->bus_width) | 0x18,
pcm_data->ctl_regs + LPDDR2_MODE_REG_CFG);
writel_relaxed(0x01, pcm_data->ctl_regs + LPDDR2_MODE_REG_DATA);
}
/*
* Disable lpddr2-nvm Overlay Window
* Overlay Window is a memory mapped area containing all LPDDR2-NVM registers
* used by device commands as well as uservisible resources like Device Status
* Register, Device ID, etc
*/
static inline void ow_disable(struct map_info *map)
{
struct pcm_int_data *pcm_data = map->fldrv_priv;
writel_relaxed(build_mr_cfgmask(pcm_data->bus_width) | 0x18,
pcm_data->ctl_regs + LPDDR2_MODE_REG_CFG);
writel_relaxed(0x02, pcm_data->ctl_regs + LPDDR2_MODE_REG_DATA);
}
/*
* Execute lpddr2-nvm operations
*/
static int lpddr2_nvm_do_op(struct map_info *map, u_long cmd_code,
Annotation
- Immediate include surface: `linux/init.h`, `linux/io.h`, `linux/module.h`, `linux/kernel.h`, `linux/mtd/map.h`, `linux/mtd/mtd.h`, `linux/mtd/partitions.h`, `linux/slab.h`.
- Detected declarations: `struct pcm_int_data`, `function build_map_word`, `function build_mr_cfgmask`, `function build_sr_ok_datamask`, `function ow_reg_add`, `function ow_enable`, `function ow_disable`, `function lpddr2_nvm_do_op`, `function lpddr2_nvm_do_block_op`, `function lpddr2_nvm_pfow_present`.
- 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.