drivers/net/ethernet/cirrus/cs89x0.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/cirrus/cs89x0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/cirrus/cs89x0.c- Extension
.c- Size
- 35931 bytes
- Lines
- 1286
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/printk.hlinux/errno.hlinux/netdevice.hlinux/etherdevice.hlinux/of.hlinux/platform_device.hlinux/kernel.hlinux/types.hlinux/fcntl.hlinux/interrupt.hlinux/ioport.hlinux/in.hlinux/jiffies.hlinux/skbuff.hlinux/spinlock.hlinux/string.hlinux/init.hlinux/bitops.hlinux/delay.hlinux/gfp.hlinux/io.hasm/irq.hlinux/atomic.hcs89x0.h
Detected Declarations
struct net_localfunction media_fnfunction readwordsfunction writewordsfunction readregfunction writeregfunction wait_eeprom_readyfunction get_eeprom_datafunction get_eeprom_cksumfunction write_irqfunction count_rx_errorsfunction control_dc_dcfunction send_test_pktfunction detect_tpfunction detect_bncfunction detect_auifunction net_rxfunction net_interruptfunction net_openfunction net_closefunction net_get_statsfunction net_timeoutfunction net_send_packetfunction set_multicast_listfunction set_mac_addressfunction net_poll_controllerfunction reset_chipfunction cs89x0_probe1function cs89x0_platform_probefunction cs89x0_platform_remove
Annotated Snippet
static const struct net_device_ops net_ops = {
.ndo_open = net_open,
.ndo_stop = net_close,
.ndo_tx_timeout = net_timeout,
.ndo_start_xmit = net_send_packet,
.ndo_get_stats = net_get_stats,
.ndo_set_rx_mode = set_multicast_list,
.ndo_set_mac_address = set_mac_address,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = net_poll_controller,
#endif
.ndo_validate_addr = eth_validate_addr,
};
static void __init reset_chip(struct net_device *dev)
{
struct net_local *lp = netdev_priv(dev);
unsigned long reset_start_time;
writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
/* wait 30 ms */
msleep(30);
if (lp->chip_type != CS8900) {
/* Hardware problem requires PNP registers to be reconfigured after a reset */
iowrite16(PP_CS8920_ISAINT, lp->virt_addr + ADD_PORT);
iowrite8(dev->irq, lp->virt_addr + DATA_PORT);
iowrite8(0, lp->virt_addr + DATA_PORT + 1);
iowrite16(PP_CS8920_ISAMemB, lp->virt_addr + ADD_PORT);
iowrite8((dev->mem_start >> 16) & 0xff,
lp->virt_addr + DATA_PORT);
iowrite8((dev->mem_start >> 8) & 0xff,
lp->virt_addr + DATA_PORT + 1);
}
/* Wait until the chip is reset */
reset_start_time = jiffies;
while ((readreg(dev, PP_SelfST) & INIT_DONE) == 0 &&
time_before(jiffies, reset_start_time + 2))
;
}
/* This is the real probe routine.
* Linux has a history of friendly device probes on the ISA bus.
* A good device probes avoids doing writes, and
* verifies that the correct device exists and functions.
* Return 0 on success.
*/
static int __init
cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
{
struct net_local *lp = netdev_priv(dev);
int i;
int tmp;
unsigned rev_type = 0;
int eeprom_buff[CHKSUM_LEN];
u8 addr[ETH_ALEN];
int retval;
/* Initialize the device structure. */
if (!modular) {
memset(lp, 0, sizeof(*lp));
spin_lock_init(&lp->lock);
#ifndef MODULE
lp->force = g_cs89x0_media__force;
#endif
}
pr_debug("PP_addr at %p[%x]: 0x%x\n",
ioaddr, ADD_PORT, ioread16(ioaddr + ADD_PORT));
iowrite16(PP_ChipID, ioaddr + ADD_PORT);
tmp = ioread16(ioaddr + DATA_PORT);
if (tmp != CHIP_EISA_ID_SIG) {
pr_debug("%s: incorrect signature at %p[%x]: 0x%x!="
CHIP_EISA_ID_SIG_STR "\n",
dev->name, ioaddr, DATA_PORT, tmp);
retval = -ENODEV;
goto out1;
}
lp->virt_addr = ioaddr;
/* get the chip type */
rev_type = readreg(dev, PRODUCT_ID_ADD);
lp->chip_type = rev_type & ~REVISON_BITS;
lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
Annotation
- Immediate include surface: `linux/module.h`, `linux/printk.h`, `linux/errno.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/of.h`, `linux/platform_device.h`, `linux/kernel.h`.
- Detected declarations: `struct net_local`, `function media_fn`, `function readwords`, `function writewords`, `function readreg`, `function writereg`, `function wait_eeprom_ready`, `function get_eeprom_data`, `function get_eeprom_cksum`, `function write_irq`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.