/* * Note on opcode nomenclature: some opcodes have a format like * SPINOR_OP_FUNCTION{4,}_x_y_z. The numbers x, y, and z stand for the number * of I/O lines used for the opcode, address, and data (respectively). The * FUNCTION has an optional suffix of '4', to represent an opcode which * requires a 4-byte (32-bit) address.
*/
/** * struct spi_nor_hwcaps - Structure for describing the hardware capabilies * supported by the SPI controller (bus master). * @mask: the bitmask listing all the supported hw capabilies
*/ struct spi_nor_hwcaps {
u32 mask;
};
/* *(Fast) Read capabilities. * MUST be ordered by priority: the higher bit position, the higher priority. * As a matter of performances, it is relevant to use Octal SPI protocols first, * then Quad SPI protocols before Dual SPI protocols, Fast Read and lastly * (Slow) Read.
*/ #define SNOR_HWCAPS_READ_MASK GENMASK(15, 0) #define SNOR_HWCAPS_READ BIT(0) #define SNOR_HWCAPS_READ_FAST BIT(1) #define SNOR_HWCAPS_READ_1_1_1_DTR BIT(2)
/* * Page Program capabilities. * MUST be ordered by priority: the higher bit position, the higher priority. * Like (Fast) Read capabilities, Octal/Quad SPI protocols are preferred to the * legacy SPI 1-1-1 protocol. * Note that Dual Page Programs are not supported because there is no existing * JEDEC/SFDP standard to define them. Also at this moment no SPI flash memory * implements such commands.
*/ #define SNOR_HWCAPS_PP_MASK GENMASK(23, 16) #define SNOR_HWCAPS_PP BIT(16)
/* Forward declaration that is used in 'struct spi_nor_controller_ops' */ struct spi_nor;
/** * struct spi_nor_controller_ops - SPI NOR controller driver specific * operations. * @prepare: [OPTIONAL] do some preparations for the * read/write/erase/lock/unlock operations. * @unprepare: [OPTIONAL] do some post work after the * read/write/erase/lock/unlock operations. * @read_reg: read out the register. * @write_reg: write data to the register. * @read: read data from the SPI NOR. * @write: write data to the SPI NOR. * @erase: erase a sector of the SPI NOR at the offset @offs; if * not provided by the driver, SPI NOR will send the erase * opcode via write_reg().
*/ struct spi_nor_controller_ops { int (*prepare)(struct spi_nor *nor); void (*unprepare)(struct spi_nor *nor); int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, size_t len); int (*write_reg)(struct spi_nor *nor, u8 opcode, const u8 *buf,
size_t len);
/** * enum spi_nor_cmd_ext - describes the command opcode extension in DTR mode * @SPI_NOR_EXT_NONE: no extension. This is the default, and is used in Legacy * SPI mode * @SPI_NOR_EXT_REPEAT: the extension is same as the opcode * @SPI_NOR_EXT_INVERT: the extension is the bitwise inverse of the opcode * @SPI_NOR_EXT_HEX: the extension is any hex value. The command and opcode * combine to form a 16-bit opcode.
*/ enum spi_nor_cmd_ext {
SPI_NOR_EXT_NONE = 0,
SPI_NOR_EXT_REPEAT,
SPI_NOR_EXT_INVERT,
SPI_NOR_EXT_HEX,
};
/* * Forward declarations that are used internally by the core and manufacturer * drivers.
*/ struct flash_info; struct spi_nor_manufacturer; struct spi_nor_flash_parameter;
/** * struct spi_nor - Structure for defining the SPI NOR layer * @mtd: an mtd_info structure * @lock: the lock for the read/write/erase/lock/unlock operations * @rww: Read-While-Write (RWW) sync lock * @rww.wait: wait queue for the RWW sync * @rww.ongoing_io: the bus is busy * @rww.ongoing_rd: a read is ongoing on the chip * @rww.ongoing_pe: a program/erase is ongoing on the chip * @rww.used_banks: bitmap of the banks in use * @dev: pointer to an SPI device or an SPI NOR controller device * @spimem: pointer to the SPI memory device * @bouncebuf: bounce buffer used when the buffer passed by the MTD * layer is not DMA-able * @bouncebuf_size: size of the bounce buffer * @id: The flash's ID bytes. Always contains * SPI_NOR_MAX_ID_LEN bytes. * @info: SPI NOR part JEDEC MFR ID and other info * @manufacturer: SPI NOR manufacturer * @addr_nbytes: number of address bytes * @erase_opcode: the opcode for erasing a sector * @read_opcode: the read opcode * @read_dummy: the dummy needed by the read operation * @program_opcode: the program opcode * @sst_write_second: used by the SST write operation * @flags: flag options for the current SPI NOR (SNOR_F_*) * @cmd_ext_type: the command opcode extension type for DTR mode. * @read_proto: the SPI protocol for read operations * @write_proto: the SPI protocol for write operations * @reg_proto: the SPI protocol for read_reg/write_reg/erase operations * @sfdp: the SFDP data of the flash * @debugfs_root: pointer to the debugfs directory * @controller_ops: SPI NOR controller driver specific operations. * @params: [FLASH-SPECIFIC] SPI NOR flash parameters and settings. * The structure includes legacy flash parameters and * settings that can be overwritten by the spi_nor_fixups * hooks, or dynamically when parsing the SFDP tables. * @dirmap: pointers to struct spi_mem_dirmap_desc for reads/writes. * @priv: pointer to the private data
*/ struct spi_nor { struct mtd_info mtd; struct mutex lock; struct spi_nor_rww {
wait_queue_head_t wait; bool ongoing_io; bool ongoing_rd; bool ongoing_pe; unsignedint used_banks;
} rww; struct device *dev; struct spi_mem *spimem;
u8 *bouncebuf;
size_t bouncebuf_size;
u8 *id; conststruct flash_info *info; conststruct spi_nor_manufacturer *manufacturer;
u8 addr_nbytes;
u8 erase_opcode;
u8 read_opcode;
u8 read_dummy;
u8 program_opcode; enum spi_nor_protocol read_proto; enum spi_nor_protocol write_proto; enum spi_nor_protocol reg_proto; bool sst_write_second;
u32 flags; enum spi_nor_cmd_ext cmd_ext_type; struct sfdp *sfdp; struct dentry *debugfs_root;
/** * spi_nor_scan() - scan the SPI NOR * @nor: the spi_nor structure * @name: the chip type name * @hwcaps: the hardware capabilities supported by the controller driver * * The drivers can use this function to scan the SPI NOR. * In the scanning, it will try to get all the necessary information to * fill the mtd_info{} and the spi_nor{}. * * The chip type name can be provided through the @name parameter. * * Return: 0 for success, others for failure.
*/ int spi_nor_scan(struct spi_nor *nor, constchar *name, conststruct spi_nor_hwcaps *hwcaps);
#endif
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.