]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/linux/mtd/nand.h
mtd: nand: introduce NAND_CREATE_EMPTY_BBT
[mirror_ubuntu-bionic-kernel.git] / include / linux / mtd / nand.h
index 102e12c58cb3bbef023e0802c81f532a8cf428b0..023866572fb1e7921a1779e78205acb9900a2413 100644 (file)
@@ -53,8 +53,8 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
  * is supported now. If you add a chip with bigger oobsize/page
  * adjust this accordingly.
  */
-#define NAND_MAX_OOBSIZE       256
-#define NAND_MAX_PAGESIZE      4096
+#define NAND_MAX_OOBSIZE       576
+#define NAND_MAX_PAGESIZE      8192
 
 /*
  * Constants for hardware specific CLE/ALE/NCE function
@@ -88,6 +88,7 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 #define NAND_CMD_RNDIN         0x85
 #define NAND_CMD_READID                0x90
 #define NAND_CMD_ERASE2                0xd0
+#define NAND_CMD_PARAM         0xec
 #define NAND_CMD_RESET         0xff
 
 #define NAND_CMD_LOCK          0x2a
@@ -205,8 +206,10 @@ typedef enum {
 #define NAND_CHIPOPTIONS_MSK   (0x0000ffff & ~NAND_NO_AUTOINCR)
 
 /* Non chip related options */
-/* Use a flash based bad block table. This option is passed to the
- * default bad block table function. */
+/*
+ * Use a flash based bad block table. OOB identifier is saved in OOB area.
+ * This option is passed to the default bad block table function.
+ */
 #define NAND_USE_FLASH_BBT     0x00010000
 /* This option skips the bbt scan during initialization. */
 #define NAND_SKIP_BBTSCAN      0x00020000
@@ -215,6 +218,13 @@ typedef enum {
 #define NAND_OWN_BUFFERS       0x00040000
 /* Chip may not exist, so silence any errors in scan */
 #define NAND_SCAN_SILENT_NODEV 0x00080000
+/*
+ * If passed additionally to NAND_USE_FLASH_BBT then BBT code will not touch
+ * the OOB area.
+ */
+#define NAND_USE_FLASH_BBT_NO_OOB      0x00100000
+/* Create an empty BBT with no vendor information if the BBT is available */
+#define NAND_CREATE_EMPTY_BBT          0x00200000
 
 /* Options set by nand scan */
 /* Nand scan has allocated controller struct */
@@ -227,6 +237,69 @@ typedef enum {
 /* Keep gcc happy */
 struct nand_chip;
 
+struct nand_onfi_params {
+       /* rev info and features block */
+       u8              sig[4]; /* 'O' 'N' 'F' 'I'  */
+       __le16          revision;
+       __le16          features;
+       __le16          opt_cmd;
+       u8              reserved[22];
+
+       /* manufacturer information block */
+       char            manufacturer[12];
+       char            model[20];
+       u8              jedec_id;
+       __le16          date_code;
+       u8              reserved2[13];
+
+       /* memory organization block */
+       __le32          byte_per_page;
+       __le16          spare_bytes_per_page;
+       __le32          data_bytes_per_ppage;
+       __le16          spare_bytes_per_ppage;
+       __le32          pages_per_block;
+       __le32          blocks_per_lun;
+       u8              lun_count;
+       u8              addr_cycles;
+       u8              bits_per_cell;
+       __le16          bb_per_lun;
+       __le16          block_endurance;
+       u8              guaranteed_good_blocks;
+       __le16          guaranteed_block_endurance;
+       u8              programs_per_page;
+       u8              ppage_attr;
+       u8              ecc_bits;
+       u8              interleaved_bits;
+       u8              interleaved_ops;
+       u8              reserved3[13];
+
+       /* electrical parameter block */
+       u8              io_pin_capacitance_max;
+       __le16          async_timing_mode;
+       __le16          program_cache_timing_mode;
+       __le16          t_prog;
+       __le16          t_bers;
+       __le16          t_r;
+       __le16          t_ccs;
+       __le16          src_sync_timing_mode;
+       __le16          src_ssync_features;
+       __le16          clk_pin_capacitance_typ;
+       __le16          io_pin_capacitance_typ;
+       __le16          input_pin_capacitance_typ;
+       u8              input_pin_capacitance_max;
+       u8              driver_strenght_support;
+       __le16          t_int_r;
+       __le16          t_ald;
+       u8              reserved4[7];
+
+       /* vendor */
+       u8              reserved5[90];
+
+       __le16 crc;
+} __attribute__((packed));
+
+#define ONFI_CRC_BASE  0x4F4E
+
 /**
  * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independent devices
  * @lock:               protection lock
@@ -332,6 +405,10 @@ struct nand_buffers {
  * @block_markbad:     [REPLACEABLE] mark the block bad
  * @cmd_ctrl:          [BOARDSPECIFIC] hardwarespecific funtion for controlling
  *                     ALE/CLE/nCE. Also used to write command and address
+ * @init_size:         [BOARDSPECIFIC] hardwarespecific funtion for setting
+ *                     mtd->oobsize, mtd->writesize and so on.
+ *                     @id_data contains the 8 bytes values of NAND_CMD_READID.
+ *                     Return with the bus width.
  * @dev_ready:         [BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line
  *                     If set to NULL no access to ready/busy is available and the ready/busy information
  *                     is read from the chip status register
@@ -359,6 +436,8 @@ struct nand_buffers {
  * @pagemask:          [INTERN] page number mask = number of (pages / chip) - 1
  * @pagebuf:           [INTERN] holds the pagenumber which is currently in data_buf
  * @subpagesize:       [INTERN] holds the subpagesize
+ * @onfi_version:      [INTERN] holds the chip ONFI version (BCD encoded), non 0 if ONFI supported
+ * @onfi_params:       [INTERN] holds the ONFI page parameter when ONFI is supported, 0 otherwise
  * @ecclayout:         [REPLACEABLE] the default ecc placement scheme
  * @bbt:               [INTERN] bad block table pointer
  * @bbt_td:            [REPLACEABLE] bad block table descriptor for flash lookup
@@ -386,6 +465,8 @@ struct nand_chip {
        int             (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
        void            (*cmd_ctrl)(struct mtd_info *mtd, int dat,
                                    unsigned int ctrl);
+       int             (*init_size)(struct mtd_info *mtd,
+                                       struct nand_chip *this, u8 *id_data);
        int             (*dev_ready)(struct mtd_info *mtd);
        void            (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
        int             (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
@@ -411,6 +492,9 @@ struct nand_chip {
        int             badblockpos;
        int             badblockbits;
 
+       int             onfi_version;
+       struct nand_onfi_params onfi_params;
+
        flstate_t       state;
 
        uint8_t         *oob_poi;