drivers/soc/aspeed/aspeed-lpc-ctrl.c
Source file repositories/reference/linux-study-clean/drivers/soc/aspeed/aspeed-lpc-ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/aspeed/aspeed-lpc-ctrl.c- Extension
.c- Size
- 9430 bytes
- Lines
- 357
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/clk.hlinux/log2.hlinux/mfd/syscon.hlinux/miscdevice.hlinux/mm.hlinux/module.hlinux/of_address.hlinux/of_reserved_mem.hlinux/platform_device.hlinux/poll.hlinux/regmap.hlinux/aspeed-lpc-ctrl.h
Detected Declarations
struct aspeed_lpc_ctrlfunction aspeed_lpc_ctrl_mmapfunction aspeed_lpc_ctrl_ioctlfunction aspeed_lpc_ctrl_probefunction aspeed_lpc_ctrl_remove
Annotated Snippet
static const struct file_operations aspeed_lpc_ctrl_fops = {
.owner = THIS_MODULE,
.mmap = aspeed_lpc_ctrl_mmap,
.unlocked_ioctl = aspeed_lpc_ctrl_ioctl,
};
static int aspeed_lpc_ctrl_probe(struct platform_device *pdev)
{
struct aspeed_lpc_ctrl *lpc_ctrl;
struct device_node *node;
struct resource resm;
struct device *dev;
struct device_node *np;
int rc;
dev = &pdev->dev;
lpc_ctrl = devm_kzalloc(dev, sizeof(*lpc_ctrl), GFP_KERNEL);
if (!lpc_ctrl)
return -ENOMEM;
/* If flash is described in device tree then store */
node = of_parse_phandle(dev->of_node, "flash", 0);
if (!node) {
dev_dbg(dev, "Didn't find host pnor flash node\n");
} else {
rc = of_address_to_resource(node, 1, &resm);
of_node_put(node);
if (rc) {
dev_err(dev, "Couldn't address to resource for flash\n");
return rc;
}
lpc_ctrl->pnor_size = resource_size(&resm);
lpc_ctrl->pnor_base = resm.start;
}
dev_set_drvdata(&pdev->dev, lpc_ctrl);
/* If memory-region is described in device tree then store */
rc = of_reserved_mem_region_to_resource(dev->of_node, 0, &resm);
if (!rc) {
lpc_ctrl->mem_size = resource_size(&resm);
lpc_ctrl->mem_base = resm.start;
if (!is_power_of_2(lpc_ctrl->mem_size)) {
dev_err(dev, "Reserved memory size must be a power of 2, got %u\n",
(unsigned int)lpc_ctrl->mem_size);
return -EINVAL;
}
if (!IS_ALIGNED(lpc_ctrl->mem_base, lpc_ctrl->mem_size)) {
dev_err(dev, "Reserved memory must be naturally aligned for size %u\n",
(unsigned int)lpc_ctrl->mem_size);
return -EINVAL;
}
}
np = pdev->dev.parent->of_node;
if (!of_device_is_compatible(np, "aspeed,ast2400-lpc-v2") &&
!of_device_is_compatible(np, "aspeed,ast2500-lpc-v2") &&
!of_device_is_compatible(np, "aspeed,ast2600-lpc-v2")) {
dev_err(dev, "unsupported LPC device binding\n");
return -ENODEV;
}
lpc_ctrl->regmap = syscon_node_to_regmap(np);
if (IS_ERR(lpc_ctrl->regmap)) {
dev_err(dev, "Couldn't get regmap\n");
return -ENODEV;
}
if (of_device_is_compatible(dev->of_node, "aspeed,ast2600-lpc-ctrl")) {
lpc_ctrl->fwh2ahb = true;
lpc_ctrl->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2600-scu");
if (IS_ERR(lpc_ctrl->scu)) {
dev_err(dev, "couldn't find scu\n");
return PTR_ERR(lpc_ctrl->scu);
}
}
lpc_ctrl->clk = devm_clk_get(dev, NULL);
if (IS_ERR(lpc_ctrl->clk))
return dev_err_probe(dev, PTR_ERR(lpc_ctrl->clk),
"couldn't get clock\n");
rc = clk_prepare_enable(lpc_ctrl->clk);
if (rc) {
dev_err(dev, "couldn't enable clock\n");
Annotation
- Immediate include surface: `linux/clk.h`, `linux/log2.h`, `linux/mfd/syscon.h`, `linux/miscdevice.h`, `linux/mm.h`, `linux/module.h`, `linux/of_address.h`, `linux/of_reserved_mem.h`.
- Detected declarations: `struct aspeed_lpc_ctrl`, `function aspeed_lpc_ctrl_mmap`, `function aspeed_lpc_ctrl_ioctl`, `function aspeed_lpc_ctrl_probe`, `function aspeed_lpc_ctrl_remove`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.