drivers/nvmem/imx-ocotp-ele.c
Source file repositories/reference/linux-study-clean/drivers/nvmem/imx-ocotp-ele.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvmem/imx-ocotp-ele.c- Extension
.c- Size
- 5760 bytes
- Lines
- 250
- Domain
- Driver Families
- Bucket
- drivers/nvmem
- 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/device.hlinux/io.hlinux/module.hlinux/nvmem-provider.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/if_ether.h
Detected Declarations
struct ocotp_map_entrystruct ocotp_devtype_datastruct imx_ocotp_privenum fuse_typefunction imx_ocotp_fuse_typefunction imx_ocotp_reg_readfunction imx_ocotp_cell_ppfunction imx_ocotp_fixup_dt_cell_infofunction imx_ele_ocotp_probe
Annotated Snippet
struct ocotp_map_entry {
u32 start; /* start word */
u32 num; /* num words */
enum fuse_type type;
};
struct ocotp_devtype_data {
u32 reg_off;
char *name;
u32 size;
u32 num_entry;
u32 flag;
nvmem_reg_read_t reg_read;
struct ocotp_map_entry entry[];
};
struct imx_ocotp_priv {
struct device *dev;
void __iomem *base;
struct nvmem_config config;
struct mutex lock;
const struct ocotp_devtype_data *data;
};
static enum fuse_type imx_ocotp_fuse_type(void *context, u32 index)
{
struct imx_ocotp_priv *priv = context;
const struct ocotp_devtype_data *data = priv->data;
u32 start, end;
int i;
for (i = 0; i < data->num_entry; i++) {
start = data->entry[i].start;
end = data->entry[i].start + data->entry[i].num;
if (index >= start && index < end)
return data->entry[i].type;
}
return FUSE_INVALID;
}
static int imx_ocotp_reg_read(void *context, unsigned int offset, void *val, size_t bytes)
{
struct imx_ocotp_priv *priv = context;
void __iomem *reg = priv->base + priv->data->reg_off;
u32 count, index, num_bytes;
enum fuse_type type;
u32 *buf;
void *p;
int i;
u8 skipbytes;
if (offset + bytes > priv->data->size)
bytes = priv->data->size - offset;
index = offset >> 2;
skipbytes = offset - (index << 2);
num_bytes = round_up(bytes + skipbytes, 4);
count = num_bytes >> 2;
p = kzalloc(num_bytes, GFP_KERNEL);
if (!p)
return -ENOMEM;
mutex_lock(&priv->lock);
buf = p;
for (i = index; i < (index + count); i++) {
type = imx_ocotp_fuse_type(context, i);
if (type == FUSE_INVALID || type == FUSE_ELE) {
*buf++ = 0;
continue;
}
if (type & FUSE_ECC)
*buf++ = readl_relaxed(reg + (i << 2)) & GENMASK(15, 0);
else
*buf++ = readl_relaxed(reg + (i << 2));
}
memcpy(val, ((u8 *)p) + skipbytes, bytes);
mutex_unlock(&priv->lock);
kfree(p);
return 0;
};
Annotation
- Immediate include surface: `linux/device.h`, `linux/io.h`, `linux/module.h`, `linux/nvmem-provider.h`, `linux/of.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/if_ether.h`.
- Detected declarations: `struct ocotp_map_entry`, `struct ocotp_devtype_data`, `struct imx_ocotp_priv`, `enum fuse_type`, `function imx_ocotp_fuse_type`, `function imx_ocotp_reg_read`, `function imx_ocotp_cell_pp`, `function imx_ocotp_fixup_dt_cell_info`, `function imx_ele_ocotp_probe`.
- Atlas domain: Driver Families / drivers/nvmem.
- 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.