drivers/net/ieee802154/cc2520.c
Source file repositories/reference/linux-study-clean/drivers/net/ieee802154/cc2520.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ieee802154/cc2520.c- Extension
.c- Size
- 28912 bytes
- Lines
- 1193
- 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.
- 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.
- 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/gpio/consumer.hlinux/delay.hlinux/spi/spi.hlinux/property.hlinux/workqueue.hlinux/interrupt.hlinux/skbuff.hlinux/ieee802154.hlinux/crc-ccitt.hlinux/unaligned.hnet/mac802154.hnet/cfg802154.h
Detected Declarations
struct cc2520_privatefunction cc2520_cmd_strobefunction cc2520_get_statusfunction cc2520_write_registerfunction cc2520_write_ramfunction cc2520_read_registerfunction cc2520_write_txfifofunction cc2520_read_rxfifofunction cc2520_startfunction cc2520_stopfunction cc2520_txfunction cc2520_rxfunction CRCfunction cc2520_edfunction cc2520_set_channelfunction cc2520_filterfunction cc2520_set_tx_powerfunction cc2520_cc2591_set_tx_powerfunction cc2520_set_txpowerfunction cc2520_set_promiscuous_modefunction cc2520_registerfunction cc2520_fifop_irqworkfunction cc2520_fifop_isrfunction cc2520_sfd_isrfunction cc2520_hw_initfunction cc2520_probefunction cc2520_remove
Annotated Snippet
struct cc2520_private {
struct spi_device *spi; /* SPI device structure */
struct ieee802154_hw *hw; /* IEEE-802.15.4 device */
u8 *buf; /* SPI TX/Rx data buffer */
struct mutex buffer_mutex; /* SPI buffer mutex */
bool is_tx; /* Flag for sync b/w Tx and Rx */
bool amplified; /* Flag for CC2591 */
struct gpio_desc *fifo_pin; /* FIFO GPIO pin number */
struct work_struct fifop_irqwork;/* Workqueue for FIFOP */
spinlock_t lock; /* Lock for is_tx*/
struct completion tx_complete; /* Work completion for Tx */
bool promiscuous; /* Flag for promiscuous mode */
};
/* Generic Functions */
static int
cc2520_cmd_strobe(struct cc2520_private *priv, u8 cmd)
{
int ret;
struct spi_message msg;
struct spi_transfer xfer = {
.len = 0,
.tx_buf = priv->buf,
.rx_buf = priv->buf,
};
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
mutex_lock(&priv->buffer_mutex);
priv->buf[xfer.len++] = cmd;
dev_vdbg(&priv->spi->dev,
"command strobe buf[0] = %02x\n",
priv->buf[0]);
ret = spi_sync(priv->spi, &msg);
dev_vdbg(&priv->spi->dev,
"buf[0] = %02x\n", priv->buf[0]);
mutex_unlock(&priv->buffer_mutex);
return ret;
}
static int
cc2520_get_status(struct cc2520_private *priv, u8 *status)
{
int ret;
struct spi_message msg;
struct spi_transfer xfer = {
.len = 0,
.tx_buf = priv->buf,
.rx_buf = priv->buf,
};
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
mutex_lock(&priv->buffer_mutex);
priv->buf[xfer.len++] = CC2520_CMD_SNOP;
dev_vdbg(&priv->spi->dev,
"get status command buf[0] = %02x\n", priv->buf[0]);
ret = spi_sync(priv->spi, &msg);
if (!ret)
*status = priv->buf[0];
dev_vdbg(&priv->spi->dev,
"buf[0] = %02x\n", priv->buf[0]);
mutex_unlock(&priv->buffer_mutex);
return ret;
}
static int
cc2520_write_register(struct cc2520_private *priv, u8 reg, u8 value)
{
int status;
struct spi_message msg;
struct spi_transfer xfer = {
.len = 0,
.tx_buf = priv->buf,
.rx_buf = priv->buf,
};
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
mutex_lock(&priv->buffer_mutex);
if (reg <= CC2520_FREG_MASK) {
priv->buf[xfer.len++] = CC2520_CMD_REGISTER_WRITE | reg;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/gpio/consumer.h`, `linux/delay.h`, `linux/spi/spi.h`, `linux/property.h`, `linux/workqueue.h`, `linux/interrupt.h`.
- Detected declarations: `struct cc2520_private`, `function cc2520_cmd_strobe`, `function cc2520_get_status`, `function cc2520_write_register`, `function cc2520_write_ram`, `function cc2520_read_register`, `function cc2520_write_txfifo`, `function cc2520_read_rxfifo`, `function cc2520_start`, `function cc2520_stop`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.