drivers/net/ethernet/microchip/encx24j600-regmap.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/encx24j600-regmap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/encx24j600-regmap.c- Extension
.c- Size
- 11806 bytes
- Lines
- 518
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/errno.hlinux/init.hlinux/module.hlinux/netdevice.hlinux/regmap.hlinux/spi/spi.hencx24j600_hw.h
Detected Declarations
function encx24j600_switch_bankfunction encx24j600_cmdnfunction regmap_lock_mutexfunction regmap_unlock_mutexfunction regmap_encx24j600_sfr_readfunction regmap_encx24j600_sfr_updatefunction regmap_encx24j600_sfr_writefunction regmap_encx24j600_sfr_set_bitsfunction regmap_encx24j600_sfr_clr_bitsfunction regmap_encx24j600_reg_update_bitsfunction regmap_encx24j600_spi_writefunction regmap_encx24j600_spi_readfunction regmap_encx24j600_writefunction regmap_encx24j600_readfunction encx24j600_regmap_readablefunction encx24j600_regmap_writeablefunction encx24j600_regmap_volatilefunction encx24j600_regmap_preciousfunction regmap_encx24j600_phy_reg_readfunction regmap_encx24j600_phy_reg_writefunction encx24j600_phymap_readablefunction encx24j600_phymap_writeablefunction encx24j600_phymap_volatilefunction devm_regmap_init_encx24j600export regmap_encx24j600_spi_writeexport regmap_encx24j600_spi_readexport devm_regmap_init_encx24j600
Annotated Snippet
switch (reg) {
case EGPRDPT:
cmd = RGPRDPT; break;
case EGPWRPT:
cmd = RGPWRPT; break;
case ERXRDPT:
cmd = RRXRDPT; break;
case ERXWRPT:
cmd = RRXWRPT; break;
case EUDARDPT:
cmd = RUDARDPT; break;
case EUDAWRPT:
cmd = RUDAWRPT; break;
case EGPDATA:
case ERXDATA:
case EUDADATA:
default:
return -EINVAL;
}
}
tx_buf[i++] = cmd;
if (cmd == RCRU)
tx_buf[i++] = reg;
ret = spi_write_then_read(ctx->spi, tx_buf, i, val, len);
return ret;
}
static int regmap_encx24j600_sfr_update(struct encx24j600_context *ctx,
u8 reg, u8 *val, size_t len,
u8 unbanked_cmd, u8 banked_code)
{
u8 banked_reg = reg & ADDR_MASK;
u8 bank = ((reg & BANK_MASK) >> BANK_SHIFT);
u8 cmd = unbanked_cmd;
struct spi_message m;
struct spi_transfer t[3] = { { .tx_buf = &cmd, .len = sizeof(cmd), },
{ .tx_buf = ®, .len = sizeof(reg), },
{ .tx_buf = val, .len = len }, };
if (reg < 0x80) {
int ret = 0;
cmd = banked_code | banked_reg;
if ((banked_reg < 0x16) && (ctx->bank != bank))
ret = encx24j600_switch_bank(ctx, bank);
if (unlikely(ret))
return ret;
} else {
/* Translate registers that are more efficient using
* 3-byte SPI commands
*/
switch (reg) {
case EGPRDPT:
cmd = WGPRDPT; break;
case EGPWRPT:
cmd = WGPWRPT; break;
case ERXRDPT:
cmd = WRXRDPT; break;
case ERXWRPT:
cmd = WRXWRPT; break;
case EUDARDPT:
cmd = WUDARDPT; break;
case EUDAWRPT:
cmd = WUDAWRPT; break;
case EGPDATA:
case ERXDATA:
case EUDADATA:
default:
return -EINVAL;
}
}
spi_message_init(&m);
spi_message_add_tail(&t[0], &m);
if (cmd == unbanked_cmd) {
t[1].tx_buf = ®
spi_message_add_tail(&t[1], &m);
}
spi_message_add_tail(&t[2], &m);
return spi_sync(ctx->spi, &m);
}
static int regmap_encx24j600_sfr_write(void *context, u8 reg, u8 *val,
size_t len)
{
Annotation
- Immediate include surface: `linux/delay.h`, `linux/errno.h`, `linux/init.h`, `linux/module.h`, `linux/netdevice.h`, `linux/regmap.h`, `linux/spi/spi.h`, `encx24j600_hw.h`.
- Detected declarations: `function encx24j600_switch_bank`, `function encx24j600_cmdn`, `function regmap_lock_mutex`, `function regmap_unlock_mutex`, `function regmap_encx24j600_sfr_read`, `function regmap_encx24j600_sfr_update`, `function regmap_encx24j600_sfr_write`, `function regmap_encx24j600_sfr_set_bits`, `function regmap_encx24j600_sfr_clr_bits`, `function regmap_encx24j600_reg_update_bits`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.