drivers/misc/keba/lan9252.c
Source file repositories/reference/linux-study-clean/drivers/misc/keba/lan9252.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/keba/lan9252.c- Extension
.c- Size
- 8136 bytes
- Lines
- 360
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/spi/spi.hlinux/mii.h
Detected Declarations
struct lan9252_read_cmdstruct lan9252_write_cmdfunction lan9252_spi_readfunction lan9252_spi_writefunction lan9252_initfunction lan9252_esc_get_sizefunction lan9252_esc_waitfunction lan9252_esc_readfunction lan9252_esc_writefunction lan9252_access_miifunction lan9252_mii_waitfunction lan9252_mii_readfunction lan9252_mii_writefunction lan9252_probe
Annotated Snippet
struct lan9252_read_cmd {
u8 cmd;
u8 addr_0;
u8 addr_1;
} __packed;
struct lan9252_write_cmd {
u8 cmd;
u8 addr_0;
u8 addr_1;
u32 data;
} __packed;
/* byte test register */
#define LAN9252_BYTE_TEST 0x64
#define LAN9252_BYTE_TEST_VALUE 0x87654321
/* hardware configuration register */
#define LAN9252_HW_CFG 0x74
#define LAN9252_HW_CFG_READY 0x08000000
/* EtherCAT CSR interface data register */
#define LAN9252_ECAT_CSR_DATA 0x300
/* EtherCAT CSR interface command register */
#define LAN9252_ECAT_CSR_CMD 0x304
#define LAN9252_ECAT_CSR_BUSY 0x80000000
#define LAN9252_ECAT_CSR_READ 0x40000000
/* EtherCAT slave controller MII register */
#define LAN9252_ESC_MII 0x510
#define LAN9252_ESC_MII_BUSY 0x8000
#define LAN9252_ESC_MII_CMD_ERR 0x4000
#define LAN9252_ESC_MII_READ_ERR 0x2000
#define LAN9252_ESC_MII_ERR_MASK (LAN9252_ESC_MII_CMD_ERR | \
LAN9252_ESC_MII_READ_ERR)
#define LAN9252_ESC_MII_WRITE 0x0200
#define LAN9252_ESC_MII_READ 0x0100
/* EtherCAT slave controller PHY address register */
#define LAN9252_ESC_PHY_ADDR 0x512
/* EtherCAT slave controller PHY register address register */
#define LAN9252_ESC_PHY_REG_ADDR 0x513
/* EtherCAT slave controller PHY data register */
#define LAN9252_ESC_PHY_DATA 0x514
/* EtherCAT slave controller PDI access state register */
#define LAN9252_ESC_MII_PDI 0x517
#define LAN9252_ESC_MII_ACCESS_PDI 0x01
#define LAN9252_ESC_MII_ACCESS_ECAT 0x00
/* PHY address */
#define PHY_ADDRESS 2
#define SPI_RETRY_COUNT 10
#define SPI_WAIT_US 100
#define SPI_CSR_WAIT_US 500
static int lan9252_spi_read(struct spi_device *spi, u16 addr, u32 *data)
{
struct lan9252_read_cmd cmd;
cmd.cmd = LAN9252_SPI_READ;
cmd.addr_0 = (addr >> 8) & 0xFF;
cmd.addr_1 = addr & 0xFF;
return spi_write_then_read(spi, (u8 *)&cmd,
sizeof(struct lan9252_read_cmd),
(u8 *)data, sizeof(u32));
}
static int lan9252_spi_write(struct spi_device *spi, u16 addr, u32 data)
{
struct lan9252_write_cmd cmd;
cmd.cmd = LAN9252_SPI_WRITE;
cmd.addr_0 = (addr >> 8) & 0xFF;
cmd.addr_1 = addr & 0xFF;
cmd.data = data;
return spi_write(spi, (u8 *)&cmd, sizeof(struct lan9252_write_cmd));
}
static bool lan9252_init(struct spi_device *spi)
{
u32 data;
int ret;
Annotation
- Immediate include surface: `linux/spi/spi.h`, `linux/mii.h`.
- Detected declarations: `struct lan9252_read_cmd`, `struct lan9252_write_cmd`, `function lan9252_spi_read`, `function lan9252_spi_write`, `function lan9252_init`, `function lan9252_esc_get_size`, `function lan9252_esc_wait`, `function lan9252_esc_read`, `function lan9252_esc_write`, `function lan9252_access_mii`.
- Atlas domain: Driver Families / drivers/misc.
- 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.