drivers/spi/spi-armada-3700.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-armada-3700.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-armada-3700.c- Extension
.c- Size
- 23582 bytes
- Lines
- 898
- Domain
- Driver Families
- Bucket
- drivers/spi
- 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.
- 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/clk.hlinux/completion.hlinux/delay.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pinctrl/consumer.hlinux/spi/spi.h
Detected Declarations
struct a3700_spifunction spireg_readfunction spireg_writefunction a3700_spi_auto_cs_unsetfunction a3700_spi_activate_csfunction a3700_spi_deactivate_csfunction a3700_spi_pin_mode_setfunction a3700_spi_fifo_mode_setfunction a3700_spi_mode_setfunction a3700_spi_clock_setfunction a3700_spi_bytelen_setfunction a3700_spi_fifo_flushfunction a3700_spi_initfunction a3700_spi_interruptfunction a3700_spi_wait_completionfunction a3700_spi_transfer_waitfunction a3700_spi_fifo_thres_setfunction a3700_spi_transfer_setupfunction a3700_spi_set_csfunction a3700_spi_header_setfunction a3700_is_wfifo_fullfunction a3700_spi_fifo_writefunction a3700_is_rfifo_emptyfunction a3700_spi_fifo_readfunction a3700_spi_transfer_abort_fifofunction a3700_spi_prepare_messagefunction a3700_spi_transfer_one_fifofunction a3700_spi_transfer_one_full_duplexfunction a3700_spi_transfer_onefunction a3700_spi_unprepare_messagefunction a3700_spi_probe
Annotated Snippet
struct a3700_spi {
struct spi_controller *host;
void __iomem *base;
struct clk *clk;
unsigned int irq;
unsigned int flags;
bool xmit_data;
const u8 *tx_buf;
u8 *rx_buf;
size_t buf_len;
u8 byte_len;
u32 wait_mask;
struct completion done;
};
static u32 spireg_read(struct a3700_spi *a3700_spi, u32 offset)
{
return readl(a3700_spi->base + offset);
}
static void spireg_write(struct a3700_spi *a3700_spi, u32 offset, u32 data)
{
writel(data, a3700_spi->base + offset);
}
static void a3700_spi_auto_cs_unset(struct a3700_spi *a3700_spi)
{
u32 val;
val = spireg_read(a3700_spi, A3700_SPI_IF_CFG_REG);
val &= ~A3700_SPI_AUTO_CS;
spireg_write(a3700_spi, A3700_SPI_IF_CFG_REG, val);
}
static void a3700_spi_activate_cs(struct a3700_spi *a3700_spi, unsigned int cs)
{
u32 val;
val = spireg_read(a3700_spi, A3700_SPI_IF_CTRL_REG);
val |= (A3700_SPI_EN << cs);
spireg_write(a3700_spi, A3700_SPI_IF_CTRL_REG, val);
}
static void a3700_spi_deactivate_cs(struct a3700_spi *a3700_spi,
unsigned int cs)
{
u32 val;
val = spireg_read(a3700_spi, A3700_SPI_IF_CTRL_REG);
val &= ~(A3700_SPI_EN << cs);
spireg_write(a3700_spi, A3700_SPI_IF_CTRL_REG, val);
}
static int a3700_spi_pin_mode_set(struct a3700_spi *a3700_spi,
unsigned int pin_mode, bool receiving)
{
u32 val;
val = spireg_read(a3700_spi, A3700_SPI_IF_CFG_REG);
val &= ~(A3700_SPI_INST_PIN | A3700_SPI_ADDR_PIN);
val &= ~(A3700_SPI_DATA_PIN0 | A3700_SPI_DATA_PIN1);
switch (pin_mode) {
case SPI_NBITS_SINGLE:
break;
case SPI_NBITS_DUAL:
val |= A3700_SPI_DATA_PIN0;
break;
case SPI_NBITS_QUAD:
val |= A3700_SPI_DATA_PIN1;
/* RX during address reception uses 4-pin */
if (receiving)
val |= A3700_SPI_ADDR_PIN;
break;
default:
dev_err(&a3700_spi->host->dev, "wrong pin mode %u", pin_mode);
return -EINVAL;
}
spireg_write(a3700_spi, A3700_SPI_IF_CFG_REG, val);
return 0;
}
static void a3700_spi_fifo_mode_set(struct a3700_spi *a3700_spi, bool enable)
{
u32 val;
val = spireg_read(a3700_spi, A3700_SPI_IF_CFG_REG);
if (enable)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct a3700_spi`, `function spireg_read`, `function spireg_write`, `function a3700_spi_auto_cs_unset`, `function a3700_spi_activate_cs`, `function a3700_spi_deactivate_cs`, `function a3700_spi_pin_mode_set`, `function a3700_spi_fifo_mode_set`, `function a3700_spi_mode_set`, `function a3700_spi_clock_set`.
- Atlas domain: Driver Families / drivers/spi.
- Implementation status: source 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.