drivers/spi/spi-qpic-snand.c

Source file repositories/reference/linux-study-clean/drivers/spi/spi-qpic-snand.c

File Facts

System
Linux kernel
Corpus path
drivers/spi/spi-qpic-snand.c
Extension
.c
Size
46747 bytes
Lines
1649
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct snandc_read_status {
	__le32 snandc_flash;
	__le32 snandc_buffer;
	__le32 snandc_erased_cw;
};

/*
 * ECC state struct
 * @corrected:		ECC corrected
 * @bitflips:		Max bit flip
 * @failed:		ECC failed
 */
struct qcom_ecc_stats {
	u32 corrected;
	u32 bitflips;
	u32 failed;
};

struct qpic_ecc {
	int ecc_bytes_hw;
	int spare_bytes;
	int bbm_size;
	int ecc_mode;
	int bytes;
	int steps;
	int step_size;
	int strength;
	int cw_size;
	int cw_data;
	u32 cfg0;
	u32 cfg1;
	u32 cfg0_raw;
	u32 cfg1_raw;
	u32 ecc_buf_cfg;
	u32 ecc_bch_cfg;
	bool bch_enabled;
};

struct qpic_spi_nand {
	struct qcom_nand_controller *snandc;
	struct spi_controller *ctlr;
	struct mtd_info *mtd;
	struct clk *iomacro_clk;
	struct qpic_ecc *ecc;
	struct qcom_ecc_stats ecc_stats;
	struct nand_ecc_engine ecc_eng;
	u8 *data_buf;
	u8 *oob_buf;
	__le32 addr1;
	__le32 addr2;
	__le32 cmd;
	u32 num_cw;
	bool oob_rw;
	bool page_rw;
	bool raw_rw;
};

static void qcom_spi_set_read_loc_first(struct qcom_nand_controller *snandc,
					int reg, int cw_offset, int read_size,
					int is_last_read_loc)
{
	__le32 locreg_val;
	u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
		  FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
		  FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);

	locreg_val = cpu_to_le32(val);

	if (reg == NAND_READ_LOCATION_0)
		snandc->regs->read_location0 = locreg_val;
	else if (reg == NAND_READ_LOCATION_1)
		snandc->regs->read_location1 = locreg_val;
	else if (reg == NAND_READ_LOCATION_2)
		snandc->regs->read_location2 = locreg_val;
	else if (reg == NAND_READ_LOCATION_3)
		snandc->regs->read_location3 = locreg_val;
}

static void qcom_spi_set_read_loc_last(struct qcom_nand_controller *snandc,
				       int reg, int cw_offset, int read_size,
				       int is_last_read_loc)
{
	__le32 locreg_val;
	u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
		  FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
		  FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);

	locreg_val = cpu_to_le32(val);

	if (reg == NAND_READ_LOCATION_LAST_CW_0)

Annotation

Implementation Notes