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.

Dependency Surface

Detected Declarations

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

Implementation Notes