drivers/spi/spi-bcm2835aux.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-bcm2835aux.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-bcm2835aux.c- Extension
.c- Size
- 16662 bytes
- Lines
- 586
- 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/debugfs.hlinux/delay.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/spi/spi.hlinux/spinlock.h
Detected Declarations
struct bcm2835aux_spifunction bcm2835aux_debugfs_createfunction bcm2835aux_debugfs_removefunction bcm2835aux_debugfs_createfunction bcm2835aux_wrfunction bcm2835aux_rd_fifofunction bcm2835aux_wr_fifofunction bcm2835aux_spi_reset_hwfunction bcm2835aux_spi_transfer_helperfunction bcm2835aux_spi_interruptfunction __bcm2835aux_spi_transfer_one_irqfunction bcm2835aux_spi_transfer_one_irqfunction bcm2835aux_spi_transfer_one_pollfunction bcm2835aux_spi_transfer_onefunction bcm2835aux_spi_prepare_messagefunction bcm2835aux_spi_unprepare_messagefunction bcm2835aux_spi_handle_errfunction bcm2835aux_spi_setupfunction bcm2835aux_spi_probefunction bcm2835aux_spi_remove
Annotated Snippet
struct bcm2835aux_spi {
void __iomem *regs;
struct clk *clk;
int irq;
u32 cntl[2];
const u8 *tx_buf;
u8 *rx_buf;
int tx_len;
int rx_len;
int pending;
u64 count_transfer_polling;
u64 count_transfer_irq;
u64 count_transfer_irq_after_poll;
struct dentry *debugfs_dir;
};
#if defined(CONFIG_DEBUG_FS)
static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs,
const char *dname)
{
char name[64];
struct dentry *dir;
/* get full name */
snprintf(name, sizeof(name), "spi-bcm2835aux-%s", dname);
/* the base directory */
dir = debugfs_create_dir(name, NULL);
bs->debugfs_dir = dir;
/* the counters */
debugfs_create_u64("count_transfer_polling", 0444, dir,
&bs->count_transfer_polling);
debugfs_create_u64("count_transfer_irq", 0444, dir,
&bs->count_transfer_irq);
debugfs_create_u64("count_transfer_irq_after_poll", 0444, dir,
&bs->count_transfer_irq_after_poll);
}
static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs)
{
debugfs_remove_recursive(bs->debugfs_dir);
bs->debugfs_dir = NULL;
}
#else
static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs,
const char *dname)
{
}
static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs)
{
}
#endif /* CONFIG_DEBUG_FS */
static inline u32 bcm2835aux_rd(struct bcm2835aux_spi *bs, unsigned int reg)
{
return readl(bs->regs + reg);
}
static inline void bcm2835aux_wr(struct bcm2835aux_spi *bs, unsigned int reg,
u32 val)
{
writel(val, bs->regs + reg);
}
static inline void bcm2835aux_rd_fifo(struct bcm2835aux_spi *bs)
{
u32 data;
int count = min(bs->rx_len, 3);
data = bcm2835aux_rd(bs, BCM2835_AUX_SPI_IO);
if (bs->rx_buf) {
switch (count) {
case 3:
*bs->rx_buf++ = (data >> 16) & 0xff;
fallthrough;
case 2:
*bs->rx_buf++ = (data >> 8) & 0xff;
fallthrough;
case 1:
*bs->rx_buf++ = (data >> 0) & 0xff;
/* fallthrough - no default */
}
}
bs->rx_len -= count;
bs->pending -= count;
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/debugfs.h`, `linux/delay.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `struct bcm2835aux_spi`, `function bcm2835aux_debugfs_create`, `function bcm2835aux_debugfs_remove`, `function bcm2835aux_debugfs_create`, `function bcm2835aux_wr`, `function bcm2835aux_rd_fifo`, `function bcm2835aux_wr_fifo`, `function bcm2835aux_spi_reset_hw`, `function bcm2835aux_spi_transfer_helper`, `function bcm2835aux_spi_interrupt`.
- 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.