drivers/nvmem/imx-ocotp-scu.c
Source file repositories/reference/linux-study-clean/drivers/nvmem/imx-ocotp-scu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvmem/imx-ocotp-scu.c- Extension
.c- Size
- 5584 bytes
- Lines
- 276
- 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/arm-smccc.hlinux/firmware/imx/sci.hlinux/module.hlinux/nvmem-provider.hlinux/of.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct ocotp_regionstruct ocotp_devtype_datastruct ocotp_privstruct imx_sc_msg_misc_fuse_readenum ocotp_devtypefunction in_holefunction in_eccfunction imx_sc_misc_otp_fuse_readfunction imx_scu_ocotp_readfunction imx_scu_ocotp_writefunction imx_scu_ocotp_probe
Annotated Snippet
struct ocotp_region {
u32 start;
u32 end;
u32 flag;
};
struct ocotp_devtype_data {
int devtype;
int nregs;
u32 num_region;
struct ocotp_region region[];
};
struct ocotp_priv {
struct device *dev;
const struct ocotp_devtype_data *data;
struct imx_sc_ipc *nvmem_ipc;
};
struct imx_sc_msg_misc_fuse_read {
struct imx_sc_rpc_msg hdr;
u32 word;
} __packed;
static DEFINE_MUTEX(scu_ocotp_mutex);
static struct ocotp_devtype_data imx8qxp_data = {
.devtype = IMX8QXP,
.nregs = 800,
.num_region = 3,
.region = {
{0x10, 0x10f, ECC_REGION},
{0x110, 0x21F, HOLE_REGION},
{0x220, 0x31F, ECC_REGION},
},
};
static struct ocotp_devtype_data imx8qm_data = {
.devtype = IMX8QM,
.nregs = 800,
.num_region = 2,
.region = {
{0x10, 0x10f, ECC_REGION},
{0x1a0, 0x1ff, ECC_REGION},
},
};
static bool in_hole(void *context, u32 index)
{
struct ocotp_priv *priv = context;
const struct ocotp_devtype_data *data = priv->data;
int i;
for (i = 0; i < data->num_region; i++) {
if (data->region[i].flag & HOLE_REGION) {
if ((index >= data->region[i].start) &&
(index <= data->region[i].end))
return true;
}
}
return false;
}
static bool in_ecc(void *context, u32 index)
{
struct ocotp_priv *priv = context;
const struct ocotp_devtype_data *data = priv->data;
int i;
for (i = 0; i < data->num_region; i++) {
if (data->region[i].flag & ECC_REGION) {
if ((index >= data->region[i].start) &&
(index <= data->region[i].end))
return true;
}
}
return false;
}
static int imx_sc_misc_otp_fuse_read(struct imx_sc_ipc *ipc, u32 word,
u32 *val)
{
struct imx_sc_msg_misc_fuse_read msg;
struct imx_sc_rpc_msg *hdr = &msg.hdr;
int ret;
hdr->ver = IMX_SC_RPC_VERSION;
hdr->svc = IMX_SC_RPC_SVC_MISC;
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/firmware/imx/sci.h`, `linux/module.h`, `linux/nvmem-provider.h`, `linux/of.h`, `linux/platform_device.h`, `linux/slab.h`.
- Detected declarations: `struct ocotp_region`, `struct ocotp_devtype_data`, `struct ocotp_priv`, `struct imx_sc_msg_misc_fuse_read`, `enum ocotp_devtype`, `function in_hole`, `function in_ecc`, `function imx_sc_misc_otp_fuse_read`, `function imx_scu_ocotp_read`, `function imx_scu_ocotp_write`.
- 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.