Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
0004  *           Steven J. Hill <sjhill@realitydiluted.com>
0005  *           Thomas Gleixner <tglx@linutronix.de>
0006  *
0007  * Contains all ONFI related definitions
0008  */
0009 
0010 #ifndef __LINUX_MTD_ONFI_H
0011 #define __LINUX_MTD_ONFI_H
0012 
0013 #include <linux/types.h>
0014 #include <linux/bitfield.h>
0015 
0016 /* ONFI version bits */
0017 #define ONFI_VERSION_1_0        BIT(1)
0018 #define ONFI_VERSION_2_0        BIT(2)
0019 #define ONFI_VERSION_2_1        BIT(3)
0020 #define ONFI_VERSION_2_2        BIT(4)
0021 #define ONFI_VERSION_2_3        BIT(5)
0022 #define ONFI_VERSION_3_0        BIT(6)
0023 #define ONFI_VERSION_3_1        BIT(7)
0024 #define ONFI_VERSION_3_2        BIT(8)
0025 #define ONFI_VERSION_4_0        BIT(9)
0026 
0027 /* ONFI features */
0028 #define ONFI_FEATURE_16_BIT_BUS     BIT(0)
0029 #define ONFI_FEATURE_NV_DDR     BIT(5)
0030 #define ONFI_FEATURE_EXT_PARAM_PAGE BIT(7)
0031 
0032 /* ONFI timing mode, used in both asynchronous and synchronous mode */
0033 #define ONFI_DATA_INTERFACE_SDR     0
0034 #define ONFI_DATA_INTERFACE_NVDDR   BIT(4)
0035 #define ONFI_DATA_INTERFACE_NVDDR2  BIT(5)
0036 #define ONFI_TIMING_MODE_0      BIT(0)
0037 #define ONFI_TIMING_MODE_1      BIT(1)
0038 #define ONFI_TIMING_MODE_2      BIT(2)
0039 #define ONFI_TIMING_MODE_3      BIT(3)
0040 #define ONFI_TIMING_MODE_4      BIT(4)
0041 #define ONFI_TIMING_MODE_5      BIT(5)
0042 #define ONFI_TIMING_MODE_UNKNOWN    BIT(6)
0043 #define ONFI_TIMING_MODE_PARAM(x)   FIELD_GET(GENMASK(3, 0), (x))
0044 
0045 /* ONFI feature number/address */
0046 #define ONFI_FEATURE_NUMBER     256
0047 #define ONFI_FEATURE_ADDR_TIMING_MODE   0x1
0048 
0049 /* Vendor-specific feature address (Micron) */
0050 #define ONFI_FEATURE_ADDR_READ_RETRY    0x89
0051 #define ONFI_FEATURE_ON_DIE_ECC     0x90
0052 #define   ONFI_FEATURE_ON_DIE_ECC_EN    BIT(3)
0053 
0054 /* ONFI subfeature parameters length */
0055 #define ONFI_SUBFEATURE_PARAM_LEN   4
0056 
0057 /* ONFI optional commands SET/GET FEATURES supported? */
0058 #define ONFI_OPT_CMD_SET_GET_FEATURES   BIT(2)
0059 
0060 struct nand_onfi_params {
0061     /* rev info and features block */
0062     /* 'O' 'N' 'F' 'I'  */
0063     u8 sig[4];
0064     __le16 revision;
0065     __le16 features;
0066     __le16 opt_cmd;
0067     u8 reserved0[2];
0068     __le16 ext_param_page_length; /* since ONFI 2.1 */
0069     u8 num_of_param_pages;        /* since ONFI 2.1 */
0070     u8 reserved1[17];
0071 
0072     /* manufacturer information block */
0073     char manufacturer[12];
0074     char model[20];
0075     u8 jedec_id;
0076     __le16 date_code;
0077     u8 reserved2[13];
0078 
0079     /* memory organization block */
0080     __le32 byte_per_page;
0081     __le16 spare_bytes_per_page;
0082     __le32 data_bytes_per_ppage;
0083     __le16 spare_bytes_per_ppage;
0084     __le32 pages_per_block;
0085     __le32 blocks_per_lun;
0086     u8 lun_count;
0087     u8 addr_cycles;
0088     u8 bits_per_cell;
0089     __le16 bb_per_lun;
0090     __le16 block_endurance;
0091     u8 guaranteed_good_blocks;
0092     __le16 guaranteed_block_endurance;
0093     u8 programs_per_page;
0094     u8 ppage_attr;
0095     u8 ecc_bits;
0096     u8 interleaved_bits;
0097     u8 interleaved_ops;
0098     u8 reserved3[13];
0099 
0100     /* electrical parameter block */
0101     u8 io_pin_capacitance_max;
0102     __le16 sdr_timing_modes;
0103     __le16 program_cache_timing_mode;
0104     __le16 t_prog;
0105     __le16 t_bers;
0106     __le16 t_r;
0107     __le16 t_ccs;
0108     u8 nvddr_timing_modes;
0109     u8 nvddr2_timing_modes;
0110     u8 nvddr_nvddr2_features;
0111     __le16 clk_pin_capacitance_typ;
0112     __le16 io_pin_capacitance_typ;
0113     __le16 input_pin_capacitance_typ;
0114     u8 input_pin_capacitance_max;
0115     u8 driver_strength_support;
0116     __le16 t_int_r;
0117     __le16 t_adl;
0118     u8 reserved4[8];
0119 
0120     /* vendor */
0121     __le16 vendor_revision;
0122     u8 vendor[88];
0123 
0124     __le16 crc;
0125 } __packed;
0126 
0127 #define ONFI_CRC_BASE   0x4F4E
0128 
0129 /* Extended ECC information Block Definition (since ONFI 2.1) */
0130 struct onfi_ext_ecc_info {
0131     u8 ecc_bits;
0132     u8 codeword_size;
0133     __le16 bb_per_lun;
0134     __le16 block_endurance;
0135     u8 reserved[2];
0136 } __packed;
0137 
0138 #define ONFI_SECTION_TYPE_0 0   /* Unused section. */
0139 #define ONFI_SECTION_TYPE_1 1   /* for additional sections. */
0140 #define ONFI_SECTION_TYPE_2 2   /* for ECC information. */
0141 struct onfi_ext_section {
0142     u8 type;
0143     u8 length;
0144 } __packed;
0145 
0146 #define ONFI_EXT_SECTION_MAX 8
0147 
0148 /* Extended Parameter Page Definition (since ONFI 2.1) */
0149 struct onfi_ext_param_page {
0150     __le16 crc;
0151     u8 sig[4];             /* 'E' 'P' 'P' 'S' */
0152     u8 reserved0[10];
0153     struct onfi_ext_section sections[ONFI_EXT_SECTION_MAX];
0154 
0155     /*
0156      * The actual size of the Extended Parameter Page is in
0157      * @ext_param_page_length of nand_onfi_params{}.
0158      * The following are the variable length sections.
0159      * So we do not add any fields below. Please see the ONFI spec.
0160      */
0161 } __packed;
0162 
0163 /**
0164  * struct onfi_params - ONFI specific parameters that will be reused
0165  * @version: ONFI version (BCD encoded), 0 if ONFI is not supported
0166  * @tPROG: Page program time
0167  * @tBERS: Block erase time
0168  * @tR: Page read time
0169  * @tCCS: Change column setup time
0170  * @fast_tCAD: Command/Address/Data slow or fast delay (NV-DDR only)
0171  * @sdr_timing_modes: Supported asynchronous/SDR timing modes
0172  * @nvddr_timing_modes: Supported source synchronous/NV-DDR timing modes
0173  * @vendor_revision: Vendor specific revision number
0174  * @vendor: Vendor specific data
0175  */
0176 struct onfi_params {
0177     int version;
0178     u16 tPROG;
0179     u16 tBERS;
0180     u16 tR;
0181     u16 tCCS;
0182     bool fast_tCAD;
0183     u16 sdr_timing_modes;
0184     u16 nvddr_timing_modes;
0185     u16 vendor_revision;
0186     u8 vendor[88];
0187 };
0188 
0189 #endif /* __LINUX_MTD_ONFI_H */