drivers/spi/spi-tegra114.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-tegra114.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-tegra114.c- Extension
.c- Size
- 42359 bytes
- Lines
- 1527
- 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.
- 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/clk.hlinux/completion.hlinux/delay.hlinux/dmaengine.hlinux/dma-mapping.hlinux/dmapool.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/kthread.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/of.hlinux/reset.hlinux/spi/spi.h
Detected Declarations
struct tegra_spi_soc_datastruct tegra_spi_client_datastruct tegra_spi_datafunction tegra_spi_readlfunction tegra_spi_writelfunction tegra_spi_clear_statusfunction tegra_spi_calculate_curr_xfer_paramfunction tegra_spi_fill_tx_fifo_from_client_txbuffunction tegra_spi_read_rx_fifo_to_client_rxbuffunction tegra_spi_copy_client_txbuf_to_spi_txbuffunction tegra_spi_copy_spi_rxbuf_to_client_rxbuffunction tegra_spi_dma_completefunction tegra_spi_start_tx_dmafunction tegra_spi_start_rx_dmafunction tegra_spi_flush_fifosfunction tegra_spi_start_dma_based_transferfunction tegra_spi_start_cpu_based_transferfunction tegra_spi_init_dma_paramfunction tegra_spi_deinit_dma_paramfunction tegra_spi_set_hw_cs_timingfunction tegra_spi_setup_transfer_onefunction tegra_spi_start_transfer_onefunction tegra_spi_cleanupfunction tegra_spi_setupfunction tegra_spi_transfer_endfunction tegra_spi_dump_regsfunction tegra_spi_transfer_one_messagefunction handle_cpu_based_xferfunction handle_dma_based_xferfunction tegra_spi_isr_threadfunction tegra_spi_isrfunction tegra_spi_probefunction tegra_spi_removefunction tegra_spi_suspendfunction tegra_spi_resumefunction tegra_spi_runtime_suspendfunction tegra_spi_runtime_resume
Annotated Snippet
struct tegra_spi_soc_data {
bool has_intr_mask_reg;
};
struct tegra_spi_client_data {
int tx_clk_tap_delay;
int rx_clk_tap_delay;
};
struct tegra_spi_data {
struct device *dev;
struct spi_controller *host;
spinlock_t lock;
struct clk *clk;
struct reset_control *rst;
void __iomem *base;
phys_addr_t phys;
unsigned irq;
u32 cur_speed;
struct spi_device *cur_spi;
struct spi_device *cs_control;
unsigned cur_pos;
unsigned words_per_32bit;
unsigned bytes_per_word;
unsigned curr_dma_words;
unsigned cur_direction;
unsigned cur_rx_pos;
unsigned cur_tx_pos;
unsigned dma_buf_size;
unsigned max_buf_size;
bool is_curr_dma_xfer;
bool use_hw_based_cs;
struct completion rx_dma_complete;
struct completion tx_dma_complete;
u32 tx_status;
u32 rx_status;
u32 status_reg;
bool is_packed;
u32 command1_reg;
u32 dma_control_reg;
u32 def_command1_reg;
u32 def_command2_reg;
u32 spi_cs_timing1;
u32 spi_cs_timing2;
u8 last_used_cs;
struct completion xfer_completion;
struct spi_transfer *curr_xfer;
struct dma_chan *rx_dma_chan;
u32 *rx_dma_buf;
dma_addr_t rx_dma_phys;
struct dma_async_tx_descriptor *rx_dma_desc;
struct dma_chan *tx_dma_chan;
u32 *tx_dma_buf;
dma_addr_t tx_dma_phys;
struct dma_async_tx_descriptor *tx_dma_desc;
const struct tegra_spi_soc_data *soc_data;
};
static int tegra_spi_runtime_suspend(struct device *dev);
static int tegra_spi_runtime_resume(struct device *dev);
static inline u32 tegra_spi_readl(struct tegra_spi_data *tspi,
unsigned long reg)
{
return readl(tspi->base + reg);
}
static inline void tegra_spi_writel(struct tegra_spi_data *tspi,
u32 val, unsigned long reg)
{
writel(val, tspi->base + reg);
/* Read back register to make sure that register writes completed */
if (reg != SPI_TX_FIFO)
readl(tspi->base + SPI_COMMAND1);
}
static void tegra_spi_clear_status(struct tegra_spi_data *tspi)
{
u32 val;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/err.h`, `linux/interrupt.h`.
- Detected declarations: `struct tegra_spi_soc_data`, `struct tegra_spi_client_data`, `struct tegra_spi_data`, `function tegra_spi_readl`, `function tegra_spi_writel`, `function tegra_spi_clear_status`, `function tegra_spi_calculate_curr_xfer_param`, `function tegra_spi_fill_tx_fifo_from_client_txbuf`, `function tegra_spi_read_rx_fifo_to_client_rxbuf`, `function tegra_spi_copy_client_txbuf_to_spi_txbuf`.
- 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.