drivers/spi/spi-intel.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-intel.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-intel.c- Extension
.c- Size
- 41085 bytes
- Lines
- 1525
- Domain
- Driver Families
- Bucket
- drivers/spi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/iopoll.hlinux/module.hlinux/mtd/partitions.hlinux/mtd/spi-nor.hlinux/spi/flash.hlinux/spi/spi.hlinux/spi/spi-mem.hspi-intel.h
Detected Declarations
struct intel_spistruct intel_spi_mem_opfunction intel_spi_dump_regsfunction intel_spi_read_blockfunction intel_spi_write_blockfunction intel_spi_wait_hw_busyfunction intel_spi_wait_sw_busyfunction intel_spi_set_writeablefunction intel_spi_opcode_indexfunction intel_spi_hw_cyclefunction intel_spi_sw_cyclefunction intel_spi_chip_addrfunction intel_spi_read_regfunction intel_spi_write_regfunction opcodesfunction intel_spi_readfunction intel_spi_writefunction intel_spi_erasefunction intel_spi_adjust_op_sizefunction intel_spi_cmp_mem_opfunction intel_spi_match_mem_opfunction intel_spi_supports_mem_opfunction intel_spi_exec_mem_opfunction intel_spi_dirmap_createfunction intel_spi_dirmap_readfunction intel_spi_dirmap_writefunction intel_spi_initfunction intel_spi_is_protectedfunction intel_spi_fill_partitionfunction intel_spi_read_descfunction intel_spi_populate_chipfunction intel_spi_protected_showfunction intel_spi_locked_showfunction intel_spi_bios_locked_showfunction intel_spi_probeexport intel_spi_groupsexport intel_spi_probe
Annotated Snippet
struct intel_spi {
struct device *dev;
const struct intel_spi_boardinfo *info;
void __iomem *base;
void __iomem *pregs;
void __iomem *sregs;
struct spi_controller *host;
size_t nregions;
size_t pr_num;
size_t chip0_size;
bool locked;
bool protected;
bool bios_locked;
bool swseq_reg;
bool swseq_erase;
u8 atomic_preopcode;
u8 opcodes[8];
const struct intel_spi_mem_op *mem_ops;
};
struct intel_spi_mem_op {
struct spi_mem_op mem_op;
u32 replacement_op;
int (*exec_op)(struct intel_spi *ispi,
const struct spi_mem *mem,
const struct intel_spi_mem_op *iop,
const struct spi_mem_op *op);
};
static bool writeable;
module_param(writeable, bool, 0);
MODULE_PARM_DESC(writeable, "Enable write access to SPI flash chip (default=0)");
static bool ignore_protection_status;
module_param(ignore_protection_status, bool, 0);
MODULE_PARM_DESC(
ignore_protection_status,
"Do not block SPI flash chip write access even if it is write-protected (default=0)");
static void intel_spi_dump_regs(struct intel_spi *ispi)
{
u32 value;
int i;
dev_dbg(ispi->dev, "BFPREG=0x%08x\n", readl(ispi->base + BFPREG));
value = readl(ispi->base + HSFSTS_CTL);
dev_dbg(ispi->dev, "HSFSTS_CTL=0x%08x\n", value);
if (value & HSFSTS_CTL_FLOCKDN)
dev_dbg(ispi->dev, "-> Locked\n");
dev_dbg(ispi->dev, "FADDR=0x%08x\n", readl(ispi->base + FADDR));
dev_dbg(ispi->dev, "DLOCK=0x%08x\n", readl(ispi->base + DLOCK));
for (i = 0; i < 16; i++)
dev_dbg(ispi->dev, "FDATA(%d)=0x%08x\n",
i, readl(ispi->base + FDATA(i)));
dev_dbg(ispi->dev, "FRACC=0x%08x\n", readl(ispi->base + FRACC));
for (i = 0; i < ispi->nregions; i++)
dev_dbg(ispi->dev, "FREG(%d)=0x%08x\n", i,
readl(ispi->base + FREG(i)));
for (i = 0; i < ispi->pr_num; i++)
dev_dbg(ispi->dev, "PR(%d)=0x%08x\n", i,
readl(ispi->pregs + PR(i)));
if (ispi->sregs) {
value = readl(ispi->sregs + SSFSTS_CTL);
dev_dbg(ispi->dev, "SSFSTS_CTL=0x%08x\n", value);
dev_dbg(ispi->dev, "PREOP_OPTYPE=0x%08x\n",
readl(ispi->sregs + PREOP_OPTYPE));
dev_dbg(ispi->dev, "OPMENU0=0x%08x\n",
readl(ispi->sregs + OPMENU0));
dev_dbg(ispi->dev, "OPMENU1=0x%08x\n",
readl(ispi->sregs + OPMENU1));
}
dev_dbg(ispi->dev, "LVSCC=0x%08x\n", readl(ispi->base + LVSCC));
dev_dbg(ispi->dev, "UVSCC=0x%08x\n", readl(ispi->base + UVSCC));
dev_dbg(ispi->dev, "Protected regions:\n");
for (i = 0; i < ispi->pr_num; i++) {
u32 base, limit;
value = readl(ispi->pregs + PR(i));
if (!(value & (PR_WPE | PR_RPE)))
continue;
limit = (value & PR_LIMIT_MASK) >> PR_LIMIT_SHIFT;
base = value & PR_BASE_MASK;
Annotation
- Immediate include surface: `linux/iopoll.h`, `linux/module.h`, `linux/mtd/partitions.h`, `linux/mtd/spi-nor.h`, `linux/spi/flash.h`, `linux/spi/spi.h`, `linux/spi/spi-mem.h`, `spi-intel.h`.
- Detected declarations: `struct intel_spi`, `struct intel_spi_mem_op`, `function intel_spi_dump_regs`, `function intel_spi_read_block`, `function intel_spi_write_block`, `function intel_spi_wait_hw_busy`, `function intel_spi_wait_sw_busy`, `function intel_spi_set_writeable`, `function intel_spi_opcode_index`, `function intel_spi_hw_cycle`.
- Atlas domain: Driver Families / drivers/spi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.