drivers/spi/spi-imx.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-imx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-imx.c- Extension
.c- Size
- 67852 bytes
- Lines
- 2472
- 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/bits.hlinux/bitfield.hlinux/clk.hlinux/completion.hlinux/delay.hlinux/dmaengine.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/irq.hlinux/kernel.hlinux/math.hlinux/math64.hlinux/module.hlinux/overflow.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/spi/spi.hlinux/types.hlinux/of.hlinux/property.hlinux/dma/imx-dma.h
Detected Declarations
struct spi_imx_datastruct spi_imx_devtype_datastruct dma_data_packagestruct spi_imx_dataenum spi_imx_devtypefunction is_imx27_cspifunction is_imx35_cspifunction is_imx51_ecspifunction is_imx53_ecspifunction spi_imx_clkdiv_1function spi_imx_clkdiv_2function spi_imx_bytes_per_wordfunction spi_imx_can_dmafunction spi_imx_buf_rx_swap_u32function spi_imx_buf_rx_swapfunction spi_imx_buf_tx_swap_u32function spi_imx_buf_tx_swapfunction mx53_ecspi_rx_targetfunction mx53_ecspi_tx_targetfunction mx51_ecspi_clkdivfunction mx51_ecspi_intctrlfunction mx51_ecspi_triggerfunction mx51_ecspi_disablefunction mx51_ecspi_channelfunction mx51_ecspi_prepare_messagefunction mx51_configure_cphafunction mx51_ecspi_prepare_transferfunction mx51_setup_wmlfunction mx51_ecspi_rx_availablefunction mx51_ecspi_resetfunction mx31_intctrlfunction mx31_triggerfunction mx31_prepare_messagefunction mx31_prepare_transferfunction mx31_rx_availablefunction mx31_resetfunction mx21_intctrlfunction mx21_triggerfunction mx21_prepare_messagefunction mx21_prepare_transferfunction mx21_rx_availablefunction mx21_resetfunction mx1_intctrlfunction mx1_triggerfunction mx1_prepare_messagefunction mx1_prepare_transferfunction mx1_rx_availablefunction mx1_reset
Annotated Snippet
struct spi_imx_devtype_data {
void (*intctrl)(struct spi_imx_data *spi_imx, int enable);
int (*prepare_message)(struct spi_imx_data *spi_imx, struct spi_message *msg);
int (*prepare_transfer)(struct spi_imx_data *spi_imx, struct spi_device *spi,
struct spi_transfer *t);
void (*trigger)(struct spi_imx_data *spi_imx);
int (*rx_available)(struct spi_imx_data *spi_imx);
void (*reset)(struct spi_imx_data *spi_imx);
void (*setup_wml)(struct spi_imx_data *spi_imx);
void (*disable)(struct spi_imx_data *spi_imx);
bool has_dmamode;
bool has_targetmode;
unsigned int fifo_size;
bool dynamic_burst;
/*
* ERR009165 fixed or not:
* https://www.nxp.com/docs/en/errata/IMX6DQCE.pdf
*/
bool tx_glitch_fixed;
enum spi_imx_devtype devtype;
};
struct dma_data_package {
u32 cmd_word;
void *dma_rx_buf;
void *dma_tx_buf;
dma_addr_t dma_tx_addr;
dma_addr_t dma_rx_addr;
int dma_len;
int data_len;
};
struct spi_imx_data {
struct spi_controller *controller;
struct device *dev;
struct completion xfer_done;
void __iomem *base;
unsigned long base_phys;
struct clk *clk_per;
struct clk *clk_ipg;
unsigned long spi_clk;
unsigned int spi_bus_clk;
unsigned int bits_per_word;
unsigned int spi_drctl;
unsigned int count, remainder;
void (*tx)(struct spi_imx_data *spi_imx);
void (*rx)(struct spi_imx_data *spi_imx);
void *rx_buf;
const void *tx_buf;
unsigned int txfifo; /* number of words pushed in tx FIFO */
unsigned int dynamic_burst;
bool rx_only;
/* Target mode */
bool target_mode;
bool target_aborted;
unsigned int target_burst;
/* DMA */
bool usedma;
u32 wml;
struct completion dma_rx_completion;
struct completion dma_tx_completion;
size_t dma_package_num;
struct dma_data_package *dma_data;
int rx_offset;
const struct spi_imx_devtype_data *devtype_data;
};
static inline int is_imx27_cspi(struct spi_imx_data *d)
{
return d->devtype_data->devtype == IMX27_CSPI;
}
static inline int is_imx35_cspi(struct spi_imx_data *d)
{
return d->devtype_data->devtype == IMX35_CSPI;
}
static inline int is_imx51_ecspi(struct spi_imx_data *d)
{
return d->devtype_data->devtype == IMX51_ECSPI;
}
static inline int is_imx53_ecspi(struct spi_imx_data *d)
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/err.h`.
- Detected declarations: `struct spi_imx_data`, `struct spi_imx_devtype_data`, `struct dma_data_package`, `struct spi_imx_data`, `enum spi_imx_devtype`, `function is_imx27_cspi`, `function is_imx35_cspi`, `function is_imx51_ecspi`, `function is_imx53_ecspi`, `function spi_imx_clkdiv_1`.
- 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.