drivers/spi/spi-bcmbca-hsspi.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-bcmbca-hsspi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-bcmbca-hsspi.c- Extension
.c- Size
- 17029 bytes
- Lines
- 628
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/init.hlinux/io.hlinux/clk.hlinux/module.hlinux/platform_device.hlinux/delay.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/spi/spi.hlinux/mutex.hlinux/of.hlinux/spi/spi-mem.hlinux/pm_runtime.h
Detected Declarations
struct bcmbca_hsspifunction wait_mode_showfunction wait_mode_storefunction bcmbca_hsspi_set_csfunction bcmbca_hsspi_set_clkfunction bcmbca_hsspi_wait_cmdfunction bcmbca_hsspi_do_txrxfunction bcmbca_hsspi_setupfunction bcmbca_hsspi_transfer_onefunction bcmbca_hsspi_interruptfunction bcmbca_hsspi_probefunction bcmbca_hsspi_removefunction bcmbca_hsspi_suspendfunction bcmbca_hsspi_resume
Annotated Snippet
struct bcmbca_hsspi {
struct completion done;
struct mutex bus_mutex;
struct mutex msg_mutex;
struct platform_device *pdev;
struct clk *clk;
struct clk *pll_clk;
void __iomem *regs;
void __iomem *spim_ctrl;
u8 __iomem *fifo;
u32 speed_hz;
u8 cs_polarity;
u32 wait_mode;
};
static ssize_t wait_mode_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcmbca_hsspi *bs = spi_controller_get_devdata(ctrl);
return sprintf(buf, "%d\n", bs->wait_mode);
}
static ssize_t wait_mode_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcmbca_hsspi *bs = spi_controller_get_devdata(ctrl);
u32 val;
if (kstrtou32(buf, 10, &val))
return -EINVAL;
if (val > HSSPI_WAIT_MODE_MAX) {
dev_warn(dev, "invalid wait mode %u\n", val);
return -EINVAL;
}
mutex_lock(&bs->msg_mutex);
bs->wait_mode = val;
/* clear interrupt status to avoid spurious int on next transfer */
if (val == HSSPI_WAIT_MODE_INTR)
__raw_writel(HSSPI_INT_CLEAR_ALL, bs->regs + HSSPI_INT_STATUS_REG);
mutex_unlock(&bs->msg_mutex);
return count;
}
static DEVICE_ATTR_RW(wait_mode);
static struct attribute *bcmbca_hsspi_attrs[] = {
&dev_attr_wait_mode.attr,
NULL,
};
static const struct attribute_group bcmbca_hsspi_group = {
.attrs = bcmbca_hsspi_attrs,
};
static void bcmbca_hsspi_set_cs(struct bcmbca_hsspi *bs, unsigned int cs,
bool active)
{
u32 reg;
/* No cs orerriden needed for SS7 internal cs on pcm based voice dev */
if (cs == 7)
return;
mutex_lock(&bs->bus_mutex);
reg = __raw_readl(bs->spim_ctrl);
if (active)
reg |= BIT(cs + SPIM_CTRL_CS_OVERRIDE_SEL_SHIFT);
else
reg &= ~BIT(cs + SPIM_CTRL_CS_OVERRIDE_SEL_SHIFT);
__raw_writel(reg, bs->spim_ctrl);
mutex_unlock(&bs->bus_mutex);
}
static void bcmbca_hsspi_set_clk(struct bcmbca_hsspi *bs,
struct spi_device *spi, int hz)
{
unsigned int profile = spi_get_chipselect(spi, 0);
u32 reg;
reg = DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz));
__raw_writel(CLK_CTRL_ACCUM_RST_ON_LOOP | reg,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/io.h`, `linux/clk.h`, `linux/module.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct bcmbca_hsspi`, `function wait_mode_show`, `function wait_mode_store`, `function bcmbca_hsspi_set_cs`, `function bcmbca_hsspi_set_clk`, `function bcmbca_hsspi_wait_cmd`, `function bcmbca_hsspi_do_txrx`, `function bcmbca_hsspi_setup`, `function bcmbca_hsspi_transfer_one`, `function bcmbca_hsspi_interrupt`.
- 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.