drivers/spi/spi-meson-spicc.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-meson-spicc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-meson-spicc.c- Extension
.c- Size
- 32066 bytes
- Lines
- 1148
- 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/bitfield.hlinux/clk.hlinux/clk-provider.hlinux/device.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/spi/spi.hlinux/types.hlinux/interrupt.hlinux/reset.hlinux/pinctrl/consumer.hlinux/dma-mapping.h
Detected Declarations
struct meson_spicc_datastruct meson_spicc_devicefunction meson_spicc_oen_enablefunction meson_spicc_dma_mapfunction meson_spicc_dma_unmapfunction meson_spicc_calc_dma_lenfunction meson_spicc_setup_dmafunction meson_spicc_dma_irqfunction meson_spicc_txfullfunction meson_spicc_rxreadyfunction meson_spicc_pull_datafunction meson_spicc_push_datafunction meson_spicc_rxfunction meson_spicc_txfunction meson_spicc_setup_burstfunction meson_spicc_irqfunction meson_spicc_auto_io_delayfunction meson_spicc_setup_xferfunction meson_spicc_reset_fifofunction meson_spicc_transfer_onefunction meson_spicc_prepare_messagefunction meson_spicc_unprepare_transferfunction meson_spicc_setupfunction meson_spicc_cleanupfunction meson_spicc_pow2_recalc_ratefunction meson_spicc_pow2_determine_ratefunction meson_spicc_pow2_set_ratefunction meson_spicc_pow2_clk_initfunction meson_spicc_enh_clk_initfunction meson_spicc_probefunction meson_spicc_remove
Annotated Snippet
struct meson_spicc_data {
unsigned int max_speed_hz;
unsigned int min_speed_hz;
unsigned int fifo_size;
bool has_oen;
bool has_enhance_clk_div;
bool has_pclk;
};
struct meson_spicc_device {
struct spi_controller *host;
struct platform_device *pdev;
void __iomem *base;
struct clk *core;
struct clk *pclk;
struct clk_divider pow2_div;
struct clk *clk;
struct spi_message *message;
struct spi_transfer *xfer;
struct completion done;
const struct meson_spicc_data *data;
u8 *tx_buf;
u8 *rx_buf;
unsigned int bytes_per_word;
unsigned long tx_remain;
unsigned long rx_remain;
unsigned long xfer_remain;
struct pinctrl *pinctrl;
struct pinctrl_state *pins_idle_high;
struct pinctrl_state *pins_idle_low;
dma_addr_t tx_dma;
dma_addr_t rx_dma;
bool using_dma;
};
#define pow2_clk_to_spicc(_div) container_of(_div, struct meson_spicc_device, pow2_div)
static void meson_spicc_oen_enable(struct meson_spicc_device *spicc)
{
u32 conf;
if (!spicc->data->has_oen) {
/* Try to get pinctrl states for idle high/low */
spicc->pins_idle_high = pinctrl_lookup_state(spicc->pinctrl,
"idle-high");
if (IS_ERR(spicc->pins_idle_high)) {
dev_warn(&spicc->pdev->dev, "can't get idle-high pinctrl\n");
spicc->pins_idle_high = NULL;
}
spicc->pins_idle_low = pinctrl_lookup_state(spicc->pinctrl,
"idle-low");
if (IS_ERR(spicc->pins_idle_low)) {
dev_warn(&spicc->pdev->dev, "can't get idle-low pinctrl\n");
spicc->pins_idle_low = NULL;
}
return;
}
conf = readl_relaxed(spicc->base + SPICC_ENH_CTL0) |
SPICC_ENH_MOSI_OEN | SPICC_ENH_CLK_OEN | SPICC_ENH_CS_OEN;
writel_relaxed(conf, spicc->base + SPICC_ENH_CTL0);
}
static int meson_spicc_dma_map(struct meson_spicc_device *spicc,
struct spi_transfer *t)
{
struct device *dev = spicc->host->dev.parent;
if (!(t->tx_buf && t->rx_buf))
return -EINVAL;
t->tx_dma = dma_map_single(dev, (void *)t->tx_buf, t->len, DMA_TO_DEVICE);
if (dma_mapping_error(dev, t->tx_dma))
return -ENOMEM;
t->rx_dma = dma_map_single(dev, t->rx_buf, t->len, DMA_FROM_DEVICE);
if (dma_mapping_error(dev, t->rx_dma))
return -ENOMEM;
spicc->tx_dma = t->tx_dma;
spicc->rx_dma = t->rx_dma;
return 0;
}
static void meson_spicc_dma_unmap(struct meson_spicc_device *spicc,
struct spi_transfer *t)
{
struct device *dev = spicc->host->dev.parent;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/device.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct meson_spicc_data`, `struct meson_spicc_device`, `function meson_spicc_oen_enable`, `function meson_spicc_dma_map`, `function meson_spicc_dma_unmap`, `function meson_spicc_calc_dma_len`, `function meson_spicc_setup_dma`, `function meson_spicc_dma_irq`, `function meson_spicc_txfull`, `function meson_spicc_rxready`.
- 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.