arch/powerpc/platforms/powernv/opal-lpc.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powernv/opal-lpc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powernv/opal-lpc.c- Extension
.c- Size
- 10137 bytes
- Lines
- 419
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/kernel.hlinux/of.hlinux/bug.hlinux/io.hlinux/slab.hlinux/debugfs.hasm/machdep.hasm/firmware.hasm/opal.hasm/prom.hlinux/uaccess.hasm/isa-bridge.h
Detected Declarations
struct lpc_debugfs_entryfunction opal_lpc_inbfunction __opal_lpc_inwfunction opal_lpc_inwfunction __opal_lpc_inlfunction opal_lpc_inlfunction opal_lpc_outbfunction __opal_lpc_outwfunction opal_lpc_outwfunction __opal_lpc_outlfunction opal_lpc_outlfunction opal_lpc_insbfunction opal_lpc_inswfunction opal_lpc_inslfunction opal_lpc_outsbfunction opal_lpc_outswfunction opal_lpc_outslfunction lpc_debug_readfunction positionsfunction lpc_debug_writefunction opal_lpc_debugfs_create_typefunction opal_lpc_init_debugfsfunction opal_lpc_init
Annotated Snippet
static const struct file_operations lpc_fops = {
.read = lpc_debug_read,
.write = lpc_debug_write,
.open = simple_open,
.llseek = default_llseek,
};
static int opal_lpc_debugfs_create_type(struct dentry *folder,
const char *fname,
enum OpalLPCAddressType type)
{
struct lpc_debugfs_entry *entry;
entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
entry->lpc_type = type;
debugfs_create_file(fname, 0600, folder, entry, &lpc_fops);
return 0;
}
static int opal_lpc_init_debugfs(void)
{
struct dentry *root;
int rc = 0;
if (opal_lpc_chip_id < 0)
return -ENODEV;
root = debugfs_create_dir("lpc", arch_debugfs_dir);
rc |= opal_lpc_debugfs_create_type(root, "io", OPAL_LPC_IO);
rc |= opal_lpc_debugfs_create_type(root, "mem", OPAL_LPC_MEM);
rc |= opal_lpc_debugfs_create_type(root, "fw", OPAL_LPC_FW);
return rc;
}
machine_device_initcall(powernv, opal_lpc_init_debugfs);
#endif /* CONFIG_DEBUG_FS */
void __init opal_lpc_init(void)
{
struct device_node *np;
/*
* Look for a Power8 LPC bus tagged as "primary",
* we currently support only one though the OPAL APIs
* support any number.
*/
for_each_compatible_node(np, NULL, "ibm,power8-lpc") {
if (!of_device_is_available(np))
continue;
if (!of_property_present(np, "primary"))
continue;
opal_lpc_chip_id = of_get_ibm_chip_id(np);
of_node_put(np);
break;
}
if (opal_lpc_chip_id < 0)
return;
/* Does it support direct mapping ? */
if (of_property_present(np, "ranges")) {
pr_info("OPAL: Found memory mapped LPC bus on chip %d\n",
opal_lpc_chip_id);
isa_bridge_init_non_pci(np);
} else {
pr_info("OPAL: Found non-mapped LPC bus on chip %d\n",
opal_lpc_chip_id);
/* Setup special IO ops */
ppc_pci_io = opal_lpc_io;
isa_io_special = true;
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/of.h`, `linux/bug.h`, `linux/io.h`, `linux/slab.h`, `linux/debugfs.h`, `asm/machdep.h`, `asm/firmware.h`.
- Detected declarations: `struct lpc_debugfs_entry`, `function opal_lpc_inb`, `function __opal_lpc_inw`, `function opal_lpc_inw`, `function __opal_lpc_inl`, `function opal_lpc_inl`, `function opal_lpc_outb`, `function __opal_lpc_outw`, `function opal_lpc_outw`, `function __opal_lpc_outl`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.