drivers/fpga/socfpga.c
Source file repositories/reference/linux-study-clean/drivers/fpga/socfpga.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/fpga/socfpga.c- Extension
.c- Size
- 17091 bytes
- Lines
- 599
- Domain
- Driver Families
- Bucket
- drivers/fpga
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/completion.hlinux/delay.hlinux/fpga/fpga-mgr.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of_address.hlinux/of_irq.hlinux/pm.h
Detected Declarations
struct socfpga_fpga_privstruct cfgmgr_modefunction socfpga_fpga_readlfunction socfpga_fpga_writelfunction socfpga_fpga_raw_readlfunction socfpga_fpga_raw_writelfunction socfpga_fpga_data_writelfunction socfpga_fpga_set_bitslfunction socfpga_fpga_clr_bitslfunction socfpga_fpga_mon_status_getfunction socfpga_fpga_state_getfunction socfpga_fpga_clear_done_statusfunction socfpga_fpga_dclk_set_and_wait_clearfunction socfpga_fpga_wait_for_statefunction socfpga_fpga_enable_irqsfunction socfpga_fpga_disable_irqsfunction socfpga_fpga_isrfunction socfpga_fpga_wait_for_config_donefunction socfpga_fpga_cfg_mode_getfunction socfpga_fpga_cfg_mode_setfunction socfpga_fpga_resetfunction socfpga_fpga_ops_configure_initfunction socfpga_fpga_ops_configure_writefunction socfpga_fpga_ops_configure_completefunction socfpga_fpga_ops_statefunction socfpga_fpga_probe
Annotated Snippet
struct socfpga_fpga_priv {
void __iomem *fpga_base_addr;
void __iomem *fpga_data_addr;
struct completion status_complete;
int irq;
};
struct cfgmgr_mode {
/* Values to set in the CTRL register */
u32 ctrl;
/* flag that this table entry is a valid mode */
bool valid;
};
/* For SOCFPGA_FPGMGR_STAT_MSEL field */
static struct cfgmgr_mode cfgmgr_modes[] = {
[MSEL_PP16_FAST_NOAES_NODC] = { CFGWDTH_16 | CDRATIO_X1, 1 },
[MSEL_PP16_FAST_AES_NODC] = { CFGWDTH_16 | CDRATIO_X2, 1 },
[MSEL_PP16_FAST_AESOPT_DC] = { CFGWDTH_16 | CDRATIO_X4, 1 },
[MSEL_PP16_SLOW_NOAES_NODC] = { CFGWDTH_16 | CDRATIO_X1, 1 },
[MSEL_PP16_SLOW_AES_NODC] = { CFGWDTH_16 | CDRATIO_X2, 1 },
[MSEL_PP16_SLOW_AESOPT_DC] = { CFGWDTH_16 | CDRATIO_X4, 1 },
[MSEL_PP32_FAST_NOAES_NODC] = { CFGWDTH_32 | CDRATIO_X1, 1 },
[MSEL_PP32_FAST_AES_NODC] = { CFGWDTH_32 | CDRATIO_X4, 1 },
[MSEL_PP32_FAST_AESOPT_DC] = { CFGWDTH_32 | CDRATIO_X8, 1 },
[MSEL_PP32_SLOW_NOAES_NODC] = { CFGWDTH_32 | CDRATIO_X1, 1 },
[MSEL_PP32_SLOW_AES_NODC] = { CFGWDTH_32 | CDRATIO_X4, 1 },
[MSEL_PP32_SLOW_AESOPT_DC] = { CFGWDTH_32 | CDRATIO_X8, 1 },
};
static u32 socfpga_fpga_readl(struct socfpga_fpga_priv *priv, u32 reg_offset)
{
return readl(priv->fpga_base_addr + reg_offset);
}
static void socfpga_fpga_writel(struct socfpga_fpga_priv *priv, u32 reg_offset,
u32 value)
{
writel(value, priv->fpga_base_addr + reg_offset);
}
static u32 socfpga_fpga_raw_readl(struct socfpga_fpga_priv *priv,
u32 reg_offset)
{
return __raw_readl(priv->fpga_base_addr + reg_offset);
}
static void socfpga_fpga_raw_writel(struct socfpga_fpga_priv *priv,
u32 reg_offset, u32 value)
{
__raw_writel(value, priv->fpga_base_addr + reg_offset);
}
static void socfpga_fpga_data_writel(struct socfpga_fpga_priv *priv, u32 value)
{
writel(value, priv->fpga_data_addr);
}
static inline void socfpga_fpga_set_bitsl(struct socfpga_fpga_priv *priv,
u32 offset, u32 bits)
{
u32 val;
val = socfpga_fpga_readl(priv, offset);
val |= bits;
socfpga_fpga_writel(priv, offset, val);
}
static inline void socfpga_fpga_clr_bitsl(struct socfpga_fpga_priv *priv,
u32 offset, u32 bits)
{
u32 val;
val = socfpga_fpga_readl(priv, offset);
val &= ~bits;
socfpga_fpga_writel(priv, offset, val);
}
static u32 socfpga_fpga_mon_status_get(struct socfpga_fpga_priv *priv)
{
return socfpga_fpga_readl(priv, SOCFPGA_FPGMGR_GPIO_EXT_PORTA_OFST) &
SOCFPGA_FPGMGR_MON_STATUS_MASK;
}
static u32 socfpga_fpga_state_get(struct socfpga_fpga_priv *priv)
{
u32 status = socfpga_fpga_mon_status_get(priv);
if ((status & SOCFPGA_FPGMGR_MON_FPGA_POWER_ON) == 0)
Annotation
- Immediate include surface: `linux/completion.h`, `linux/delay.h`, `linux/fpga/fpga-mgr.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/of_address.h`, `linux/of_irq.h`.
- Detected declarations: `struct socfpga_fpga_priv`, `struct cfgmgr_mode`, `function socfpga_fpga_readl`, `function socfpga_fpga_writel`, `function socfpga_fpga_raw_readl`, `function socfpga_fpga_raw_writel`, `function socfpga_fpga_data_writel`, `function socfpga_fpga_set_bitsl`, `function socfpga_fpga_clr_bitsl`, `function socfpga_fpga_mon_status_get`.
- Atlas domain: Driver Families / drivers/fpga.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.