drivers/soc/aspeed/aspeed-socinfo.c
Source file repositories/reference/linux-study-clean/drivers/soc/aspeed/aspeed-socinfo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/aspeed/aspeed-socinfo.c- Extension
.c- Size
- 3195 bytes
- Lines
- 159
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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/of.hlinux/of_address.hlinux/of_platform.hlinux/platform_device.hlinux/slab.hlinux/sys_soc.h
Detected Declarations
function aspeed_socinfo_init
Annotated Snippet
switch (rev) {
case 0:
return "A0";
case 1:
return "A1";
case 3:
return "A2";
}
} else {
/* AST2600 */
switch (rev) {
case 0:
return "A0";
case 1:
return "A1";
case 2:
return "A2";
case 3:
return "A3";
}
}
return "??";
}
static int __init aspeed_socinfo_init(void)
{
struct soc_device_attribute *attrs;
struct soc_device *soc_dev;
struct device_node *np;
void __iomem *reg;
bool has_chipid = false;
u32 siliconid;
u32 chipid[2];
const char *machine = NULL;
np = of_find_compatible_node(NULL, NULL, "aspeed,silicon-id");
if (!of_device_is_available(np)) {
of_node_put(np);
return -ENODEV;
}
reg = of_iomap(np, 0);
if (!reg) {
of_node_put(np);
return -ENODEV;
}
siliconid = readl(reg);
iounmap(reg);
/* This is optional, the ast2400 does not have it */
reg = of_iomap(np, 1);
if (reg) {
has_chipid = true;
chipid[0] = readl(reg);
chipid[1] = readl(reg + 4);
iounmap(reg);
}
of_node_put(np);
attrs = kzalloc_obj(*attrs);
if (!attrs)
return -ENODEV;
/*
* Machine: Romulus BMC
* Family: AST2500
* Revision: A1
* SoC ID: raw silicon revision id
* Serial Number: 64-bit chipid
*/
np = of_find_node_by_path("/");
of_property_read_string(np, "model", &machine);
if (machine)
attrs->machine = kstrdup(machine, GFP_KERNEL);
of_node_put(np);
attrs->family = siliconid_to_name(siliconid);
attrs->revision = siliconid_to_rev(siliconid);
attrs->soc_id = kasprintf(GFP_KERNEL, "%08x", siliconid);
if (has_chipid)
attrs->serial_number = kasprintf(GFP_KERNEL, "%08x%08x",
chipid[1], chipid[0]);
soc_dev = soc_device_register(attrs);
if (IS_ERR(soc_dev)) {
kfree(attrs->machine);
kfree(attrs->soc_id);
Annotation
- Immediate include surface: `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/sys_soc.h`.
- Detected declarations: `function aspeed_socinfo_init`.
- Atlas domain: Driver Families / drivers/soc.
- 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.