drivers/net/ethernet/qualcomm/qca_spi.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qualcomm/qca_spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/qualcomm/qca_spi.c- Extension
.c- Size
- 25374 bytes
- Lines
- 1051
- 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.
- 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/errno.hlinux/etherdevice.hlinux/if_arp.hlinux/if_ether.hlinux/init.hlinux/interrupt.hlinux/jiffies.hlinux/kernel.hlinux/kthread.hlinux/module.hlinux/moduleparam.hlinux/netdevice.hlinux/of.hlinux/of_net.hlinux/sched.hlinux/skbuff.hlinux/spi/spi.hlinux/types.hqca_7k.hqca_7k_common.hqca_debug.hqca_spi.h
Detected Declarations
function start_spi_intr_handlingfunction end_spi_intr_handlingfunction qcaspi_write_burstfunction qcaspi_write_legacyfunction qcaspi_read_burstfunction qcaspi_read_legacyfunction qcaspi_tx_cmdfunction qcaspi_tx_framefunction qcaspi_transmitfunction qcaspi_receivefunction qcaspi_tx_ring_has_spacefunction qcaspi_flush_tx_ringfunction qcaspi_qca7k_syncfunction qcaspi_spi_threadfunction qcaspi_intr_handlerfunction qcaspi_netdev_openfunction qcaspi_netdev_closefunction qcaspi_netdev_xmitfunction qcaspi_netdev_tx_timeoutfunction qcaspi_netdev_initfunction qcaspi_netdev_uninitfunction qcaspi_netdev_setupfunction qca_spi_probefunction qca_spi_remove
Annotated Snippet
static const struct net_device_ops qcaspi_netdev_ops = {
.ndo_init = qcaspi_netdev_init,
.ndo_uninit = qcaspi_netdev_uninit,
.ndo_open = qcaspi_netdev_open,
.ndo_stop = qcaspi_netdev_close,
.ndo_start_xmit = qcaspi_netdev_xmit,
.ndo_set_mac_address = eth_mac_addr,
.ndo_tx_timeout = qcaspi_netdev_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
};
static void
qcaspi_netdev_setup(struct net_device *dev)
{
struct qcaspi *qca = NULL;
dev->netdev_ops = &qcaspi_netdev_ops;
qcaspi_set_ethtool_ops(dev);
dev->watchdog_timeo = QCASPI_TX_TIMEOUT;
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
dev->needed_tailroom = ALIGN(QCAFRM_FOOTER_LEN + QCAFRM_MIN_LEN, 4);
dev->needed_headroom = ALIGN(QCAFRM_HEADER_LEN, 4);
dev->tx_queue_len = 100;
/* MTU range: 46 - 1500 */
dev->min_mtu = QCAFRM_MIN_MTU;
dev->max_mtu = QCAFRM_MAX_MTU;
qca = netdev_priv(dev);
memset(qca, 0, sizeof(struct qcaspi));
memset(&qca->txr, 0, sizeof(qca->txr));
qca->txr.count = QCASPI_TX_RING_MAX_LEN;
}
static const struct of_device_id qca_spi_of_match[] = {
{ .compatible = "qca,qca7000" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, qca_spi_of_match);
static int
qca_spi_probe(struct spi_device *spi)
{
struct qcaspi *qca = NULL;
struct net_device *qcaspi_devs = NULL;
u8 legacy_mode = 0;
u16 signature;
int ret;
if (!spi->dev.of_node) {
dev_err(&spi->dev, "Missing device tree\n");
return -EINVAL;
}
legacy_mode = of_property_read_bool(spi->dev.of_node,
"qca,legacy-mode");
if (qcaspi_clkspeed)
spi->max_speed_hz = qcaspi_clkspeed;
else if (!spi->max_speed_hz)
spi->max_speed_hz = QCASPI_CLK_SPEED;
if (spi->max_speed_hz < QCASPI_CLK_SPEED_MIN ||
spi->max_speed_hz > QCASPI_CLK_SPEED_MAX) {
dev_err(&spi->dev, "Invalid clkspeed: %u\n",
spi->max_speed_hz);
return -EINVAL;
}
if ((qcaspi_burst_len < QCASPI_BURST_LEN_MIN) ||
(qcaspi_burst_len > QCASPI_BURST_LEN_MAX)) {
dev_err(&spi->dev, "Invalid burst len: %d\n",
qcaspi_burst_len);
return -EINVAL;
}
if ((qcaspi_pluggable < QCASPI_PLUGGABLE_MIN) ||
(qcaspi_pluggable > QCASPI_PLUGGABLE_MAX)) {
dev_err(&spi->dev, "Invalid pluggable: %d\n",
qcaspi_pluggable);
return -EINVAL;
}
if (wr_verify < QCASPI_WRITE_VERIFY_MIN ||
wr_verify > QCASPI_WRITE_VERIFY_MAX) {
dev_err(&spi->dev, "Invalid write verify: %d\n",
wr_verify);
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/etherdevice.h`, `linux/if_arp.h`, `linux/if_ether.h`, `linux/init.h`, `linux/interrupt.h`, `linux/jiffies.h`, `linux/kernel.h`.
- Detected declarations: `function start_spi_intr_handling`, `function end_spi_intr_handling`, `function qcaspi_write_burst`, `function qcaspi_write_legacy`, `function qcaspi_read_burst`, `function qcaspi_read_legacy`, `function qcaspi_tx_cmd`, `function qcaspi_tx_frame`, `function qcaspi_transmit`, `function qcaspi_receive`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.