STRUCT FLASH_INFO(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct flash_info(9)

okay bestie, welcome to struct flash_info(9) from the Kernel API Manual ✨ β€” this is the little glow-up card that tells the kernel everything it needs to know about one SPI NOR flash chip. Think of it as the flash's profile pic and bio combined πŸŽ€

✨ NAME ✨

struct flash_info β€” SPI NOR flash_info entry. literally the whole personality of a flash chip in one struct πŸ’–

🌸 SYNOPSIS 🌸

struct flash_info {
    char *name;
    const struct spi_nor_id *id;
    size_t size;
    unsigned sector_size;
    u16 page_size;
    u8 n_banks;
    u8 addr_nbytes;
    u16 flags;
  #define SPI_NOR_HAS_LOCK                BIT(0);
  #define SPI_NOR_HAS_TB                  BIT(1);
  #define SPI_NOR_TB_SR_BIT6              BIT(2);
  #define SPI_NOR_4BIT_BP                 BIT(3);
  #define SPI_NOR_BP3_SR_BIT6             BIT(4);
  #define SPI_NOR_SWP_IS_VOLATILE         BIT(5);
  #define SPI_NOR_NO_ERASE                BIT(6);
  #define SPI_NOR_QUAD_PP                 BIT(8);
  #define SPI_NOR_RWW                     BIT(9);
  #define SPI_NOR_HAS_CMP                 BIT(10);
    u8 no_sfdp_flags;
  #define SPI_NOR_SKIP_SFDP               BIT(0);
  #define SECT_4K                         BIT(1);
  #define SPI_NOR_DUAL_READ               BIT(3);
  #define SPI_NOR_QUAD_READ               BIT(4);
  #define SPI_NOR_OCTAL_READ              BIT(5);
  #define SPI_NOR_OCTAL_DTR_READ          BIT(6);
  #define SPI_NOR_OCTAL_DTR_PP            BIT(7);
    u8 fixup_flags;
  #define SPI_NOR_4B_OPCODES              BIT(0);
  #define SPI_NOR_IO_MODE_EN_VOLATILE     BIT(1);
    u8 mfr_flags;
    const struct spi_nor_otp_organization *otp;
    const struct spi_nor_fixups *fixups;
 };

no cap, that's the whole thing πŸ‘‘

πŸ¦‹ Members πŸ¦‹

  • name β€” (obsolete) the name of the flash. Do not set it for new additions, bestie, it's giving legacy energy πŸ™ˆ
  • id β€” pointer to struct spi_nor_id or NULL, which means "no ID" (mostly older chips). so if a chip has no ID, it just shows up with no ID, iconic πŸ’€
  • size β€” the size of the flash in bytes. The flash size is one property parsed by the SFDP. We use it as an indicator whether we need SFDP parsing for a particular flash. I.e. non-legacy flash entries in flash_info will have a size of zero iff SFDP should be used. so size == 0 is the "pls parse my SFDP" bat signal πŸ”₯
  • sector_size β€” (optional) the size listed here is what works with SPINOR_OP_SE, which isn't necessarily called a "sector" by the vendor. Defaults to 64k. vendors really be naming things however they want 😭
  • page_size β€” (optional) the flash's page size. Defaults to 256.
  • n_banks β€” (optional) the number of banks. Defaults to 1.
  • addr_nbytes β€” number of address bytes to send.
  • flags β€” flags that indicate support that is not defined by the JESD216 standard in its SFDP tables. Flag meanings:
    • SPI_NOR_HAS_LOCK β€” flash supports lock/unlock via SR.
    • SPI_NOR_HAS_TB β€” flash SR has Top/Bottom (TB) protect bit. Must be used with SPI_NOR_HAS_LOCK.
    • SPI_NOR_TB_SR_BIT6 β€” Top/Bottom (TB) is bit 6 of status register. Must be used with SPI_NOR_HAS_TB.
    • SPI_NOR_4BIT_BP β€” flash SR has 4 bit fields (BP0-3) for block protection.
    • SPI_NOR_BP3_SR_BIT6 β€” BP3 is bit 6 of status register. Must be used with SPI_NOR_4BIT_BP.
    • SPI_NOR_SWP_IS_VOLATILE β€” flash has volatile software write protection bits. Usually these will power-up in a write-protected state.
    • SPI_NOR_NO_ERASE β€” no erase command needed.
    • SPI_NOR_QUAD_PP β€” flash supports Quad Input Page Program.
    • SPI_NOR_RWW β€” flash supports reads while write.
    • SPI_NOR_HAS_CMP β€” flash SR2 has complement (CMP) protect bit. Must be used with SPI_NOR_HAS_LOCK.
  • no_sfdp_flags β€” flags that indicate support that can be discovered via SFDP. Used when SFDP tables are not defined in the flash. These flags are used together with the SPI_NOR_SKIP_SFDP flag. Meanings:
    • SPI_NOR_SKIP_SFDP β€” skip parsing of SFDP tables.
    • SECT_4K β€” SPINOR_OP_BE_4K works uniformly.
    • SPI_NOR_DUAL_READ β€” flash supports Dual Read.
    • SPI_NOR_QUAD_READ β€” flash supports Quad Read.
    • SPI_NOR_OCTAL_READ β€” flash supports Octal Read.
    • SPI_NOR_OCTAL_DTR_READ β€” flash supports octal DTR Read.
    • SPI_NOR_OCTAL_DTR_PP β€” flash supports Octal DTR Page Program.
  • fixup_flags β€” flags that indicate support that can be discovered via SFDP ideally, but can not be discovered for this particular flash because the SFDP table that indicates this support is not defined by the flash. In case the table for this support is defined but has wrong values, one should instead use a post_sfdp hook to set the SNOR_F equivalent flag. (yes, that's the whole vibe of this field πŸ’…)
  • mfr_flags β€” manufacturer private flags. Used in the manufacturer fixup hooks to differentiate support between flashes of the same manufacturer.
  • fixups β€” part specific fixup hooks.

πŸ’œ Description πŸ’œ

okay so these two belong to fixup_flags, and here's what they actually mean πŸ‘‡

  • SPI_NOR_4B_OPCODES β€” use dedicated 4byte address op codes to support memory size above 128Mib.
  • SPI_NOR_IO_MODE_EN_VOLATILE β€” flash enables the best available I/O mode via a volatile bit.
ngl these are the ones that make the SFDP tables go "not defined by this flash" and you're out here doing the fixups manually. it's giving main character energy 🫢

🌈 SEE ALSO 🌈

Kernel file ./drivers/mtd/spi-nor/core.h and also, bestie, go read these:

  • struct spi_nor_erase_type(9)
  • struct spi_nor_erase_command(9)
  • struct spi_nor_erase_region(9)
  • struct spi_nor_erase_map(9)
  • struct spi_nor_locking_ops(9)
  • struct spi_nor_otp_organization(9)
  • struct spi_nor_otp_ops(9)
  • struct spi_nor_otp(9)
  • struct spi_nor_flash_parameter(9)
  • struct spi_nor_fixups(9)
  • struct spi_nor_id(9)
  • struct spi_nor_manufacturer(9)
  • struct sfdp(9)
  • spi_nor_needs_sfdp(9)

πŸŽ€ and that's the whole page, bestie! this one's from ./drivers/mtd/spi-nor, dated October 2026, page struct flash_info(9) β€” slay, go forth and describe your flash chips correctly πŸ’–βœ¨πŸ“

πŸ“¦ where this page comes from