1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
4 * Steven J. Hill <sjhill@realitydiluted.com>
5 * Thomas Gleixner <tglx@linutronix.de>
7 * Contains all ONFI related definitions
10 #ifndef __LINUX_MTD_ONFI_H
11 #define __LINUX_MTD_ONFI_H
13 #include <linux/types.h>
14 #include <linux/bitfield.h>
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)
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)
32 /* ONFI timing mode, used in both asynchronous and synchronous mode */
33 #define ONFI_DATA_INTERFACE_SDR 0
34 #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))
45 /* ONFI feature number/address */
46 #define ONFI_FEATURE_NUMBER 256
47 #define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
49 /* Vendor-specific feature address (Micron) */
50 #define ONFI_FEATURE_ADDR_READ_RETRY 0x89
51 #define ONFI_FEATURE_ON_DIE_ECC 0x90
52 #define ONFI_FEATURE_ON_DIE_ECC_EN BIT(3)
54 /* ONFI subfeature parameters length */
55 #define ONFI_SUBFEATURE_PARAM_LEN 4
57 /* ONFI optional commands SET/GET FEATURES supported? */
58 #define ONFI_OPT_CMD_SET_GET_FEATURES BIT(2)
60 struct nand_onfi_params {
61 /* rev info and features block */
68 __le16 ext_param_page_length; /* since ONFI 2.1 */
69 u8 num_of_param_pages; /* since ONFI 2.1 */
72 /* manufacturer information block */
73 char manufacturer[12];
79 /* memory organization block */
81 __le16 spare_bytes_per_page;
82 __le32 data_bytes_per_ppage;
83 __le16 spare_bytes_per_ppage;
84 __le32 pages_per_block;
85 __le32 blocks_per_lun;
90 __le16 block_endurance;
91 u8 guaranteed_good_blocks;
92 __le16 guaranteed_block_endurance;
100 /* electrical parameter block */
101 u8 io_pin_capacitance_max;
102 __le16 sdr_timing_modes;
103 __le16 program_cache_timing_mode;
108 u8 nvddr_timing_modes;
109 u8 nvddr2_timing_modes;
110 u8 nvddr_nvddr2_features;
111 __le16 clk_pin_capacitance_typ;
112 __le16 io_pin_capacitance_typ;
113 __le16 input_pin_capacitance_typ;
114 u8 input_pin_capacitance_max;
115 u8 driver_strength_support;
121 __le16 vendor_revision;
127 #define ONFI_CRC_BASE 0x4F4E
129 /* Extended ECC information Block Definition (since ONFI 2.1) */
130 struct onfi_ext_ecc_info {
134 __le16 block_endurance;
138 #define ONFI_SECTION_TYPE_0 0 /* Unused section. */
139 #define ONFI_SECTION_TYPE_1 1 /* for additional sections. */
140 #define ONFI_SECTION_TYPE_2 2 /* for ECC information. */
141 struct onfi_ext_section {
146 #define ONFI_EXT_SECTION_MAX 8
148 /* Extended Parameter Page Definition (since ONFI 2.1) */
149 struct onfi_ext_param_page {
151 u8 sig[4]; /* 'E' 'P' 'P' 'S' */
153 struct onfi_ext_section sections[ONFI_EXT_SECTION_MAX];
156 * The actual size of the Extended Parameter Page is in
157 * @ext_param_page_length of nand_onfi_params{}.
158 * The following are the variable length sections.
159 * So we do not add any fields below. Please see the ONFI spec.
164 * struct onfi_params - ONFI specific parameters that will be reused
165 * @version: ONFI version (BCD encoded), 0 if ONFI is not supported
166 * @tPROG: Page program time
167 * @tBERS: Block erase time
168 * @tR: Page read time
169 * @tCCS: Change column setup time
170 * @fast_tCAD: Command/Address/Data slow or fast delay (NV-DDR only)
171 * @sdr_timing_modes: Supported asynchronous/SDR timing modes
172 * @nvddr_timing_modes: Supported source synchronous/NV-DDR timing modes
173 * @vendor_revision: Vendor specific revision number
174 * @vendor: Vendor specific data
183 u16 sdr_timing_modes;
184 u16 nvddr_timing_modes;
189 #endif /* __LINUX_MTD_ONFI_H */