drivers/spi/spi-zynqmp-gqspi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-zynqmp-gqspi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-zynqmp-gqspi.c- Extension
.c- Size
- 41966 bytes
- Lines
- 1394
- 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/clk.hlinux/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/firmware/xlnx-zynqmp.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/spi/spi.hlinux/spinlock.hlinux/workqueue.hlinux/spi/spi-mem.h
Detected Declarations
struct qspi_platform_datastruct zynqmp_qspienum mode_typefunction zynqmp_gqspi_readfunction zynqmp_gqspi_writefunction zynqmp_gqspi_selecttargetfunction zynqmp_qspi_set_tapdelayfunction zynqmp_qspi_init_hwfunction zynqmp_qspi_copy_read_datafunction zynqmp_qspi_chipselectfunction zynqmp_qspi_selectspimodefunction frequencyfunction zynqmp_qspi_setup_opfunction zynqmp_qspi_filltxfifofunction zynqmp_qspi_readrxfifofunction zynqmp_qspi_fillgenfifofunction zynqmp_qspi_disable_dmafunction zynqmp_qspi_enable_dmafunction zynqmp_process_dma_irqfunction zynqmp_qspi_irqfunction zynqmp_qspi_setuprxdmafunction zynqmp_qspi_write_opfunction zynqmp_qspi_read_opfunction zynqmp_qspi_suspendfunction zynqmp_qspi_resumefunction zynqmp_runtime_suspendfunction zynqmp_runtime_resumefunction zynqmp_qspi_timeoutfunction zynqmp_qspi_exec_opfunction zynqmp_qspi_probefunction zynqmp_qspi_remove
Annotated Snippet
struct qspi_platform_data {
u32 quirks;
};
/**
* struct zynqmp_qspi - Defines qspi driver instance
* @ctlr: Pointer to the spi controller information
* @regs: Virtual address of the QSPI controller registers
* @refclk: Pointer to the peripheral clock
* @pclk: Pointer to the APB clock
* @irq: IRQ number
* @dev: Pointer to struct device
* @txbuf: Pointer to the TX buffer
* @rxbuf: Pointer to the RX buffer
* @bytes_to_transfer: Number of bytes left to transfer
* @bytes_to_receive: Number of bytes left to receive
* @genfifocs: Used for chip select
* @genfifobus: Used to select the upper or lower bus
* @dma_rx_bytes: Remaining bytes to receive by DMA mode
* @dma_addr: DMA address after mapping the kernel buffer
* @genfifoentry: Used for storing the genfifoentry instruction.
* @mode: Defines the mode in which QSPI is operating
* @data_completion: completion structure
* @op_lock: Operational lock
* @speed_hz: Current SPI bus clock speed in hz
* @has_tapdelay: Used for tapdelay register available in qspi
*/
struct zynqmp_qspi {
struct spi_controller *ctlr;
void __iomem *regs;
struct clk *refclk;
struct clk *pclk;
int irq;
struct device *dev;
const void *txbuf;
void *rxbuf;
int bytes_to_transfer;
int bytes_to_receive;
u32 genfifocs;
u32 genfifobus;
u32 dma_rx_bytes;
dma_addr_t dma_addr;
u32 genfifoentry;
enum mode_type mode;
struct completion data_completion;
struct mutex op_lock;
u32 speed_hz;
bool has_tapdelay;
};
/**
* zynqmp_gqspi_read - For GQSPI controller read operation
* @xqspi: Pointer to the zynqmp_qspi structure
* @offset: Offset from where to read
* Return: Value at the offset
*/
static u32 zynqmp_gqspi_read(struct zynqmp_qspi *xqspi, u32 offset)
{
return readl_relaxed(xqspi->regs + offset);
}
/**
* zynqmp_gqspi_write - For GQSPI controller write operation
* @xqspi: Pointer to the zynqmp_qspi structure
* @offset: Offset where to write
* @val: Value to be written
*/
static inline void zynqmp_gqspi_write(struct zynqmp_qspi *xqspi, u32 offset,
u32 val)
{
writel_relaxed(val, (xqspi->regs + offset));
}
/**
* zynqmp_gqspi_selecttarget - For selection of target device
* @instanceptr: Pointer to the zynqmp_qspi structure
* @targetcs: For chip select
* @targetbus: To check which bus is selected- upper or lower
*/
static void zynqmp_gqspi_selecttarget(struct zynqmp_qspi *instanceptr,
u8 targetcs, u8 targetbus)
{
/*
* Bus and CS lines selected here will be updated in the instance and
* used for subsequent GENFIFO entries during transfer.
*/
/* Choose target select line */
switch (targetcs) {
case GQSPI_SELECT_FLASH_CS_BOTH:
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/firmware/xlnx-zynqmp.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct qspi_platform_data`, `struct zynqmp_qspi`, `enum mode_type`, `function zynqmp_gqspi_read`, `function zynqmp_gqspi_write`, `function zynqmp_gqspi_selecttarget`, `function zynqmp_qspi_set_tapdelay`, `function zynqmp_qspi_init_hw`, `function zynqmp_qspi_copy_read_data`, `function zynqmp_qspi_chipselect`.
- 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.