drivers/nvmem/imx-iim.c
Source file repositories/reference/linux-study-clean/drivers/nvmem/imx-iim.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvmem/imx-iim.c- Extension
.c- Size
- 3042 bytes
- Lines
- 144
- 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.
- 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/clk.h
Detected Declarations
struct imx_iim_drvdatastruct iim_privfunction imx_iim_readfunction imx_iim_probe
Annotated Snippet
struct imx_iim_drvdata {
unsigned int nregs;
};
struct iim_priv {
void __iomem *base;
struct clk *clk;
};
static int imx_iim_read(void *context, unsigned int offset,
void *buf, size_t bytes)
{
struct iim_priv *iim = context;
int i, ret;
u8 *buf8 = buf;
ret = clk_prepare_enable(iim->clk);
if (ret)
return ret;
for (i = offset; i < offset + bytes; i++) {
int bank = i >> 5;
int reg = i & 0x1f;
*buf8++ = readl(iim->base + IIM_BANK_BASE(bank) + reg * 4);
}
clk_disable_unprepare(iim->clk);
return 0;
}
static struct imx_iim_drvdata imx27_drvdata = {
.nregs = 2 * 32,
};
static struct imx_iim_drvdata imx25_imx31_imx35_drvdata = {
.nregs = 3 * 32,
};
static struct imx_iim_drvdata imx51_drvdata = {
.nregs = 4 * 32,
};
static struct imx_iim_drvdata imx53_drvdata = {
.nregs = 4 * 32 + 16,
};
static const struct of_device_id imx_iim_dt_ids[] = {
{
.compatible = "fsl,imx25-iim",
.data = &imx25_imx31_imx35_drvdata,
}, {
.compatible = "fsl,imx27-iim",
.data = &imx27_drvdata,
}, {
.compatible = "fsl,imx31-iim",
.data = &imx25_imx31_imx35_drvdata,
}, {
.compatible = "fsl,imx35-iim",
.data = &imx25_imx31_imx35_drvdata,
}, {
.compatible = "fsl,imx51-iim",
.data = &imx51_drvdata,
}, {
.compatible = "fsl,imx53-iim",
.data = &imx53_drvdata,
}, {
/* sentinel */
},
};
MODULE_DEVICE_TABLE(of, imx_iim_dt_ids);
static int imx_iim_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct iim_priv *iim;
struct nvmem_device *nvmem;
struct nvmem_config cfg = {};
const struct imx_iim_drvdata *drvdata = NULL;
iim = devm_kzalloc(dev, sizeof(*iim), GFP_KERNEL);
if (!iim)
return -ENOMEM;
iim->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(iim->base))
return PTR_ERR(iim->base);
drvdata = of_device_get_match_data(&pdev->dev);
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/clk.h`.
- Detected declarations: `struct imx_iim_drvdata`, `struct iim_priv`, `function imx_iim_read`, `function imx_iim_probe`.
- Atlas domain: Driver Families / drivers/nvmem.
- 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.