Lines Matching +full:spi +full:- +full:lsb +full:- +full:first
1 /* SPDX-License-Identifier: GPL-2.0+ */
12 #include <linux/spi/spi-mem.h>
17 * The first byte returned from the flash after sending opcode SPINOR_OP_RDID.
35 * requires a 4-byte (32-bit) address.
46 #define SPINOR_OP_READ_1_1_2 0x3b /* Read data bytes (Dual Output SPI) */
47 #define SPINOR_OP_READ_1_2_2 0xbb /* Read data bytes (Dual I/O SPI) */
48 #define SPINOR_OP_READ_1_1_4 0x6b /* Read data bytes (Quad Output SPI) */
49 #define SPINOR_OP_READ_1_4_4 0xeb /* Read data bytes (Quad I/O SPI) */
50 #define SPINOR_OP_READ_1_1_8 0x8b /* Read data bytes (Octal Output SPI) */
51 #define SPINOR_OP_READ_1_8_8 0xcb /* Read data bytes (Octal I/O SPI) */
70 /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */
73 #define SPINOR_OP_READ_1_1_2_4B 0x3c /* Read data bytes (Dual Output SPI) */
74 #define SPINOR_OP_READ_1_2_2_4B 0xbc /* Read data bytes (Dual I/O SPI) */
75 #define SPINOR_OP_READ_1_1_4_4B 0x6c /* Read data bytes (Quad Output SPI) */
76 #define SPINOR_OP_READ_1_4_4_4B 0xec /* Read data bytes (Quad I/O SPI) */
77 #define SPINOR_OP_READ_1_1_8_4B 0x7c /* Read data bytes (Octal Output SPI) */
78 #define SPINOR_OP_READ_1_8_8_4B 0xcc /* Read data bytes (Octal I/O SPI) */
88 /* Double Transfer Rate opcodes - defined in JEDEC JESD216B. */
112 #define SPINOR_OP_EN4B 0xb7 /* Enter 4-byte mode */
113 #define SPINOR_OP_EX4B 0xe9 /* Exit 4-byte mode */
153 /* Supported SPI protocols */
249 * struct spi_nor_erase_type - Structure to describe a SPI NOR erase type
255 * @opcode: the SPI command op code to erase the sector/block.
270 * struct spi_nor_erase_command - Used for non-uniform erases
273 * are run-length encoded.
278 * @opcode: the SPI command op code to erase the sector/block.
288 * struct spi_nor_erase_region - Structure to describe a SPI NOR erase region
290 * LSB bits are used as a bitmask encoding flags to
292 * the last in the SPI NOR flash memory and to indicate
304 #define SNOR_ERASE_TYPE_MASK GENMASK_ULL(SNOR_ERASE_TYPE_MAX - 1, 0)
310 #define SNOR_ERASE_FLAGS_MASK GENMASK_ULL(SNOR_ERASE_FLAGS_MAX - 1, 0)
313 * struct spi_nor_erase_map - Structure to describe the SPI NOR erase map
317 * @uniform_region: a pre-allocated erase region for SPI NOR with a uniform
321 * smallest Erase Type size being the first member in the
325 * uniform and non-uniform SPI NOR flash memories if they
337 * struct spi_nor_hwcaps - Structure for describing the hardware capabilies
338 * supported by the SPI controller (bus master).
348 * As a matter of performances, it is relevant to use Octal SPI protocols first,
349 * then Quad SPI protocols before Dual SPI protocols, Fast Read and lastly
378 * Like (Fast) Read capabilities, Octal/Quad SPI protocols are preferred to the
379 * legacy SPI 1-1-1 protocol.
381 * JEDEC/SFDP standard to define them. Also at this moment no SPI flash memory
428 /* Dual SPI */
434 /* Quad SPI */
440 /* Octal SPI */
452 /* Quad SPI */
457 /* Octal SPI */
469 * struct spi_nor_locking_ops - SPI NOR locking methods
470 * @lock: lock a region of the SPI NOR.
471 * @unlock: unlock a region of the SPI NOR.
472 * @is_locked: check if a region of the SPI NOR is completely locked
481 * struct spi_nor_flash_parameter - SPI NOR flash parameters and settings.
487 * @page_size: the page size of the SPI NOR flash memory.
496 * @quad_enable: enables SPI NOR quad mode.
497 * @set_4byte: puts the SPI NOR in 4 byte addressing mode.
500 * not a power-of-2.
501 * @setup: configures the SPI NOR memory. Useful for SPI NOR
502 * flashes that have peculiarities to the SPI NOR standard
505 * @locking_ops: SPI NOR locking methods.
526 * struct flash_info - Forward declaration of a structure used internally by
532 * struct spi_nor - Structure for defining a the SPI NOR layer
535 * @dev: point to a spi device, or a spi nor controller device.
536 * @spimem: point to the spi mem device
538 * layer is not DMA-able
540 * @info: spi-nor part JDEC MFR id and other info
541 * @page_size: the page size of the SPI NOR
548 * @flags: flag options for the current SPI-NOR (SNOR_F_*)
549 * @read_proto: the SPI protocol for read operations
550 * @write_proto: the SPI protocol for write operations
551 * @reg_proto the SPI protocol for read_reg/write_reg/erase operations
556 * @read_reg: [DRIVER-SPECIFIC] read out the register
557 * @write_reg: [DRIVER-SPECIFIC] write data to the register
558 * @read: [DRIVER-SPECIFIC] read data from the SPI NOR
559 * @write: [DRIVER-SPECIFIC] write data to the SPI NOR
560 * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR
562 * spi-nor will send the erase opcode via write_reg()
563 * @clear_sr_bp: [FLASH-SPECIFIC] clears the Block Protection Bits from
564 * the SPI NOR Status Register.
565 * @params: [FLASH-SPECIFIC] SPI-NOR flash parameters and settings.
611 return region->offset & SNOR_LAST_REGION; in spi_nor_region_is_last()
617 return (region->offset & ~SNOR_ERASE_FLAGS_MASK) + region->size; in spi_nor_region_end()
623 region->offset |= SNOR_LAST_REGION; in spi_nor_region_mark_end()
629 region->offset |= SNOR_OVERLAID_REGION; in spi_nor_region_mark_overlay()
634 return !!nor->params.erase_map.uniform_erase_type; in spi_nor_has_uniform_erase()
640 mtd_set_of_node(&nor->mtd, np); in spi_nor_set_flash_node()
645 return mtd_get_of_node(&nor->mtd); in spi_nor_get_flash_node()
649 * spi_nor_scan() - scan the SPI NOR
654 * The drivers can use this fuction to scan the SPI NOR.
666 * spi_nor_restore_addr_mode() - restore the status of SPI NOR