drivers/mtd/devices/st_spi_fsm.c
Source file repositories/reference/linux-study-clean/drivers/mtd/devices/st_spi_fsm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/devices/st_spi_fsm.c- Extension
.c- Size
- 58717 bytes
- Lines
- 2145
- Domain
- Driver Families
- Bucket
- drivers/mtd
- 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.
- 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/kernel.hlinux/module.hlinux/regmap.hlinux/platform_device.hlinux/mfd/syscon.hlinux/mtd/mtd.hlinux/mtd/partitions.hlinux/mtd/spi-nor.hlinux/sched.hlinux/delay.hlinux/io.hlinux/of.hlinux/clk.hserial_flash_cmds.h
Detected Declarations
struct stfsm_seqstruct stfsmstruct seq_rw_configstruct flash_infofunction stfsm_mx25_en_32bit_addr_seqfunction stfsm_n25q_en_32bit_addr_seqfunction stfsm_is_idlefunction stfsm_fifo_availablefunction stfsm_load_seqfunction stfsm_wait_seqfunction stfsm_read_fifofunction stfsm_clear_fifofunction stfsm_write_fifofunction stfsm_enter_32bit_addrfunction stfsm_wait_busyfunction stfsm_read_statusfunction stfsm_write_statusfunction timefunction stfsm_prepare_erasesec_seqfunction stfsm_search_seq_rw_configsfunction stfsm_prepare_rw_seqfunction stfsm_search_prepare_rw_seqfunction stfsm_prepare_rwe_seqs_defaultfunction stfsm_mx25_configfunction stfsm_n25q_configfunction stfsm_s25fl_prepare_erasesec_seq_32function stfsm_s25fl_read_dybfunction stfsm_s25fl_write_dybfunction stfsm_s25fl_clear_status_regfunction stfsm_s25fl_configfunction necessaryfunction stfsm_w25q_configfunction stfsm_readfunction stfsm_writefunction stfsm_mtd_readfunction stfsm_erase_sectorfunction stfsm_erase_chipfunction stfsm_mtd_writefunction stfsm_mtd_erasefunction stfsm_read_jedecfunction stfsm_set_modefunction stfsm_set_freqfunction stfsm_initfunction stfsm_fetch_platform_configsfunction stfsm_probefunction stfsm_removefunction stfsmfsm_suspendfunction stfsmfsm_resume
Annotated Snippet
struct stfsm_seq {
uint32_t data_size;
uint32_t addr1;
uint32_t addr2;
uint32_t addr_cfg;
uint32_t seq_opc[5];
uint32_t mode;
uint32_t dummy;
uint32_t status;
uint8_t seq[16];
uint32_t seq_cfg;
} __packed __aligned(4);
struct stfsm {
struct device *dev;
void __iomem *base;
struct mtd_info mtd;
struct mutex lock;
struct flash_info *info;
struct clk *clk;
uint32_t configuration;
uint32_t fifo_dir_delay;
bool booted_from_spi;
bool reset_signal;
bool reset_por;
struct stfsm_seq stfsm_seq_read;
struct stfsm_seq stfsm_seq_write;
struct stfsm_seq stfsm_seq_en_32bit_addr;
};
/* Parameters to configure a READ or WRITE FSM sequence */
struct seq_rw_config {
uint32_t flags; /* flags to support config */
uint8_t cmd; /* FLASH command */
int write; /* Write Sequence */
uint8_t addr_pads; /* No. of addr pads (MODE & DUMMY) */
uint8_t data_pads; /* No. of data pads */
uint8_t mode_data; /* MODE data */
uint8_t mode_cycles; /* No. of MODE cycles */
uint8_t dummy_cycles; /* No. of DUMMY cycles */
};
/* SPI Flash Device Table */
struct flash_info {
char *name;
/*
* JEDEC id zero means "no ID" (most older chips); otherwise it has
* a high byte of zero plus three data bytes: the manufacturer id,
* then a two byte device id.
*/
u32 jedec_id;
u16 ext_id;
/*
* The size listed here is what works with SPINOR_OP_SE, which isn't
* necessarily called a "sector" by the vendor.
*/
unsigned sector_size;
u16 n_sectors;
u32 flags;
/*
* Note, where FAST_READ is supported, freq_max specifies the
* FAST_READ frequency, not the READ frequency.
*/
u32 max_freq;
int (*config)(struct stfsm *);
};
static int stfsm_n25q_config(struct stfsm *fsm);
static int stfsm_mx25_config(struct stfsm *fsm);
static int stfsm_s25fl_config(struct stfsm *fsm);
static int stfsm_w25q_config(struct stfsm *fsm);
static struct flash_info flash_types[] = {
/*
* ST Microelectronics/Numonyx --
* (newer production versions may have feature updates
* (eg faster operating frequency)
*/
#define M25P_FLAG (FLASH_FLAG_READ_WRITE | FLASH_FLAG_READ_FAST)
{ "m25p40", 0x202013, 0, 64 * 1024, 8, M25P_FLAG, 25, NULL },
{ "m25p80", 0x202014, 0, 64 * 1024, 16, M25P_FLAG, 25, NULL },
{ "m25p16", 0x202015, 0, 64 * 1024, 32, M25P_FLAG, 25, NULL },
{ "m25p32", 0x202016, 0, 64 * 1024, 64, M25P_FLAG, 50, NULL },
{ "m25p64", 0x202017, 0, 64 * 1024, 128, M25P_FLAG, 50, NULL },
{ "m25p128", 0x202018, 0, 256 * 1024, 64, M25P_FLAG, 50, NULL },
#define M25PX_FLAG (FLASH_FLAG_READ_WRITE | \
FLASH_FLAG_READ_FAST | \
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/regmap.h`, `linux/platform_device.h`, `linux/mfd/syscon.h`, `linux/mtd/mtd.h`, `linux/mtd/partitions.h`, `linux/mtd/spi-nor.h`.
- Detected declarations: `struct stfsm_seq`, `struct stfsm`, `struct seq_rw_config`, `struct flash_info`, `function stfsm_mx25_en_32bit_addr_seq`, `function stfsm_n25q_en_32bit_addr_seq`, `function stfsm_is_idle`, `function stfsm_fifo_available`, `function stfsm_load_seq`, `function stfsm_wait_seq`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source 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.