drivers/net/ethernet/asix/ax88796c_spi.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/asix/ax88796c_spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/asix/ax88796c_spi.c- Extension
.c- Size
- 2926 bytes
- Lines
- 116
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/string.hlinux/spi/spi.hax88796c_spi.h
Detected Declarations
function axspi_wakeupfunction axspi_read_statusfunction axspi_read_rxqfunction axspi_write_txqfunction axspi_read_regfunction axspi_write_reg
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2010 ASIX Electronics Corporation
* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* ASIX AX88796C SPI Fast Ethernet Linux driver
*/
#define pr_fmt(fmt) "ax88796c: " fmt
#include <linux/string.h>
#include <linux/spi/spi.h>
#include "ax88796c_spi.h"
const u8 ax88796c_rx_cmd_buf[5] = {AX_SPICMD_READ_RXQ, 0xFF, 0xFF, 0xFF, 0xFF};
const u8 ax88796c_tx_cmd_buf[4] = {AX_SPICMD_WRITE_TXQ, 0xFF, 0xFF, 0xFF};
/* driver bus management functions */
int axspi_wakeup(struct axspi_data *ax_spi)
{
int ret;
ax_spi->cmd_buf[0] = AX_SPICMD_EXIT_PWD; /* OP */
ret = spi_write(ax_spi->spi, ax_spi->cmd_buf, 1);
if (ret)
dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret);
return ret;
}
int axspi_read_status(struct axspi_data *ax_spi, struct spi_status *status)
{
int ret;
/* OP */
ax_spi->cmd_buf[0] = AX_SPICMD_READ_STATUS;
ret = spi_write_then_read(ax_spi->spi, ax_spi->cmd_buf, 1, (u8 *)status, 3);
if (ret)
dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret);
else
le16_to_cpus(&status->isr);
return ret;
}
int axspi_read_rxq(struct axspi_data *ax_spi, void *data, int len)
{
struct spi_transfer *xfer = ax_spi->spi_rx_xfer;
int ret;
memcpy(ax_spi->cmd_buf, ax88796c_rx_cmd_buf, 5);
xfer->tx_buf = ax_spi->cmd_buf;
xfer->rx_buf = NULL;
xfer->len = ax_spi->comp ? 2 : 5;
xfer->bits_per_word = 8;
spi_message_add_tail(xfer, &ax_spi->rx_msg);
xfer++;
xfer->rx_buf = data;
xfer->tx_buf = NULL;
xfer->len = len;
xfer->bits_per_word = 8;
spi_message_add_tail(xfer, &ax_spi->rx_msg);
ret = spi_sync(ax_spi->spi, &ax_spi->rx_msg);
if (ret)
dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret);
return ret;
}
int axspi_write_txq(const struct axspi_data *ax_spi, void *data, int len)
{
return spi_write(ax_spi->spi, data, len);
}
u16 axspi_read_reg(struct axspi_data *ax_spi, u8 reg)
{
int ret;
int len = ax_spi->comp ? 3 : 4;
ax_spi->cmd_buf[0] = 0x03; /* OP code read register */
ax_spi->cmd_buf[1] = reg; /* register address */
ax_spi->cmd_buf[2] = 0xFF; /* dumy cycle */
ax_spi->cmd_buf[3] = 0xFF; /* dumy cycle */
ret = spi_write_then_read(ax_spi->spi,
ax_spi->cmd_buf, len,
ax_spi->rx_buf, 2);
if (ret) {
dev_err(&ax_spi->spi->dev,
Annotation
- Immediate include surface: `linux/string.h`, `linux/spi/spi.h`, `ax88796c_spi.h`.
- Detected declarations: `function axspi_wakeup`, `function axspi_read_status`, `function axspi_read_rxq`, `function axspi_write_txq`, `function axspi_read_reg`, `function axspi_write_reg`.
- Atlas domain: Driver Families / drivers/net.
- 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.