drivers/mtd/devices/spear_smi.c
Source file repositories/reference/linux-study-clean/drivers/mtd/devices/spear_smi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/devices/spear_smi.c- Extension
.c- Size
- 29973 bytes
- Lines
- 1103
- 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.
- 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/clk.hlinux/delay.hlinux/device.hlinux/err.hlinux/errno.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/jiffies.hlinux/kernel.hlinux/module.hlinux/param.hlinux/platform_device.hlinux/pm.hlinux/mtd/mtd.hlinux/mtd/partitions.hlinux/mtd/spear_smi.hlinux/mutex.hlinux/sched.hlinux/slab.hlinux/wait.hlinux/of.hlinux/of_address.h
Detected Declarations
struct flash_devicestruct spear_snor_flashstruct spear_smistruct spear_snor_flashfunction spear_smi_read_srfunction WIPfunction spear_smi_int_handlerfunction spear_smi_hw_initfunction get_flash_indexfunction spear_smi_write_enablefunction get_sector_erase_cmdfunction spear_smi_erase_sectorfunction spear_mtd_erasefunction spear_mtd_readfunction memcpy_toiofunction spear_smi_cpy_toiofunction spear_mtd_writefunction spear_smi_probe_flashfunction spear_smi_probe_config_dtfunction spear_smi_probe_config_dtfunction spear_smi_setup_banksfunction spear_smi_probefunction spear_smi_removefunction spear_smi_suspendfunction spear_smi_resume
Annotated Snippet
struct flash_device {
char *name;
u8 erase_cmd;
u32 device_id;
u32 pagesize;
unsigned long sectorsize;
unsigned long size_in_bytes;
};
#define FLASH_ID(n, es, id, psize, ssize, size) \
{ \
.name = n, \
.erase_cmd = es, \
.device_id = id, \
.pagesize = psize, \
.sectorsize = ssize, \
.size_in_bytes = size \
}
static struct flash_device flash_devices[] = {
FLASH_ID("st m25p16" , 0xd8, 0x00152020, 0x100, 0x10000, 0x200000),
FLASH_ID("st m25p32" , 0xd8, 0x00162020, 0x100, 0x10000, 0x400000),
FLASH_ID("st m25p64" , 0xd8, 0x00172020, 0x100, 0x10000, 0x800000),
FLASH_ID("st m25p128" , 0xd8, 0x00182020, 0x100, 0x40000, 0x1000000),
FLASH_ID("st m25p05" , 0xd8, 0x00102020, 0x80 , 0x8000 , 0x10000),
FLASH_ID("st m25p10" , 0xd8, 0x00112020, 0x80 , 0x8000 , 0x20000),
FLASH_ID("st m25p20" , 0xd8, 0x00122020, 0x100, 0x10000, 0x40000),
FLASH_ID("st m25p40" , 0xd8, 0x00132020, 0x100, 0x10000, 0x80000),
FLASH_ID("st m25p80" , 0xd8, 0x00142020, 0x100, 0x10000, 0x100000),
FLASH_ID("st m45pe10" , 0xd8, 0x00114020, 0x100, 0x10000, 0x20000),
FLASH_ID("st m45pe20" , 0xd8, 0x00124020, 0x100, 0x10000, 0x40000),
FLASH_ID("st m45pe40" , 0xd8, 0x00134020, 0x100, 0x10000, 0x80000),
FLASH_ID("st m45pe80" , 0xd8, 0x00144020, 0x100, 0x10000, 0x100000),
FLASH_ID("sp s25fl004" , 0xd8, 0x00120201, 0x100, 0x10000, 0x80000),
FLASH_ID("sp s25fl008" , 0xd8, 0x00130201, 0x100, 0x10000, 0x100000),
FLASH_ID("sp s25fl016" , 0xd8, 0x00140201, 0x100, 0x10000, 0x200000),
FLASH_ID("sp s25fl032" , 0xd8, 0x00150201, 0x100, 0x10000, 0x400000),
FLASH_ID("sp s25fl064" , 0xd8, 0x00160201, 0x100, 0x10000, 0x800000),
FLASH_ID("atmel 25f512" , 0x52, 0x0065001F, 0x80 , 0x8000 , 0x10000),
FLASH_ID("atmel 25f1024" , 0x52, 0x0060001F, 0x100, 0x8000 , 0x20000),
FLASH_ID("atmel 25f2048" , 0x52, 0x0063001F, 0x100, 0x10000, 0x40000),
FLASH_ID("atmel 25f4096" , 0x52, 0x0064001F, 0x100, 0x10000, 0x80000),
FLASH_ID("atmel 25fs040" , 0xd7, 0x0004661F, 0x100, 0x10000, 0x80000),
FLASH_ID("mac 25l512" , 0xd8, 0x001020C2, 0x010, 0x10000, 0x10000),
FLASH_ID("mac 25l1005" , 0xd8, 0x001120C2, 0x010, 0x10000, 0x20000),
FLASH_ID("mac 25l2005" , 0xd8, 0x001220C2, 0x010, 0x10000, 0x40000),
FLASH_ID("mac 25l4005" , 0xd8, 0x001320C2, 0x010, 0x10000, 0x80000),
FLASH_ID("mac 25l4005a" , 0xd8, 0x001320C2, 0x010, 0x10000, 0x80000),
FLASH_ID("mac 25l8005" , 0xd8, 0x001420C2, 0x010, 0x10000, 0x100000),
FLASH_ID("mac 25l1605" , 0xd8, 0x001520C2, 0x100, 0x10000, 0x200000),
FLASH_ID("mac 25l1605a" , 0xd8, 0x001520C2, 0x010, 0x10000, 0x200000),
FLASH_ID("mac 25l3205" , 0xd8, 0x001620C2, 0x100, 0x10000, 0x400000),
FLASH_ID("mac 25l3205a" , 0xd8, 0x001620C2, 0x100, 0x10000, 0x400000),
FLASH_ID("mac 25l6405" , 0xd8, 0x001720C2, 0x100, 0x10000, 0x800000),
};
/* Define spear specific structures */
struct spear_snor_flash;
/**
* struct spear_smi - Structure for SMI Device
*
* @clk: functional clock
* @status: current status register of SMI.
* @clk_rate: functional clock rate of SMI (default: SMI_MAX_CLOCK_FREQ)
* @lock: lock to prevent parallel access of SMI.
* @io_base: base address for registers of SMI.
* @pdev: platform device
* @cmd_complete: queue to wait for command completion of NOR-flash.
* @num_flashes: number of flashes actually present on board.
* @flash: separate structure for each Serial NOR-flash attached to SMI.
*/
struct spear_smi {
struct clk *clk;
u32 status;
unsigned long clk_rate;
struct mutex lock;
void __iomem *io_base;
struct platform_device *pdev;
wait_queue_head_t cmd_complete;
u32 num_flashes;
struct spear_snor_flash *flash[MAX_NUM_FLASH_CHIP];
};
/**
* struct spear_snor_flash - Structure for Serial NOR Flash
*
* @bank: Bank number(0, 1, 2, 3) for each NOR-flash.
* @dev_id: Device ID of NOR-flash.
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/io.h`, `linux/ioport.h`.
- Detected declarations: `struct flash_device`, `struct spear_snor_flash`, `struct spear_smi`, `struct spear_snor_flash`, `function spear_smi_read_sr`, `function WIP`, `function spear_smi_int_handler`, `function spear_smi_hw_init`, `function get_flash_index`, `function spear_smi_write_enable`.
- 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.
- 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.