drivers/nvmem/apple-efuses.c
Source file repositories/reference/linux-study-clean/drivers/nvmem/apple-efuses.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvmem/apple-efuses.c- Extension
.c- Size
- 1877 bytes
- Lines
- 83
- 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/io.hlinux/mod_devicetable.hlinux/module.hlinux/nvmem-provider.hlinux/platform_device.h
Detected Declarations
struct apple_efuses_privfunction apple_efuses_readfunction apple_efuses_probe
Annotated Snippet
struct apple_efuses_priv {
void __iomem *fuses;
};
static int apple_efuses_read(void *context, unsigned int offset, void *val,
size_t bytes)
{
struct apple_efuses_priv *priv = context;
u32 *dst = val;
while (bytes >= sizeof(u32)) {
*dst++ = readl_relaxed(priv->fuses + offset);
bytes -= sizeof(u32);
offset += sizeof(u32);
}
return 0;
}
static int apple_efuses_probe(struct platform_device *pdev)
{
struct apple_efuses_priv *priv;
struct resource *res;
struct nvmem_config config = {
.dev = &pdev->dev,
.add_legacy_fixed_of_cells = true,
.read_only = true,
.reg_read = apple_efuses_read,
.stride = sizeof(u32),
.word_size = sizeof(u32),
.name = "apple_efuses_nvmem",
.id = NVMEM_DEVID_AUTO,
.root_only = true,
};
priv = devm_kzalloc(config.dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->fuses = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(priv->fuses))
return PTR_ERR(priv->fuses);
config.priv = priv;
config.size = resource_size(res);
return PTR_ERR_OR_ZERO(devm_nvmem_register(config.dev, &config));
}
static const struct of_device_id apple_efuses_of_match[] = {
{ .compatible = "apple,efuses", },
{}
};
MODULE_DEVICE_TABLE(of, apple_efuses_of_match);
static struct platform_driver apple_efuses_driver = {
.driver = {
.name = "apple_efuses",
.of_match_table = apple_efuses_of_match,
},
.probe = apple_efuses_probe,
};
module_platform_driver(apple_efuses_driver);
MODULE_AUTHOR("Sven Peter <sven@svenpeter.dev>");
MODULE_DESCRIPTION("Apple SoC eFuse driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/io.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/nvmem-provider.h`, `linux/platform_device.h`.
- Detected declarations: `struct apple_efuses_priv`, `function apple_efuses_read`, `function apple_efuses_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.