drivers/mtd/spi-nor/spansion.c
Source file repositories/reference/linux-study-clean/drivers/mtd/spi-nor/spansion.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/spi-nor/spansion.c- Extension
.c- Size
- 32955 bytes
- Lines
- 1177
- 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.
- 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/bitfield.hlinux/device.hlinux/errno.hlinux/mtd/spi-nor.hcore.h
Detected Declarations
struct spansion_nor_paramsfunction spansion_nor_clear_srfunction cypress_nor_sr_ready_and_clear_regfunction cypress_nor_sr_ready_and_clearfunction cypress_nor_set_memlatfunction cypress_nor_set_octal_dtr_bitsfunction cypress_nor_octal_dtr_enfunction cypress_nor_set_single_spi_bitsfunction cypress_nor_octal_dtr_disfunction cypress_nor_quad_enable_volatile_regfunction cypress_nor_quad_enable_volatilefunction cypress_nor_set_4byte_addr_modefunction cypress_nor_determine_addr_mode_by_sr1function cypress_nor_set_addr_mode_nbytesfunction cypress_nor_get_page_sizefunction cypress_nor_ecc_initfunction s25fs256t_post_bfpt_fixupfunction s25fs256t_post_sfdp_fixupfunction s25fs256t_late_initfunction s25hx_t_post_bfpt_fixupfunction s25hx_t_post_sfdp_fixupfunction s25hx_t_late_initfunction cypress_nor_set_octal_dtrfunction s28hx_t_post_sfdp_fixupfunction s28hx_t_post_bfpt_fixupfunction s28hx_t_late_initfunction s25fs_s_nor_post_bfpt_fixupsfunction s25fs_s_nor_smpt_read_dummyfunction s25fs_s_nor_smpt_map_id_dummyfunction spansion_nor_sr_ready_and_clearfunction spansion_nor_late_init
Annotated Snippet
struct spansion_nor_params {
u8 clsr;
};
/**
* spansion_nor_clear_sr() - Clear the Status Register.
* @nor: pointer to 'struct spi_nor'.
*/
static void spansion_nor_clear_sr(struct spi_nor *nor)
{
const struct spansion_nor_params *priv_params = nor->params->priv;
int ret;
if (nor->spimem) {
struct spi_mem_op op = SPANSION_OP(priv_params->clsr);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
ret = spi_mem_exec_op(nor->spimem, &op);
} else {
ret = spi_nor_controller_ops_write_reg(nor, SPINOR_OP_CLSR,
NULL, 0);
}
if (ret)
dev_dbg(nor->dev, "error %d clearing SR\n", ret);
}
static int cypress_nor_sr_ready_and_clear_reg(struct spi_nor *nor, u64 addr)
{
struct spi_nor_flash_parameter *params = nor->params;
struct spi_mem_op op =
CYPRESS_NOR_RD_ANY_REG_OP(params->addr_mode_nbytes, addr,
0, nor->bouncebuf);
int ret;
if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) {
op.addr.nbytes = nor->addr_nbytes;
op.dummy.nbytes = params->rdsr_dummy;
op.data.nbytes = 2;
}
ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto);
if (ret)
return ret;
if (nor->bouncebuf[0] & (SR_E_ERR | SR_P_ERR)) {
if (nor->bouncebuf[0] & SR_E_ERR)
dev_err(nor->dev, "Erase Error occurred\n");
else
dev_err(nor->dev, "Programming Error occurred\n");
spansion_nor_clear_sr(nor);
ret = spi_nor_write_disable(nor);
if (ret)
return ret;
return -EIO;
}
return !(nor->bouncebuf[0] & SR_WIP);
}
/**
* cypress_nor_sr_ready_and_clear() - Query the Status Register of each die by
* using Read Any Register command to see if the whole flash is ready for new
* commands and clear it if there are any errors.
* @nor: pointer to 'struct spi_nor'.
*
* Return: 1 if ready, 0 if not ready, -errno on errors.
*/
static int cypress_nor_sr_ready_and_clear(struct spi_nor *nor)
{
struct spi_nor_flash_parameter *params = nor->params;
u64 addr;
int ret;
u8 i;
for (i = 0; i < params->n_dice; i++) {
addr = params->vreg_offset[i] + SPINOR_REG_CYPRESS_STR1;
ret = cypress_nor_sr_ready_and_clear_reg(nor, addr);
if (ret < 0)
return ret;
else if (ret == 0)
return 0;
}
return 1;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/device.h`, `linux/errno.h`, `linux/mtd/spi-nor.h`, `core.h`.
- Detected declarations: `struct spansion_nor_params`, `function spansion_nor_clear_sr`, `function cypress_nor_sr_ready_and_clear_reg`, `function cypress_nor_sr_ready_and_clear`, `function cypress_nor_set_memlat`, `function cypress_nor_set_octal_dtr_bits`, `function cypress_nor_octal_dtr_en`, `function cypress_nor_set_single_spi_bits`, `function cypress_nor_octal_dtr_dis`, `function cypress_nor_quad_enable_volatile_reg`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
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.