STRUCT ONENAND_CHIP(9)
π NAME
struct onenand_chip β the OneNAND Private Flash Chip Data, aka the one struct that holds literally everything the kernel needs to gossip with your OneNAND flash chip π
okay so real quick before we dive in: this page lives in the Kernel API Manual and it is genuinely giving "one struct to hold the whole entire chip" energy. it ate. it's iconic. periodt. π
β¨ SYNOPSIS
struct onenand_chip {
void __iomem *base;
unsigned dies;
unsigned boundary[MAX_DIES];
loff_t diesize[MAX_DIES];
unsigned int chipsize;
unsigned int device_id;
unsigned int version_id;
unsigned int technology;
unsigned int density_mask;
unsigned int options;
unsigned int badblockpos;
unsigned int erase_shift;
unsigned int page_shift;
unsigned int page_mask;
unsigned int writesize;
unsigned int bufferram_index;
struct onenand_bufferram bufferram[MAX_BUFFERRAM];
int (*command)(struct mtd_info *mtd, int cmd, loff_t address, size_t len);
int (*wait)(struct mtd_info *mtd, int state);
int (*bbt_wait)(struct mtd_info *mtd, int state);
void (*unlock_all)(struct mtd_info *mtd);
int (*read_bufferram)(struct mtd_info *mtd, int area, unsigned char *buffer, int offset, size_t count);
int (*write_bufferram)(struct mtd_info *mtd, int area, const unsigned char *buffer, int offset, size_t count);
unsigned short (*read_word)(void __iomem *addr);
void (*write_word)(unsigned short value, void __iomem *addr);
void (*mmcontrol)(struct mtd_info *mtd, int sync_read);
int (*chip_probe)(struct mtd_info *mtd);
int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
int (*scan_bbt)(struct mtd_info *mtd);
int (*enable)(struct mtd_info *mtd);
int (*disable)(struct mtd_info *mtd);
struct completion complete;
int irq;
spinlock_t chip_lock;
wait_queue_head_t wq;
flstate_t state;
unsigned char *page_buf;
unsigned char *oob_buf;
#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE;
unsigned char *verify_buf;
#endif;
int subpagesize;
void *bbm;
void *priv;
unsigned int ongoing;
};
lowkey look at all those function pointers π the struct is basically a whole personality made of callbacks π¦
πΈ MEMBERS
btw if you're wondering what those lil bracketed tags mean, they're the vibe check on each member β [INTERN], [BOARDSPECIFIC], [REPLACEABLE], [OPTIONAL], and [INTERN][FLEX-ONENAND] for the Flex-OneNAND-specific ones. they tell you who's allowed to touch it, iykyk π
baseβ[BOARDSPECIFIC]the address you use to access OneNANDdiesβ[INTERN][FLEX-ONENAND]how many dies are on the chipboundaryβ[INTERN][FLEX-ONENAND]the boundary of the diesdiesizeβ[INTERN][FLEX-ONENAND]the size of the dieschipsizeβ[INTERN]the size of one chip for multichip arrays. there's a straight-up FIXME here: for Flex-OneNAND,chipsizeholds the maximum possible device size, i.e. when all blocks are considered MLC π«device_idβ[INTERN]the device IDdensity_maskβ chip density, used for DDP devicesoptionsβ[BOARDSPECIFIC]various chip options. they can partly be set to informonenand_scanabout stufferase_shiftβ[INTERN]number of address bits in a blockpage_shiftβ[INTERN]number of address bits in a pagepage_maskβ[INTERN]a page per block maskwritesizeβ[INTERN]a real page sizebufferram_indexβ[INTERN]BufferRAM indexbufferramβ[INTERN]BufferRAM infocommandβ[REPLACEABLE]hardware specific function for writing commands to the chipwaitβ[REPLACEABLE]hardware specific function for wait on readybbt_waitβ[REPLACEABLE]hardware specific function for bbt wait on readyunlock_allβ[REPLACEABLE]hardware specific function for unlock allread_bufferramβ[REPLACEABLE]hardware specific function for BufferRAM Areawrite_bufferramβ[REPLACEABLE]hardware specific function for BufferRAM Arearead_wordβ[REPLACEABLE]hardware specific function for read register of OneNANDwrite_wordβ[REPLACEABLE]hardware specific function for write register of OneNANDmmcontrolβ sync burst read functionchip_probeβ[REPLACEABLE]hardware specific function for chip probeblock_markbadβ function to mark a block as badscan_bbtβ[REPLACEALBE]hardware specific function for scanning Bad block Table (and yes, that spelling is straight from the source, bestie β we don't edit the source, we respect the source π)chip_lockβ[INTERN]spinlock used to protect access to this structure and the chipwqβ[INTERN]wait queue to sleep on if a OneNAND operation is in progressstateβ[INTERN]the current state of the OneNAND devicepage_bufβ[INTERN]page main data bufferoob_bufβ[INTERN]page oob data buffersubpagesizeβ[INTERN]holds the subpagesizebbmβ[REPLACEABLE]pointer to Bad Block Managementprivβ[OPTIONAL]pointer to private chip date
ngl a couple of the fields up in the struct above don't get their own lil blurb in this Members list βversion_id,technology,badblockpos,enable,disable,complete,irqandongoingare just out here living their lives. that's not me gatekeeping, that's literally how the page is written π
π¦ SEE ALSO
- Kernel file
./include/linux/mtd/onenand.h struct onenand_bufferram(9)struct onenand_manufacturers(9)
go read those next, bestie, the lore goes deep π
and that's the whole page!! this lil rewrite came to you from the Kernel API Manual, sourced from ./include/linux/mtd, dated October 2026 π«Ά stay hydrated, back up your flash, and don't forget to #ifdef your verify_buf πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms