drivers/platform/x86/amd/pmc/mp2_stb.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/amd/pmc/mp2_stb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/amd/pmc/mp2_stb.c- Extension
.c- Size
- 5947 bytes
- Lines
- 281
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- 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/debugfs.hlinux/device.hlinux/io.hlinux/io-64-nonatomic-lo-hi.hlinux/iopoll.hlinux/pci.hlinux/sizes.hlinux/time.hpmc.h
Detected Declarations
struct mp2_cmd_basestruct mp2_cmd_responsestruct mp2_stb_data_validfunction amd_mp2_wait_responsefunction amd_mp2_stb_send_cmdfunction amd_mp2_stb_regionfunction amd_mp2_process_cmdfunction amd_mp2_stb_debugfs_openfunction amd_mp2_stb_debugfs_readfunction amd_mp2_dbgfs_registerfunction amd_mp2_stb_deinitfunction amd_mp2_stb_init
Annotated Snippet
static const struct file_operations amd_mp2_stb_debugfs_fops = {
.owner = THIS_MODULE,
.open = amd_mp2_stb_debugfs_open,
.read = amd_mp2_stb_debugfs_read,
};
static void amd_mp2_dbgfs_register(struct amd_pmc_dev *dev)
{
if (!dev->dbgfs_dir)
return;
debugfs_create_file("stb_read_previous_boot", 0644, dev->dbgfs_dir, dev,
&amd_mp2_stb_debugfs_fops);
}
void amd_mp2_stb_deinit(struct amd_pmc_dev *dev)
{
struct amd_mp2_dev *mp2 = dev->mp2;
struct pci_dev *pdev;
if (mp2 && mp2->pdev) {
pdev = mp2->pdev;
if (mp2->mmio)
pci_clear_master(pdev);
pci_dev_put(pdev);
if (mp2->devres_gid)
devres_release_group(&pdev->dev, mp2->devres_gid);
dev->mp2 = NULL;
}
}
void amd_mp2_stb_init(struct amd_pmc_dev *dev)
{
struct amd_mp2_dev *mp2 = NULL;
struct pci_dev *pdev;
int rc;
mp2 = devm_kzalloc(dev->dev, sizeof(*mp2), GFP_KERNEL);
if (!mp2)
return;
pdev = pci_get_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MP2_STB, NULL);
if (!pdev)
return;
dev->mp2 = mp2;
mp2->pdev = pdev;
mp2->devres_gid = devres_open_group(&pdev->dev, NULL, GFP_KERNEL);
if (!mp2->devres_gid) {
dev_err(&pdev->dev, "devres_open_group failed\n");
goto mp2_error;
}
rc = pcim_enable_device(pdev);
if (rc) {
dev_err(&pdev->dev, "pcim_enable_device failed\n");
goto mp2_error;
}
rc = pcim_iomap_regions(pdev, BIT(MP2_MMIO_BAR), "mp2 stb");
if (rc) {
dev_err(&pdev->dev, "pcim_iomap_regions failed\n");
goto mp2_error;
}
mp2->mmio = pcim_iomap_table(pdev)[MP2_MMIO_BAR];
if (!mp2->mmio) {
dev_err(&pdev->dev, "pcim_iomap_table failed\n");
goto mp2_error;
}
pci_set_master(pdev);
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (rc) {
dev_err(&pdev->dev, "failed to set DMA mask\n");
goto mp2_error;
}
amd_mp2_dbgfs_register(dev);
return;
mp2_error:
amd_mp2_stb_deinit(dev);
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/device.h`, `linux/io.h`, `linux/io-64-nonatomic-lo-hi.h`, `linux/iopoll.h`, `linux/pci.h`, `linux/sizes.h`, `linux/time.h`.
- Detected declarations: `struct mp2_cmd_base`, `struct mp2_cmd_response`, `struct mp2_stb_data_valid`, `function amd_mp2_wait_response`, `function amd_mp2_stb_send_cmd`, `function amd_mp2_stb_region`, `function amd_mp2_process_cmd`, `function amd_mp2_stb_debugfs_open`, `function amd_mp2_stb_debugfs_read`, `function amd_mp2_dbgfs_register`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: pattern 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.