mtd: rawnand: Reorganize the nand_chip structure
Reorder fields in this structure and pack entries by theme: * The main descriptive structures * The data interface details * Bad block information * The device layout * Extra buffers matching the device layout * Internal values * External objects like the ECC controller, the ECC engine and a private data pointer. While at it, adapt the documentation style. I changed on purpose the description of @oob_poi which was weird. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://lore.kernel.org/linux-mtd/20200529111322.7184-7-miquel.raynal@bootlin.com
This commit is contained in:
@@ -1055,120 +1055,106 @@ struct nand_manufacturer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* struct nand_chip - NAND Private Flash Chip Data
|
* struct nand_chip - NAND Private Flash Chip Data
|
||||||
* @base: Inherit from the generic NAND device
|
* @base: Inherit from the generic NAND device
|
||||||
* @ops: NAND chip operations
|
* @id: Holds NAND ID
|
||||||
* @manufacturer: Manufacturer information
|
* @parameters: Holds generic parameters under an easily readable form
|
||||||
* @legacy: All legacy fields/hooks. If you develop a new driver,
|
* @manufacturer: Manufacturer information
|
||||||
* don't even try to use any of these fields/hooks, and if
|
* @ops: NAND chip operations
|
||||||
* you're modifying an existing driver that is using those
|
* @legacy: All legacy fields/hooks. If you develop a new driver, don't even try
|
||||||
* fields/hooks, you should consider reworking the driver
|
* to use any of these fields/hooks, and if you're modifying an
|
||||||
* avoid using them.
|
* existing driver that is using those fields/hooks, you should
|
||||||
* @ecc: [BOARDSPECIFIC] ECC control structure
|
* consider reworking the driver and avoid using them.
|
||||||
* @buf_align: minimum buffer alignment required by a platform
|
* @options: Various chip options. They can partly be set to inform nand_scan
|
||||||
* @oob_poi: "poison value buffer," used for laying out OOB data
|
* about special functionality. See the defines for further
|
||||||
* before writing
|
* explanation.
|
||||||
* @page_shift: [INTERN] number of address bits in a page (column
|
* @onfi_timing_mode_default: Default ONFI timing mode. This field is set to the
|
||||||
* address bits).
|
* actually used ONFI mode if the chip is ONFI
|
||||||
* @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock
|
* compliant or deduced from the datasheet otherwise
|
||||||
* @bbt_erase_shift: [INTERN] number of address bits in a bbt entry
|
* @data_interface: NAND interface timing information
|
||||||
* @chip_shift: [INTERN] number of address bits in one chip
|
* @bbt_erase_shift: Number of address bits in a bbt entry
|
||||||
* @options: [BOARDSPECIFIC] various chip options. They can partly
|
* @bbt_options: Bad block table specific options. All options used here must
|
||||||
* be set to inform nand_scan about special functionality.
|
* come from bbm.h. By default, these options will be copied to
|
||||||
* See the defines for further explanation.
|
* the appropriate nand_bbt_descr's.
|
||||||
* @bbt_options: [INTERN] bad block specific options. All options used
|
* @badblockpos: Bad block marker position in the oob area
|
||||||
* here must come from bbm.h. By default, these options
|
* @badblockbits: Minimum number of set bits in a good block's bad block marker
|
||||||
* will be copied to the appropriate nand_bbt_descr's.
|
* position; i.e., BBM = 11110111b is good when badblockbits = 7
|
||||||
* @badblockpos: [INTERN] position of the bad block marker in the oob
|
* @bbt_td: Bad block table descriptor for flash lookup
|
||||||
* area.
|
* @bbt_md: Bad block table mirror descriptor
|
||||||
* @badblockbits: [INTERN] minimum number of set bits in a good block's
|
* @badblock_pattern: Bad block scan pattern used for initial bad block scan
|
||||||
* bad block marker position; i.e., BBM == 11110111b is
|
* @bbt: Bad block table pointer
|
||||||
* not bad when badblockbits == 7
|
* @page_shift: Number of address bits in a page (column address bits)
|
||||||
* @onfi_timing_mode_default: [INTERN] default ONFI timing mode. This field is
|
* @phys_erase_shift: Number of address bits in a physical eraseblock
|
||||||
* set to the actually used ONFI mode if the chip is
|
* @chip_shift: Number of address bits in one chip
|
||||||
* ONFI compliant or deduced from the datasheet if
|
* @pagemask: Page number mask = number of (pages / chip) - 1
|
||||||
* the NAND chip is not ONFI compliant.
|
* @subpagesize: Holds the subpagesize
|
||||||
* @pagemask: [INTERN] page number mask = number of (pages / chip) - 1
|
* @data_buf: Buffer for data, size is (page size + oobsize)
|
||||||
* @data_buf: [INTERN] buffer for data, size is (page size + oobsize).
|
* @oob_poi: pointer on the OOB area covered by data_buf
|
||||||
* @pagecache: Structure containing page cache related fields
|
* @pagecache: Structure containing page cache related fields
|
||||||
* @pagecache.bitflips: Number of bitflips of the cached page
|
* @pagecache.bitflips: Number of bitflips of the cached page
|
||||||
* @pagecache.page: Page number currently in the cache. -1 means no page is
|
* @pagecache.page: Page number currently in the cache. -1 means no page is
|
||||||
* currently cached
|
* currently cached
|
||||||
* @subpagesize: [INTERN] holds the subpagesize
|
* @buf_align: Minimum buffer alignment required by a platform
|
||||||
* @id: [INTERN] holds NAND ID
|
* @lock: Lock protecting the suspended field. Also used to serialize accesses
|
||||||
* @parameters: [INTERN] holds generic parameters under an easily
|
* to the NAND device
|
||||||
* readable form.
|
* @suspended: Set to 1 when the device is suspended, 0 when it's not
|
||||||
* @data_interface: [INTERN] NAND interface timing information
|
* @cur_cs: Currently selected target. -1 means no target selected, otherwise we
|
||||||
* @cur_cs: currently selected target. -1 means no target selected,
|
* should always have cur_cs >= 0 && cur_cs < nanddev_ntargets().
|
||||||
* otherwise we should always have cur_cs >= 0 &&
|
* NAND Controller drivers should not modify this value, but they're
|
||||||
* cur_cs < nanddev_ntargets(). NAND Controller drivers
|
* allowed to read it.
|
||||||
* should not modify this value, but they're allowed to
|
* @read_retries: The number of read retry modes supported
|
||||||
* read it.
|
* @controller: The hardware controller structure which is shared among multiple
|
||||||
* @read_retries: [INTERN] the number of read retry modes supported
|
* independent devices
|
||||||
* @lock: lock protecting the suspended field. Also used to
|
* @ecc: The ECC controller structure
|
||||||
* serialize accesses to the NAND device.
|
* @priv: Chip private data
|
||||||
* @suspended: set to 1 when the device is suspended, 0 when it's not.
|
|
||||||
* @bbt: [INTERN] bad block table pointer
|
|
||||||
* @bbt_td: [REPLACEABLE] bad block table descriptor for flash
|
|
||||||
* lookup.
|
|
||||||
* @bbt_md: [REPLACEABLE] bad block table mirror descriptor
|
|
||||||
* @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial
|
|
||||||
* bad block scan.
|
|
||||||
* @controller: [REPLACEABLE] a pointer to a hardware controller
|
|
||||||
* structure which is shared among multiple independent
|
|
||||||
* devices.
|
|
||||||
* @priv: [OPTIONAL] pointer to private chip data
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct nand_chip {
|
struct nand_chip {
|
||||||
struct nand_device base;
|
struct nand_device base;
|
||||||
|
struct nand_id id;
|
||||||
|
struct nand_parameters parameters;
|
||||||
struct nand_manufacturer manufacturer;
|
struct nand_manufacturer manufacturer;
|
||||||
struct nand_chip_ops ops;
|
struct nand_chip_ops ops;
|
||||||
struct nand_legacy legacy;
|
struct nand_legacy legacy;
|
||||||
|
|
||||||
unsigned int options;
|
unsigned int options;
|
||||||
unsigned int bbt_options;
|
|
||||||
|
|
||||||
|
/* Data interface */
|
||||||
|
int onfi_timing_mode_default;
|
||||||
|
struct nand_data_interface data_interface;
|
||||||
|
|
||||||
|
/* Bad block information */
|
||||||
|
unsigned int bbt_erase_shift;
|
||||||
|
unsigned int bbt_options;
|
||||||
|
unsigned int badblockpos;
|
||||||
|
unsigned int badblockbits;
|
||||||
|
struct nand_bbt_descr *bbt_td;
|
||||||
|
struct nand_bbt_descr *bbt_md;
|
||||||
|
struct nand_bbt_descr *badblock_pattern;
|
||||||
|
u8 *bbt;
|
||||||
|
|
||||||
|
/* Device internal layout */
|
||||||
unsigned int page_shift;
|
unsigned int page_shift;
|
||||||
unsigned int phys_erase_shift;
|
unsigned int phys_erase_shift;
|
||||||
unsigned int bbt_erase_shift;
|
|
||||||
unsigned int chip_shift;
|
unsigned int chip_shift;
|
||||||
unsigned int pagemask;
|
unsigned int pagemask;
|
||||||
u8 *data_buf;
|
unsigned int subpagesize;
|
||||||
|
|
||||||
|
/* Buffers */
|
||||||
|
u8 *data_buf;
|
||||||
|
u8 *oob_poi;
|
||||||
struct {
|
struct {
|
||||||
unsigned int bitflips;
|
unsigned int bitflips;
|
||||||
int page;
|
int page;
|
||||||
} pagecache;
|
} pagecache;
|
||||||
|
|
||||||
unsigned int subpagesize;
|
|
||||||
int onfi_timing_mode_default;
|
|
||||||
unsigned int badblockpos;
|
|
||||||
unsigned int badblockbits;
|
|
||||||
|
|
||||||
struct nand_id id;
|
|
||||||
struct nand_parameters parameters;
|
|
||||||
|
|
||||||
struct nand_data_interface data_interface;
|
|
||||||
|
|
||||||
int cur_cs;
|
|
||||||
|
|
||||||
int read_retries;
|
|
||||||
|
|
||||||
struct mutex lock;
|
|
||||||
unsigned int suspended : 1;
|
|
||||||
|
|
||||||
u8 *oob_poi;
|
|
||||||
struct nand_controller *controller;
|
|
||||||
|
|
||||||
struct nand_ecc_ctrl ecc;
|
|
||||||
unsigned long buf_align;
|
unsigned long buf_align;
|
||||||
|
|
||||||
u8 *bbt;
|
/* Internals */
|
||||||
struct nand_bbt_descr *bbt_td;
|
struct mutex lock;
|
||||||
struct nand_bbt_descr *bbt_md;
|
unsigned int suspended : 1;
|
||||||
|
int cur_cs;
|
||||||
struct nand_bbt_descr *badblock_pattern;
|
int read_retries;
|
||||||
|
|
||||||
|
/* Externals */
|
||||||
|
struct nand_controller *controller;
|
||||||
|
struct nand_ecc_ctrl ecc;
|
||||||
void *priv;
|
void *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user