drivers/fpga/altera-pr-ip-core.c
Source file repositories/reference/linux-study-clean/drivers/fpga/altera-pr-ip-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/fpga/altera-pr-ip-core.c- Extension
.c- Size
- 4812 bytes
- Lines
- 202
- Domain
- Driver Families
- Bucket
- drivers/fpga
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/delay.hlinux/fpga/altera-pr-ip-core.hlinux/fpga/fpga-mgr.hlinux/module.h
Detected Declarations
struct alt_pr_privfunction alt_pr_fpga_statefunction alt_pr_fpga_write_initfunction alt_pr_fpga_writefunction alt_pr_fpga_write_completefunction alt_pr_registerexport alt_pr_register
Annotated Snippet
struct alt_pr_priv {
void __iomem *reg_base;
};
static enum fpga_mgr_states alt_pr_fpga_state(struct fpga_manager *mgr)
{
struct alt_pr_priv *priv = mgr->priv;
const char *err = "unknown";
enum fpga_mgr_states ret = FPGA_MGR_STATE_UNKNOWN;
u32 val;
val = readl(priv->reg_base + ALT_PR_CSR_OFST);
val &= ALT_PR_CSR_STATUS_MSK;
switch (val) {
case ALT_PR_CSR_STATUS_NRESET:
return FPGA_MGR_STATE_RESET;
case ALT_PR_CSR_STATUS_PR_ERR:
err = "pr error";
ret = FPGA_MGR_STATE_WRITE_ERR;
break;
case ALT_PR_CSR_STATUS_CRC_ERR:
err = "crc error";
ret = FPGA_MGR_STATE_WRITE_ERR;
break;
case ALT_PR_CSR_STATUS_BAD_BITS:
err = "bad bits";
ret = FPGA_MGR_STATE_WRITE_ERR;
break;
case ALT_PR_CSR_STATUS_PR_IN_PROG:
return FPGA_MGR_STATE_WRITE;
case ALT_PR_CSR_STATUS_PR_SUCCESS:
return FPGA_MGR_STATE_OPERATING;
default:
break;
}
dev_err(&mgr->dev, "encountered error code %d (%s) in %s()\n",
val, err, __func__);
return ret;
}
static int alt_pr_fpga_write_init(struct fpga_manager *mgr,
struct fpga_image_info *info,
const char *buf, size_t count)
{
struct alt_pr_priv *priv = mgr->priv;
u32 val;
if (!(info->flags & FPGA_MGR_PARTIAL_RECONFIG)) {
dev_err(&mgr->dev, "%s Partial Reconfiguration flag not set\n",
__func__);
return -EINVAL;
}
val = readl(priv->reg_base + ALT_PR_CSR_OFST);
if (val & ALT_PR_CSR_PR_START) {
dev_err(&mgr->dev,
"%s Partial Reconfiguration already started\n",
__func__);
return -EINVAL;
}
writel(val | ALT_PR_CSR_PR_START, priv->reg_base + ALT_PR_CSR_OFST);
return 0;
}
static int alt_pr_fpga_write(struct fpga_manager *mgr, const char *buf,
size_t count)
{
struct alt_pr_priv *priv = mgr->priv;
u32 *buffer_32 = (u32 *)buf;
size_t i = 0;
if (!count)
return -EINVAL;
/* Write out the complete 32-bit chunks */
while (count >= sizeof(u32)) {
writel(buffer_32[i++], priv->reg_base);
count -= sizeof(u32);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/fpga/altera-pr-ip-core.h`, `linux/fpga/fpga-mgr.h`, `linux/module.h`.
- Detected declarations: `struct alt_pr_priv`, `function alt_pr_fpga_state`, `function alt_pr_fpga_write_init`, `function alt_pr_fpga_write`, `function alt_pr_fpga_write_complete`, `function alt_pr_register`, `export alt_pr_register`.
- Atlas domain: Driver Families / drivers/fpga.
- Implementation status: integration 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.