drivers/spi/spi-clps711x.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-clps711x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-clps711x.c- Extension
.c- Size
- 4016 bytes
- Lines
- 160
- 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/io.hlinux/clk.hlinux/gpio/consumer.hlinux/module.hlinux/of.hlinux/interrupt.hlinux/platform_device.hlinux/regmap.hlinux/mfd/syscon.hlinux/mfd/syscon/clps711x.hlinux/spi/spi.h
Detected Declarations
struct spi_clps711x_datafunction spi_clps711x_prepare_messagefunction spi_clps711x_transfer_onefunction spi_clps711x_isrfunction spi_clps711x_probe
Annotated Snippet
struct spi_clps711x_data {
void __iomem *syncio;
struct regmap *syscon;
struct clk *spi_clk;
u8 *tx_buf;
u8 *rx_buf;
unsigned int bpw;
int len;
};
static int spi_clps711x_prepare_message(struct spi_controller *host,
struct spi_message *msg)
{
struct spi_clps711x_data *hw = spi_controller_get_devdata(host);
struct spi_device *spi = msg->spi;
/* Setup mode for transfer */
return regmap_update_bits(hw->syscon, SYSCON_OFFSET, SYSCON3_ADCCKNSEN,
(spi->mode & SPI_CPHA) ?
SYSCON3_ADCCKNSEN : 0);
}
static int spi_clps711x_transfer_one(struct spi_controller *host,
struct spi_device *spi,
struct spi_transfer *xfer)
{
struct spi_clps711x_data *hw = spi_controller_get_devdata(host);
u8 data;
clk_set_rate(hw->spi_clk, xfer->speed_hz ? : spi->max_speed_hz);
hw->len = xfer->len;
hw->bpw = xfer->bits_per_word;
hw->tx_buf = (u8 *)xfer->tx_buf;
hw->rx_buf = (u8 *)xfer->rx_buf;
/* Initiate transfer */
data = hw->tx_buf ? *hw->tx_buf++ : 0;
writel(data | SYNCIO_FRMLEN(hw->bpw) | SYNCIO_TXFRMEN, hw->syncio);
return 1;
}
static irqreturn_t spi_clps711x_isr(int irq, void *dev_id)
{
struct spi_controller *host = dev_id;
struct spi_clps711x_data *hw = spi_controller_get_devdata(host);
u8 data;
/* Handle RX */
data = readb(hw->syncio);
if (hw->rx_buf)
*hw->rx_buf++ = data;
/* Handle TX */
if (--hw->len > 0) {
data = hw->tx_buf ? *hw->tx_buf++ : 0;
writel(data | SYNCIO_FRMLEN(hw->bpw) | SYNCIO_TXFRMEN,
hw->syncio);
} else
spi_finalize_current_transfer(host);
return IRQ_HANDLED;
}
static int spi_clps711x_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct spi_clps711x_data *hw;
struct spi_controller *host;
int irq, ret;
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
host = devm_spi_alloc_host(&pdev->dev, sizeof(*hw));
if (!host)
return -ENOMEM;
host->use_gpio_descriptors = true;
host->bus_num = -1;
host->mode_bits = SPI_CPHA | SPI_CS_HIGH;
host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 8);
host->prepare_message = spi_clps711x_prepare_message;
host->transfer_one = spi_clps711x_transfer_one;
hw = spi_controller_get_devdata(host);
Annotation
- Immediate include surface: `linux/io.h`, `linux/clk.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/of.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct spi_clps711x_data`, `function spi_clps711x_prepare_message`, `function spi_clps711x_transfer_one`, `function spi_clps711x_isr`, `function spi_clps711x_probe`.
- 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.