drivers/spi/spi-nxp-xspi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-nxp-xspi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-nxp-xspi.c- Extension
.c- Size
- 37038 bytes
- Lines
- 1382
- 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/bitops.hlinux/bitfield.hlinux/clk.hlinux/completion.hlinux/delay.hlinux/err.hlinux/errno.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/jiffies.hlinux/kernel.hlinux/log2.hlinux/module.hlinux/mutex.hlinux/of.hlinux/platform_device.hlinux/pinctrl/consumer.hlinux/pm_runtime.hlinux/spi/spi.hlinux/spi/spi-mem.h
Detected Declarations
struct nxp_xspi_devtype_datastruct nxp_xspifunction needs_ip_onlyfunction nxp_xspi_irq_handlerfunction nxp_xspi_check_buswidthfunction nxp_xspi_supports_opfunction nxp_xspi_prepare_lutfunction nxp_xspi_disable_ddrfunction nxp_xspi_enable_ddrfunction nxp_xspi_sw_resetfunction enabledfunction nxp_xspi_dll_bypassfunction nxp_xspi_dll_autofunction nxp_xspi_select_memfunction nxp_xspi_ahb_readfunction nxp_xspi_fill_txfifofunction nxp_xspi_read_rxfifofunction nxp_xspi_do_opfunction nxp_xspi_exec_opfunction nxp_xspi_adjust_op_sizefunction nxp_xspi_config_ahb_bufferfunction nxp_xspi_default_setupfunction nxp_xspi_cleanupfunction nxp_xspi_probefunction nxp_xspi_runtime_suspendfunction nxp_xspi_runtime_resumefunction nxp_xspi_suspendfunction nxp_xspi_resume
Annotated Snippet
struct nxp_xspi_devtype_data {
unsigned int rxfifo;
unsigned int txfifo;
unsigned int ahb_buf_size;
unsigned int quirks;
};
static struct nxp_xspi_devtype_data imx94_data = {
.rxfifo = SZ_512, /* (128 * 4 bytes) */
.txfifo = SZ_1K, /* (256 * 4 bytes) */
.ahb_buf_size = SZ_4K, /* (1024 * 4 bytes) */
};
struct nxp_xspi {
void __iomem *iobase;
void __iomem *ahb_addr;
u32 memmap_phy;
u32 memmap_phy_size;
u32 memmap_start;
u32 memmap_len;
struct clk *clk;
struct device *dev;
struct completion c;
const struct nxp_xspi_devtype_data *devtype_data;
/* mutex lock for each operation */
struct mutex lock;
int selected;
#define XSPI_DTR_PROTO BIT(0)
int flags;
/* Save the previous operation clock rate */
unsigned long pre_op_rate;
/* The max clock rate xspi supported output to device */
unsigned long support_max_rate;
};
static inline int needs_ip_only(struct nxp_xspi *xspi)
{
return xspi->devtype_data->quirks & XSPI_QUIRK_USE_IP_ONLY;
}
static irqreturn_t nxp_xspi_irq_handler(int irq, void *dev_id)
{
struct nxp_xspi *xspi = dev_id;
u32 reg;
reg = readl(xspi->iobase + XSPI_FR);
if (reg & XSPI_FR_TFF) {
/* Clear interrupt */
writel(XSPI_FR_TFF, xspi->iobase + XSPI_FR);
complete(&xspi->c);
return IRQ_HANDLED;
}
return IRQ_NONE;
}
static int nxp_xspi_check_buswidth(struct nxp_xspi *xspi, u8 width)
{
return (is_power_of_2(width) && width <= 8) ? 0 : -EOPNOTSUPP;
}
static bool nxp_xspi_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op)
{
struct nxp_xspi *xspi = spi_controller_get_devdata(mem->spi->controller);
int ret;
ret = nxp_xspi_check_buswidth(xspi, op->cmd.buswidth);
if (op->addr.nbytes)
ret |= nxp_xspi_check_buswidth(xspi, op->addr.buswidth);
if (op->dummy.nbytes)
ret |= nxp_xspi_check_buswidth(xspi, op->dummy.buswidth);
if (op->data.nbytes)
ret |= nxp_xspi_check_buswidth(xspi, op->data.buswidth);
if (ret)
return false;
/*
* The number of address bytes should be equal to or less than 4 bytes.
*/
if (op->addr.nbytes > 4)
return false;
/* Max 32 dummy clock cycles supported */
if (op->dummy.buswidth &&
(op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/err.h`, `linux/errno.h`, `linux/interrupt.h`.
- Detected declarations: `struct nxp_xspi_devtype_data`, `struct nxp_xspi`, `function needs_ip_only`, `function nxp_xspi_irq_handler`, `function nxp_xspi_check_buswidth`, `function nxp_xspi_supports_op`, `function nxp_xspi_prepare_lut`, `function nxp_xspi_disable_ddr`, `function nxp_xspi_enable_ddr`, `function nxp_xspi_sw_reset`.
- 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.