drivers/spi/spi-cadence-xspi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-cadence-xspi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-cadence-xspi.c- Extension
.c- Size
- 40706 bytes
- Lines
- 1353
- 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/completion.hlinux/delay.hlinux/err.hlinux/errno.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hlinux/spi/spi.hlinux/spi/spi-mem.hlinux/bitfield.hlinux/limits.hlinux/log2.hlinux/bitrev.hlinux/util_macros.h
Detected Declarations
struct cdns_xspi_driver_datastruct cdns_xspi_devenum cdns_xspi_stig_instr_typeenum cdns_xspi_sdma_direnum cdns_xspi_stig_cmd_dirfunction cdns_xspi_reset_dllfunction cdns_xspi_is_dll_lockedfunction cdns_xspi_configure_phyfunction cdns_mrvl_xspi_setup_clockfunction cdns_xspi_wait_for_controller_idlefunction cdns_xspi_trigger_commandfunction cdns_xspi_check_command_statusfunction cdns_xspi_set_interruptsfunction marvell_xspi_set_interruptsfunction cdns_xspi_controller_initfunction cdns_xspi_sdma_readfunction cdns_xspi_sdma_writefunction cdns_xspi_sdma_handlefunction m_ioreadqfunction m_iowriteqfunction marvell_xspi_sdma_handlefunction cdns_xspi_send_stig_commandfunction cdns_xspi_mem_opfunction cdns_xspi_mem_op_executefunction marvell_xspi_mem_op_executefunction cdns_xspi_supports_opfunction cdns_xspi_adjust_mem_op_sizefunction cdns_xspi_irq_handlerfunction cdns_xspi_of_get_plat_datafunction device_for_each_child_nodefunction cdns_xspi_print_phy_configfunction cdns_xspi_prepare_genericfunction marvell_xspi_read_single_qwordfunction cdns_xspi_finish_readfunction cdns_xspi_prepare_transferfunction cdns_xspi_is_stig_readyfunction cdns_xspi_is_sdma_readyfunction cdns_xspi_transfer_one_message_b0function list_for_each_entryfunction cdns_xspi_probefunction cdns_xspi_suspendfunction cdns_xspi_resume
Annotated Snippet
struct cdns_xspi_driver_data {
bool mrvl_hw_overlay;
u32 dll_phy_ctrl;
u32 ctb_rfile_phy_ctrl;
u32 rfile_phy_tsel;
u32 rfile_phy_dq_timing;
u32 rfile_phy_dqs_timing;
u32 rfile_phy_gate_lpbk_ctrl;
u32 rfile_phy_dll_master_ctrl;
u32 rfile_phy_dll_slave_ctrl;
};
static struct cdns_xspi_driver_data marvell_driver_data = {
.mrvl_hw_overlay = true,
.dll_phy_ctrl = MARVELL_REGS_DLL_PHY_CTRL,
.ctb_rfile_phy_ctrl = MARVELL_CTB_RFILE_PHY_CTRL,
.rfile_phy_tsel = MARVELL_RFILE_PHY_TSEL,
.rfile_phy_dq_timing = MARVELL_RFILE_PHY_DQ_TIMING,
.rfile_phy_dqs_timing = MARVELL_RFILE_PHY_DQS_TIMING,
.rfile_phy_gate_lpbk_ctrl = MARVELL_RFILE_PHY_GATE_LPBK_CTRL,
.rfile_phy_dll_master_ctrl = MARVELL_RFILE_PHY_DLL_MASTER_CTRL,
.rfile_phy_dll_slave_ctrl = MARVELL_RFILE_PHY_DLL_SLAVE_CTRL,
};
static struct cdns_xspi_driver_data cdns_driver_data = {
.mrvl_hw_overlay = false,
};
static const int cdns_mrvl_xspi_clk_div_list[] = {
4, //0x0 = Divide by 4. SPI clock is 200 MHz.
6, //0x1 = Divide by 6. SPI clock is 133.33 MHz.
8, //0x2 = Divide by 8. SPI clock is 100 MHz.
10, //0x3 = Divide by 10. SPI clock is 80 MHz.
12, //0x4 = Divide by 12. SPI clock is 66.666 MHz.
16, //0x5 = Divide by 16. SPI clock is 50 MHz.
18, //0x6 = Divide by 18. SPI clock is 44.44 MHz.
20, //0x7 = Divide by 20. SPI clock is 40 MHz.
24, //0x8 = Divide by 24. SPI clock is 33.33 MHz.
32, //0x9 = Divide by 32. SPI clock is 25 MHz.
40, //0xA = Divide by 40. SPI clock is 20 MHz.
50, //0xB = Divide by 50. SPI clock is 16 MHz.
64, //0xC = Divide by 64. SPI clock is 12.5 MHz.
128 //0xD = Divide by 128. SPI clock is 6.25 MHz.
};
struct cdns_xspi_dev {
struct platform_device *pdev;
struct spi_controller *host;
struct device *dev;
void __iomem *iobase;
void __iomem *auxbase;
void __iomem *sdmabase;
void __iomem *xferbase;
int irq;
int cur_cs;
unsigned int sdmasize;
struct completion cmd_complete;
struct completion auto_cmd_complete;
struct completion sdma_complete;
bool sdma_error;
void *in_buffer;
const void *out_buffer;
/* Slave DMA data width in bytes (4 or 8). */
u8 dma_data_width;
u8 hw_num_banks;
const struct cdns_xspi_driver_data *driver_data;
void (*sdma_handler)(struct cdns_xspi_dev *cdns_xspi);
void (*set_interrupts_handler)(struct cdns_xspi_dev *cdns_xspi, bool enabled);
bool xfer_in_progress;
int current_xfer_qword;
};
static void cdns_xspi_reset_dll(struct cdns_xspi_dev *cdns_xspi)
{
u32 dll_cntrl = readl(cdns_xspi->iobase +
CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL);
/* Reset DLL */
dll_cntrl |= CDNS_XSPI_DLL_RST_N;
writel(dll_cntrl, cdns_xspi->iobase +
CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL);
}
Annotation
- Immediate include surface: `linux/completion.h`, `linux/delay.h`, `linux/err.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/kernel.h`.
- Detected declarations: `struct cdns_xspi_driver_data`, `struct cdns_xspi_dev`, `enum cdns_xspi_stig_instr_type`, `enum cdns_xspi_sdma_dir`, `enum cdns_xspi_stig_cmd_dir`, `function cdns_xspi_reset_dll`, `function cdns_xspi_is_dll_locked`, `function cdns_xspi_configure_phy`, `function cdns_mrvl_xspi_setup_clock`, `function cdns_xspi_wait_for_controller_idle`.
- 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.