drivers/fpga/dfl-n3000-nios.c
Source file repositories/reference/linux-study-clean/drivers/fpga/dfl-n3000-nios.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/fpga/dfl-n3000-nios.c- Extension
.c- Size
- 18088 bytes
- Lines
- 589
- 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.
- 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/bitfield.hlinux/dfl.hlinux/errno.hlinux/io.hlinux/io-64-nonatomic-lo-hi.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/regmap.hlinux/stddef.hlinux/spi/altera.hlinux/spi/spi.hlinux/types.h
Detected Declarations
struct n3000_niosfunction nios_fw_version_showfunction get_retimer_modefunction retimer_A_mode_showfunction retimer_B_mode_showfunction fec_mode_showfunction n3000_nios_init_done_checkfunction uninitializedfunction create_altera_spi_controllerfunction destroy_altera_spi_controllerfunction n3000_nios_poll_stat_timeoutfunction n3000_nios_reg_writefunction n3000_nios_reg_readfunction n3000_nios_probefunction n3000_nios_remove
Annotated Snippet
struct n3000_nios {
void __iomem *base;
struct regmap *regmap;
struct device *dev;
struct platform_device *altera_spi;
};
static ssize_t nios_fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct n3000_nios *nn = dev_get_drvdata(dev);
unsigned int val;
int ret;
ret = regmap_read(nn->regmap, N3000_NIOS_FW_VERSION, &val);
if (ret)
return ret;
return sysfs_emit(buf, "%x.%x.%x\n",
(u8)FIELD_GET(N3000_NIOS_FW_VERSION_MAJOR, val),
(u8)FIELD_GET(N3000_NIOS_FW_VERSION_MINOR, val),
(u8)FIELD_GET(N3000_NIOS_FW_VERSION_PATCH, val));
}
static DEVICE_ATTR_RO(nios_fw_version);
#define IS_MODE_STATUS_OK(mode_stat) \
(FIELD_GET(N3000_NIOS_PKVL_MODE_STS_GROUP_MSK, (mode_stat)) == \
N3000_NIOS_PKVL_MODE_STS_GROUP_OK)
#define IS_RETIMER_FEC_SUPPORTED(retimer_mode) \
((retimer_mode) != N3000_NIOS_PKVL_MODE_ID_RESET && \
(retimer_mode) != N3000_NIOS_PKVL_MODE_ID_4X10G)
static int get_retimer_mode(struct n3000_nios *nn, unsigned int mode_stat_reg,
unsigned int *retimer_mode)
{
unsigned int val;
int ret;
ret = regmap_read(nn->regmap, mode_stat_reg, &val);
if (ret)
return ret;
if (!IS_MODE_STATUS_OK(val))
return -EFAULT;
*retimer_mode = FIELD_GET(N3000_NIOS_PKVL_MODE_STS_ID_MSK, val);
return 0;
}
static ssize_t retimer_A_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct n3000_nios *nn = dev_get_drvdata(dev);
unsigned int mode;
int ret;
ret = get_retimer_mode(nn, N3000_NIOS_PKVL_A_MODE_STS, &mode);
if (ret)
return ret;
return sysfs_emit(buf, "0x%x\n", mode);
}
static DEVICE_ATTR_RO(retimer_A_mode);
static ssize_t retimer_B_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct n3000_nios *nn = dev_get_drvdata(dev);
unsigned int mode;
int ret;
ret = get_retimer_mode(nn, N3000_NIOS_PKVL_B_MODE_STS, &mode);
if (ret)
return ret;
return sysfs_emit(buf, "0x%x\n", mode);
}
static DEVICE_ATTR_RO(retimer_B_mode);
static ssize_t fec_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned int val, retimer_a_mode, retimer_b_mode, fec_modes;
struct n3000_nios *nn = dev_get_drvdata(dev);
int ret;
/* FEC mode setting is not supported in early FW versions */
ret = regmap_read(nn->regmap, N3000_NIOS_FW_VERSION, &val);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/dfl.h`, `linux/errno.h`, `linux/io.h`, `linux/io-64-nonatomic-lo-hi.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct n3000_nios`, `function nios_fw_version_show`, `function get_retimer_mode`, `function retimer_A_mode_show`, `function retimer_B_mode_show`, `function fec_mode_show`, `function n3000_nios_init_done_check`, `function uninitialized`, `function create_altera_spi_controller`, `function destroy_altera_spi_controller`.
- Atlas domain: Driver Families / drivers/fpga.
- Implementation status: source 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.