drivers/spi/spi-ti-qspi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-ti-qspi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-ti-qspi.c- Extension
.c- Size
- 22826 bytes
- Lines
- 931
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/init.hlinux/interrupt.hlinux/module.hlinux/device.hlinux/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/omap-dma.hlinux/platform_device.hlinux/err.hlinux/clk.hlinux/io.hlinux/slab.hlinux/pm_runtime.hlinux/of.hlinux/pinctrl/consumer.hlinux/mfd/syscon.hlinux/regmap.hlinux/sizes.hlinux/spi/spi.hlinux/spi/spi-mem.h
Detected Declarations
struct ti_qspi_regsstruct ti_qspifunction ti_qspi_readfunction ti_qspi_writefunction ti_qspi_setupfunction ti_qspi_setup_clkfunction ti_qspi_restore_ctxfunction qspi_is_busyfunction ti_qspi_poll_wcfunction qspi_write_msgfunction qspi_read_msgfunction qspi_transfer_msgfunction ti_qspi_dma_callbackfunction ti_qspi_dma_xferfunction ti_qspi_dma_bounce_bufferfunction ti_qspi_dma_xfer_sgfunction for_each_sgfunction ti_qspi_enable_memory_mapfunction ti_qspi_disable_memory_mapfunction ti_qspi_setup_mmap_readfunction ti_qspi_adjust_op_sizefunction ti_qspi_exec_mem_opfunction ti_qspi_start_transfer_onefunction list_for_each_entryfunction ti_qspi_runtime_resumefunction ti_qspi_dma_cleanupfunction ti_qspi_probefunction ti_qspi_remove
Annotated Snippet
struct ti_qspi_regs {
u32 clkctrl;
};
struct ti_qspi {
struct completion transfer_complete;
/* list synchronization */
struct mutex list_lock;
struct spi_controller *host;
void __iomem *base;
void __iomem *mmap_base;
size_t mmap_size;
struct regmap *ctrl_base;
unsigned int ctrl_reg;
struct clk *fclk;
struct device *dev;
struct ti_qspi_regs ctx_reg;
dma_addr_t mmap_phys_base;
dma_addr_t rx_bb_dma_addr;
void *rx_bb_addr;
struct dma_chan *rx_chan;
u32 cmd;
u32 dc;
bool mmap_enabled;
int current_cs;
};
#define QSPI_PID (0x0)
#define QSPI_SYSCONFIG (0x10)
#define QSPI_SPI_CLOCK_CNTRL_REG (0x40)
#define QSPI_SPI_DC_REG (0x44)
#define QSPI_SPI_CMD_REG (0x48)
#define QSPI_SPI_STATUS_REG (0x4c)
#define QSPI_SPI_DATA_REG (0x50)
#define QSPI_SPI_SETUP_REG(n) ((0x54 + 4 * n))
#define QSPI_SPI_SWITCH_REG (0x64)
#define QSPI_SPI_DATA_REG_1 (0x68)
#define QSPI_SPI_DATA_REG_2 (0x6c)
#define QSPI_SPI_DATA_REG_3 (0x70)
#define QSPI_COMPLETION_TIMEOUT msecs_to_jiffies(2000)
/* Clock Control */
#define QSPI_CLK_EN (1 << 31)
#define QSPI_CLK_DIV_MAX 0xffff
/* Command */
#define QSPI_EN_CS(n) (n << 28)
#define QSPI_WLEN(n) ((n - 1) << 19)
#define QSPI_3_PIN (1 << 18)
#define QSPI_RD_SNGL (1 << 16)
#define QSPI_WR_SNGL (2 << 16)
#define QSPI_RD_DUAL (3 << 16)
#define QSPI_RD_QUAD (7 << 16)
#define QSPI_INVAL (4 << 16)
#define QSPI_FLEN(n) ((n - 1) << 0)
#define QSPI_WLEN_MAX_BITS 128
#define QSPI_WLEN_MAX_BYTES 16
#define QSPI_WLEN_MASK QSPI_WLEN(QSPI_WLEN_MAX_BITS)
/* STATUS REGISTER */
#define BUSY 0x01
#define WC 0x02
/* Device Control */
#define QSPI_DD(m, n) (m << (3 + n * 8))
#define QSPI_CKPHA(n) (1 << (2 + n * 8))
#define QSPI_CSPOL(n) (1 << (1 + n * 8))
#define QSPI_CKPOL(n) (1 << (n * 8))
#define QSPI_FRAME 4096
#define QSPI_AUTOSUSPEND_TIMEOUT 2000
#define MEM_CS_EN(n) ((n + 1) << 8)
#define MEM_CS_MASK (7 << 8)
#define MM_SWITCH 0x1
#define QSPI_SETUP_RD_NORMAL (0x0 << 12)
#define QSPI_SETUP_RD_DUAL (0x1 << 12)
#define QSPI_SETUP_RD_QUAD (0x3 << 12)
#define QSPI_SETUP_ADDR_SHIFT 8
#define QSPI_SETUP_DUMMY_SHIFT 10
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/interrupt.h`, `linux/module.h`, `linux/device.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`.
- Detected declarations: `struct ti_qspi_regs`, `struct ti_qspi`, `function ti_qspi_read`, `function ti_qspi_write`, `function ti_qspi_setup`, `function ti_qspi_setup_clk`, `function ti_qspi_restore_ctx`, `function qspi_is_busy`, `function ti_qspi_poll_wc`, `function qspi_write_msg`.
- Atlas domain: Driver Families / drivers/spi.
- 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.