drivers/net/dsa/b53/b53_srab.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/b53/b53_srab.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/b53/b53_srab.c- Extension
.c- Size
- 16623 bytes
- Lines
- 697
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/kernel.hlinux/module.hlinux/delay.hlinux/interrupt.hlinux/platform_device.hlinux/platform_data/b53.hlinux/of.hb53_priv.hb53_serdes.h
Detected Declarations
struct b53_srab_port_privstruct b53_srab_privfunction b53_srab_request_grantfunction b53_srab_release_grantfunction b53_srab_opfunction b53_srab_read8function b53_srab_read16function b53_srab_read32function b53_srab_read48function b53_srab_read64function b53_srab_write8function b53_srab_write16function b53_srab_write32function b53_srab_write48function b53_srab_write64function b53_srab_port_threadfunction b53_srab_port_isrfunction b53_srab_serdes_map_lanefunction b53_srab_irq_enablefunction b53_srab_irq_disablefunction b53_srab_phylink_get_capsfunction b53_srab_intr_setfunction b53_srab_prepare_irqfunction b53_srab_mux_initfunction b53_srab_probefunction b53_srab_removefunction b53_srab_shutdown
Annotated Snippet
struct b53_srab_port_priv {
int irq;
bool irq_enabled;
struct b53_device *dev;
unsigned int num;
phy_interface_t mode;
};
struct b53_srab_priv {
void __iomem *regs;
void __iomem *mux_config;
struct b53_srab_port_priv port_intrs[B53_N_PORTS];
};
static int b53_srab_request_grant(struct b53_device *dev)
{
struct b53_srab_priv *priv = dev->priv;
u8 __iomem *regs = priv->regs;
u32 ctrls;
int i;
ctrls = readl(regs + B53_SRAB_CTRLS);
ctrls |= B53_SRAB_CTRLS_RCAREQ;
writel(ctrls, regs + B53_SRAB_CTRLS);
for (i = 0; i < 20; i++) {
ctrls = readl(regs + B53_SRAB_CTRLS);
if (ctrls & B53_SRAB_CTRLS_RCAGNT)
break;
usleep_range(10, 100);
}
if (WARN_ON(i == 5))
return -EIO;
return 0;
}
static void b53_srab_release_grant(struct b53_device *dev)
{
struct b53_srab_priv *priv = dev->priv;
u8 __iomem *regs = priv->regs;
u32 ctrls;
ctrls = readl(regs + B53_SRAB_CTRLS);
ctrls &= ~B53_SRAB_CTRLS_RCAREQ;
writel(ctrls, regs + B53_SRAB_CTRLS);
}
static int b53_srab_op(struct b53_device *dev, u8 page, u8 reg, u32 op)
{
struct b53_srab_priv *priv = dev->priv;
u8 __iomem *regs = priv->regs;
int i;
u32 cmdstat;
/* set register address */
cmdstat = (page << B53_SRAB_CMDSTAT_PAGE) |
(reg << B53_SRAB_CMDSTAT_REG) |
B53_SRAB_CMDSTAT_GORDYN |
op;
writel(cmdstat, regs + B53_SRAB_CMDSTAT);
/* check if operation completed */
for (i = 0; i < 5; ++i) {
cmdstat = readl(regs + B53_SRAB_CMDSTAT);
if (!(cmdstat & B53_SRAB_CMDSTAT_GORDYN))
break;
usleep_range(10, 100);
}
if (WARN_ON(i == 5))
return -EIO;
return 0;
}
static int b53_srab_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)
{
struct b53_srab_priv *priv = dev->priv;
u8 __iomem *regs = priv->regs;
int ret = 0;
ret = b53_srab_request_grant(dev);
if (ret)
goto err;
ret = b53_srab_op(dev, page, reg, 0);
if (ret)
goto err;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/platform_data/b53.h`, `linux/of.h`, `b53_priv.h`.
- Detected declarations: `struct b53_srab_port_priv`, `struct b53_srab_priv`, `function b53_srab_request_grant`, `function b53_srab_release_grant`, `function b53_srab_op`, `function b53_srab_read8`, `function b53_srab_read16`, `function b53_srab_read32`, `function b53_srab_read48`, `function b53_srab_read64`.
- Atlas domain: Driver Families / drivers/net.
- 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.