drivers/spi/spi-omap2-mcspi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-omap2-mcspi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-omap2-mcspi.c- Extension
.c- Size
- 43479 bytes
- Lines
- 1676
- 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.
- 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/interrupt.hlinux/module.hlinux/device.hlinux/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/err.hlinux/clk.hlinux/io.hlinux/slab.hlinux/pm_runtime.hlinux/of.hlinux/gcd.hlinux/spi/spi.hinternals.hlinux/platform_data/spi-omap2-mcspi.h
Detected Declarations
struct omap2_mcspi_dmastruct omap2_mcspi_regsstruct omap2_mcspistruct omap2_mcspi_csfunction mcspi_write_regfunction mcspi_read_regfunction mcspi_write_cs_regfunction mcspi_read_cs_regfunction mcspi_cached_chconf0function mcspi_write_chconf0function mcspi_bytes_per_wordfunction omap2_mcspi_set_dma_reqfunction omap2_mcspi_set_enablefunction omap2_mcspi_set_csfunction omap2_mcspi_set_modefunction omap2_mcspi_set_fifofunction mcspi_wait_for_reg_bitfunction mcspi_wait_for_completionfunction omap2_mcspi_rx_callbackfunction omap2_mcspi_tx_callbackfunction omap2_mcspi_tx_dmafunction omap2_mcspi_rx_dmafunction omap2_mcspi_txrx_dmafunction omap2_mcspi_txrx_piofunction omap2_mcspi_calc_divisorfunction omap2_mcspi_setup_transferfunction omap2_mcspi_request_dmafunction omap2_mcspi_release_dmafunction omap2_mcspi_cleanupfunction omap2_mcspi_setupfunction omap2_mcspi_irq_handlerfunction omap2_mcspi_target_abortfunction omap2_mcspi_transfer_onefunction omap2_mcspi_prepare_messagefunction list_for_each_entryfunction omap2_mcspi_can_dmafunction omap2_mcspi_max_xfer_sizefunction omap2_mcspi_controller_setupfunction omap_mcspi_runtime_suspendfunction omap_mcspi_runtime_resumefunction list_for_each_entryfunction omap2_mcspi_probefunction omap2_mcspi_removefunction omap2_mcspi_suspendfunction omap2_mcspi_resume
Annotated Snippet
struct omap2_mcspi_dma {
struct dma_chan *dma_tx;
struct dma_chan *dma_rx;
struct completion dma_tx_completion;
struct completion dma_rx_completion;
char dma_rx_ch_name[14];
char dma_tx_ch_name[14];
};
/* use PIO for small transfers, avoiding DMA setup/teardown overhead and
* cache operations; better heuristics consider wordsize and bitrate.
*/
#define DMA_MIN_BYTES 160
/*
* Used for context save and restore, structure members to be updated whenever
* corresponding registers are modified.
*/
struct omap2_mcspi_regs {
u32 modulctrl;
u32 wakeupenable;
struct list_head cs;
};
struct omap2_mcspi {
struct completion txdone;
struct spi_controller *ctlr;
/* Virtual base address of the controller */
void __iomem *base;
unsigned long phys;
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma *dma_channels;
struct device *dev;
struct omap2_mcspi_regs ctx;
struct clk *ref_clk;
int fifo_depth;
bool target_aborted;
unsigned int pin_dir:1;
size_t max_xfer_len;
u32 ref_clk_hz;
bool use_multi_mode;
bool last_msg_kept_cs;
};
struct omap2_mcspi_cs {
void __iomem *base;
unsigned long phys;
int word_len;
u16 mode;
struct list_head node;
/* Context save and restore shadow register */
u32 chconf0, chctrl0;
};
static inline void mcspi_write_reg(struct spi_controller *ctlr,
int idx, u32 val)
{
struct omap2_mcspi *mcspi = spi_controller_get_devdata(ctlr);
writel_relaxed(val, mcspi->base + idx);
}
static inline u32 mcspi_read_reg(struct spi_controller *ctlr, int idx)
{
struct omap2_mcspi *mcspi = spi_controller_get_devdata(ctlr);
return readl_relaxed(mcspi->base + idx);
}
static inline void mcspi_write_cs_reg(const struct spi_device *spi,
int idx, u32 val)
{
struct omap2_mcspi_cs *cs = spi->controller_state;
writel_relaxed(val, cs->base + idx);
}
static inline u32 mcspi_read_cs_reg(const struct spi_device *spi, int idx)
{
struct omap2_mcspi_cs *cs = spi->controller_state;
return readl_relaxed(cs->base + idx);
}
static inline u32 mcspi_cached_chconf0(const struct spi_device *spi)
{
struct omap2_mcspi_cs *cs = spi->controller_state;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/interrupt.h`, `linux/module.h`, `linux/device.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/pinctrl/consumer.h`.
- Detected declarations: `struct omap2_mcspi_dma`, `struct omap2_mcspi_regs`, `struct omap2_mcspi`, `struct omap2_mcspi_cs`, `function mcspi_write_reg`, `function mcspi_read_reg`, `function mcspi_write_cs_reg`, `function mcspi_read_cs_reg`, `function mcspi_cached_chconf0`, `function mcspi_write_chconf0`.
- 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.