191 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>4 * Steven J. Hill <sjhill@realitydiluted.com>5 * Thomas Gleixner <tglx@linutronix.de>6 *7 * Contains all ONFI related definitions8 */9 10#ifndef __LINUX_MTD_ONFI_H11#define __LINUX_MTD_ONFI_H12 13#include <linux/types.h>14#include <linux/bitfield.h>15 16/* ONFI version bits */17#define ONFI_VERSION_1_0 BIT(1)18#define ONFI_VERSION_2_0 BIT(2)19#define ONFI_VERSION_2_1 BIT(3)20#define ONFI_VERSION_2_2 BIT(4)21#define ONFI_VERSION_2_3 BIT(5)22#define ONFI_VERSION_3_0 BIT(6)23#define ONFI_VERSION_3_1 BIT(7)24#define ONFI_VERSION_3_2 BIT(8)25#define ONFI_VERSION_4_0 BIT(9)26 27/* ONFI features */28#define ONFI_FEATURE_16_BIT_BUS BIT(0)29#define ONFI_FEATURE_NV_DDR BIT(5)30#define ONFI_FEATURE_EXT_PARAM_PAGE BIT(7)31 32/* ONFI timing mode, used in both asynchronous and synchronous mode */33#define ONFI_DATA_INTERFACE_SDR 034#define ONFI_DATA_INTERFACE_NVDDR BIT(4)35#define ONFI_DATA_INTERFACE_NVDDR2 BIT(5)36#define ONFI_TIMING_MODE_0 BIT(0)37#define ONFI_TIMING_MODE_1 BIT(1)38#define ONFI_TIMING_MODE_2 BIT(2)39#define ONFI_TIMING_MODE_3 BIT(3)40#define ONFI_TIMING_MODE_4 BIT(4)41#define ONFI_TIMING_MODE_5 BIT(5)42#define ONFI_TIMING_MODE_UNKNOWN BIT(6)43#define ONFI_TIMING_MODE_PARAM(x) FIELD_GET(GENMASK(3, 0), (x))44 45/* ONFI feature number/address */46#define ONFI_FEATURE_NUMBER 25647#define ONFI_FEATURE_ADDR_TIMING_MODE 0x148 49/* Vendor-specific feature address (Micron) */50#define ONFI_FEATURE_ADDR_READ_RETRY 0x8951#define ONFI_FEATURE_ON_DIE_ECC 0x9052#define ONFI_FEATURE_ON_DIE_ECC_EN BIT(3)53 54/* ONFI subfeature parameters length */55#define ONFI_SUBFEATURE_PARAM_LEN 456 57/* ONFI optional commands SET/GET FEATURES supported? */58#define ONFI_OPT_CMD_READ_CACHE BIT(1)59#define ONFI_OPT_CMD_SET_GET_FEATURES BIT(2)60 61struct nand_onfi_params {62 /* rev info and features block */63 /* 'O' 'N' 'F' 'I' */64 u8 sig[4];65 __le16 revision;66 __le16 features;67 __le16 opt_cmd;68 u8 reserved0[2];69 __le16 ext_param_page_length; /* since ONFI 2.1 */70 u8 num_of_param_pages; /* since ONFI 2.1 */71 u8 reserved1[17];72 73 /* manufacturer information block */74 char manufacturer[12];75 char model[20];76 u8 jedec_id;77 __le16 date_code;78 u8 reserved2[13];79 80 /* memory organization block */81 __le32 byte_per_page;82 __le16 spare_bytes_per_page;83 __le32 data_bytes_per_ppage;84 __le16 spare_bytes_per_ppage;85 __le32 pages_per_block;86 __le32 blocks_per_lun;87 u8 lun_count;88 u8 addr_cycles;89 u8 bits_per_cell;90 __le16 bb_per_lun;91 __le16 block_endurance;92 u8 guaranteed_good_blocks;93 __le16 guaranteed_block_endurance;94 u8 programs_per_page;95 u8 ppage_attr;96 u8 ecc_bits;97 u8 interleaved_bits;98 u8 interleaved_ops;99 u8 reserved3[13];100 101 /* electrical parameter block */102 u8 io_pin_capacitance_max;103 __le16 sdr_timing_modes;104 __le16 program_cache_timing_mode;105 __le16 t_prog;106 __le16 t_bers;107 __le16 t_r;108 __le16 t_ccs;109 u8 nvddr_timing_modes;110 u8 nvddr2_timing_modes;111 u8 nvddr_nvddr2_features;112 __le16 clk_pin_capacitance_typ;113 __le16 io_pin_capacitance_typ;114 __le16 input_pin_capacitance_typ;115 u8 input_pin_capacitance_max;116 u8 driver_strength_support;117 __le16 t_int_r;118 __le16 t_adl;119 u8 reserved4[8];120 121 /* vendor */122 __le16 vendor_revision;123 u8 vendor[88];124 125 __le16 crc;126} __packed;127 128#define ONFI_CRC_BASE 0x4F4E129 130/* Extended ECC information Block Definition (since ONFI 2.1) */131struct onfi_ext_ecc_info {132 u8 ecc_bits;133 u8 codeword_size;134 __le16 bb_per_lun;135 __le16 block_endurance;136 u8 reserved[2];137} __packed;138 139#define ONFI_SECTION_TYPE_0 0 /* Unused section. */140#define ONFI_SECTION_TYPE_1 1 /* for additional sections. */141#define ONFI_SECTION_TYPE_2 2 /* for ECC information. */142struct onfi_ext_section {143 u8 type;144 u8 length;145} __packed;146 147#define ONFI_EXT_SECTION_MAX 8148 149/* Extended Parameter Page Definition (since ONFI 2.1) */150struct onfi_ext_param_page {151 __le16 crc;152 u8 sig[4]; /* 'E' 'P' 'P' 'S' */153 u8 reserved0[10];154 struct onfi_ext_section sections[ONFI_EXT_SECTION_MAX];155 156 /*157 * The actual size of the Extended Parameter Page is in158 * @ext_param_page_length of nand_onfi_params{}.159 * The following are the variable length sections.160 * So we do not add any fields below. Please see the ONFI spec.161 */162} __packed;163 164/**165 * struct onfi_params - ONFI specific parameters that will be reused166 * @version: ONFI version (BCD encoded), 0 if ONFI is not supported167 * @tPROG: Page program time168 * @tBERS: Block erase time169 * @tR: Page read time170 * @tCCS: Change column setup time171 * @fast_tCAD: Command/Address/Data slow or fast delay (NV-DDR only)172 * @sdr_timing_modes: Supported asynchronous/SDR timing modes173 * @nvddr_timing_modes: Supported source synchronous/NV-DDR timing modes174 * @vendor_revision: Vendor specific revision number175 * @vendor: Vendor specific data176 */177struct onfi_params {178 int version;179 u16 tPROG;180 u16 tBERS;181 u16 tR;182 u16 tCCS;183 bool fast_tCAD;184 u16 sdr_timing_modes;185 u16 nvddr_timing_modes;186 u16 vendor_revision;187 u8 vendor[88];188};189 190#endif /* __LINUX_MTD_ONFI_H */191