Commit a63674c7 authored by Miquel Raynal's avatar Miquel Raynal

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: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200529111322.7184-7-miquel.raynal@bootlin.com
parent 36017af4
...@@ -1056,119 +1056,105 @@ struct nand_manufacturer { ...@@ -1056,119 +1056,105 @@ 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
* @parameters: Holds generic parameters under an easily readable form
* @manufacturer: Manufacturer information * @manufacturer: Manufacturer information
* @legacy: All legacy fields/hooks. If you develop a new driver, * @ops: NAND chip operations
* don't even try to use any of these fields/hooks, and if * @legacy: All legacy fields/hooks. If you develop a new driver, don't even try
* you're modifying an existing driver that is using those * to use any of these fields/hooks, and if you're modifying an
* fields/hooks, you should consider reworking the driver * existing driver that is using those fields/hooks, you should
* avoid using them. * consider reworking the driver and avoid using them.
* @ecc: [BOARDSPECIFIC] ECC control structure * @options: Various chip options. They can partly be set to inform nand_scan
* @buf_align: minimum buffer alignment required by a platform * about special functionality. See the defines for further
* @oob_poi: "poison value buffer," used for laying out OOB data * explanation.
* before writing * @onfi_timing_mode_default: Default ONFI timing mode. This field is set to the
* @page_shift: [INTERN] number of address bits in a page (column * actually used ONFI mode if the chip is ONFI
* address bits). * compliant or deduced from the datasheet otherwise
* @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock * @data_interface: NAND interface timing information
* @bbt_erase_shift: [INTERN] number of address bits in a bbt entry * @bbt_erase_shift: Number of address bits in a bbt entry
* @chip_shift: [INTERN] number of address bits in one chip * @bbt_options: Bad block table specific options. All options used here must
* @options: [BOARDSPECIFIC] various chip options. They can partly * come from bbm.h. By default, these options will be copied to
* be set to inform nand_scan about special functionality. * the appropriate nand_bbt_descr's.
* See the defines for further explanation. * @badblockpos: Bad block marker position in the oob area
* @bbt_options: [INTERN] bad block specific options. All options used * @badblockbits: Minimum number of set bits in a good block's bad block marker
* here must come from bbm.h. By default, these options * position; i.e., BBM = 11110111b is good when badblockbits = 7
* will be copied to the appropriate nand_bbt_descr's. * @bbt_td: Bad block table descriptor for flash lookup
* @badblockpos: [INTERN] position of the bad block marker in the oob * @bbt_md: Bad block table mirror descriptor
* area. * @badblock_pattern: Bad block scan pattern used for initial bad block scan
* @badblockbits: [INTERN] minimum number of set bits in a good block's * @bbt: Bad block table pointer
* bad block marker position; i.e., BBM == 11110111b is * @page_shift: Number of address bits in a page (column address bits)
* not bad when badblockbits == 7 * @phys_erase_shift: Number of address bits in a physical eraseblock
* @onfi_timing_mode_default: [INTERN] default ONFI timing mode. This field is * @chip_shift: Number of address bits in one chip
* set to the actually used ONFI mode if the chip is * @pagemask: Page number mask = number of (pages / chip) - 1
* ONFI compliant or deduced from the datasheet if * @subpagesize: Holds the subpagesize
* the NAND chip is not ONFI compliant. * @data_buf: Buffer for data, size is (page size + oobsize)
* @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 * @oob_poi: pointer on the OOB area covered by data_buf
* @data_buf: [INTERN] buffer for data, size is (page size + oobsize).
* @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;
/* 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 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 long buf_align;
unsigned int subpagesize; /* Internals */
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; struct mutex lock;
unsigned int suspended : 1; unsigned int suspended : 1;
int cur_cs;
int read_retries;
u8 *oob_poi; /* Externals */
struct nand_controller *controller; struct nand_controller *controller;
struct nand_ecc_ctrl ecc; struct nand_ecc_ctrl ecc;
unsigned long buf_align;
u8 *bbt;
struct nand_bbt_descr *bbt_td;
struct nand_bbt_descr *bbt_md;
struct nand_bbt_descr *badblock_pattern;
void *priv; void *priv;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment